From ca1ae66ff91657781a10f1630c7a7b9e9fe02fcd Mon Sep 17 00:00:00 2001 From: Brandon Paiz Date: Sat, 24 Dec 2022 14:36:27 -0800 Subject: [PATCH 1/3] feat: generate Nugget FATFS from sourcefiles --- src/Dockerfile | 15 +++++++---- src/fatfs/default/.usbnugget.conf | 16 ++++++++++++ src/fatfs/default/Linux/Example/Colors.txt | 21 ++++++++++++++++ src/fatfs/default/Linux/Prank/Glitch.txt | 9 +++++++ src/fatfs/default/Linux/Prank/RickRoll.txt | 8 ++++++ src/fatfs/default/Mac/Example/RickRoll.txt | 25 +++++++++++++++++++ src/fatfs/default/Starred/Example/Colors.txt | 21 ++++++++++++++++ src/fatfs/default/Starred/Prank/Glitch.txt | 9 +++++++ src/fatfs/default/Starred/Prank/RickRoll.txt | 8 ++++++ src/fatfs/default/Windows/Example/Colors.txt | 24 ++++++++++++++++++ src/fatfs/{default.img => fs_template.img} | Bin 3080192 -> 3076096 bytes src/fatfs/generate_fs.sh | 19 ++++++++++++++ src/makefile | 11 +++++--- 13 files changed, 177 insertions(+), 9 deletions(-) create mode 100644 src/fatfs/default/.usbnugget.conf create mode 100644 src/fatfs/default/Linux/Example/Colors.txt create mode 100644 src/fatfs/default/Linux/Prank/Glitch.txt create mode 100644 src/fatfs/default/Linux/Prank/RickRoll.txt create mode 100644 src/fatfs/default/Mac/Example/RickRoll.txt create mode 100644 src/fatfs/default/Starred/Example/Colors.txt create mode 100644 src/fatfs/default/Starred/Prank/Glitch.txt create mode 100644 src/fatfs/default/Starred/Prank/RickRoll.txt create mode 100644 src/fatfs/default/Windows/Example/Colors.txt rename src/fatfs/{default.img => fs_template.img} (95%) create mode 100755 src/fatfs/generate_fs.sh diff --git a/src/Dockerfile b/src/Dockerfile index 9dd725c..9f51421 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -3,12 +3,13 @@ FROM debian:buster WORKDIR /app RUN apt-get update && apt-get install -y \ - wget \ - zip \ bsdmainutils \ - xz-utils \ + mtools \ + python3 python3-pip \ + wget \ xxd \ - python3 python3-pip + xz-utils \ + zip RUN pip3 install pyserial esptool==4.2.1 ARG ARDUINO_CLI_VERSION=0.22.0 @@ -31,9 +32,13 @@ RUN ./third_party/arduino_cli_install.sh $(readlink -f ./arduino-cli) RUN sed -i '/.*args = parser.parse_args(argv)/a\ \ \ \ args.after="no_reset"' $(grep -r parser.parse_args /root/.arduino15/packages/esp32/tools/esptool_py/ -l) COPY RubberNugget ./RubberNugget -COPY fatfs/default.img . +COPY fatfs ./fatfs COPY scripts ./scripts RUN ./scripts/build_web_ui.sh +ARG FATFS_OUTPUT_FILE +ARG FATFS_FROM_DIR +RUN mkdir build +RUN OUTPUT_FILE=${FATFS_OUTPUT_FILE} DIR=${FATFS_FROM_DIR} ./fatfs/generate_fs.sh && mv ./fatfs/${FATFS_OUTPUT_FILE} ./build RUN ./arduino-cli compile -b esp32:esp32:esp32s2 RubberNugget \ --build-property build.partitions=noota_3gffat \ --build-property build.cdc_on_boot=1 \ diff --git a/src/fatfs/default/.usbnugget.conf b/src/fatfs/default/.usbnugget.conf new file mode 100644 index 0000000..ce268fe --- /dev/null +++ b/src/fatfs/default/.usbnugget.conf @@ -0,0 +1,16 @@ +# USB Nugget Settings + +# USB settings +# Here you can change the vendor ID (VID) and product ID (PID) that the USB +# Nugget reports itself as to any computer it is plugged in to. By default, the +# Nugget is set to identify as an Apple keyboard. +vid = "0x05ac" +pid = "0x20b" + +# Wi-Fi settings +# Change these settings to modify the Wi-Fi network name and password the +# Nugget creates for its Wi-Fi interface. Change the password to prevent others +# from logging into your nugget. Passwords must be at least 8 characters in +# length. Invalid passwords will be set to default value "nugget123". +network = "Nugget AP" +password = "nugget123" diff --git a/src/fatfs/default/Linux/Example/Colors.txt b/src/fatfs/default/Linux/Example/Colors.txt new file mode 100644 index 0000000..a4f02f8 --- /dev/null +++ b/src/fatfs/default/Linux/Example/Colors.txt @@ -0,0 +1,21 @@ +CTRL ALT T +DELAY 1000 +STRING echo testing out some colors! +ENTER +DELAY 500 +LED R +DELAY 500 +LED G +DELAY 500 +LED B +DELAY 500 +LED C +DELAY 500 +LED Y +DELAY 500 +LED M +DELAY 500 +LED W +DELAY 1000 +STRING done! +ENTER diff --git a/src/fatfs/default/Linux/Prank/Glitch.txt b/src/fatfs/default/Linux/Prank/Glitch.txt new file mode 100644 index 0000000..e7a9bcd --- /dev/null +++ b/src/fatfs/default/Linux/Prank/Glitch.txt @@ -0,0 +1,9 @@ +CTRL ALT T +DELAY 1000 +STRING wget https://gist.githubusercontent.com/AlexLynd/2f8081f1940934e19a5a450ca358d142/raw/b6d4bfe05cb73f8140872448da54fb1824c4d627/linux-color-flasher.sh +ENTER +DELAY 500 +STRING chmod +x linux-color-flasher.sh +ENTER +STRING ./linux-color-flasher.sh & +ENTER diff --git a/src/fatfs/default/Linux/Prank/RickRoll.txt b/src/fatfs/default/Linux/Prank/RickRoll.txt new file mode 100644 index 0000000..9896b16 --- /dev/null +++ b/src/fatfs/default/Linux/Prank/RickRoll.txt @@ -0,0 +1,8 @@ +CTRL ALT T +DELAY 1000 +STRING firefox "https://www.youtube.com/watch?v=dQw4w9WgXcQ" +ENTER +DELAY 4000 +SPACE +DELAY 1000 +STRING F diff --git a/src/fatfs/default/Mac/Example/RickRoll.txt b/src/fatfs/default/Mac/Example/RickRoll.txt new file mode 100644 index 0000000..242b0c4 --- /dev/null +++ b/src/fatfs/default/Mac/Example/RickRoll.txt @@ -0,0 +1,25 @@ +REM Title: macOS rickroll +REM Author: Nils Streedain +REM Description:Opens a rickroll in YouTube in full screen at maximum volume. +REM Target: macOS 11.0+ +REM Version: 1.0 +REM Category: Prank +REM Source: https://github.com/nilsstreedain/Ducky-Scripts/ + +DELAY 100 +GUI SPACE +DELAY 10 +STRING terminal +DELAY 100 +ENTER +DELAY 100 +STRING open 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' +ENTER +DELAY 1000 +COMMAND TAB +DELAY 10 +STRING osascript -e 'set volume 7' && killall Terminal +ENTER +DELAY 1500 +STRING f + diff --git a/src/fatfs/default/Starred/Example/Colors.txt b/src/fatfs/default/Starred/Example/Colors.txt new file mode 100644 index 0000000..a4f02f8 --- /dev/null +++ b/src/fatfs/default/Starred/Example/Colors.txt @@ -0,0 +1,21 @@ +CTRL ALT T +DELAY 1000 +STRING echo testing out some colors! +ENTER +DELAY 500 +LED R +DELAY 500 +LED G +DELAY 500 +LED B +DELAY 500 +LED C +DELAY 500 +LED Y +DELAY 500 +LED M +DELAY 500 +LED W +DELAY 1000 +STRING done! +ENTER diff --git a/src/fatfs/default/Starred/Prank/Glitch.txt b/src/fatfs/default/Starred/Prank/Glitch.txt new file mode 100644 index 0000000..e7a9bcd --- /dev/null +++ b/src/fatfs/default/Starred/Prank/Glitch.txt @@ -0,0 +1,9 @@ +CTRL ALT T +DELAY 1000 +STRING wget https://gist.githubusercontent.com/AlexLynd/2f8081f1940934e19a5a450ca358d142/raw/b6d4bfe05cb73f8140872448da54fb1824c4d627/linux-color-flasher.sh +ENTER +DELAY 500 +STRING chmod +x linux-color-flasher.sh +ENTER +STRING ./linux-color-flasher.sh & +ENTER diff --git a/src/fatfs/default/Starred/Prank/RickRoll.txt b/src/fatfs/default/Starred/Prank/RickRoll.txt new file mode 100644 index 0000000..9896b16 --- /dev/null +++ b/src/fatfs/default/Starred/Prank/RickRoll.txt @@ -0,0 +1,8 @@ +CTRL ALT T +DELAY 1000 +STRING firefox "https://www.youtube.com/watch?v=dQw4w9WgXcQ" +ENTER +DELAY 4000 +SPACE +DELAY 1000 +STRING F diff --git a/src/fatfs/default/Windows/Example/Colors.txt b/src/fatfs/default/Windows/Example/Colors.txt new file mode 100644 index 0000000..b2b161e --- /dev/null +++ b/src/fatfs/default/Windows/Example/Colors.txt @@ -0,0 +1,24 @@ +GUI R +DELAY 1000 +STRING cmd +ENTER +DELAY 500 +STRING echo trying out some colors! +ENTER +DELAY 500 +LED R +DELAY 500 +LED G +DELAY 500 +LED B +DELAY 500 +LED C +DELAY 500 +LED Y +DELAY 500 +LED M +DELAY 500 +LED W +DELAY 1000 +STRING done! +ENTER diff --git a/src/fatfs/default.img b/src/fatfs/fs_template.img similarity index 95% rename from src/fatfs/default.img rename to src/fatfs/fs_template.img index c4a122b95522dfe8fd65866025a40a29c2aa6349..7bb9d0f211228013f2b0e58812a5558621ea898f 100644 GIT binary patch delta 283 zcmZ{aOD;nJ07boie5y)ld7!C zhHT1~)MQ(Bq%OM;MEf^IQjbN_-Mcs{XO3%^pSO*2=IH#s`5chy?EN=)qiXIc{yG@= JrT=~}`~Y3QUxNSu delta 10654 zcmeGiYiv{3`8Whh48$fh6lf@igb^6TkHkrwXuvME6H*)}*f%7Zy6WCsU)xu)?{)9J zj*}l?DB7LYO6%AJsHH!k>n8ZOF4D9$}^oYnhFe;w0notGU2DvSgqq8yq;4)hsB)|!v;9`1__jp!J$6YV~G z`dNA_z$I;!4xj2rEaKpG7C`^QT1#4EeLod2R%2NI)T%SadeSZ<>kEh))(MCs2?&t$ zNYP=H01Wpp{xYE1y7ttJ2v6+6p_4CtLVrRVEzE#t zzlajh5SBR58>F!wqtoUBSPB{gF~WEbs7(S?6}ey$2dIW(`vJw#*1$ky9)Y}0p#`2G z@L0e}YjVH>p92J*5_lqZ39!x>2)sIiOV2x*Ji&``NydFayyI|Ra3^NPIL^vaJjbbe z=OF1+Q>?1b23!Ez#3u7usUWKg7F2~#CorpERRRE0n3FQuoXX2Ef&~R<(}cV@7DSlf z!uzLioKLX1w7Q!BEdhk7KrsO##CcH_5>o^w&`V{rX&#UBQ)3b<$6fXbA&&RpM$e?D z(9Uv=_N?{Y>KSV!n;#ZhdISQ@U`G=U6nCuf#eRY*BgF|G!U|)N$g6ot9>*e^;SFxE ziUK|Ha#}f=XH{M)-~@0F7+|gzMA&wM<#^W|lsH=iApvuF;JJz=Kq)IgYeJSXI4vcU zAUR+W&;(+Vv8apGg$K>G3eMyd6^{W?Do*n(y!$a%NU<`@0Zx#D2*A?3m{e0P+$T=3 zY2b>5S;2WBohGYI4x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YcT+@^>63n2Nc4r=7V2qsc>r5BZlw7$3k0w; za|76~?J{#u(r!T?+sJL?Via=S+&VxF`pD9!AnHVIM4#wI2Ee#NpXMQe^YYFD=jG1( zhr3}*zq8tu4QchlLb>eA#*M-TwSer)l9#f=#YU36Os`u|3+@fp>UZcwt;ij^UN|ae zZP~ba$G#ZWE}L7J!st)Mys!)Pqfw$3ZQyTi;f}o$0VoCJg*UWc_lD&3|6U-HBSo`@ z`2j}RxTzG2i4VrDVjPJNHk0^Z@8S$%SvBt=bQB~LSU@sM{(k{`ez#ojQeDNYt61fX zyIWf+km5>N*rq3a7BP3cwgT=C>MEqBWEDf^CY@X+UPc?qcFiEyFs<^`?I^bJdNro9 z+HyzmAO&*@{XhU(xBnmS1}6lRZ4Ja_i;Z>p|cOupn? z@v{p#R&+K!w&p<3`WHUD@M85luf6@<FXAFnz~JJ&;71LXyAW& z>0cY9szij??^h@XMAG|Pe=F7kM ziJO@!>{WXXI>PMdV_r7Yl1U>iOzxGYrm^U2%0h4m+sQ>@~ diff --git a/src/fatfs/generate_fs.sh b/src/fatfs/generate_fs.sh new file mode 100755 index 0000000..ace8ee5 --- /dev/null +++ b/src/fatfs/generate_fs.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# cd to dir where this script is held so relative paths work +cd "$(dirname "$(readlink -f "$0")")" + +# The directory to pack into the generated image +dir=${DIR:-default} +output_file=${OUTPUT_FILE:-fatfs.img} + +cp fs_template.img "$output_file" + + +# Asterisk globbing doesn't work here because we need to include dotfiles +for entry in $(find "$dir" -mindepth 1 -maxdepth 1); do + # mcopy has an option to print what it's copying but it only prints the + # filename, not the whole path + echo "copying (recursive): $entry" + mcopy -i "$output_file" -s "$entry" :: +done diff --git a/src/makefile b/src/makefile index ba812d6..4392ff5 100644 --- a/src/makefile +++ b/src/makefile @@ -4,12 +4,15 @@ IMAGE_NAME = rubber-nugget CONTAINER_NAME := $(IMAGE_NAME)-$(shell date +%s) ARDUINO_CLI_VERSION = 0.22.0 +# File system name to generate +FATFS ?= fatfs.img + submodules: git submodule init git submodule update build: submodules - docker build . --file Dockerfile --build-arg ARDUINO_CLI_VERSION=$(ARDUINO_CLI_VERSION) --tag rubber-nugget + docker build . --file Dockerfile --build-arg FATFS_OUTPUT_FILE=$(FATFS) --build-arg FATFS_FROM_DIR=default --build-arg ARDUINO_CLI_VERSION=$(ARDUINO_CLI_VERSION) --tag rubber-nugget flash: check-port build docker create --name $(CONTAINER_NAME) --device=$(PORT) -t rubber-nugget:latest @@ -18,7 +21,7 @@ flash: check-port build './arduino-cli upload -b esp32:esp32:esp32s2 --port $(PORT) RubberNugget/ && sleep 2' ifeq ($(RESET_SCRIPTS_DURING_FLASH), true) docker exec $(CONTAINER_NAME) bash -c \ - 'python3 -m esptool --after no_reset write_flash 0x110000 default.img' + 'python3 -m esptool --after no_reset write_flash 0x111000 $(FATFS)' endif docker rm --force $(CONTAINER_NAME) @@ -29,7 +32,7 @@ generate_bin: build docker rm --force $(CONTAINER_NAME) cp usb_nugget_bin_template usb_nugget.bin dd of=usb_nugget.bin if=build/RubberNugget.ino.bin seek=65536 bs=1 conv=notrunc - dd of=usb_nugget.bin if=fatfs/default.img seek=1114112 bs=1 conv=notrunc count=3080192 + dd of=usb_nugget.bin if=build/$(FATFS) seek=1118208 bs=1 conv=notrunc count=3076096 check-port: @ls $(PORT) || { echo "Device not found at $(PORT)" && exit 1; } @@ -67,7 +70,7 @@ flash-on-mac: check-mac-port check-mac-deps arduino-cli mac-build sudo docker cp $(CONTAINER_NAME):/app/build . sudo docker rm --force $(CONTAINER_NAME) ifeq ($(RESET_SCRIPTS_DURING_FLASH), true) - python3 -m esptool --after no_reset write_flash 0x110000 fatfs/default.img + python3 -m esptool --after no_reset write_flash 0x110000 fatfs/$(FATFS) endif { sudo ./scripts/arduino-cli upload -b esp32:esp32:esp32s2 --port $(MAC_PORT) --config-file arduino-cli-mac.yaml --input-dir build; } || echo \ 'If you get the error: "esptool.py can not exit the download mode over USB..." this is a bug in arduino-cli and can be ignored' From e8b5447feaafca95b9055fec260225be4468fdaf Mon Sep 17 00:00:00 2001 From: Brandon Paiz Date: Wed, 8 Feb 2023 21:02:38 -0800 Subject: [PATCH 2/3] fix makefile targets --- src/makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/makefile b/src/makefile index 4392ff5..9b33989 100644 --- a/src/makefile +++ b/src/makefile @@ -21,7 +21,7 @@ flash: check-port build './arduino-cli upload -b esp32:esp32:esp32s2 --port $(PORT) RubberNugget/ && sleep 2' ifeq ($(RESET_SCRIPTS_DURING_FLASH), true) docker exec $(CONTAINER_NAME) bash -c \ - 'python3 -m esptool --after no_reset write_flash 0x111000 $(FATFS)' + 'python3 -m esptool --after no_reset write_flash 0x111000 build/$(FATFS)' endif docker rm --force $(CONTAINER_NAME) @@ -70,7 +70,7 @@ flash-on-mac: check-mac-port check-mac-deps arduino-cli mac-build sudo docker cp $(CONTAINER_NAME):/app/build . sudo docker rm --force $(CONTAINER_NAME) ifeq ($(RESET_SCRIPTS_DURING_FLASH), true) - python3 -m esptool --after no_reset write_flash 0x110000 fatfs/$(FATFS) + python3 -m esptool --after no_reset write_flash 0x111000 build/$(FATFS) endif { sudo ./scripts/arduino-cli upload -b esp32:esp32:esp32s2 --port $(MAC_PORT) --config-file arduino-cli-mac.yaml --input-dir build; } || echo \ 'If you get the error: "esptool.py can not exit the download mode over USB..." this is a bug in arduino-cli and can be ignored' From da20d2192d87a78f4c67bf6f55ff4e444d3a4f03 Mon Sep 17 00:00:00 2001 From: Brandon Paiz Date: Wed, 8 Feb 2023 21:45:09 -0800 Subject: [PATCH 3/3] fix mac-build target --- src/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/makefile b/src/makefile index 9b33989..2c85060 100644 --- a/src/makefile +++ b/src/makefile @@ -63,7 +63,7 @@ check-mac-port: @ls $(MAC_PORT) || { echo "Device not found at $(MAC_PORT)" && exit 1; } mac-build: submodules - sudo docker build . --file Dockerfile --build-arg ARDUINO_CLI_VERSION=$(ARDUINO_CLI_VERSION) --tag rubber-nugget + sudo docker build . --file Dockerfile --build-arg FATFS_OUTPUT_FILE=$(FATFS) --build-arg FATFS_FROM_DIR=default --build-arg ARDUINO_CLI_VERSION=$(ARDUINO_CLI_VERSION) --tag rubber-nugget flash-on-mac: check-mac-port check-mac-deps arduino-cli mac-build sudo docker create --name $(CONTAINER_NAME) -t rubber-nugget:latest