usb: add automatic loader reflash (v2) - #545
Merged
Merged
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
pillo79
force-pushed
the
loader_version_iconfig_v2
branch
from
July 15, 2026 13:11
3e6f066 to
f7a0eed
Compare
This comment was marked as outdated.
This comment was marked as outdated.
pillo79
force-pushed
the
loader_version_iconfig_v2
branch
3 times, most recently
from
July 15, 2026 13:55
f47670e to
28c0dfa
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
pillo79
force-pushed
the
loader_version_iconfig_v2
branch
from
July 16, 2026 11:27
a0bf771 to
00cc2a8
Compare
This comment was marked as outdated.
This comment was marked as outdated.
pillo79
force-pushed
the
loader_version_iconfig_v2
branch
from
July 17, 2026 08:34
00cc2a8 to
77052d6
Compare
Escape double quotes and backslashes everywhere in the JSON output of get_board_details.sh to ensure that the output is a valid JSON.
Rewrite get_core_version.sh to properly separate each version component during processing. Export a Zephyr-compatible VERSION file if a filename is provided as the first argument.
Add the possibility of writing to platform.local.txt instead of boards.local.txt when the board variable is not set. This allows for global configuration settings that are not specific to any particular board to be saved.
The build.sh script now saves the build version to loader/VERSION (so it is picked up by the Zephyr build system) and updates the version field in both platform.local.txt and boards.local.txt. To ensure multiple boards share the same version, the build_all.sh script exports a global PINNED_CORE_VERSION environment variable so that get_core_version.sh can use it instead of generating a new version for each run.
This is step 1. for automatic flash of the loader if the onboard version is different from the one shipped with the core: passing the current build version in the USB descriptor as iConfig, so that it is available on the host side to check if the loader needs to be reflashed. For the legacy USB stack, the version is passed to USB drivers directly via the Kconfig option CONFIG_USB_CONFIGURATION_STRING_DESC. Boards using the new USB stack, like the Portenta C33, set this value via the USBD_DESC_CONFIG_DEFINE macro instead.
Add generic 'upload.artifacts.loader' and 'upload.artifacts.sketch' variables to platform.txt to allow for cleaner upload patterns and explicit file dependencies. Remove 'stm32flash' and 'adb' upload patterns, as they are not used by any of the supported boards. Also remove any '.erase' patterns, as all of them were empty anyway.
tracks https://github.com/arduino/arduino-renesas-bootloader/tree/zephyr_alt , allows consecutive uploads (loader+sketch)
Switching to this core requires an updated bootloader. Since it will be flashed only if needed, the procedure is now: * Double click reset to enter bootloader mode * Burn bootloader * Wait until the blue led starts flashing * Double click reset to enter bootloader mode again * Upload sketch
For boards that have soft USB, use the new 'scripting-tools' tool to
check the USB configuration string reported by the board. If it does not
match the expected version, reflash the bootloader before uploading the
sketch.
Refactor loader and sketch commands so they can be reused in both the
bootloader and upload patterns. Note that {loader.cmd} should leave the
target waiting for the sketch upload, and additional arguments are
passed to the loader command depending on whether the sketch will be
flashed in the same session or not.
Convert the bossac tool to use the new loader/sketch commands, and
remove the old upload/bootloader patterns.
pillo79
force-pushed
the
loader_version_iconfig_v2
branch
from
July 17, 2026 08:57
77052d6 to
60922e2
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Requires a new version of rp2040tool that: - includes the option to skip the final RESET of the CPU - accepts .uf2 files without always adding the extension Add missing artifact with the new version.
pillo79
force-pushed
the
loader_version_iconfig_v2
branch
from
July 17, 2026 09:48
60922e2 to
2d15311
Compare
Built
|
| Artifact | Board | Core | Tests | RAM | Sketches | Warnings | Errors |
|---|---|---|---|---|---|---|---|
✅* zephyr_contrib |
ek_ra8d1
| 1 🏷️ | ✅* |
11.9% |
2 | 2 | - |
frdm_mcxn947
| 7 🏷️ | ✅* |
58.6% |
2 | 2 | - | |
frdm_rw612
| 2 🏷️ | ✅* |
83.2% |
2 | 2 | - | |
✔️* zephyr_main |
giga
| 5 🏷️ | ✅* |
39.3% |
72 | 40 | - |
nano33ble
| 1 🏷️ | ✅* |
78.9% |
42 | 18 | - | |
nano_connect
| 📗 | ✅* |
48.1% |
32 | 18 | - | |
nano_matter
| 2 🏷️ | ✅* |
|
22 | 10 | - | |
nicla_sense
| 3 🏷️ | ✅* |
|
18 | 10 | - | |
nicla_vision
| 4 🏷️ | ✔️* |
39.5% |
56 | 28 | (2*) | |
opta
| 4 🏷️ | ✅* |
42.4% |
66 | 44 | - | |
portentac33
| 3 🏷️ | ✅* |
81.8% |
70 | 70 | - | |
portentah7
| 3 🏷️ | ✅* |
41.2% |
84 | 52 | - | |
✅* zephyr_unoq |
unoq
| 1 🏷️ | ✅* |
43.5% |
56 | 12 | - |
Legend
Board Test Status description 🔥 🔥 Test run failed to complete. ❌ 🔴 Test completed with unexpected errors. ⁉️ ⁉️ Test was expected to fail but passed; exception entry is outdated. ✔️* 🚫 Test completed with errors, but all are known/expected. ✅* 🟡 Test completed with some warnings; no errors detected. ✅ 🟢 Test passed successfully, with no warnings or errors. 🌑 🌑 Test was skipped.
|
Memory usage change @ 2d15311
Click for full report table
Click for full report CSV |
|
Tested on windows: C33 Nano33BLE NanoRP2040 OPTA GIGA 💚 |
pennam
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a reimplementation of #441 with the final implementation of the support machinery.
Compared to the previous PR:
scripting-toolstool, with no CLI changesAPP_VERSIONtokens.build_all.shrun