Skip to content

Commit a1f99d9

Browse files
NRF52840_DK support, update for latest Mbed and mcuboot
1 parent 31ab7d2 commit a1f99d9

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ This repository and the demo app both contain a default secondary_bd.cpp which u
7474

7575
The returned BlockDevice is expected to have a size equivalent to the configuration `mcuboot.slot-size` as mentioned previously. The default implementation uses a SlicingBlockDevice to reduce the BD size to meet this constraint.
7676

77-
Since the Mbed-OS mcuboot port uses Mbed's `BlockDevice` API, there is a lot of flexibility when providing the secondary memory region. For example, you can use a `FlashIAPBlockDevice` if your application is small enough to fit two copies in the internal flash. If you also use your external flash chip for data storage you can simply wrap the whole `BlockDevice` object in a `SlicingBlockDevice` with a nonzero offset to give mcuboot access to a certain region of your external flash.
77+
Since the Mbed-OS mcuboot port uses Mbed's `BlockDevice` API, there is a lot of flexibility when providing the secondary memory region. For example, if you enable the `secondary-slot-in-flash` option, you can use a `FlashIAPBlockDevice` if your application is small enough to fit two copies in the internal flash. If you also use your external flash chip for data storage you can simply wrap the whole `BlockDevice` object in a `SlicingBlockDevice` with a nonzero offset to give mcuboot access to a certain region of your external flash.
7878

7979
## Additional Configuration
8080

@@ -90,9 +90,6 @@ By default, the mcuboot repository/library is configured to build a bootloader,
9090

9191
Other commonly-used configuration options are:
9292
```
93-
"target.restrict_size",
94-
"target.mbed_app_start",
95-
"target.mbed_app_size",
9693
"mcuboot.primary-slot-address",
9794
"mcuboot.slot-size",
9895
"mcuboot.scratch-address",
@@ -318,7 +315,7 @@ Target ROM banks: -----------------------------------------------------------
318315

319316
We can see that there is exactly one ROM bank called EXT_FLASH, and its size is 8.0 MiB. If you see multiple ROM banks instead of one, you will need to consult your target MCU's manual and linker script to determine which one is used for the main application.
320317

321-
The other piece of information that you need is the page and sector size of your ROM bank, and of the secondary block device if not using XIP mode. This will require a trip to your MCU datasheet, or the datasheet for the external flash for chips that don't have internal flash like the MIMXRT1060. Note that mcuboot *can* handle flashes with non-uniform sector sizes, but you will have to be extra careful about assigning things to sectors correctly.
318+
The other piece of information that you need is the page size (program size) and the sector size (erase size) of your ROM bank, and of the secondary block device if not using XIP mode. This will require a trip to your MCU datasheet, or the datasheet for the external flash for chips that don't have internal flash like the MIMXRT1060. Note that mcuboot *can* handle flashes with non-uniform sector sizes, but you will have to be extra careful about assigning things to sectors correctly.
322319

323320
### Allocating Memory
324321

mbed-os

Submodule mbed-os updated 764 files

mbed_app.json5

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,13 @@
2121
"mcuboot.log-enable": true,
2222
"mcuboot.log-level": "MCUBOOT_LOG_LEVEL_INFO", // Change INFO to DEBUG for debug prints
2323
"mbed-trace.enable": true,
24-
"mbed-trace.max-level": "TRACE_LEVEL_DEBUG",
24+
"mbed-trace.max-level": "TRACE_LEVEL_INFO", // Change INFO to DEBUG for debug prints
2525
"mbed-trace.fea-ipv6": false,
2626

2727
// Uncomment to enable encryption of the image
2828
// "mcuboot.encrypt-rsa": true
2929
},
30-
// "NRF52840_DK": {
31-
// "target.features_remove": ["CRYPTOCELL310"],
32-
// "target.macros_remove": ["MBEDTLS_CONFIG_HW_SUPPORT"],
33-
// "mcuboot.primary-slot-address": "0x20000",
34-
// "mcuboot.slot-size": "0xC0000",
35-
// "mcuboot.scratch-address": "0xE0000",
36-
// "mcuboot.scratch-size": "0x20000",
37-
// "mcuboot.max-img-sectors": "0x180",
38-
// "mcuboot.read-granularity": 4,
39-
// "qspif.QSPI_MIN_PROG_SIZE": 4
40-
// },
30+
4131
// "EP_AGORA": {
4232
// "target.features_remove": ["CRYPTOCELL310"],
4333
// "target.macros_remove": ["MBEDTLS_CONFIG_HW_SUPPORT"],
@@ -176,6 +166,32 @@
176166
// Since STM32 nucleo boards have no external block device, keep everything in the MCU flash.
177167
"app.secondary-slot-in-flash": true,
178168
"app.secondary-slot-flash-start-addr": 0x0804F000 // primary-slot-address + slot-size
169+
},
170+
171+
"NRF52840_DK": {
172+
"target.features_remove": ["CRYPTOCELL310"],
173+
"target.macros_remove": ["MBEDTLS_CONFIG_HW_SUPPORT"],
174+
175+
"target.memory_bank_config": {
176+
"IROM1": {
177+
"size": 0x20000
178+
}
179+
},
180+
181+
// Primary slot starts right after the bootloader and takes up 768k of flash
182+
"mcuboot.primary-slot-address": 0x20000,
183+
"mcuboot.slot-size": 0xC0000,
184+
185+
// Scratch sector uses the last 128k of flash
186+
"mcuboot.scratch-address": 0xE0000,
187+
"mcuboot.scratch-size": 0x20000,
188+
189+
// Max flash sectors per slot. 768k/4k = 192
190+
"mcuboot.max-img-sectors": 192,
191+
192+
// Flash is word addressable
193+
"mcuboot.read-granularity": 4,
194+
179195
}
180196
}
181197
}

0 commit comments

Comments
 (0)