6 Commits

Author SHA1 Message Date
cecio
8369117d73 updated README 2025-05-31 22:00:14 +02:00
cecio
13422f4c8c bump to release 0.21.1 2025-05-31 21:51:57 +02:00
cecio
c1618bc201 bump to release 0.21.0 2025-02-02 16:27:37 +01:00
cecio
d756e20eb4 new HID count and freq adjustment 2025-02-02 16:25:26 +01:00
cecio
1387103199 adjusted versions and freq 2025-02-02 16:24:30 +01:00
cecio
f4e9ed918b updates 2024-12-22 22:34:12 +01:00
9 changed files with 43 additions and 19 deletions

View File

@@ -23,17 +23,17 @@ RUN cd /app \
&& ./install.sh \
&& export PATH=$PATH:/app/arduino-cli/bin \
&& arduino-cli --additional-urls https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json core search 2040 \
&& arduino-cli --additional-urls https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json core install rp2040:rp2040@4.4.0 \
&& arduino-cli lib install "Adafruit TinyUSB Library@3.4.2" \
&& arduino-cli lib install "Adafruit SSD1306@2.5.13" \
&& arduino-cli lib install "Pico PIO USB@0.6.1" \
&& arduino-cli --additional-urls https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json core install rp2040:rp2040@4.5.4 \
&& arduino-cli lib install "Adafruit TinyUSB Library@3.6.0" \
&& arduino-cli lib install "Adafruit SSD1306@2.5.14" \
&& arduino-cli lib install "Pico PIO USB@0.7.2" \
&& arduino-cli lib install "XxHash_arduino@2.1.0" \
&& arduino-cli lib install "GFX Library for Arduino@1.5.0"
&& arduino-cli lib install "GFX Library for Arduino@1.6.0"
# Compilation setup
RUN echo "#!/bin/bash" > /app/entrypoint.sh \
&& echo "export PATH=\$PATH:/app/arduino-cli/bin" >> /app/entrypoint.sh \
&& echo "arduino-cli compile --fqbn rp2040:rp2040:rpipico --build-property \"build.extra_flags=-DCFG_TUD_CDC=1\" --board-options \"usbstack=tinyusb\" --board-options \"freq=120\" --output-dir \"/mnt/USBvalve_out\" \"\$1\"" >> /app/entrypoint.sh \
&& echo "arduino-cli compile --fqbn rp2040:rp2040:rpipico --build-property \"build.extra_flags=-DCFG_TUD_CDC=1\" --board-options \"usbstack=tinyusb\" --board-options \"freq=240\" --output-dir \"/mnt/USBvalve_out\" \"\$1\"" >> /app/entrypoint.sh \
&& chmod +x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]

View File

@@ -23,17 +23,17 @@ RUN cd /app \
&& ./install.sh \
&& export PATH=$PATH:/app/arduino-cli/bin \
&& arduino-cli --additional-urls https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json core search 2040 \
&& arduino-cli --additional-urls https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json core install rp2040:rp2040@4.4.0 \
&& arduino-cli lib install "Adafruit TinyUSB Library@3.4.2" \
&& arduino-cli lib install "Adafruit SSD1306@2.5.13" \
&& arduino-cli lib install "Pico PIO USB@0.6.1" \
&& arduino-cli --additional-urls https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json core install rp2040:rp2040@4.5.4 \
&& arduino-cli lib install "Adafruit TinyUSB Library@3.6.0" \
&& arduino-cli lib install "Adafruit SSD1306@2.5.14" \
&& arduino-cli lib install "Pico PIO USB@0.7.2" \
&& arduino-cli lib install "XxHash_arduino@2.1.0" \
&& arduino-cli lib install "GFX Library for Arduino@1.5.0"
&& arduino-cli lib install "GFX Library for Arduino@1.6.0"
# Compilation setup
RUN echo "#!/bin/bash" > /app/entrypoint.sh \
&& echo "export PATH=\$PATH:/app/arduino-cli/bin" >> /app/entrypoint.sh \
&& echo "arduino-cli compile --fqbn rp2040:rp2040:rpipico2 --build-property \"build.extra_flags=-DCFG_TUD_CDC=1\" --board-options \"usbstack=tinyusb\" --board-options \"freq=120\" --output-dir \"/mnt/USBvalve_out\" \"\$1\"" >> /app/entrypoint.sh \
&& echo "arduino-cli compile --fqbn rp2040:rp2040:rpipico2 --build-property \"build.extra_flags=-DCFG_TUD_CDC=1\" --board-options \"usbstack=tinyusb\" --board-options \"freq=240\" --output-dir \"/mnt/USBvalve_out\" \"\$1\"" >> /app/entrypoint.sh \
&& chmod +x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]

View File

