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 c4a122b..7bb9d0f 100644 Binary files a/src/fatfs/default.img and b/src/fatfs/fs_template.img differ 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..2c85060 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 build/$(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; } @@ -60,14 +63,14 @@ 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 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 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'