README >
usb3sun uses Nix (the package manager) to get exact versions of its dependencies. you can build the firmware without Nix, but your mileage may vary.
there are two build environments, pico
and linux
.
pico
is the real firmware that runs on a real usb3sun adapter.
linux
runs on an ordinary linux machine, for the test suite and interactive demo.
git apply picopiousb1.patch
(picopiousb1.patch, #12)
→ improves compatibility with Microsoft Wired Keyboard 600 (045E:0750)git apply tinyusb3.patch
(tinyusb3.patch, #13)
→ fixes a bug where dummy event callbacks shadow our own callbacks (Adafruit_TinyUSB_Arduino#296)git apply debug1.patch
(debug1.patch)
→ makes TinyUSB debug logging configurable at runtimegit -C ~/.platformio/packages/framework-arduinopico apply $PWD/debug2.patch
(debug2.patch)
→ makes arduino-pico debug logging configurable at runtimegit -C ~/.platformio/packages/framework-arduinopico apply $PWD/debug3.patch
(debug3.patch)
→ makes TinyUSB debug logging configurable at runtime- (if using Nix)
nix-shell
pio run -e pico
- (if using Nix)
nix-shell
pio run -e linux
the interactive demo can only be built for the linux
environment, and uses a named pipe (fifo(7)) to emulate the display:
$ ./run-demo.sh # run, creating a random fifo in /tmp
$ ./run-demo.sh <path/to/fifo> # run, creating a fifo at the given path
to get a live view of the emulated display, open another terminal, and cat the same path you gave in a loop:
$ while :; do cat <path/to/fifo>; done
note that due to the way named pipes work, the demo will pause until you start reading from the fifo, and will get killed with SIGPIPE if you stop reading from the fifo.
input in the terminal where you ran the demo is (roughly and incompletely) translated to usb keyboard input, with a couple of exceptions:
- Alt+Space becomes Right Ctrl+Space, opening the menu
- q quits the demo
the main test suite can only be built for the linux
environment, and automatically runs multiple times to test every combination of -DSUNK_ENABLE and -DSUNM_ENABLE:
$ ./run-tests.sh # run all tests
$ ./run-tests.sh all # (same as above)
$ ./run-tests.sh <test> # run a specific test
$ pio run -e linux -t exec # list available tests
the build tests compile the firmware with a few different sets of build flags, to ensure that they all build without errors (and show you the warnings for each):
$ ./run-build-tests.sh # both pico and linux
$ ./run-build-tests.sh -e pico # pico only
$ ./run-build-tests.sh -e linux # linux only
*** [.pio/build/pico/firmware.elf] ModuleNotFoundError : No module named 'SCons.Tool.FortranCommon'
— in vscode with the platformio extension, this can happen if you start building the firmware too quickly after making changes to platformio.ini.
wait a moment, then try again.
if you get “patch does not apply” errors:
$ dos2unix '.pio/libdeps/pico/Adafruit TinyUSB Library/src/host/usbh.c'
copy these commands to do all of the above:
dos2unix '.pio/libdeps/pico/Adafruit TinyUSB Library/src/host/usbh.c'
git apply tinyusb1.patch
git apply tinyusb2.patch
git apply debug1.patch
git -C ~/.platformio/packages/framework-arduinopico apply $PWD/debug2.patch
if you encounter problems with paths being too long:
- open an admin command prompt (Win+X, A)
git config --system core.longpaths true
- whenever you get
[WinError 3]
or[WinError 145]
, delete%USERPROFILE%\.platformio\.cache\tmp
if you get “patch does not apply” errors in step 2:
- change the line endings from CRLF to LF in <.pio/libdeps/pico/Adafruit TinyUSB Library/src/host/usbh.c>
$ pio run -t compiledb