Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cd21551

Browse filesBrowse files
committed
feat(esptool): Upgrade to esptool v5
1 parent e9813c6 commit cd21551
Copy full SHA for cd21551

File tree

Expand file treeCollapse file tree

3 files changed

+170
-41
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+170
-41
lines changed

‎.github/scripts/package_esptool.sh

Copy file name to clipboard
+129Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
# Check version argument
6+
if [[ $# -ne 3 ]]; then
7+
echo "Usage: $0 <version> <base_folder> <json_path>"
8+
echo "Example: $0 5.0.dev1 /tmp/esptool /tmp/esptool-5.0.dev1.json"
9+
exit 1
10+
fi
11+
12+
VERSION=$1
13+
BASE_FOLDER=$2
14+
JSON_PATH=$3
15+
16+
export COPYFILE_DISABLE=1
17+
18+
shopt -s nullglob # So for loop doesn't run if no matches
19+
20+
# Function to update JSON for a given host
21+
function update_json_for_host {
22+
local host=$1
23+
local archive=$2
24+
25+
# Extract the old url from the JSON for this host, then replace only the filename
26+
old_url=$(jq -r --arg host "$host" '
27+
.packages[].tools[] | select(.name == "esptool_py") | .systems[] | select(.host == $host) | .url // empty
28+
' "$tmp_json")
29+
if [[ -n "$old_url" ]]; then
30+
base_url="${old_url%/*}"
31+
url="$base_url/$archive"
32+
else
33+
echo "No old url found for $host"
34+
exit 1
35+
fi
36+
37+
archiveFileName="$archive"
38+
checksum="SHA-256:$(shasum -a 256 "$archive" | awk '{print $1}')"
39+
size=$(stat -f%z "$archive")
40+
41+
# Use jq to update the JSON
42+
jq --arg host "$host" \
43+
--arg url "$url" \
44+
--arg archiveFileName "$archiveFileName" \
45+
--arg checksum "$checksum" \
46+
--arg size "$size" \
47+
'
48+
.packages[].tools[]
49+
|= if .name == "esptool_py" then
50+
.systems = (
51+
((.systems // []) | map(select(.host != $host))) + [{
52+
host: $host,
53+
url: $url,
54+
archiveFileName: $archiveFileName,
55+
checksum: $checksum,
56+
size: $size
57+
}]
58+
)
59+
else
60+
.
61+
end
62+
' "$tmp_json" > "$tmp_json.new" && mv "$tmp_json.new" "$tmp_json"
63+
}
64+
65+
cd "$BASE_FOLDER"
66+
67+
# Delete all archives before starting
68+
rm -f esptool-*.tar.gz esptool-*.zip
69+
70+
for dir in esptool-*; do
71+
# Check if directory exists and is a directory
72+
if [[ ! -d "$dir" ]]; then
73+
continue
74+
fi
75+
76+
base="${dir#esptool-}"
77+
78+
# Add 'linux-' prefix if base doesn't contain linux/macos/win64
79+
if [[ "$base" != *linux* && "$base" != *macos* && "$base" != *win64* ]]; then
80+
base="linux-${base}"
81+
fi
82+
83+
if [[ "$dir" == esptool-win* ]]; then
84+
# Windows zip archive
85+
zipfile="esptool-v${VERSION}-${base}.zip"
86+
echo "Creating $zipfile from $dir ..."
87+
zip -r "$zipfile" "$dir"
88+
else
89+
# Non-Windows: set permissions and tar.gz archive
90+
tarfile="esptool-v${VERSION}-${base}.tar.gz"
91+
echo "Setting permissions and creating $tarfile from $dir ..."
92+
chmod -R u=rwx,g=rx,o=rx "$dir"
93+
tar -cvzf "$tarfile" "$dir"
94+
fi
95+
done
96+
97+
# After the for loop, update the JSON for each archive
98+
# Create a temporary JSON file to accumulate changes
99+
tmp_json="${JSON_PATH}.tmp"
100+
cp "$JSON_PATH" "$tmp_json"
101+
102+
for archive in esptool-v"${VERSION}"-*.tar.gz esptool-v"${VERSION}"-*.zip; do
103+
[ -f "$archive" ] || continue
104+
105+
echo "Updating JSON for $archive"
106+
107+
# Determine host from archive name
108+
case "$archive" in
109+
*linux-amd64*) host="x86_64-pc-linux-gnu" ;;
110+
*linux-armv7*) host="arm-linux-gnueabihf" ;;
111+
*linux-aarch64*) host="aarch64-linux-gnu" ;;
112+
*macos-amd64*) host="x86_64-apple-darwin" ;;
113+
*macos-arm64*) host="arm64-apple-darwin" ;;
114+
*win64*) hosts=("x86_64-mingw32" "i686-mingw32") ;;
115+
*) echo "Unknown host for $archive"; continue ;;
116+
esac
117+
118+
# For win64, loop over both hosts; otherwise, use a single host
119+
if [[ "$archive" == *win64* ]]; then
120+
for host in "${hosts[@]}"; do
121+
update_json_for_host "$host" "$archive"
122+
done
123+
else
124+
update_json_for_host "$host" "$archive"
125+
fi
126+
done
127+
128+
# After all archives are processed, move the temporary JSON to the final file
129+
mv "$tmp_json" "$JSON_PATH"