@@ -196,10 +196,10 @@ I grouped most of the variables you may want to modify in this section ([see Doc
Obviously you can also build your own firmware. To build the *standard* one I used:
- Arduino IDE `2.3.4`
- `Adafruit TinyUSB Library` version `3.4.2`, `Pico-PIO-USB` version `0.6.1`, Board `Raspberry Pi RP2040 (4.4.0)` setting Tools=>CPU Speed at `133MHz` and Tools=>USB Stack to `Adafruit TinyUSB`
- `Adafruit_SSD1306` OLED library version `2.5.13`
- `Adafruit TinyUSB Library` version `3.6.0`, `Pico-PIO-USB` version `0.7.2`, Board `Raspberry Pi RP2040 (4.5.4)` setting Tools=>CPU Speed at `133MHz` and Tools=>USB Stack to `Adafruit TinyUSB`
- `Adafruit_SSD1306` OLED library version `2.5.14`
Remember to add `https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json` in the `Additional Board Manager URLs` to install the proper board. Also, starting from `TinyUSB` version `3.4.2` is necessary to force the following macro setting `DCFG_TUD_CDC=1`. I strongly suggesto you to use the provided *Dockerfiles* (see below).
Remember to add `https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json` in the `Additional Board Manager URLs` to install the proper board. Also, starting from `TinyUSB` version `3.4.2` is necessary to force the following macro setting `DCFG_TUD_CDC=1`. I strongly suggest you to use the provided *Dockerfiles* (see below).
If you want to re-create a new fake filesystem, you may want to have a look to the `utils` folder, where I placed some utilities to build a new one.
@@ -207,7 +207,7 @@ If you want to re-create a new fake filesystem, you may want to have a look to t
If you want to build your own firmware, after you customized it, I provide a `Dockerfile` which builds a complete **Arduino** environment and compile the firmware. I added them for both `Pico` version 1 and 2.
Enter the following commands in the main `USBvalve` folder:
Enter the following commands in the main `USBvalve` folder to build for Pico `v1`:
```
docker build -t usbvalve-pico1/arduino-cli -f Dockerfile.pico1 .

View File

@@ -116,7 +116,7 @@ bool activeState = false;
//
// USBvalve globals
//
#define VERSION "USBvalve - 0.20.0"
#define VERSION "USBvalve - 0.21.1"
boolean readme = false;
boolean autorun = false;
boolean written = false;
@@ -125,6 +125,7 @@ boolean written_reported = false;
boolean deleted_reported = false;
boolean hid_sent = false;
boolean hid_reported = false;
uint hid_event_num = 0;
static spin_lock_t *lock;
@@ -252,7 +253,12 @@ void setup() {
// Core 1 Setup: will be used for the USB host functions for BADUSB detector
void setup1() {
// Set a custom clock (multiple of 12Mhz) to achieve maximum compatibility for HID
// Differntiated between Pico 1 and Pico 2
#ifdef PICO_RP2350
set_sys_clock_khz(144000, true);
#elif defined PICO_RP2040
set_sys_clock_khz(240000, true);
#endif
pio_usb_configuration_t pio_cfg = PIO_USB_DEFAULT_CONFIG;
pio_cfg.pin_dp = HOST_PIN_DP;
@@ -308,9 +314,23 @@ void loop() {
}
if (BOOTSEL) {
uint32_t press_start = to_ms_since_boot(get_absolute_time());
while (BOOTSEL) {
sleep_ms(10);
}
uint32_t press_end = to_ms_since_boot(get_absolute_time());
uint32_t press_duration = press_end - press_start;
if (press_duration > 2000) { // Press duration > 2sec
// Print the number of HID events detected so far
char outstr[22];
snprintf(outstr, 21, "\n[+] HID Evt# %d", hid_event_num);
printout(outstr);
} else {
printout("\n[+] RESETTING");
swreset();
}
}
}
// Main Core1 loop: managing USB Host
@@ -577,6 +597,7 @@ void tuh_hid_umount_cb(uint8_t dev_addr, uint8_t instance) {
// Reset HID sent flag
hid_sent = false;
hid_reported = false;
hid_event_num = 0;
spin_unlock(lock, lock_num);
}
@@ -602,6 +623,7 @@ void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t cons
mouse_printed = false;
}
process_kbd_report((hid_keyboard_report_t const*)report);
hid_event_num++;
break;
case HID_ITF_PROTOCOL_MOUSE:
@@ -611,11 +633,13 @@ void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t cons
kbd_printed = false;
}
process_mouse_report((hid_mouse_report_t const*)report);
hid_event_num++;
break;
default:
// Generic report: for the time being we use kbd for this as well
process_kbd_report((hid_keyboard_report_t const*)report);
hid_event_num++;
break;
}