-
Notifications
You must be signed in to change notification settings - Fork 8k
STM32 Bootloader support with retained ram boot mode infrastructure #84272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
petejohanson
wants to merge
6
commits into
zephyrproject-rtos:main
Choose a base branch
from
petejohanson:zephyr-upstream/stm32-bootloader-jump-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+169
−4
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7c2f179
arm: stm32: Add DTS describing ROM bootloader for f0
petejohanson b88e890
dts: arm: st: Add STM32WB bootloader information
petejohanson 7a9aa46
boards: st: Add boot mode retention support to Nucleo WB55RG board
petejohanson fb868c3
arm: stm32: Add DTS describing ROM bootloader for f411
petejohanson f8322ef
retention: Skip mutex usage when in pre-kernel
petejohanson 741435c
soc: arm: stm32: Add ROM bootloader support
petejohanson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright (c) 2025 Peter Johanson | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
description: ST STM32 ROM Bootloader Details | ||
|
||
compatible: "st,stm32-bootloader" | ||
|
||
include: base.yaml | ||
|
||
properties: | ||
reg: | ||
required: true |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (c) 2020 Google LLC. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <soc.h> | ||
#include <zephyr/init.h> | ||
#include <zephyr/retention/retention.h> | ||
#include <zephyr/retention/bootmode.h> | ||
#include <stm32_ll_system.h> | ||
|
||
#if defined(CONFIG_ARM_MPU) | ||
extern void arm_core_mpu_disable(void); | ||
#endif | ||
|
||
static const uint32_t bootloader = DT_REG_ADDR(DT_INST(0, st_stm32_bootloader)); | ||
static FUNC_NORETURN void jump_to_bootloader(void) | ||
{ | ||
int i; | ||
void (*jmp)(void); | ||
|
||
__disable_irq(); | ||
|
||
for (i = 0; i < ARRAY_SIZE(NVIC->ICER); i++) { | ||
NVIC->ICER[i] = 0xFFFFFFFF; | ||
NVIC->ICPR[i] = 0xFFFFFFFF; | ||
} | ||
|
||
#if defined(CONFIG_ARM_MPU) | ||
/* | ||
* Needed to allow the bootloader to erase/write to flash, and the MPU | ||
* is set up in the arch init phase. | ||
*/ | ||
arm_core_mpu_disable(); | ||
#endif | ||
|
||
/* | ||
* Disable SysTick before jumping, to keep the bootloader happy | ||
*/ | ||
SysTick->CTRL = 0; | ||
|
||
LL_SYSCFG_SetRemapMemory(LL_SYSCFG_REMAP_SYSTEMFLASH); | ||
|
||
jmp = (void (*)(void))(void (*)(void))(*((uint32_t *)((bootloader + 4)))); | ||
|
||
/* | ||
* We need to clear a few things set by the Zephyr early startup code | ||
*/ | ||
__set_CONTROL(0); | ||
#if !defined(CONFIG_CPU_CORTEX_M0) | ||
__set_BASEPRI(0); | ||
#endif | ||
|
||
__set_MSP(*(uint32_t *)bootloader); | ||
|
||
__enable_irq(); | ||
|
||
jmp(); | ||
|
||
CODE_UNREACHABLE; | ||
} | ||
|
||
static int bootloader_check_boot_init(void) | ||
{ | ||
if (bootmode_check(BOOT_MODE_TYPE_BOOTLOADER) > 0) { | ||
bootmode_clear(); | ||
jump_to_bootloader(); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
SYS_INIT(bootloader_check_boot_init, POST_KERNEL, CONFIG_STM32_BOOTLOADER_INIT_PRIORITY); |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed and not a good use of DT, use a Zephyr memory-region instead.