‎package/package_esp32_index.template.json

Copy file name to clipboardExpand all lines: package/package_esp32_index.template.json
+35-35Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
{
8282
"packager": "esp32",
8383
"name": "esptool_py",
84-
"version": "4.9.dev3"
84+
"version": "5.0.dev1"
8585
},
8686
{
8787
"packager": "esp32",
@@ -469,56 +469,56 @@
469469
},
470470
{
471471
"name": "esptool_py",
472-
"version": "4.9.dev3",
472+
"version": "5.0.dev1",
473473
"systems": [
474474
{
475-
"host": "x86_64-pc-linux-gnu",
476-
"url": "https://github.com/espressif/arduino-esp32/releases/download/3.1.0-RC3/esptool-v4.9.dev3-linux-amd64.tar.gz",
477-
"archiveFileName": "esptool-v4.9.dev3-linux-amd64.tar.gz",
478-
"checksum": "SHA-256:4ecaf51836cbf4ea3c19840018bfef3b0b8cd8fc3c95f6e1e043ca5bbeab9bf0",
479-
"size": "64958202"
475+
"host": "aarch64-linux-gnu",
476+
"url": "https://github.com/espressif/arduino-esp32/releases/download/3.2.0/esptool-v5.0.dev1-linux-aarch64.tar.gz",
477+
"archiveFileName": "esptool-v5.0.dev1-linux-aarch64.tar.gz",
478+
"checksum": "SHA-256:bfafa7a7723ebbabfd8b6e3ca5ae00bfead0331de923754aeddb43b2c116a078",
479+
"size": "58241736"
480480
},
481481
{
482-
"host": "arm-linux-gnueabihf",
483-
"url": "https://github.com/espressif/arduino-esp32/releases/download/3.1.0-RC3/esptool-v4.9.dev3-linux-armv7.tar.gz",
484-
"archiveFileName": "esptool-v4.9.dev3-linux-armv7.tar.gz",
485-
"checksum": "SHA-256:fff818573bce483ee793ac83c8211f6abf764aa3350f198228859f696a0a0b36",
486-
"size": "31530030"
482+
"host": "x86_64-pc-linux-gnu",
483+
"url": "https://github.com/espressif/arduino-esp32/releases/download/3.2.0/esptool-v5.0.dev1-linux-amd64.tar.gz",
484+
"archiveFileName": "esptool-v5.0.dev1-linux-amd64.tar.gz",
485+
"checksum": "SHA-256:acd0486e96586b99d053a1479acbbbfcae8667227c831cdc53a171f9ccfa27ee",
486+
"size": "100740042"
487487
},
488488
{
489-
"host": "aarch64-linux-gnu",
490-
"url": "https://github.com/espressif/arduino-esp32/releases/download/3.1.0-RC3/esptool-v4.9.dev3-linux-aarch64.tar.gz",
491-
"archiveFileName": "esptool-v4.9.dev3-linux-aarch64.tar.gz",
492-
"checksum": "SHA-256:5b274bdff2f62e6a07c3c1dfa51b1128924621f661747eca3dbe0f77972f2f06",
493-
"size": "33663882"
489+
"host": "arm-linux-gnueabihf",
490+
"url": "https://github.com/espressif/arduino-esp32/releases/download/3.2.0/esptool-v5.0.dev1-linux-armv7.tar.gz",
491+
"archiveFileName": "esptool-v5.0.dev1-linux-armv7.tar.gz",
492+
"checksum": "SHA-256:ea77a38681506761bbb7b0b39c130811ed565667b67ebbdb4d6dcc6cb6e07368",
493+
"size": "53451939"
494494
},
495495
{
496496
"host": "x86_64-apple-darwin",
497-
"url": "https://github.com/espressif/arduino-esp32/releases/download/3.1.0-RC3/esptool-v4.9.dev3-macos-amd64.tar.gz",
498-
"archiveFileName": "esptool-v4.9.dev3-macos-amd64.tar.gz",
499-
"checksum": "SHA-256:c733c83b58fcf5f642fbb2fddb8ff24640c2c785126cba0821fb70c4a5ceea7a",
500-
"size": "32767836"
497+
"url": "https://github.com/espressif/arduino-esp32/releases/download/3.2.0/esptool-v5.0.dev1-macos-amd64.tar.gz",
498+
"archiveFileName": "esptool-v5.0.dev1-macos-amd64.tar.gz",
499+
"checksum": "SHA-256:900a8e90731208bee96647e0e207a43612b9452c2120c4fdc0ff4c6be226257b",
500+
"size": "59631998"
501501
},
502502
{
503503
"host": "arm64-apple-darwin",
504-
"url": "https://github.com/espressif/arduino-esp32/releases/download/3.1.0-RC3/esptool-v4.9.dev3-macos-arm64.tar.gz",
505-
"archiveFileName": "esptool-v4.9.dev3-macos-arm64.tar.gz",
506-
"checksum": "SHA-256:83c195a15981e6a5e7a130db2ccfb21e2d8093912e5b003681f9a5abadd71af7",
507-
"size": "30121441"
504+
"url": "https://github.com/espressif/arduino-esp32/releases/download/3.2.0/esptool-v5.0.dev1-macos-arm64.tar.gz",
505+
"archiveFileName": "esptool-v5.0.dev1-macos-arm64.tar.gz",
506+
"checksum": "SHA-256:3653f4de73cb4fc6a25351eaf663708e91c65ae3265d75bd54ca4315a4350bb4",
507+
"size": "56349992"
508508
},
509509
{
510-
"host": "i686-mingw32",
511-
"url": "https://github.com/espressif/arduino-esp32/releases/download/3.1.0-RC3/esptool-v4.9.dev3-win64.zip",
512-
"archiveFileName": "esptool-v4.9.dev3-win64.zip",
513-
"checksum": "SHA-256:890051a4fdc684ff6f4af18d0bb27d274ca940ee0eef716a9455f8c64b25b215",
514-
"size": "36072564"
510+
"host": "x86_64-mingw32",
511+
"url": "https://github.com/espressif/arduino-esp32/releases/download/3.2.0/esptool-v5.0.dev1-win64.zip",
512+
"archiveFileName": "esptool-v5.0.dev1-win64.zip",
513+
"checksum": "SHA-256:1e8fd89645daf94f2d4406ec73c9004e617ea921079515f9fd749205eece4d6d",
514+
"size": "59102658"
515515
},
516516
{
517-
"host": "x86_64-mingw32",
518-
"url": "https://github.com/espressif/arduino-esp32/releases/download/3.1.0-RC3/esptool-v4.9.dev3-win64.zip",
519-
"archiveFileName": "esptool-v4.9.dev3-win64.zip",
520-
"checksum": "SHA-256:890051a4fdc684ff6f4af18d0bb27d274ca940ee0eef716a9455f8c64b25b215",
521-
"size": "36072564"
517+
"host": "i686-mingw32",
518+
"url": "https://github.com/espressif/arduino-esp32/releases/download/3.2.0/esptool-v5.0.dev1-win64.zip",
519+
"archiveFileName": "esptool-v5.0.dev1-win64.zip",
520+
"checksum": "SHA-256:1e8fd89645daf94f2d4406ec73c9004e617ea921079515f9fd749205eece4d6d",
521+
"size": "59102658"
522522
}
523523
]
524524
},

