From 421bdb7ccc59be0e86053eece9d1f45178c4b530 Mon Sep 17 00:00:00 2001 From: John Hunter Date: Thu, 24 Apr 2025 22:09:36 +0100 Subject: [PATCH 01/11] Update to Mpy 1.24 --- .github/workflows/build.yml | 2 +- .gitmodules | 1 + Dockerfile | 2 +- README.md | 8 ++++---- flasher/README.md | 2 +- micropython | 2 +- patches/micropython-lib.diff | 8 ++++---- patches/micropython.diff | 19 +++++++++++++++++-- scripts/build.sh | 2 -- scripts/hard-reset.sh | 12 ++++++++++++ 10 files changed, 42 insertions(+), 16 deletions(-) create mode 100755 scripts/hard-reset.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 81039919..f628d708 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: uses: actions/checkout@v4 with: repository: espressif/esp-idf - ref: v5.2.1 + ref: v5.2.3 path: esp-idf submodules: true - name: Submodules diff --git a/.gitmodules b/.gitmodules index 8bbd3af0..b69d1d94 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "micropython"] path = micropython url = https://github.com/micropython/micropython.git + branch = v1.24-release diff --git a/Dockerfile b/Dockerfile index 1668a2d5..0818718c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM espressif/idf:v5.2.1 +FROM espressif/idf:v5.2.3 # Mark the firmware as a safe include directory for git RUN git config --global --add safe.directory "*" diff --git a/README.md b/README.md index 0e4381f1..02ba9c63 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,11 @@ To build with a consistent toolchain, use docker. Pull the firmware build image: - docker pull matthewwilkes/esp_idf:5.2.1 + docker pull matthewwilkes/esp_idf:5.2.3 (Or build it yourself, if you prefer): - docker build . -t matthewwilkes/esp_idf:5.2.1 + docker build . -t matthewwilkes/esp_idf:5.2.3 Initialize submodules: @@ -41,12 +41,12 @@ Before you build the first time, apply any patches to vendored content: Then to build the images run: - docker run -it --rm --env "TARGET=esp32s3" -v "$(pwd)"/:/firmware matthewwilkes/esp_idf:5.2.1 + docker run -it --rm --env "TARGET=esp32s3" -v "$(pwd)"/:/firmware -u $UID -e HOME=/tmp matthewwilkes/esp_idf:5.2.3 Alternatively, to flash a badge: put the badge into bootloader by disconnecting the usb in, press and hold bat and boop buttons for 20 seconds then reconnect the usb in and run: - docker run -it --rm --device /dev/ttyACM0:/dev/ttyUSB0 --env "TARGET=esp32s3" -v "$(pwd)"/:/firmware matthewwilkes/esp_idf:5.2.1 deploy + docker run -it --rm --device /dev/ttyACM0:/dev/ttyUSB0 --env "TARGET=esp32s3" -v "$(pwd)"/:/firmware -u $UID -e HOME=/tmp matthewwilkes/esp_idf:5.2.3 deploy where /dev/ttyACM0 is the device's endpoint. This value is correct on Linux. diff --git a/flasher/README.md b/flasher/README.md index f3fdf8ff..9313b82b 100644 --- a/flasher/README.md +++ b/flasher/README.md @@ -2,7 +2,7 @@ First, create a merged firmware binary. This can be done by building as normal, then using: - docker run -it --entrypoint /firmware/scripts/merge-firmwares.sh --env "TARGET=esp32s3" -v "$(pwd)"/:/firmware matthewwilkes/esp_idf:5.2.1 + docker run -it --entrypoint /firmware/scripts/merge-firmwares.sh --env "TARGET=esp32s3" -v "$(pwd)"/:/firmware -u $UID -e HOME=/tmp matthewwilkes/esp_idf:5.2.3 Then, copy the merged firmware to this directory: diff --git a/micropython b/micropython index 5114f2c1..ecfdd5d6 160000 --- a/micropython +++ b/micropython @@ -1 +1 @@ -Subproject commit 5114f2c1ea7c05fc7ab920299967595cfc5307de +Subproject commit ecfdd5d6f9be971852003c2049600dc7b3e2a838 diff --git a/patches/micropython-lib.diff b/patches/micropython-lib.diff index e642ae61..74adb7ba 100644 --- a/patches/micropython-lib.diff +++ b/patches/micropython-lib.diff @@ -1,5 +1,5 @@ diff --git a/python-ecosys/requests/requests/__init__.py b/python-ecosys/requests/requests/__init__.py -index 7401029..e55840b 100644 +index a9a1836..555d5d2 100644 --- a/python-ecosys/requests/requests/__init__.py +++ b/python-ecosys/requests/requests/__init__.py @@ -43,6 +43,7 @@ def request( @@ -8,9 +8,9 @@ index 7401029..e55840b 100644 parse_headers=True, + allow_redirects=True, ): - redirect = None # redirection url, None means no redirection - chunked_data = data and getattr(data, "__next__", None) and not getattr(data, "__len__", None) -@@ -159,7 +160,7 @@ def request( + if headers is None: + headers = {} +@@ -178,7 +179,7 @@ def request( s.close() raise diff --git a/patches/micropython.diff b/patches/micropython.diff index b298e8be..57680192 100644 --- a/patches/micropython.diff +++ b/patches/micropython.diff @@ -1,5 +1,5 @@ diff --git a/ports/esp32/esp32_common.cmake b/ports/esp32/esp32_common.cmake -index e928fb439..fde5160a5 100644 +index 565f6feec..abca80a72 100644 --- a/ports/esp32/esp32_common.cmake +++ b/ports/esp32/esp32_common.cmake @@ -11,6 +11,9 @@ endif() @@ -12,7 +12,7 @@ index e928fb439..fde5160a5 100644 # CMAKE_BUILD_EARLY_EXPANSION is set during the component-discovery phase of # `idf.py build`, so none of the extmod/usermod (and in reality, most of the # micropython) rules need to happen. Specifically, you cannot invoke add_library. -@@ -69,7 +72,7 @@ list(APPEND MICROPY_SOURCE_PORT +@@ -101,7 +104,7 @@ list(APPEND MICROPY_SOURCE_PORT machine_pin.c machine_touchpad.c machine_dac.c @@ -21,3 +21,18 @@ index e928fb439..fde5160a5 100644 network_common.c network_lan.c network_ppp.c +diff --git a/ports/esp32/mpconfigport.h b/ports/esp32/mpconfigport.h +index e36d12bc0..7fff5a767 100644 +--- a/ports/esp32/mpconfigport.h ++++ b/ports/esp32/mpconfigport.h +@@ -12,6 +12,10 @@ + #include "driver/i2s_std.h" + #include "esp_wifi_types.h" + ++#ifndef USB_SERIAL_JTAG_PACKET_SZ_BYTES ++#define USB_SERIAL_JTAG_PACKET_SZ_BYTES (64) ++#endif ++ + #ifndef MICROPY_CONFIG_ROM_LEVEL + #define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES) + #endif diff --git a/scripts/build.sh b/scripts/build.sh index 11cf9b8d..5de080c9 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,8 +1,6 @@ #!/bin/bash set -e -o pipefail -source ~/.profile - find /firmware -name '.git' -exec bash -c 'git config --global --add safe.directory ${0%/.git}' {} \; cd /firmware diff --git a/scripts/hard-reset.sh b/scripts/hard-reset.sh new file mode 100755 index 00000000..c5df54a1 --- /dev/null +++ b/scripts/hard-reset.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Hard resets submodules. +# Assumes submodules are initialised. +# scripts/firstTime.sh will need to be rerun after this. + +# Use: sudo scripts/hard_reset.sh + +cd micropython +git submodule foreach git clean -fdx +git clean -fdx +git reset --hard --recurse-submodules \ No newline at end of file From aa264ec71857c838897385485cbc07332ecaa402 Mon Sep 17 00:00:00 2001 From: John Hunter Date: Thu, 24 Apr 2025 22:21:05 +0100 Subject: [PATCH 02/11] update to 1.25 --- .github/workflows/build.yml | 2 +- .gitmodules | 1 - Dockerfile | 2 +- README.md | 8 ++++---- flasher/README.md | 2 +- micropython | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f628d708..28e0f5e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: uses: actions/checkout@v4 with: repository: espressif/esp-idf - ref: v5.2.3 + ref: v5.4.1 path: esp-idf submodules: true - name: Submodules diff --git a/.gitmodules b/.gitmodules index b69d1d94..8bbd3af0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,3 @@ [submodule "micropython"] path = micropython url = https://github.com/micropython/micropython.git - branch = v1.24-release diff --git a/Dockerfile b/Dockerfile index 0818718c..bb6a4868 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM espressif/idf:v5.2.3 +FROM espressif/idf:v5.4.1 # Mark the firmware as a safe include directory for git RUN git config --global --add safe.directory "*" diff --git a/README.md b/README.md index 02ba9c63..e34079b0 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,11 @@ To build with a consistent toolchain, use docker. Pull the firmware build image: - docker pull matthewwilkes/esp_idf:5.2.3 + docker pull matthewwilkes/esp_idf:5.4.1 (Or build it yourself, if you prefer): - docker build . -t matthewwilkes/esp_idf:5.2.3 + docker build . -t matthewwilkes/esp_idf:5.4.1 Initialize submodules: @@ -41,12 +41,12 @@ Before you build the first time, apply any patches to vendored content: Then to build the images run: - docker run -it --rm --env "TARGET=esp32s3" -v "$(pwd)"/:/firmware -u $UID -e HOME=/tmp matthewwilkes/esp_idf:5.2.3 + docker run -it --rm --env "TARGET=esp32s3" -v "$(pwd)"/:/firmware -u $UID -e HOME=/tmp matthewwilkes/esp_idf:5.4.1 Alternatively, to flash a badge: put the badge into bootloader by disconnecting the usb in, press and hold bat and boop buttons for 20 seconds then reconnect the usb in and run: - docker run -it --rm --device /dev/ttyACM0:/dev/ttyUSB0 --env "TARGET=esp32s3" -v "$(pwd)"/:/firmware -u $UID -e HOME=/tmp matthewwilkes/esp_idf:5.2.3 deploy + docker run -it --rm --device /dev/ttyACM0:/dev/ttyUSB0 --env "TARGET=esp32s3" -v "$(pwd)"/:/firmware -u $UID -e HOME=/tmp matthewwilkes/esp_idf:5.4.1 deploy where /dev/ttyACM0 is the device's endpoint. This value is correct on Linux. diff --git a/flasher/README.md b/flasher/README.md index 9313b82b..53d6a03f 100644 --- a/flasher/README.md +++ b/flasher/README.md @@ -2,7 +2,7 @@ First, create a merged firmware binary. This can be done by building as normal, then using: - docker run -it --entrypoint /firmware/scripts/merge-firmwares.sh --env "TARGET=esp32s3" -v "$(pwd)"/:/firmware -u $UID -e HOME=/tmp matthewwilkes/esp_idf:5.2.3 + docker run -it --entrypoint /firmware/scripts/merge-firmwares.sh --env "TARGET=esp32s3" -v "$(pwd)"/:/firmware -u $UID -e HOME=/tmp matthewwilkes/esp_idf:5.4.1 Then, copy the merged firmware to this directory: diff --git a/micropython b/micropython index ecfdd5d6..f498a16c 160000 --- a/micropython +++ b/micropython @@ -1 +1 @@ -Subproject commit ecfdd5d6f9be971852003c2049600dc7b3e2a838 +Subproject commit f498a16c7db6d4b2de200b3e0856528dfe0613c3 From 3afe3480abbba0af587a2549afa711048601d235 Mon Sep 17 00:00:00 2001 From: John Hunter Date: Thu, 24 Apr 2025 23:05:40 +0100 Subject: [PATCH 03/11] 1.25 fixes --- components/flow3r_bmi270/CMakeLists.txt | 2 +- components/flow3r_bsp/CMakeLists.txt | 2 +- patches/micropython-lib.diff | 8 ++++---- patches/micropython.diff | 18 ++++++++++++++---- tildagon/sdkconfig.board | 2 -- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/components/flow3r_bmi270/CMakeLists.txt b/components/flow3r_bmi270/CMakeLists.txt index 98d4ad93..8222a932 100644 --- a/components/flow3r_bmi270/CMakeLists.txt +++ b/components/flow3r_bmi270/CMakeLists.txt @@ -6,5 +6,5 @@ idf_component_register( . ../st3m REQUIRES - main_esp32s3 + main ) \ No newline at end of file diff --git a/components/flow3r_bsp/CMakeLists.txt b/components/flow3r_bsp/CMakeLists.txt index fa2f5e81..62676371 100644 --- a/components/flow3r_bsp/CMakeLists.txt +++ b/components/flow3r_bsp/CMakeLists.txt @@ -10,5 +10,5 @@ idf_component_register( REQUIRES driver vfs - main_esp32s3 + main ) diff --git a/patches/micropython-lib.diff b/patches/micropython-lib.diff index 74adb7ba..2a86cf52 100644 --- a/patches/micropython-lib.diff +++ b/patches/micropython-lib.diff @@ -1,5 +1,5 @@ diff --git a/python-ecosys/requests/requests/__init__.py b/python-ecosys/requests/requests/__init__.py -index a9a1836..555d5d2 100644 +index 4ca7489..04481e3 100644 --- a/python-ecosys/requests/requests/__init__.py +++ b/python-ecosys/requests/requests/__init__.py @@ -43,6 +43,7 @@ def request( @@ -10,12 +10,12 @@ index a9a1836..555d5d2 100644 ): if headers is None: headers = {} -@@ -178,7 +179,7 @@ def request( +@@ -180,7 +181,7 @@ def request( s.close() raise - if redirect: + if redirect and allow_redirects: s.close() - if status in [301, 302, 303]: - return request("GET", redirect, None, None, headers, stream) + # Use the host specified in the redirect URL, as it may not be the same as the original URL. + headers.pop("Host", None) diff --git a/patches/micropython.diff b/patches/micropython.diff index 57680192..312ad0b3 100644 --- a/patches/micropython.diff +++ b/patches/micropython.diff @@ -1,8 +1,18 @@ +diff --git a/ports/esp32/Makefile b/ports/esp32/Makefile +index 7f31ea691..1eb783685 100644 +--- a/ports/esp32/Makefile ++++ b/ports/esp32/Makefile +@@ -112,4 +112,4 @@ size-files: + # This is done in a dedicated build directory as some CMake cache values are not + # set correctly if not all submodules are loaded yet. + submodules: +- $(Q)IDF_COMPONENT_MANAGER=0 idf.py $(IDFPY_FLAGS) -B $(BUILD)/submodules -D UPDATE_SUBMODULES=1 reconfigure ++ $(Q)idf.py $(IDFPY_FLAGS) -B $(BUILD)/submodules -D UPDATE_SUBMODULES=1 reconfigure diff --git a/ports/esp32/esp32_common.cmake b/ports/esp32/esp32_common.cmake -index 565f6feec..abca80a72 100644 +index dedef6d78..f1fbb5897 100644 --- a/ports/esp32/esp32_common.cmake +++ b/ports/esp32/esp32_common.cmake -@@ -11,6 +11,9 @@ endif() +@@ -31,6 +31,9 @@ endif() # Include core source components. include(${MICROPY_DIR}/py/py.cmake) @@ -12,7 +22,7 @@ index 565f6feec..abca80a72 100644 # CMAKE_BUILD_EARLY_EXPANSION is set during the component-discovery phase of # `idf.py build`, so none of the extmod/usermod (and in reality, most of the # micropython) rules need to happen. Specifically, you cannot invoke add_library. -@@ -101,7 +104,7 @@ list(APPEND MICROPY_SOURCE_PORT +@@ -122,7 +125,7 @@ list(APPEND MICROPY_SOURCE_PORT machine_pin.c machine_touchpad.c machine_dac.c @@ -22,7 +32,7 @@ index 565f6feec..abca80a72 100644 network_lan.c network_ppp.c diff --git a/ports/esp32/mpconfigport.h b/ports/esp32/mpconfigport.h -index e36d12bc0..7fff5a767 100644 +index b5b7d63a5..7cd35d36c 100644 --- a/ports/esp32/mpconfigport.h +++ b/ports/esp32/mpconfigport.h @@ -12,6 +12,10 @@ diff --git a/tildagon/sdkconfig.board b/tildagon/sdkconfig.board index 8feb924c..dee53360 100644 --- a/tildagon/sdkconfig.board +++ b/tildagon/sdkconfig.board @@ -26,5 +26,3 @@ CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y CONFIG_APP_EXCLUDE_PROJECT_VER_VAR=n CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR=n CONFIG_APP_PROJECT_VER_FROM_CONFIG=y - -CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP=y From 572e99197a2cd3921ac983f3ae895cefc4fdc8bf Mon Sep 17 00:00:00 2001 From: John Hunter Date: Fri, 25 Apr 2025 00:01:11 +0100 Subject: [PATCH 04/11] Appease the CI --- drivers/tildagon_usb/tildagon_usb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tildagon_usb/tildagon_usb.c b/drivers/tildagon_usb/tildagon_usb.c index 8fb1c673..c399b7d5 100644 --- a/drivers/tildagon_usb/tildagon_usb.c +++ b/drivers/tildagon_usb/tildagon_usb.c @@ -2,6 +2,7 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "esp_task.h" #define DEBUG_LED GPIO_NUM_35 From 7f792f4ef41423e0c009ee0b4dc22cd0e542e827 Mon Sep 17 00:00:00 2001 From: Molive Date: Mon, 28 Apr 2025 23:07:49 +0100 Subject: [PATCH 05/11] Remove tildagon_usb --- drivers/micropython.cmake | 3 --- drivers/tildagon_usb/tildagon_usb.c | 25 ------------------------- drivers/tildagon_usb/tildagon_usb.cmake | 15 --------------- 3 files changed, 43 deletions(-) delete mode 100644 drivers/tildagon_usb/tildagon_usb.c delete mode 100644 drivers/tildagon_usb/tildagon_usb.cmake diff --git a/drivers/micropython.cmake b/drivers/micropython.cmake index da9e56e0..fa2da145 100644 --- a/drivers/micropython.cmake +++ b/drivers/micropython.cmake @@ -7,9 +7,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/tildagon_helpers/micropython.cmake) # Add the display driver include(${CMAKE_CURRENT_LIST_DIR}/gc9a01/micropython.cmake) -# Add the HID interface -include(${CMAKE_CURRENT_LIST_DIR}/tildagon_usb/tildagon_usb.cmake) - # Add TCA9548A I2C MUX and micropython machine.I2C bindings include(${CMAKE_CURRENT_LIST_DIR}/tildagon_i2c/tildagon_i2c.cmake) diff --git a/drivers/tildagon_usb/tildagon_usb.c b/drivers/tildagon_usb/tildagon_usb.c deleted file mode 100644 index c399b7d5..00000000 --- a/drivers/tildagon_usb/tildagon_usb.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "driver/gpio.h" - -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "esp_task.h" - -#define DEBUG_LED GPIO_NUM_35 - -TaskHandle_t tildagon_usb_task_handle = NULL; - -void tildagon_usb_task(void *param __attribute__((__unused__))) { - // gpio_reset_pin(DEBUG_LED); - // gpio_set_direction(DEBUG_LED, GPIO_MODE_OUTPUT); - - while(1) { - // gpio_set_level(DEBUG_LED, 1); - vTaskDelay(500 / portTICK_PERIOD_MS); - // gpio_set_level(DEBUG_LED, 0); - // vTaskDelay(500 / portTICK_PERIOD_MS); - } -} - -void tildagon_usb_init(void) { - xTaskCreatePinnedToCore(tildagon_usb_task, "usb_task", 1024, NULL, tskIDLE_PRIORITY+3, &tildagon_usb_task_handle, 0); -} \ No newline at end of file diff --git a/drivers/tildagon_usb/tildagon_usb.cmake b/drivers/tildagon_usb/tildagon_usb.cmake deleted file mode 100644 index 1eeae833..00000000 --- a/drivers/tildagon_usb/tildagon_usb.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# Create an INTERFACE library for our C module. -add_library(usermod_tildagon_usb INTERFACE) - -# Add our source files to the lib -target_sources(usermod_tildagon_usb INTERFACE - ${CMAKE_CURRENT_LIST_DIR}/tildagon_usb.c -) - -# Add the current directory as an include directory. -target_include_directories(usermod_tildagon_usb INTERFACE - ${CMAKE_CURRENT_LIST_DIR} -) - -# Link our INTERFACE library to the usermod target. -target_link_libraries(usermod INTERFACE usermod_tildagon_usb) \ No newline at end of file From 52edce312db3a2f4d0f2836f8442b8afe7707ba6 Mon Sep 17 00:00:00 2001 From: Molive Date: Mon, 28 Apr 2025 23:17:17 +0100 Subject: [PATCH 06/11] Remove from board init --- tildagon/board_init.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tildagon/board_init.c b/tildagon/board_init.c index c8223b87..4e65323c 100644 --- a/tildagon/board_init.c +++ b/tildagon/board_init.c @@ -5,8 +5,6 @@ // This is the default startup handler for ESP32, does VFS and stuff void boardctrl_startup(void); -// TODO put this in a header and get it in the include path somehow -void tildagon_usb_init(void); // TODO put this in a header and get it in the include path somehow // it exists in tildagon_i2c.h but including it here throws an error @@ -24,9 +22,6 @@ void tildagon_startup(void) { tildagon_pins_init(); tildagon_power_init(); - - tildagon_usb_init(); - st3m_imu_init(); From 08e25562b09321768c5618a42f5b925777f413cc Mon Sep 17 00:00:00 2001 From: Molive Date: Mon, 28 Apr 2025 23:17:47 +0100 Subject: [PATCH 07/11] whitespace --- tildagon/board_init.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tildagon/board_init.c b/tildagon/board_init.c index 4e65323c..cd3d8969 100644 --- a/tildagon/board_init.c +++ b/tildagon/board_init.c @@ -5,7 +5,6 @@ // This is the default startup handler for ESP32, does VFS and stuff void boardctrl_startup(void); - // TODO put this in a header and get it in the include path somehow // it exists in tildagon_i2c.h but including it here throws an error // (some #define not set correctly?) From f2d11281245f8d175fb6ec6a0d1e476207ec5cc7 Mon Sep 17 00:00:00 2001 From: John Hunter Date: Thu, 12 Jun 2025 17:28:27 +0100 Subject: [PATCH 08/11] Update comments in scripts/hard-reset.sh --- scripts/hard-reset.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/hard-reset.sh b/scripts/hard-reset.sh index c5df54a1..5a0147c7 100755 --- a/scripts/hard-reset.sh +++ b/scripts/hard-reset.sh @@ -1,12 +1,14 @@ #!/bin/bash -# Hard resets submodules. +# Hard resets micropython submodules. Should not touch changes to this repository itself. # Assumes submodules are initialised. # scripts/firstTime.sh will need to be rerun after this. -# Use: sudo scripts/hard_reset.sh +# Use: sudo scripts/hard-reset.sh cd micropython git submodule foreach git clean -fdx git clean -fdx -git reset --hard --recurse-submodules \ No newline at end of file +git reset --hard --recurse-submodules + +echo "NOTE: Remember to run scripts/firstTime.sh before trying to compile!" From 8ee3ff74f2d44d8d85ac66cb243fbe712244407c Mon Sep 17 00:00:00 2001 From: John Hunter Date: Thu, 12 Jun 2025 17:56:28 +0100 Subject: [PATCH 09/11] Reintroduce tildagon_usb as per https://github.com/emfcamp/badge-2024-software/pull/200#issuecomment-2845905070 --- drivers/micropython.cmake | 3 +++ drivers/tildagon_usb/tildagon_usb.c | 25 +++++++++++++++++++++++++ drivers/tildagon_usb/tildagon_usb.cmake | 15 +++++++++++++++ tildagon/board_init.c | 6 ++++++ 4 files changed, 49 insertions(+) create mode 100644 drivers/tildagon_usb/tildagon_usb.c create mode 100644 drivers/tildagon_usb/tildagon_usb.cmake diff --git a/drivers/micropython.cmake b/drivers/micropython.cmake index fa2da145..da9e56e0 100644 --- a/drivers/micropython.cmake +++ b/drivers/micropython.cmake @@ -7,6 +7,9 @@ include(${CMAKE_CURRENT_LIST_DIR}/tildagon_helpers/micropython.cmake) # Add the display driver include(${CMAKE_CURRENT_LIST_DIR}/gc9a01/micropython.cmake) +# Add the HID interface +include(${CMAKE_CURRENT_LIST_DIR}/tildagon_usb/tildagon_usb.cmake) + # Add TCA9548A I2C MUX and micropython machine.I2C bindings include(${CMAKE_CURRENT_LIST_DIR}/tildagon_i2c/tildagon_i2c.cmake) diff --git a/drivers/tildagon_usb/tildagon_usb.c b/drivers/tildagon_usb/tildagon_usb.c new file mode 100644 index 00000000..943ac6ba --- /dev/null +++ b/drivers/tildagon_usb/tildagon_usb.c @@ -0,0 +1,25 @@ +#include "driver/gpio.h" + +#include "freertos/FreeRTOS.h" +#include "freertos/idf_additions.h" +#include "freertos/task.h" + +#define DEBUG_LED GPIO_NUM_35 + +TaskHandle_t tildagon_usb_task_handle = NULL; + +void tildagon_usb_task(void *param __attribute__((__unused__))) { + // gpio_reset_pin(DEBUG_LED); + // gpio_set_direction(DEBUG_LED, GPIO_MODE_OUTPUT); + + while(1) { + // gpio_set_level(DEBUG_LED, 1); + vTaskDelay(500 / portTICK_PERIOD_MS); + // gpio_set_level(DEBUG_LED, 0); + // vTaskDelay(500 / portTICK_PERIOD_MS); + } +} + +void tildagon_usb_init(void) { + xTaskCreatePinnedToCore(tildagon_usb_task, "usb_task", 1024, NULL, tskIDLE_PRIORITY+3, &tildagon_usb_task_handle, 0); +} \ No newline at end of file diff --git a/drivers/tildagon_usb/tildagon_usb.cmake b/drivers/tildagon_usb/tildagon_usb.cmake new file mode 100644 index 00000000..1eeae833 --- /dev/null +++ b/drivers/tildagon_usb/tildagon_usb.cmake @@ -0,0 +1,15 @@ +# Create an INTERFACE library for our C module. +add_library(usermod_tildagon_usb INTERFACE) + +# Add our source files to the lib +target_sources(usermod_tildagon_usb INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/tildagon_usb.c +) + +# Add the current directory as an include directory. +target_include_directories(usermod_tildagon_usb INTERFACE + ${CMAKE_CURRENT_LIST_DIR} +) + +# Link our INTERFACE library to the usermod target. +target_link_libraries(usermod INTERFACE usermod_tildagon_usb) \ No newline at end of file diff --git a/tildagon/board_init.c b/tildagon/board_init.c index cd3d8969..c8223b87 100644 --- a/tildagon/board_init.c +++ b/tildagon/board_init.c @@ -5,6 +5,9 @@ // This is the default startup handler for ESP32, does VFS and stuff void boardctrl_startup(void); +// TODO put this in a header and get it in the include path somehow +void tildagon_usb_init(void); + // TODO put this in a header and get it in the include path somehow // it exists in tildagon_i2c.h but including it here throws an error // (some #define not set correctly?) @@ -21,6 +24,9 @@ void tildagon_startup(void) { tildagon_pins_init(); tildagon_power_init(); + + tildagon_usb_init(); + st3m_imu_init(); From e70247b87319bed1953d69e88e15927de9d9838c Mon Sep 17 00:00:00 2001 From: John Hunter Date: Thu, 12 Jun 2025 19:34:26 +0100 Subject: [PATCH 10/11] Remove unneeded micropython patch Was required before mpy 1.25 --- patches/micropython.diff | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/patches/micropython.diff b/patches/micropython.diff index 312ad0b3..955fab1b 100644 --- a/patches/micropython.diff +++ b/patches/micropython.diff @@ -31,18 +31,3 @@ index dedef6d78..f1fbb5897 100644 network_common.c network_lan.c network_ppp.c -diff --git a/ports/esp32/mpconfigport.h b/ports/esp32/mpconfigport.h -index b5b7d63a5..7cd35d36c 100644 ---- a/ports/esp32/mpconfigport.h -+++ b/ports/esp32/mpconfigport.h -@@ -12,6 +12,10 @@ - #include "driver/i2s_std.h" - #include "esp_wifi_types.h" - -+#ifndef USB_SERIAL_JTAG_PACKET_SZ_BYTES -+#define USB_SERIAL_JTAG_PACKET_SZ_BYTES (64) -+#endif -+ - #ifndef MICROPY_CONFIG_ROM_LEVEL - #define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES) - #endif From a3b90bf7993d63ffa67db68b0baf35eb362ab082 Mon Sep 17 00:00:00 2001 From: Molive Date: Tue, 19 Aug 2025 20:06:13 +0200 Subject: [PATCH 11/11] Minor fixes --- .github/workflows/build-container.yml | 2 +- flasher/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml index 18a9ddd0..d2da3256 100644 --- a/.github/workflows/build-container.yml +++ b/.github/workflows/build-container.yml @@ -10,7 +10,7 @@ on: env: REGISTRY: ghcr.io IMAGE_NAME: emfcamp/esp_idf - IDF_VERSION: v5.2.1 + IDF_VERSION: v5.4.1 jobs: build-and-push-image: diff --git a/flasher/README.md b/flasher/README.md index 53d6a03f..3888c142 100644 --- a/flasher/README.md +++ b/flasher/README.md @@ -2,7 +2,7 @@ First, create a merged firmware binary. This can be done by building as normal, then using: - docker run -it --entrypoint /firmware/scripts/merge-firmwares.sh --env "TARGET=esp32s3" -v "$(pwd)"/:/firmware -u $UID -e HOME=/tmp matthewwilkes/esp_idf:5.4.1 + docker run -it --entrypoint /firmware/scripts/merge-firmwares.sh --env "TARGET=esp32s3" -v "$(pwd)"/:/firmware -u $UID -e HOME=/tmp ghcr.io/emfcamp/esp_idf:5.4.1 Then, copy the merged firmware to this directory: