Bootloader/retention boot mode support #2683
Open
+134
−4
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.
Ok, expanding our support for entering the bootloader on more targets!
Overview
This PR works to expand our bootloader support beyond the Adafruit nRF bootloader by moving to new (relatively) new Zephyr retention boot mode support. The scope of this change includes:
BOOT_MODE_TYPE_BOOTLOADER
to storing the 32-bit "magic value" to the real underlying retention location.v3.5+zmk-fixes
branch that includes a new STM32 bootloader support, to jump automatically to the ROM bootloader when startup determines the bootmode was set to bootloader before the restart. This piece is tested on stm32f072 only so far, my testing on F4 is complicated by all my devices having tinyuf2 flashed to them as a second stage bootloader.Bootloaders Supported
Adafruit nRF52
The nRF52 bootloader should be supported, will be testing this more tomorrow, by the following:
And enabling:
Adafruit bossa/samd21 and tinyuf2 UF2 Bootloaders
The adafruit tinyuf2 and samd21 bootloaders both use the same magic value stored in the last 4 bytes of RAM to trigger bootloader mode, so the setup for these two bootloaders is effectively the same:
Here is an example for samd21e18 (which has 32K of RAM)
Devicetree:
Kconfig settings:
Similar mechanism forks on stm32f4 with tinyuf2 as long as you use the correct reg/offsets for the RAM on the given device.
STM32 ROM Bootloader
The STM32 ROM bootloader is handled a bit differently, using an early init callback that checks the bootmode in RAM, and if finding
BOOT_MODE_TYPE_BOOTLOADER
, uses a small bit of code to de-init and jump to the bootloader directly. That means no magic value mapping has to occur.The following works on stm32f072.
Devicetree:
This also requires the ROM bootloader details (found in AN2606 from ST) has been added to the SoC .dtsi file, e.g. from https://github.com/zmkfirmware/zephyr/pull/39/files#diff-c3c466b9a87ae3801f4ebf6b99797e29304b66407ef9393c203b92896eafd229
Kconfig:
Testing
I've specifically tested so far:
Still needs testing: