Skip to content

Commit 31ab7d2

Browse files
Update mbed-os version, update mcuboot version, add NUCLEO_L452RE_P support
1 parent 180c908 commit 31ab7d2

File tree

7 files changed

+48
-11
lines changed

7 files changed

+48
-11
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
url = https://github.com/mbed-ce/mbed-os.git
44
[submodule "mcuboot"]
55
path = mcuboot
6-
url = https://github.com/multiplemonomials/mcuboot.git
6+
url = https://github.com/zhiyong-ft/mcuboot.git

CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ cmake_policy(VERSION 3.19)
33

44
set(MBED_APP_JSON_PATH mbed_app.json5)
55

6-
include(mbed-os/tools/cmake/app.cmake)
6+
include(mbed-os/tools/cmake/mbed_toolchain_setup.cmake)
77

8-
add_subdirectory(mbed-os)
8+
project(mbed-mcuboot-bootloader
9+
LANGUAGES C CXX ASM)
10+
11+
include(mbed_project_setup)
912

10-
project(mbed-mcuboot-bootloader)
13+
add_subdirectory(mbed-os)
1114

1215
set(MBED_MCUBOOT_BOOTLOADER_SOURCES
1316
secondary_bd.cpp
@@ -23,5 +26,3 @@ target_link_libraries(${CMAKE_PROJECT_NAME}
2326
mbed-storage
2427
mbed-mcuboot)
2528
mbed_set_post_build(${CMAKE_PROJECT_NAME})
26-
27-
mbed_finalize_build()

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,15 @@ Once your target has been programmed, open a serial terminal to view the debug o
216216
217217
```
218218

219+
#### Junk Data in Magic
220+
If, instead of the application running, you get output similar to this:
221+
```
222+
[INFO][MCUb]: Primary image: magic=bad, swap_type=0x1, copy_done=0x2, image_ok=0
223+
<snip>
224+
[INFO][MCUb]: Boot source: none
225+
```
226+
this may be caused by data in the "magic" region that mcuboot uses near the end of each slot. mcuboot expects this region to either have a valid signature, or be erased. If you had previously flashed an application to this board that had data in this region of flash, mcuboot may conclude that this is a "bad" magic value and not boot your application. To fix this, simply use your programmer of choice (e.g. STM32CubeProgrammer or J-Flash) to mass erase your chip, then reflash the bootloader and application.
227+
219228
### Erasing the secondary slot
220229

221230
By pressing the target's button (BUTTON1, if there are multiple), you will initiate erasure of the secondary slot block device in preparation for programming the update. You should see output similar to the following:
@@ -340,7 +349,7 @@ You want the entry in MEMORY called `m_text` or `m_flash` or `m_rom` -- wherever
340349

341350
If the entry is defined in terms of `MBED_CONFIGURED_ROM_BANK` constants, this linker script has already been upgraded. If not, and it references `MBED_APP_START` and `MBED_APP_SIZE`, or it just uses constant addresses, then this target still needs to be upgraded.
342351

343-
Please file a PR with mbed-ce/mbed-os asking for the linker script to be updated, or, if you are feeling adventurous, you can update the linker script yourself. Updates can be as simple as defining the text section in terms of the `MBED_CONFIGURED_ROM_BANK` constants, though there are also a number of other fixes that are useful for older linker scripts.
352+
Please file an issue with mbed-ce/mbed-os asking for the linker script to be updated, or, if you are feeling adventurous, you can update the linker script yourself. Updates can be as simple as defining the text section in terms of the `MBED_CONFIGURED_ROM_BANK` constants, though there are also a number of other fixes that are useful for older linker scripts.
344353

345354
### Setting Up Bootloader mbed_app.json
346355

@@ -388,7 +397,7 @@ Now, you can flash the bootloader to your device using the steps above. Make su
388397
```
389398

390399
### Setting Up Application mbed_app.json
391-
Now we can set up the demo app. Its mbed_app.json should look the same as the bootloader, *except* the `target.memory_bank_config` section. We want this application to go into the application region of the primary slot. So, we must set the start address to `mcuboot.primary-slot-address` + `mcuboot.header-size` (which defaults to 0x1000). Meanwhile, the size should be set to extend to the end of the primary slot (yes there are some TLVs after there, but the image tool will warn if there isn't enough space).
400+
Now we can set up the demo app. Its mbed_app.json section for your target should look the same as the bootloader, *except* the `target.memory_bank_config` section. We want this application to go into the application region of the primary slot. So, we must set the start address to `mcuboot.primary-slot-address` + `mcuboot.header-size` (which defaults to 0x1000). Meanwhile, the size should be set to extend to the end of the primary slot (yes there are some TLVs after there, but the image tool will warn if there isn't enough space).
392401

393402
So we'd add the following block:
394403
```js

assets/generic-memory-diagram.png

-475 Bytes
Loading

mbed-os

Submodule mbed-os updated 200 files

mbed_app.json5

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
"*": {
1818
"platform.stdio-baud-rate": 115200,
1919
"target.c_lib": "small",
20+
"target.application-profile": "bare-metal",
2021
"mcuboot.log-enable": true,
21-
"mcuboot.log-level": "MCUBOOT_LOG_LEVEL_INFO", // Change DEBUG to INFO for debug prints
22+
"mcuboot.log-level": "MCUBOOT_LOG_LEVEL_INFO", // Change INFO to DEBUG for debug prints
2223
"mbed-trace.enable": true,
2324
"mbed-trace.max-level": "TRACE_LEVEL_DEBUG",
2425
"mbed-trace.fea-ipv6": false,
@@ -149,6 +150,32 @@
149150
"mcuboot.scratch-size": "0x40000",
150151
"mcuboot.max-img-sectors": "0x180",
151152
"mcuboot.read-granularity": 1
153+
},
154+
155+
"NUCLEO_L452RE_P": {
156+
// Configure bootloader to live in the first 128k of flash
157+
"target.memory_bank_config": {
158+
"IROM1": {
159+
"size": 0x20000
160+
}
161+
},
162+
163+
// Sector size is 2k, make the scratch region use the last 8k of flash so it uses 4 sectors
164+
"mcuboot.scratch-address": 0x0807E000,
165+
"mcuboot.scratch-size": 0x2000,
166+
167+
// Primary and secondary slot need to fit in the remaining 376k of flash (512k total - 128k - 8k)
168+
"mcuboot.slot-size": 0x2F000, // 188kiB
169+
170+
// Primary slot starts right after the bootloader
171+
"mcuboot.primary-slot-address": 0x08020000,
172+
173+
"mcuboot.max-img-sectors": 94, // 94 flash sectors per slot
174+
"mcuboot.flash-block-size": 8, // Flash program size is 8
175+
176+
// Since STM32 nucleo boards have no external block device, keep everything in the MCU flash.
177+
"app.secondary-slot-in-flash": true,
178+
"app.secondary-slot-flash-start-addr": 0x0804F000 // primary-slot-address + slot-size
152179
}
153180
}
154181
}

mcuboot

Submodule mcuboot updated 82 files

0 commit comments

Comments
 (0)