mirror of
https://github.com/cecio/USBvalve.git
synced 2025-12-06 03:41:45 +00:00
Compare commits
6 Commits
v0.20.0
...
8369117d73
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8369117d73 | ||
|
|
13422f4c8c | ||
|
|
c1618bc201 | ||
|
|
d756e20eb4 | ||
|
|
1387103199 | ||
|
|
f4e9ed918b |
@@ -23,17 +23,17 @@ RUN cd /app \
|
|||||||
&& ./install.sh \
|
&& ./install.sh \
|
||||||
&& export PATH=$PATH:/app/arduino-cli/bin \
|
&& 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 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 --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.4.2" \
|
&& arduino-cli lib install "Adafruit TinyUSB Library@3.6.0" \
|
||||||
&& arduino-cli lib install "Adafruit SSD1306@2.5.13" \
|
&& arduino-cli lib install "Adafruit SSD1306@2.5.14" \
|
||||||
&& arduino-cli lib install "Pico PIO USB@0.6.1" \
|
&& arduino-cli lib install "Pico PIO USB@0.7.2" \
|
||||||
&& arduino-cli lib install "XxHash_arduino@2.1.0" \
|
&& 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
|
# Compilation setup
|
||||||
RUN echo "#!/bin/bash" > /app/entrypoint.sh \
|
RUN echo "#!/bin/bash" > /app/entrypoint.sh \
|
||||||
&& echo "export PATH=\$PATH:/app/arduino-cli/bin" >> /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
|
&& chmod +x /app/entrypoint.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
|
|||||||
@@ -23,17 +23,17 @@ RUN cd /app \
|
|||||||
&& ./install.sh \
|
&& ./install.sh \
|
||||||
&& export PATH=$PATH:/app/arduino-cli/bin \
|
&& 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 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 --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.4.2" \
|
&& arduino-cli lib install "Adafruit TinyUSB Library@3.6.0" \
|
||||||
&& arduino-cli lib install "Adafruit SSD1306@2.5.13" \
|
&& arduino-cli lib install "Adafruit SSD1306@2.5.14" \
|
||||||
&& arduino-cli lib install "Pico PIO USB@0.6.1" \
|
&& arduino-cli lib install "Pico PIO USB@0.7.2" \
|
||||||
&& arduino-cli lib install "XxHash_arduino@2.1.0" \
|
&& 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
|
# Compilation setup
|
||||||
RUN echo "#!/bin/bash" > /app/entrypoint.sh \
|
RUN echo "#!/bin/bash" > /app/entrypoint.sh \
|
||||||
&& echo "export PATH=\$PATH:/app/arduino-cli/bin" >> /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
|
&& chmod +x /app/entrypoint.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
|
|||||||
@@ -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:
|
Obviously you can also build your own firmware. To build the *standard* one I used:
|
||||||
|
|
||||||
- Arduino IDE `2.3.4`
|
- 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 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.13`
|
- `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.
|
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.
|
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 .
|
docker build -t usbvalve-pico1/arduino-cli -f Dockerfile.pico1 .
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ bool activeState = false;
|
|||||||
//
|
//
|
||||||
// USBvalve globals
|
// USBvalve globals
|
||||||
//
|
//
|
||||||
#define VERSION "USBvalve - 0.20.0"
|
#define VERSION "USBvalve - 0.21.1"
|
||||||
boolean readme = false;
|
boolean readme = false;
|
||||||
boolean autorun = false;
|
boolean autorun = false;
|
||||||
boolean written = false;
|
boolean written = false;
|
||||||
@@ -125,6 +125,7 @@ boolean written_reported = false;
|
|||||||
boolean deleted_reported = false;
|
boolean deleted_reported = false;
|
||||||
boolean hid_sent = false;
|
boolean hid_sent = false;
|
||||||
boolean hid_reported = false;
|
boolean hid_reported = false;
|
||||||
|
uint hid_event_num = 0;
|
||||||
|
|
||||||
static spin_lock_t *lock;
|
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
|
// Core 1 Setup: will be used for the USB host functions for BADUSB detector
|
||||||
void setup1() {
|
void setup1() {
|
||||||
// Set a custom clock (multiple of 12Mhz) to achieve maximum compatibility for HID
|
// 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);
|
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_usb_configuration_t pio_cfg = PIO_USB_DEFAULT_CONFIG;
|
||||||
pio_cfg.pin_dp = HOST_PIN_DP;
|
pio_cfg.pin_dp = HOST_PIN_DP;
|
||||||
@@ -308,8 +314,22 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (BOOTSEL) {
|
if (BOOTSEL) {
|
||||||
printout("\n[+] RESETTING");
|
uint32_t press_start = to_ms_since_boot(get_absolute_time());
|
||||||
swreset();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,6 +597,7 @@ void tuh_hid_umount_cb(uint8_t dev_addr, uint8_t instance) {
|
|||||||
// Reset HID sent flag
|
// Reset HID sent flag
|
||||||
hid_sent = false;
|
hid_sent = false;
|
||||||
hid_reported = false;
|
hid_reported = false;
|
||||||
|
hid_event_num = 0;
|
||||||
spin_unlock(lock, lock_num);
|
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;
|
mouse_printed = false;
|
||||||
}
|
}
|
||||||
process_kbd_report((hid_keyboard_report_t const*)report);
|
process_kbd_report((hid_keyboard_report_t const*)report);
|
||||||
|
hid_event_num++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HID_ITF_PROTOCOL_MOUSE:
|
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;
|
kbd_printed = false;
|
||||||
}
|
}
|
||||||
process_mouse_report((hid_mouse_report_t const*)report);
|
process_mouse_report((hid_mouse_report_t const*)report);
|
||||||
|
hid_event_num++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Generic report: for the time being we use kbd for this as well
|
// Generic report: for the time being we use kbd for this as well
|
||||||
process_kbd_report((hid_keyboard_report_t const*)report);
|
process_kbd_report((hid_keyboard_report_t const*)report);
|
||||||
|
hid_event_num++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user