Compare commits
33 Commits
v0.15.1
...
8369117d73
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8369117d73 | ||
|
|
13422f4c8c | ||
|
|
c1618bc201 | ||
|
|
d756e20eb4 | ||
|
|
1387103199 | ||
|
|
f4e9ed918b | ||
|
|
c551015cd7 | ||
|
|
08e047811a | ||
|
|
113158f9ad | ||
|
|
251db8f30d | ||
|
|
384684bdf4 | ||
|
|
35f4a00326 | ||
|
|
59815ce63d | ||
|
|
7aee69d8e1 | ||
|
|
64f44c1a1c | ||
|
|
7cfedce646 | ||
|
|
f6de47e149 | ||
|
|
4d730aecdb | ||
|
|
44e98ad924 | ||
|
|
7d218c974d | ||
|
|
f93f2b8fcb | ||
|
|
5ae2c31403 | ||
|
|
f96689ad6b | ||
|
|
896a9b8e26 | ||
|
|
c9d6a29ae9 | ||
|
|
4b87082395 | ||
|
|
977296e820 | ||
|
|
6b048cfd95 | ||
|
|
a33ffa2411 | ||
|
|
9f4be5b8cd | ||
|
|
27e0285aae | ||
|
|
07a18dadd6 | ||
|
|
805d361da8 |
@@ -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,18 +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.5.4 \
|
||||||
&& arduino-cli lib install "Adafruit TinyUSB Library" \
|
&& arduino-cli lib install "Adafruit TinyUSB Library@3.6.0" \
|
||||||
&& arduino-cli lib install "ssd1306" \
|
&& arduino-cli lib install "Adafruit SSD1306@2.5.14" \
|
||||||
&& arduino-cli lib install "Pico PIO USB" \
|
&& arduino-cli lib install "Pico PIO USB@0.7.2" \
|
||||||
&& arduino-cli lib install "XxHash_arduino" \
|
&& arduino-cli lib install "XxHash_arduino@2.1.0" \
|
||||||
&& arduino-cli lib install "GFX Library for Arduino" \
|
&& arduino-cli lib install "GFX Library for Arduino@1.6.0"
|
||||||
&& arduino-cli lib install "SSD1306Ascii"
|
|
||||||
|
|
||||||
# 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=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"]
|
||||||
39
Dockerfile.pico2
Normal 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.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.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=240\" --output-dir \"/mnt/USBvalve_out\" \"\$1\"" >> /app/entrypoint.sh \
|
||||||
|
&& chmod +x /app/entrypoint.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
BIN
PCB/USBpipe/BOM_USBpipe_Rev1.ods
Normal file
BIN
PCB/USBpipe/BOM_USBpipe_Rev1.x.xlsx
Normal file
BIN
PCB/USBpipe/Gerber_USBpipe_Rev1.1.zip
Normal file
BIN
PCB/USBpipe/PCB_USBpipe_Rev1.x.png
Normal file
|
After Width: | Height: | Size: 90 KiB |
4754
PCB/USBpipe/PCB_USBpipe_Rev1.x.svg
Normal file
|
After Width: | Height: | Size: 336 KiB |
62
README.md
@@ -5,6 +5,7 @@
|
|||||||
<p float="left">
|
<p float="left">
|
||||||
<img src="https://github.com/cecio/USBvalve/blob/main/pictures/versions.png" alt="The two models" width="30%" height="30%" />
|
<img src="https://github.com/cecio/USBvalve/blob/main/pictures/versions.png" alt="The two models" width="30%" height="30%" />
|
||||||
<img src="https://github.com/cecio/USBvalve/blob/main/pictures/USBvalve_PIWATCH.png" alt="The Watch" width="26%" height="26%" />
|
<img src="https://github.com/cecio/USBvalve/blob/main/pictures/USBvalve_PIWATCH.png" alt="The Watch" width="26%" height="26%" />
|
||||||
|
<img src="https://github.com/cecio/USBvalve/blob/main/pictures/version1_2.png" alt="1.2" width="26%" height="26%" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
I'm sure that, like me, you were asked to put your USB drive in an *unknown* device...and then the doubt:
|
I'm sure that, like me, you were asked to put your USB drive in an *unknown* device...and then the doubt:
|
||||||
@@ -51,7 +52,7 @@ This is also fully compatible with the [Waveshare RP2040-LCD-1.28](https://www.w
|
|||||||
|
|
||||||
`pictures`: images and resources used in this doc
|
`pictures`: images and resources used in this doc
|
||||||
|
|
||||||
`STL`: STL files for enclosure. In `1.1` and `1.2` folders there are full enclosures (thanks to [WhistleMaster](https://github.com/WhistleMaster)). If you want something lighter to protect the LCD you can go with `USBvalve_sliding_cover.stl`.
|
`STL`: STL files for enclosure. In `1.1` and `1.2` folders there are full enclosures (thanks to [WhistleMaster](https://github.com/WhistleMaster)). In folders `1.2_64` and `1.2_64_simple` there are enclosures for the 128x64 screen (thanks to [rtmq0227](https://github.com/rtmq0227)). If you want something lighter to protect the LCD you can go with `USBvalve_sliding_cover.stl`.
|
||||||
|
|
||||||
## Build USBvalve
|
## Build USBvalve
|
||||||
|
|
||||||
@@ -59,13 +60,15 @@ 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
|
- 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 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.
|
||||||
|
|
||||||
Starting from version 0.8.0 of the firmware, **USBvalve** can detect HID devices (used to detect *BADUSB*). This require an additional USB port behaving as Host. If you are not interested in this, you can use the old instructions [in docs folder](https://github.com/cecio/USBvalve/blob/main/docs/BUILDING-1.1.md) and use PCB version `1.1`. Otherwise go ahead with PCB version `1.2` (we have version for USB-A or USB-B, see folder).
|
Starting from version 0.8.0 of the firmware, **USBvalve** can detect HID devices (used to detect *BADUSB*). This require an additional USB port behaving as Host. If you are not interested in this, you can use the old instructions [in docs folder](https://github.com/cecio/USBvalve/blob/main/docs/BUILDING-1.1.md) and use PCB version `1.1`. Otherwise go ahead with PCB version `1.2` (we have version for USB-A or USB-B, see folder).
|
||||||
@@ -124,6 +127,28 @@ The mapping is the following:
|
|||||||
|
|
||||||
If you want to use the DEBUG functions, you can also place a header on the 3 SWD PINs at the bottom of the board.
|
If you want to use the DEBUG functions, you can also place a header on the 3 SWD PINs at the bottom of the board.
|
||||||
|
|
||||||
|
#### With USBpipe PCB
|
||||||
|
|
||||||
|
> [!CAUTION]
|
||||||
|
> This PCB is for experienced electronic makers
|
||||||
|
> **DON'T USE IT IF YOU AREN'T SURE YOU CAN HANDLE IT!**
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> R7 and R8 aren't actually connected to anything. They are added for circuit debugging purposes.
|
||||||
|
> So they don't show up in the BOM
|
||||||
|
|
||||||
|
<img src="./pictures/USB_pipe_finished_oled.jpg" alt="USBpipe PCB" width="15%" height="15%"/>
|
||||||
|
|
||||||
|
<img src="./pictures/USB_pipe_using.jpg" alt="USBpipe" width="15%" height="15%"/>
|
||||||
|
|
||||||
|
[USBpipe](https://github.com/LiPolymer/smartUSBPipe) is a dedicated PCB for this project.
|
||||||
|
|
||||||
|
You can find everything you need in `./PCB/USBpipe/` folder.
|
||||||
|
|
||||||
|
<img src="./pictures/USB_pipe_front.png" alt="Front" width="20%" height="20%"/>
|
||||||
|
|
||||||
|
<img src="./pictures/USB_pipe_back.png" alt="Back" width="20%" height="20%"/>
|
||||||
|
|
||||||
### Flash Firmware
|
### Flash Firmware
|
||||||
|
|
||||||
To flash the firmware, follow these steps:
|
To flash the firmware, follow these steps:
|
||||||
@@ -170,19 +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.1`
|
- Arduino IDE `2.3.4`
|
||||||
- `Adafruit TinyUSB Library` version `3.0.0`, `Pico-PIO-USB` version `0.5.2`, Board `Raspberry Pi RP2040 (3.7.2)` setting Tools=>CPU Speed at `120MHz` 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`
|
||||||
- `ssd1306` OLED library version `1.8.3`
|
- `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 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.
|
||||||
|
|
||||||
#### 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 to build for Pico `v1`:
|
||||||
|
|
||||||
```
|
```
|
||||||
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`.
|
||||||
@@ -190,3 +219,18 @@ The firmware will be placed with extension `uf2` in folder `USBvalve_out`.
|
|||||||
### Contribute
|
### Contribute
|
||||||
|
|
||||||
If you have ideas or improvements in your mind, I encourage you to open an issue so that we can improve the project together! Thanks!
|
If you have ideas or improvements in your mind, I encourage you to open an issue so that we can improve the project together! Thanks!
|
||||||
|
|
||||||
|
### Support
|
||||||
|
|
||||||
|
If you have question or need support you can open an `Issue` here or reach me out on Twitter/X [@red5heep](https://twitter.com/red5heep)
|
||||||
|
|
||||||
|
### Community versions
|
||||||
|
|
||||||
|
The Community created some forks implementing support for other boards, or other modifications. **Thank you to everyone** who contributed to the development of **USBvalve**.
|
||||||
|
Here below an unofficial/incomplete/unsupported list:
|
||||||
|
- [USBvalve-tbfa-Mod](https://github.com/TryBreakFixAgain/USBvalve-tbfa-Mod)
|
||||||
|
|
||||||
|
## SAFETY WARNING
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> I've received a lot of questions about **USBvalve** and *USB killer devices*. **USBvalve** is not built to test these devices, it has not any kind of insulation or protection, so if you have the suspect you are dealing with one of these devices, test it with something else, NOT with **USBvalve** or you may damage the device, yourself or objects near to you.
|
||||||
|
|||||||
BIN
STL/1.2_64/renclosure.stl
Normal file
BIN
STL/1.2_64/renclosure_backplate.stl
Normal file
BIN
STL/1.2_64/renclosure_spacer.stl
Normal file
BIN
STL/1.2_64_simple/SimpleEnclosurex64.stl
Normal file
BIN
STL/1.2_64_simple/SimpleEnclosurex64_backplate.stl
Normal file
BIN
STL/1.2_64_simple/SimpleEnclosurex64_spacer.stl
Normal file
@@ -35,7 +35,13 @@
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include "SSD1306AsciiWire.h"
|
#include <SPI.h>
|
||||||
|
#include <Wire.h>
|
||||||
|
#include <Adafruit_GFX.h>
|
||||||
|
#include <Adafruit_SSD1306.h>
|
||||||
|
|
||||||
|
// LED Pin. If solid GREEN everything is OK, otherwise it will be put OFF
|
||||||
|
#define LED_PIN 25
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -76,9 +82,10 @@ Arduino_GFX *gfx = new Arduino_GC9A01(bus, GFX_RST, 1 /* rotation */, true /* IP
|
|||||||
|
|
||||||
#define I2C_ADDRESS 0x3C // 0X3C+SA0 - 0x3C or 0x3D
|
#define I2C_ADDRESS 0x3C // 0X3C+SA0 - 0x3C or 0x3D
|
||||||
#define RST_PIN -1 // Define proper RST_PIN if required.
|
#define RST_PIN -1 // Define proper RST_PIN if required.
|
||||||
|
#define OLED_WIDTH 128
|
||||||
#define OLED_HEIGHT 32 // 64 or 32 depending on the OLED
|
#define OLED_HEIGHT 32 // 64 or 32 depending on the OLED
|
||||||
#define OLED_LINES (OLED_HEIGHT / 8)
|
|
||||||
SSD1306AsciiWire display;
|
Adafruit_SSD1306 display(OLED_WIDTH, OLED_HEIGHT, &Wire, RST_PIN);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -109,7 +116,7 @@ bool activeState = false;
|
|||||||
//
|
//
|
||||||
// USBvalve globals
|
// USBvalve globals
|
||||||
//
|
//
|
||||||
#define VERSION "USBvalve - 0.15.1"
|
#define VERSION "USBvalve - 0.21.1"
|
||||||
boolean readme = false;
|
boolean readme = false;
|
||||||
boolean autorun = false;
|
boolean autorun = false;
|
||||||
boolean written = false;
|
boolean written = false;
|
||||||
@@ -118,6 +125,9 @@ 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;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Anti-Detection settings.
|
// Anti-Detection settings.
|
||||||
@@ -152,6 +162,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);
|
||||||
@@ -202,30 +215,18 @@ void setup() {
|
|||||||
gfx->draw16bitRGBBitmap(10,0,background,210,210); // Draw background
|
gfx->draw16bitRGBBitmap(10,0,background,210,210); // Draw background
|
||||||
delay(2000);
|
delay(2000);
|
||||||
#else
|
#else
|
||||||
Wire.begin();
|
|
||||||
Wire.setClock(400000L);
|
|
||||||
#if OLED_HEIGHT == 64
|
|
||||||
#if RST_PIN >= 0
|
#if RST_PIN >= 0
|
||||||
display.begin(&Adafruit128x64, I2C_ADDRESS, RST_PIN);
|
display.begin(SSD1306_SWITCHCAPVCC, I2C_ADDRESS, RST_PIN);
|
||||||
#else
|
#else
|
||||||
display.begin(&Adafruit128x64, I2C_ADDRESS);
|
display.begin(SSD1306_SWITCHCAPVCC, I2C_ADDRESS);
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#if RST_PIN >= 0
|
|
||||||
display.begin(&Adafruit128x32, I2C_ADDRESS, RST_PIN);
|
|
||||||
#else
|
|
||||||
display.begin(&Adafruit128x32, I2C_ADDRESS);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PIWATCH)
|
#if defined(PIWATCH)
|
||||||
// gfx->setTextSize(tsb);
|
|
||||||
gfx->setTextSize(1);
|
gfx->setTextSize(1);
|
||||||
gfx->setTextColor(MAGENTA);
|
gfx->setTextColor(MAGENTA);
|
||||||
#else
|
#else
|
||||||
display.setFont(Adafruit5x7);
|
display.setTextSize(1);
|
||||||
display.setScrollMode(SCROLL_MODE_AUTO);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cls(); // Clear display
|
cls(); // Clear display
|
||||||
@@ -240,12 +241,24 @@ void setup() {
|
|||||||
delay(1000); // Loop forever
|
delay(1000); // Loop forever
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(PIWATCH)
|
||||||
|
// Set up led PIN
|
||||||
|
gpio_init(LED_PIN);
|
||||||
|
gpio_set_dir(LED_PIN, GPIO_OUT);
|
||||||
|
gpio_put(LED_PIN, 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
// 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;
|
||||||
@@ -263,6 +276,9 @@ void loop() {
|
|||||||
if (readme == true) {
|
if (readme == true) {
|
||||||
printout("\n[!] README (R)");
|
printout("\n[!] README (R)");
|
||||||
readme = false;
|
readme = false;
|
||||||
|
#if !defined(PIWATCH)
|
||||||
|
gpio_put(LED_PIN, 0); // Turn Off LED
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (autorun == true) {
|
if (autorun == true) {
|
||||||
@@ -274,23 +290,46 @@ void loop() {
|
|||||||
printout("\n[!] DELETING");
|
printout("\n[!] DELETING");
|
||||||
deleted = false;
|
deleted = false;
|
||||||
deleted_reported = true;
|
deleted_reported = true;
|
||||||
|
#if !defined(PIWATCH)
|
||||||
|
gpio_put(LED_PIN, 0); // Turn Off LED
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (written == true && written_reported == false) {
|
if (written == true && written_reported == false) {
|
||||||
printout("\n[!] WRITING");
|
printout("\n[!] WRITING");
|
||||||
written = false;
|
written = false;
|
||||||
written_reported = true;
|
written_reported = true;
|
||||||
|
#if !defined(PIWATCH)
|
||||||
|
gpio_put(LED_PIN, 0); // Turn Off LED
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hid_sent == true && hid_reported == false) {
|
if (hid_sent == true && hid_reported == false) {
|
||||||
printout("\n[!!] HID Sending data");
|
printout("\n[!!] HID Sending data");
|
||||||
hid_sent = false;
|
hid_sent = false;
|
||||||
hid_reported = true;
|
hid_reported = true;
|
||||||
|
#if !defined(PIWATCH)
|
||||||
|
gpio_put(LED_PIN, 0); // Turn Off LED
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,11 +448,46 @@ void printout(const char *str)
|
|||||||
} else {
|
} else {
|
||||||
gfx->print(str);
|
gfx->print(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Output on serial device
|
||||||
|
SerialTinyUSB.println(str);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
void scrollUp(uint8_t pixels) {
|
||||||
|
// Read the current content of the display, shift it up by 'pixels' rows
|
||||||
|
display.startscrollright(0x00, 0x07); // Dummy values to initiate scroll
|
||||||
|
display.stopscroll(); // Immediately stop to manually shift pixels in memory
|
||||||
|
for (int i = 0; i < display.height() - pixels; i++) {
|
||||||
|
for (int j = 0; j < display.width(); j++) {
|
||||||
|
uint8_t color = display.getPixel(j, i + pixels);
|
||||||
|
display.drawPixel(j, i, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear the freed space after scrolling
|
||||||
|
display.fillRect(0, display.height() - pixels, display.width(), pixels, SSD1306_BLACK);
|
||||||
|
// Refresh the display to show the changes
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkAndScroll() {
|
||||||
|
// Assumes text height of 8 pixels, but check for 16 because newline is not used
|
||||||
|
if ((display.getCursorY() + 16) > display.height()) {
|
||||||
|
// Scroll up by 8 pixels
|
||||||
|
scrollUp(8);
|
||||||
|
display.setCursor(0, display.getCursorY() - 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void printout(const char *str)
|
void printout(const char *str)
|
||||||
{
|
{
|
||||||
|
checkAndScroll();
|
||||||
display.print(str);
|
display.print(str);
|
||||||
|
display.display();
|
||||||
|
|
||||||
|
// Output on serial device
|
||||||
|
SerialTinyUSB.println(str);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -429,7 +503,9 @@ void cls(void) {
|
|||||||
#else
|
#else
|
||||||
// Clear display
|
// Clear display
|
||||||
void cls(void) {
|
void cls(void) {
|
||||||
display.clear();
|
display.clearDisplay();
|
||||||
|
display.setTextColor(SSD1306_WHITE);
|
||||||
|
display.setCursor(0, 0);
|
||||||
printout(VERSION);
|
printout(VERSION);
|
||||||
printout("\n-----------------");
|
printout("\n-----------------");
|
||||||
}
|
}
|
||||||
@@ -486,6 +562,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" };
|
||||||
|
|
||||||
@@ -495,6 +574,9 @@ void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_re
|
|||||||
tuh_vid_pid_get(dev_addr, &vid, &pid);
|
tuh_vid_pid_get(dev_addr, &vid, &pid);
|
||||||
|
|
||||||
printout("\n[!!] HID Device");
|
printout("\n[!!] HID Device");
|
||||||
|
#if !defined(PIWATCH)
|
||||||
|
gpio_put(LED_PIN, 0); // Turn Off LED
|
||||||
|
#endif
|
||||||
|
|
||||||
SerialTinyUSB.printf("HID device address = %d, instance = %d mounted\r\n", dev_addr, instance);
|
SerialTinyUSB.printf("HID device address = %d, instance = %d mounted\r\n", dev_addr, instance);
|
||||||
SerialTinyUSB.printf("VID = %04x, PID = %04x\r\n", vid, pid);
|
SerialTinyUSB.printf("VID = %04x, PID = %04x\r\n", vid, pid);
|
||||||
@@ -503,20 +585,27 @@ 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;
|
||||||
|
hid_event_num = 0;
|
||||||
|
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;
|
||||||
|
|
||||||
@@ -534,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:
|
||||||
@@ -543,17 +633,21 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
@@ -666,3 +760,39 @@ void cursor_movement(int8_t x, int8_t y, int8_t wheel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// END of BADUSB detector section
|
// END of BADUSB detector section
|
||||||
|
|
||||||
|
//
|
||||||
|
// OTHER Host devices detection section
|
||||||
|
//
|
||||||
|
|
||||||
|
// Invoked when a device with MassStorage interface is mounted
|
||||||
|
void tuh_msc_mount_cb(uint8_t dev_addr) {
|
||||||
|
uint32_t lock_num = spin_lock_blocking(lock);
|
||||||
|
printout("\n[++] Mass Device");
|
||||||
|
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
|
||||||
|
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);
|
||||||
|
spin_unlock(lock, lock_num);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invoked when a device with CDC (Communication Device Class) interface is mounted
|
||||||
|
void tuh_cdc_mount_cb(uint8_t idx) {
|
||||||
|
uint32_t lock_num = spin_lock_blocking(lock);
|
||||||
|
printout("\n[++] CDC Device");
|
||||||
|
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
|
||||||
|
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);
|
||||||
|
spin_unlock(lock, lock_num);
|
||||||
|
}
|
||||||
|
|
||||||
|
// END of OTHER Host devices detector section
|
||||||
|
|||||||
BIN
firmware/USBvalve-0.21.1-32-pico1.uf2
Normal file
BIN
firmware/USBvalve-0.21.1-64-pico1.uf2
Normal file
BIN
pictures/USB_pipe_back.png
Normal file
|
After Width: | Height: | Size: 124 KiB |
BIN
pictures/USB_pipe_finished.jpg
Normal file
|
After Width: | Height: | Size: 2.0 MiB |
BIN
pictures/USB_pipe_finished_oled.jpg
Normal file
|
After Width: | Height: | Size: 408 KiB |
BIN
pictures/USB_pipe_front.png
Normal file
|
After Width: | Height: | Size: 136 KiB |
BIN
pictures/USB_pipe_using.jpg
Normal file
|
After Width: | Height: | Size: 745 KiB |
BIN
pictures/version1_2.png
Normal file
|
After Width: | Height: | Size: 121 KiB |