Skip to content

Commit 09add09

Browse files
NRF52840_DK support, update for latest Mbed and mcuboot
1 parent d9d0f47 commit 09add09

File tree

6 files changed

+48
-30
lines changed

6 files changed

+48
-30
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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@ 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)
7+
8+
project(mbed-mcuboot-demo-app VERSION 1.0.0)
9+
10+
include(mbed_project_setup)
711

812
# Make sure that the build system generates both bin and hex files, regardless of
913
# target settings.
1014
set(MBED_OUTPUT_EXT "" CACHE STRING "" FORCE)
1115

1216
add_subdirectory(mbed-os)
1317

14-
project(mbed-mcuboot-demo-app VERSION 1.0.0)
15-
1618
# Compile mcuboot sources
1719
add_subdirectory(mcuboot/boot/bootutil)
1820
add_subdirectory(mcuboot/boot/mbed)
@@ -27,7 +29,7 @@ mcuboot_generate_update_image(SimpleApp)
2729

2830
add_executable(UpdaterApp UpdaterApp.cpp secondary_bd.cpp)
2931
target_link_libraries(UpdaterApp
30-
mbed-os
32+
mbed-baremetal
3133
mbed-storage
3234
mbed-mcuboot)
3335
mbed_set_post_build(UpdaterApp)
@@ -39,6 +41,4 @@ mcuboot_generate_update_image(UpdaterApp)
3941
# here to the linker.
4042
# See here for more details on this: https://gareus.org/wiki/embedding_resources_in_executables
4143
target_link_options(UpdaterApp PRIVATE -Wl,-b,binary,SimpleApp-update-image.bin -Wl,-b,elf32-littlearm)
42-
add_dependencies(UpdaterApp SimpleApp) # Ensure SimpleApp gets built before UpdaterApp
43-
44-
mbed_finalize_build()
44+
add_dependencies(UpdaterApp SimpleApp) # Ensure SimpleApp gets built before UpdaterApp

UpdaterApp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int main()
5252
tr_info(" - Max flash sectors per slot: %u", MCUBOOT_MAX_IMG_SECTORS);
5353
tr_info("- Scratch area: start address 0x%x, size %ukiB", MCUBOOT_SCRATCH_START_ADDR, MCUBOOT_SCRATCH_SIZE/1024);
5454
tr_info("- Secondary BD: size %" PRIu64 "kiB", secondary_bd->size()/1024);
55-
tr_info(" - Program (block) size %" PRIu64 " bytes", secondary_bd->get_program_size());
55+
tr_info(" - Program (page) size %" PRIu64 " bytes", secondary_bd->get_program_size());
5656
tr_info(" - Erase (sector) size %" PRIu64 " bytes", secondary_bd->get_erase_size());
5757
tr_info(" ");
5858

mbed-os

Submodule mbed-os updated 916 files

mbed_app.json5

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,11 @@
2626
"target.c_lib": "small",
2727
"mcuboot.log-level": "MCUBOOT_LOG_LEVEL_DEBUG",
2828
"mbed-trace.enable": true,
29+
"target.application-profile": "bare-metal"
2930

3031
// Uncomment to enable encryption of the image
3132
// "mcuboot.encrypt-rsa": true
3233
},
33-
// "NRF52840_DK": {
34-
// "demo-button-active-low": true,
35-
// "mbed_app_start": "0x21000",
36-
// "target.mbed_app_size": "0xBE000",
37-
// "mcuboot.primary-slot-address": "0x20000",
38-
// "mcuboot.slot-size": "0xC0000",
39-
// "mcuboot.scratch-address": "0xE0000",
40-
// "mcuboot.scratch-size": "0x20000",
41-
// "mcuboot.max-img-sectors": "0x180",
42-
// "mcuboot.read-granularity": 4,
43-
// "qspif.QSPI_MIN_PROG_SIZE": 4
44-
// },
4534
// "EP_AGORA": {
4635
// "demo-button-active-low": true,
4736
// "mbed_app_start": "0x21000",
@@ -120,26 +109,55 @@
120109
"MCU_STM32H743xI": {
121110
"target.memory_bank_config": {
122111
"IROM1": {
123-
"start": 0x08021000, // mcuboot.primary-slot-address + mcuboot.header-size
124-
"size": 0xDF000 // mcuboot.slot-size - mcuboot.header-size
112+
"start": 0x08021000,
113+
// mcuboot.primary-slot-address + mcuboot.header-size
114+
"size": 0xDF000
115+
// mcuboot.slot-size - mcuboot.header-size
125116
}
126117
},
127-
128118
// Since STM32H743 boards have no external block device, keep everything in the MCU flash.
129119
"app.secondary-slot-in-flash": true,
130120
"app.secondary-slot-flash-start-addr": "0x08100000",
131-
132121
// Slot size can be as big as 896k, since we need to reserve the first flash sector for the bootloader
133122
// and the last flash sector for scratch space
134123
"mcuboot.primary-slot-address": "0x08020000",
135-
"mcuboot.max-img-sectors": "7", // 7 flash sectors per slot
124+
"mcuboot.max-img-sectors": "7",
125+
// 7 flash sectors per slot
136126
"mcuboot.slot-size": "0xE0000",
137-
"mcuboot.flash-block-size": 32, // Flash program size is 32
127+
"mcuboot.flash-block-size": 32,
128+
// Flash program size is 32
138129

139130
// STM32H7 flash sector size is 128k, so we need to make the scratch region at least that big
140131
"mcuboot.scratch-address": "0x081E0000",
141-
"mcuboot.scratch-size": "0x20000"
132+
"mcuboot.scratch-size": "0x20000",
133+
},
134+
135+
"NRF52840_DK": {
136+
"target.features_remove": ["CRYPTOCELL310"],
137+
"target.macros_remove": ["MBEDTLS_CONFIG_HW_SUPPORT"],
138+
139+
"target.memory_bank_config": {
140+
"IROM1": {
141+
"start": 0x21000, // mcuboot.primary-slot-address + mcuboot.header-size
142+
"size": 0xBF000 // mcuboot.slot-size - mcuboot.header-size
143+
}
144+
},
145+
146+
// Primary slot starts right after the bootloader and takes up 768k of flash
147+
"mcuboot.primary-slot-address": 0x20000,
148+
"mcuboot.slot-size": 0xC0000,
149+
150+
// Scratch sector uses the last 128k of flash
151+
"mcuboot.scratch-address": 0xE0000,
152+
"mcuboot.scratch-size": 0x20000,
142153

154+
// Max flash sectors per slot. 768k/4k = 192
155+
"mcuboot.max-img-sectors": 192,
156+
157+
// Flash is word addressable
158+
"mcuboot.read-granularity": 4,
159+
160+
"demo-button-active-low": true
143161
}
144162
},
145163
}

mcuboot

Submodule mcuboot updated 77 files

0 commit comments

Comments
 (0)