3 Commits

Author SHA1 Message Date
cecio
c551015cd7 added comment to PIWATCH 2024-12-22 22:26:48 +01:00
cecio
08e047811a bump to release 0.20.0 2024-12-22 22:13:53 +01:00
cecio
113158f9ad Update README.md 2024-11-27 21:55:22 +01:00
9 changed files with 82 additions and 17 deletions

View File

@@ -1,9 +1,9 @@
# #
# To Build: # To Build:
# docker build -t usbvalve/arduino-cli . # docker build -t usbvalve-pico1/arduino-cli -f Dockerfile.pico1 .
# #
# To Run: # To Run:
# docker run --rm --name usbvalve -v $PWD:/mnt usbvalve/arduino-cli /mnt/USBvalve # docker run --rm --name usbvalve -v $PWD:/mnt usbvalve-pico1/arduino-cli /mnt/USBvalve
# #
FROM ubuntu:22.04 FROM ubuntu:22.04
@@ -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 \ && 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.0" \ && arduino-cli lib install "Adafruit TinyUSB Library@3.4.2" \
&& arduino-cli lib install "Adafruit SSD1306@2.5.12" \ && arduino-cli lib install "Adafruit SSD1306@2.5.13" \
&& arduino-cli lib install "Pico PIO USB@0.6.1" \ && arduino-cli lib install "Pico PIO USB@0.6.1" \
&& 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.4.9" && arduino-cli lib install "GFX Library for Arduino@1.5.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 --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=120\" --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"]

39
Dockerfile.pico2 Normal file
View File

@@ -0,0 +1,39 @@
#
# To Build:
# docker build -t usbvalve-pico2/arduino-cli -f Dockerfile.pico2 .
#
# To Run:
# docker run --rm --name usbvalve -v $PWD:/mnt usbvalve-pico2/arduino-cli /mnt/USBvalve
#
FROM ubuntu:22.04
WORKDIR /app
# OS setup
RUN apt-get update -y \
&& apt-get install -y git wget python3 \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# arduino-cli setup
RUN cd /app \
&& git clone --recursive https://github.com/arduino/arduino-cli.git \
&& cd arduino-cli \
&& ./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 lib install "XxHash_arduino@2.1.0" \
&& arduino-cli lib install "GFX Library for Arduino@1.5.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 \
&& chmod +x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]

View File

