Skip to content

Commit ba591fd

Browse files
Added non-destructive TinyUF2 support for UM ESP32-S3 boards (#6668)
Implemented a new method for allowing folks to preserve their TinyUF2 bootloader setup when flashing their boards via Arduino IDE, without being locked out of not using it if they want to use a different partition. Adafruit had already added support for keeping (reflashing) the TinyUF2 bootloader when flashing via Arduino IDE (thanks @ladyada ), but the issue with it is it doesn't allow users to not choose to use it. Even if they select a specific partition scheme from the partition drop down list, it ignores that selection and only does the TinyUF2 partitioning/bootloader thing. We wanted to let users choose between keeping their TinyUF2 partitioning and bootloader, or choose another partition scheme and have the TinyUF2 support disabled and just operate like they would expect. We've implemented this by adding the TinyUF2 support as a partition scheme option, and using these build options in platform.txt to choose to use teh UF2 path or use the standard path.
1 parent 4453ca5 commit ba591fd

11 files changed

+96
-242
lines changed

Diff for: boards.txt

+60-238
Large diffs are not rendered by default.

Diff for: platform.txt

+6-4
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ build.flash_freq=80m
127127
build.boot=qio
128128
build.boot_freq={build.flash_freq}
129129
build.bootloader_addr=0x1000
130+
build.custom_bootloader=bootloader
131+
build.custom_partitions=partitions
130132
build.code_debug=0
131133
build.defines=
132134
build.loop_core=
@@ -140,16 +142,16 @@ build.opt.path={build.path}/{build.opt.name}
140142

141143
# Check if custom partitions exist: source > variant > build.partitions
142144
recipe.hooks.prebuild.1.pattern=bash -c "[ ! -f "{build.source.path}"/partitions.csv ] || cp -f "{build.source.path}"/partitions.csv "{build.path}"/partitions.csv"
143-
recipe.hooks.prebuild.2.pattern=bash -c "[ -f "{build.path}"/partitions.csv ] || [ ! -f "{build.variant.path}"/partitions.csv ] || cp "{build.variant.path}"/partitions.csv "{build.path}"/partitions.csv"
145+
recipe.hooks.prebuild.2.pattern=bash -c "[ -f "{build.path}"/partitions.csv ] || [ ! -f "{build.variant.path}"/{build.custom_partitions}.csv ] || cp "{build.variant.path}"/{build.custom_partitions}.csv "{build.path}"/partitions.csv"
144146
recipe.hooks.prebuild.3.pattern=bash -c "[ -f "{build.path}"/partitions.csv ] || cp "{runtime.platform.path}"/tools/partitions/{build.partitions}.csv "{build.path}"/partitions.csv"
145147

146148
recipe.hooks.prebuild.1.pattern.windows=cmd /c if exist "{build.source.path}\partitions.csv" COPY /y "{build.source.path}\partitions.csv" "{build.path}\partitions.csv"
147-
recipe.hooks.prebuild.2.pattern.windows=cmd /c if not exist "{build.path}\partitions.csv" if exist "{build.variant.path}\partitions.csv" COPY "{build.variant.path}\partitions.csv" "{build.path}\partitions.csv"
149+
recipe.hooks.prebuild.2.pattern.windows=cmd /c if not exist "{build.path}\partitions.csv" if exist "{build.variant.path}\{build.custom_partitions}.csv" COPY "{build.variant.path}\{build.custom_partitions}.csv" "{build.path}\partitions.csv"
148150
recipe.hooks.prebuild.3.pattern.windows=cmd /c if not exist "{build.path}\partitions.csv" COPY "{runtime.platform.path}\tools\partitions\{build.partitions}.csv" "{build.path}\partitions.csv"
149151

150152
# Check if custom bootloader exist: source > variant > build.boot
151-
recipe.hooks.prebuild.4.pattern=bash -c "[ -f "{build.source.path}"/bootloader.bin ] && cp -f "{build.source.path}"/bootloader.bin "{build.path}"/{build.project_name}.bootloader.bin || ( [ -f "{build.variant.path}"/bootloader.bin ] && cp "{build.variant.path}"/bootloader.bin "{build.path}"/{build.project_name}.bootloader.bin || cp -f "{runtime.platform.path}"/tools/sdk/{build.mcu}/bin/bootloader_{build.boot}_{build.boot_freq}.bin "{build.path}"/{build.project_name}.bootloader.bin )"
152-
recipe.hooks.prebuild.4.pattern.windows=cmd /c IF EXIST "{build.source.path}\bootloader.bin" ( COPY /y "{build.source.path}\bootloader.bin" "{build.path}\{build.project_name}.bootloader.bin" ) ELSE ( IF EXIST "{build.variant.path}\bootloader.bin" ( COPY "{build.variant.path}\bootloader.bin" "{build.path}\{build.project_name}.bootloader.bin" ) ELSE ( COPY /y "{runtime.platform.path}\tools\sdk\{build.mcu}\bin\bootloader_{build.boot}_{build.boot_freq}.bin" "{build.path}\{build.project_name}.bootloader.bin" ) )
153+
recipe.hooks.prebuild.4.pattern=bash -c "[ -f "{build.source.path}"/bootloader.bin ] && cp -f "{build.source.path}"/bootloader.bin "{build.path}"/{build.project_name}.bootloader.bin || ( [ -f "{build.variant.path}"/{build.custom_bootloader}.bin ] && cp "{build.variant.path}"/{build.custom_bootloader}.bin "{build.path}"/{build.project_name}.bootloader.bin || cp -f "{runtime.platform.path}"/tools/sdk/{build.mcu}/bin/bootloader_{build.boot}_{build.boot_freq}.bin "{build.path}"/{build.project_name}.bootloader.bin )"
154+
recipe.hooks.prebuild.4.pattern.windows=cmd /c IF EXIST "{build.source.path}\bootloader.bin" ( COPY /y "{build.source.path}\bootloader.bin" "{build.path}\{build.project_name}.bootloader.bin" ) ELSE ( IF EXIST "{build.variant.path}\{build.custom_bootloader}.bin" ( COPY "{build.variant.path}\{build.custom_bootloader}.bin" "{build.path}\{build.project_name}.bootloader.bin" ) ELSE ( COPY /y "{runtime.platform.path}\tools\sdk\{build.mcu}\bin\bootloader_{build.boot}_{build.boot_freq}.bin" "{build.path}\{build.project_name}.bootloader.bin" ) )
153155

154156
# Check if custom build options exist in the sketch folder
155157
recipe.hooks.prebuild.5.pattern=bash -c "[ ! -f "{build.source.path}"/build_opt.h ] || cp -f "{build.source.path}"/build_opt.h "{build.path}"/build_opt.h"

Diff for: variants/um_feathers3/bootloader_tinyuf2.bin

22.2 KB
Binary file not shown.

Diff for: variants/um_feathers3/partitions_tinyuf2.csv

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# ESP-IDF Partition Table
2+
# Name, Type, SubType, Offset, Size, Flags
3+
# bootloader.bin,, 0x1000, 32K
4+
# partition table,, 0x8000, 4K
5+
nvs, data, nvs, 0x9000, 20K,
6+
otadata, data, ota, 0xe000, 8K,
7+
ota_0, 0, ota_0, 0x10000, 2048K,
8+
ota_1, 0, ota_1, 0x210000, 2048K,
9+
uf2, app, factory,0x410000, 256K,
10+
ffat, data, fat, 0x450000, 11968K,

Diff for: variants/um_feathers3/tinyuf2.bin

154 KB
Binary file not shown.

Diff for: variants/um_pros3/bootloader_tinyuf2.bin

22 KB
Binary file not shown.

Diff for: variants/um_pros3/partitions_tinyuf2.csv

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# ESP-IDF Partition Table
2+
# Name, Type, SubType, Offset, Size, Flags
3+
# bootloader.bin,, 0x1000, 32K
4+
# partition table,, 0x8000, 4K
5+
nvs, data, nvs, 0x9000, 20K,
6+
otadata, data, ota, 0xe000, 8K,
7+
ota_0, 0, ota_0, 0x10000, 2048K,
8+
ota_1, 0, ota_1, 0x210000, 2048K,
9+
uf2, app, factory,0x410000, 256K,
10+
ffat, data, fat, 0x450000, 11968K,

Diff for: variants/um_pros3/tinyuf2.bin

149 KB
Binary file not shown.

Diff for: variants/um_tinys3/bootloader_tinyuf2.bin

22 KB
Binary file not shown.

Diff for: variants/um_tinys3/partitions_tinyuf2.csv

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# ESP-IDF Partition Table
2+
# Name, Type, SubType, Offset, Size, Flags
3+
# bootloader.bin,, 0x1000, 32K
4+
# partition table,, 0x8000, 4K
5+
nvs, data, nvs, 0x9000, 20K,
6+
otadata, data, ota, 0xe000, 8K,
7+
ota_0, 0, ota_0, 0x10000, 2048K,
8+
ota_1, 0, ota_1, 0x210000, 2048K,
9+
uf2, app, factory,0x410000, 256K,
10+
ffat, data, fat, 0x450000, 3776K,

Diff for: variants/um_tinys3/tinyuf2.bin

149 KB
Binary file not shown.

0 commit comments

Comments
 (0)