‎platform.txt

Copy file name to clipboardExpand all lines: platform.txt
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ recipe.hooks.prebuild.2.pattern.windows=cmd /c if not exist "{build.path}\partit
120120
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"
121121

122122
# Check if custom bootloader exist: source > variant > build.boot
123-
recipe.hooks.prebuild.4.pattern_args=--chip {build.mcu} elf2image --flash_mode {build.flash_mode} --flash_freq {build.img_freq} --flash_size {build.flash_size} -o
123+
recipe.hooks.prebuild.4.pattern_args=--chip {build.mcu} elf2image --flash-mode {build.flash_mode} --flash-freq {build.img_freq} --flash-size {build.flash_size} -o
124124
recipe.hooks.prebuild.4.pattern=/usr/bin/env 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 || "{tools.esptool_py.path}"/{tools.esptool_py.cmd} {recipe.hooks.prebuild.4.pattern_args} "{build.path}"/{build.project_name}.bootloader.bin "{compiler.sdk.path}"/bin/bootloader_{build.boot}_{build.boot_freq}.elf )"
125125
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 ( "{tools.esptool_py.path}\{tools.esptool_py.cmd}" {recipe.hooks.prebuild.4.pattern_args} "{build.path}\{build.project_name}.bootloader.bin" "{compiler.sdk.path}\bin\bootloader_{build.boot}_{build.boot_freq}.elf" ) )
126126