@@ -60,14 +60,14 @@ This is also fully compatible with the [Waveshare RP2040-LCD-1.28](https://www.w
If you want to build your own, you need: If you want to build your own, you need:
- A Raspberry Pi Pico (or another RP2040 based board, like Arduino Nano RP2040) - A Raspberry Pi Pico 1 or 2 (or another RP2040 based board, like Arduino Nano RP2040)
- an I2C OLED screen 128x64 or 128x32 (SSD1306) - an I2C OLED screen 128x64 or 128x32 (SSD1306)
- (optional) a **USBvalve** PCB or a breadboard - (optional) a **USBvalve** PCB or a breadboard
- (optional) a 3D printed spacer to isolate the screen from the board (https://www.thingiverse.com/thing:4748043), but you can use a piece of electrical tape instead - (optional) a 3D printed spacer to isolate the screen from the board (https://www.thingiverse.com/thing:4748043), but you can use a piece of electrical tape instead
### Building instructions ### Building instructions
> Thanks to [Tz1rf](https://github.com/Tz1rf) we have a great [Video](https://youtu.be/7ymk8hD7-Hc) explaining the building process step-by-step. > Thanks to [Tz1rf](https://github.com/Tz1rf) we also have two great videos: one explaining the [building](https://youtu.be/7ymk8hD7-Hc) process step-by-step, and another showing how to [upload firmware](https://youtu.be/Tp8xvrlqxUY) and use the tool.
Almost all the job is done directly on the board by the software, so you just need to arrange the connection with the OLED for output. Almost all the job is done directly on the board by the software, so you just need to arrange the connection with the OLED for output.
@@ -195,21 +195,23 @@ 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.3` - Arduino IDE `2.3.4`
- `Adafruit TinyUSB Library` version `3.4.0`, `Pico-PIO-USB` version `0.6.1`, Board `Raspberry Pi RP2040 (4.1.1)` setting Tools=>CPU Speed at `133MHz` and Tools=>USB Stack to `Adafruit TinyUSB` - `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.12` - `Adafruit_SSD1306` OLED library version `2.5.13`
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. 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).
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.
#### Dockerfile #### Dockerfile
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. Enter the following commands in the main `USBvalve` folder: 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:
``` ```
docker build -t usbvalve/arduino-cli . docker build -t usbvalve-pico1/arduino-cli -f Dockerfile.pico1 .
docker run --rm --name usbvalve -v $PWD:/mnt usbvalve/arduino-cli /mnt/USBvalve docker run --rm --name usbvalve -v $PWD:/mnt usbvalve-pico1/arduino-cli /mnt/USBvalve
``` ```
The firmware will be placed with extension `uf2` in folder `USBvalve_out`. The firmware will be placed with extension `uf2` in folder `USBvalve_out`.

View File

@@ -116,7 +116,7 @@ bool activeState = false;
// //
// USBvalve globals // USBvalve globals
// //
#define VERSION "USBvalve - 0.19.1" #define VERSION "USBvalve - 0.20.0"
boolean readme = false; boolean readme = false;
boolean autorun = false; boolean autorun = false;
boolean written = false; boolean written = false;
@@ -126,6 +126,8 @@ boolean deleted_reported = false;
boolean hid_sent = false; boolean hid_sent = false;
boolean hid_reported = false; boolean hid_reported = false;
static spin_lock_t *lock;
// //
// Anti-Detection settings. // Anti-Detection settings.
// //
@@ -159,6 +161,9 @@ uint valid_hash = 2362816530;
// Core 0 Setup: will be used for the USB mass device functions // Core 0 Setup: will be used for the USB mass device functions
void setup() { void setup() {
// Initialize the spinlock
lock = spin_lock_instance(0);
// Change all the USB Pico settings // Change all the USB Pico settings
TinyUSBDevice.setID(USB_VENDORID, USB_PRODUCTID); TinyUSBDevice.setID(USB_VENDORID, USB_PRODUCTID);
TinyUSBDevice.setProductDescriptor(USB_DESCRIPTOR); TinyUSBDevice.setProductDescriptor(USB_DESCRIPTOR);
@@ -537,6 +542,9 @@ static uint8_t const keycode2ascii[128][2] = { HID_KEYCODE_TO_ASCII };
// Invoked when device with hid interface is mounted // Invoked when device with hid interface is mounted
void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_report, uint16_t desc_len) { void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_report, uint16_t desc_len) {
uint32_t lock_num = spin_lock_blocking(lock);
uint16_t vid, pid; uint16_t vid, pid;
const char* protocol_str[] = { "None", "Keyboard", "Mouse" }; const char* protocol_str[] = { "None", "Keyboard", "Mouse" };
@@ -557,20 +565,26 @@ void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_re
if (!tuh_hid_receive_report(dev_addr, instance)) { if (!tuh_hid_receive_report(dev_addr, instance)) {
SerialTinyUSB.printf("Error: cannot request to receive report\r\n"); SerialTinyUSB.printf("Error: cannot request to receive report\r\n");
} }
spin_unlock(lock, lock_num);
} }
// Invoked when device with hid interface is un-mounted // Invoked when device with hid interface is un-mounted
void tuh_hid_umount_cb(uint8_t dev_addr, uint8_t instance) { void tuh_hid_umount_cb(uint8_t dev_addr, uint8_t instance) {
uint32_t lock_num = spin_lock_blocking(lock);
SerialTinyUSB.printf("HID device address = %d, instance = %d unmounted\r\n", dev_addr, instance); SerialTinyUSB.printf("HID device address = %d, instance = %d unmounted\r\n", dev_addr, instance);
// Reset HID sent flag // Reset HID sent flag
hid_sent = false; hid_sent = false;
hid_reported = false; hid_reported = false;
spin_unlock(lock, lock_num);
} }
// Invoked when received report from device // Invoked when received report from device
void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len) { void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len) {
uint32_t lock_num = spin_lock_blocking(lock);
static bool kbd_printed = false; static bool kbd_printed = false;
static bool mouse_printed = false; static bool mouse_printed = false;
@@ -608,6 +622,8 @@ void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t cons
if (!tuh_hid_receive_report(dev_addr, instance)) { if (!tuh_hid_receive_report(dev_addr, instance)) {
SerialTinyUSB.println("Error: cannot request to receive report"); SerialTinyUSB.println("Error: cannot request to receive report");
} }
spin_unlock(lock, lock_num);
} }
static inline bool find_key_in_report(hid_keyboard_report_t const* report, uint8_t keycode) { static inline bool find_key_in_report(hid_keyboard_report_t const* report, uint8_t keycode) {
@@ -727,24 +743,32 @@ void cursor_movement(int8_t x, int8_t y, int8_t wheel) {
// Invoked when a device with MassStorage interface is mounted // Invoked when a device with MassStorage interface is mounted
void tuh_msc_mount_cb(uint8_t dev_addr) { void tuh_msc_mount_cb(uint8_t dev_addr) {
uint32_t lock_num = spin_lock_blocking(lock);
printout("\n[++] Mass Device"); printout("\n[++] Mass Device");
SerialTinyUSB.printf("Mass Device attached, address = %d\r\n", dev_addr); SerialTinyUSB.printf("Mass Device attached, address = %d\r\n", dev_addr);
spin_unlock(lock, lock_num);
} }
// Invoked when a device with MassStorage interface is unmounted // Invoked when a device with MassStorage interface is unmounted
void tuh_msc_umount_cb(uint8_t dev_addr) { void tuh_msc_umount_cb(uint8_t dev_addr) {
uint32_t lock_num = spin_lock_blocking(lock);
SerialTinyUSB.printf("Mass Device unmounted, address = %d\r\n", dev_addr); SerialTinyUSB.printf("Mass Device unmounted, address = %d\r\n", dev_addr);
spin_unlock(lock, lock_num);
} }
// Invoked when a device with CDC (Communication Device Class) interface is mounted // Invoked when a device with CDC (Communication Device Class) interface is mounted
void tuh_cdc_mount_cb(uint8_t idx) { void tuh_cdc_mount_cb(uint8_t idx) {
uint32_t lock_num = spin_lock_blocking(lock);
printout("\n[++] CDC Device"); printout("\n[++] CDC Device");
SerialTinyUSB.printf("CDC Device attached, idx = %d\r\n", idx); SerialTinyUSB.printf("CDC Device attached, idx = %d\r\n", idx);
spin_unlock(lock, lock_num);
} }
// Invoked when a device with CDC (Communication Device Class) interface is unmounted // Invoked when a device with CDC (Communication Device Class) interface is unmounted
void tuh_cdc_umount_cb(uint8_t idx) { void tuh_cdc_umount_cb(uint8_t idx) {
uint32_t lock_num = spin_lock_blocking(lock);
SerialTinyUSB.printf("CDC Device unmounted, idx = %d\r\n", idx); SerialTinyUSB.printf("CDC Device unmounted, idx = %d\r\n", idx);
spin_unlock(lock, lock_num);
} }
// END of OTHER Host devices detector section // END of OTHER Host devices detector section

Binary file not shown.

Binary file not shown.