@@ -164,7 +164,7 @@ recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.f
164164
recipe.objcopy.partitions.bin.pattern={tools.gen_esp32part.cmd} -q "{build.path}/partitions.csv" "{build.path}/{build.project_name}.partitions.bin"
165165

166166
## Create bin
167-
recipe.objcopy.bin.pattern_args=--chip {build.mcu} elf2image --flash_mode "{build.flash_mode}" --flash_freq "{build.img_freq}" --flash_size "{build.flash_size}" --elf-sha256-offset 0xb0 -o "{build.path}/{build.project_name}.bin" "{build.path}/{build.project_name}.elf"
167+
recipe.objcopy.bin.pattern_args=--chip {build.mcu} elf2image --flash-mode "{build.flash_mode}" --flash-freq "{build.img_freq}" --flash-size "{build.flash_size}" --elf-sha256-offset 0xb0 -o "{build.path}/{build.project_name}.bin" "{build.path}/{build.project_name}.elf"
168168
recipe.objcopy.bin.pattern="{tools.esptool_py.path}/{tools.esptool_py.cmd}" {recipe.objcopy.bin.pattern_args}
169169

170170
## Create Insights Firmware Package
@@ -177,7 +177,7 @@ recipe.hooks.objcopy.postobjcopy.2.pattern=/usr/bin/env bash -c "[ ! -d "{build.
177177
recipe.hooks.objcopy.postobjcopy.2.pattern.windows=cmd /c if exist "{build.path}\libraries\ESP_SR" if exist "{compiler.sdk.path}\esp_sr\srmodels.bin" COPY /y "{compiler.sdk.path}\esp_sr\srmodels.bin" "{build.path}\srmodels.bin"
178178

179179
# Create merged binary
180-
recipe.hooks.objcopy.postobjcopy.3.pattern_args=--chip {build.mcu} merge_bin -o "{build.path}/{build.project_name}.merged.bin" --fill-flash-size {build.flash_size} --flash_mode keep --flash_freq keep --flash_size keep {build.bootloader_addr} "{build.path}/{build.project_name}.bootloader.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin" 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0x10000 "{build.path}/{build.project_name}.bin"
180+
recipe.hooks.objcopy.postobjcopy.3.pattern_args=--chip {build.mcu} merge-bin -o "{build.path}/{build.project_name}.merged.bin" --pad-to-size {build.flash_size} --flash-mode keep --flash-freq keep --flash-size keep {build.bootloader_addr} "{build.path}/{build.project_name}.bootloader.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin" 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0x10000 "{build.path}/{build.project_name}.bin"
181181
recipe.hooks.objcopy.postobjcopy.3.pattern="{tools.esptool_py.path}/{tools.esptool_py.cmd}" {recipe.hooks.objcopy.postobjcopy.3.pattern_args}
182182

183183
## Save bin
@@ -294,22 +294,22 @@ debug.additional_config=debug_config.{build.mcu}
294294
tools.esptool_py.upload.protocol=serial
295295
tools.esptool_py.upload.params.verbose=
296296
tools.esptool_py.upload.params.quiet=
297-
tools.esptool_py.upload.pattern_args=--chip {build.mcu} --port "{serial.port}" --baud {upload.speed} {upload.flags} --before default_reset --after hard_reset write_flash {upload.erase_cmd} -z --flash_mode keep --flash_freq keep --flash_size keep {build.bootloader_addr} "{build.path}/{build.project_name}.bootloader.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin" 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0x10000 "{build.path}/{build.project_name}.bin" {upload.extra_flags}
297+
tools.esptool_py.upload.pattern_args=--chip {build.mcu} --port "{serial.port}" --baud {upload.speed} {upload.flags} --before default-reset --after hard-reset write-flash {upload.erase_cmd} -z --flash-mode keep --flash-freq keep --flash-size keep {build.bootloader_addr} "{build.path}/{build.project_name}.bootloader.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin" 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0x10000 "{build.path}/{build.project_name}.bin" {upload.extra_flags}
298298
tools.esptool_py.upload.pattern="{path}/{cmd}" {upload.pattern_args}
299299

300300
## Program Application
301301
## -------------------
302302
tools.esptool_py.program.params.verbose=
303303
tools.esptool_py.program.params.quiet=
304-
tools.esptool_py.program.pattern_args=--chip {build.mcu} --port "{serial.port}" --baud {upload.speed} {upload.flags} --before default_reset --after hard_reset write_flash -z --flash_mode keep --flash_freq keep --flash_size keep 0x10000 "{build.path}/{build.project_name}.bin"
304+
tools.esptool_py.program.pattern_args=--chip {build.mcu} --port "{serial.port}" --baud {upload.speed} {upload.flags} --before default-reset --after hard-reset write-flash -z --flash-mode keep --flash-freq keep --flash-size keep 0x10000 "{build.path}/{build.project_name}.bin"
305305
tools.esptool_py.program.pattern="{path}/{cmd}" {program.pattern_args}
306306

307307
## Erase Chip (before burning the bootloader)
308308
## ------------------------------------------
309309
tools.esptool_py.erase.protocol=serial
310310
tools.esptool_py.erase.params.verbose=
311311
tools.esptool_py.erase.params.quiet=
312-
tools.esptool_py.erase.pattern_args=--chip {build.mcu} --port "{serial.port}" --baud {upload.speed} {upload.flags} --before default_reset --after hard_reset erase_flash
312+
tools.esptool_py.erase.pattern_args=--chip {build.mcu} --port "{serial.port}" --baud {upload.speed} {upload.flags} --before default-reset --after hard-reset erase-flash
313313
tools.esptool_py.erase.pattern="{path}/{cmd}" {erase.pattern_args}
314314

315315
## Burn Bootloader

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.