Skip to content

Commit 36a8819

Browse files
author
Jamie Smith
authored
Merge pull request #1 from zhiyong-ft/master
Updated readme and added configuration for DISCO_F746NG board
2 parents 26f8a76 + aa7b2b3 commit 36a8819

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ When deciding what to boot/update, the mcuboot bootloader looks at an installed
3636

3737
By default, this header is configured to be 4kB in size. This can be adjusted using the configuration parameter `mcuboot.header_size`.
3838

39-
**However,** due to the way the FlashIAP block device currently works while erasing, the header_size should be configured to be the size of an erase sector (4kB in the case of an nRF52840). Erasing using the FlashIAPBlockDevice only works if the given address is erase-sector aligned!
39+
**However,** due to the way the FlashIAP block device currently works while erasing, the header_size should be configured to be the size of an erase sector (4kB in the case of an nRF52840). Erasing using the FlashIAPBlockDevice only works if the given address is erase-sector aligned! On the other hand, there is a hard upper limit of `< 65536` enforced by imgtool script. This needs to be carefully taken into consideration when choosing a MCU. Because a erase-sector of size >=4KB <64KB may actually not be available between the end of bootloader and start of primary application. For example, STM32F767/9xGx series MCU with dual bank enabled.
4040

4141
This header is prepended to the application binary during the signing process (explained later).
4242

@@ -60,7 +60,7 @@ In our case, our configuration gives us:
6060

6161
`TLV region size = 0xE0000 - 0xDF000 = 0x1000`
6262

63-
In most cases, 4kB will be plenty of room for the required TLV trailers. Enabling features such as update binary encryption increases the number of required TLV trailer entries and so you may need to adjust the size of the TLV trailer region based on your use case. During signing, the imgtool script will complain if there is not enough room for TLV trailers.
63+
In most cases, 4kB will be plenty of room for the required TLV trailers. Enabling features such as update binary encryption increases the number of required TLV trailer entries and so you may need to adjust the size of the TLV trailer region based on your use case. During signing, the imgtool script will complain if there is not enough room for TLV trailers. On a different note, region reserved for TLV trailers doesn't have to align with erasable flash sectors. This is different from how region reserved for application header information which needs to be carefully configured to align with erasable flash sectors.
6464

6565
See the [mcuboot Image Trailer documentation](https://github.com/mcu-tools/mcuboot/blob/master/docs/design.md#image-trailer) for more information.
6666

@@ -107,14 +107,13 @@ Other commonly-used configuration options are:
107107
"mcuboot.slot-size",
108108
"mcuboot.scratch-address",
109109
"mcuboot.scratch-size",
110-
"mcuboot.header-size",
111110
"mcuboot.max-img-sectors",
112111
"mcuboot.read-granularity",
113112
```
114113

115114
Many of these have been mentioned previously.
116115

117-
**NOTE:** It is important to ensure the `mcuboot` configuration parameters are **the same** for the bootloader and the bootable application!
116+
**NOTE:** It is important to ensure the `mcuboot` configuration parameters are **the same** for the bootloader and the bootable application! Also `mcuboot.header-size` has been deprecated as of mcuboot v1.7 and onward. We no-longer need to set it in mbed_app.json file. But we still need to note down the planned header-size and pass it to imgtool when signing built images.
118117

119118
## Running the Demo
120119

@@ -193,7 +192,7 @@ Explanation of each option:
193192
- `--header-size 4096`: this must be the same as the value specified in `mcuboot.header-size` configuration (4096 bytes by default)
194193
- `--pad-header`: this tells imgtool to insert the entire header, including any necessary padding bytes.
195194
- `-S 0xC0000`: this specifies the maximum size of the application ("slot size"). It **must** be the same as the configured `mcuboot.slot-size`!
196-
- `--pad`: this should only be used for binaries you plan on initially flashing to your target at the factory. It pads the resulting binary to the slot size and adds initialized trailer TLVs. This is not needed for update binaries.
195+
- `--pad`: this should only be used for binaries you plan on initially flashing to your target at the factory. It pads the resulting binary to the slot size and adds initialized trailer TLVs. This shall NOT be included for update binaries. Otherwise bootloader will automatically upgrade to firmware images saved into secondary block device even if `boot_set_pending()` has not been called by primary application, essentially setup an unattended firmware upgrade. This can create unwanted consequences.
197196

198197

199198
### Creating the update binary
@@ -457,4 +456,9 @@ A common goal of bootloader implementers is to minimize the code size of the boo
457456

458457
For example, you can configure `target.printf_lib` to `minimal-printf` rather than `std` to use a reduced-feature-set version of `printf`.
459458

460-
You can also entirely disable logging output by setting `mbed-trace.enable` to `false`. You can also eliminate the stdio console entirely (TODO - explain how to do this).
459+
You can also entirely disable logging output by setting `mbed-trace.enable` to `false`. You can also eliminate the stdio console entirely by including the following line in the `target_overrides` section of your mbed_app.json/json5 file:
460+
```
461+
"target.console-uart": false,
462+
"target.console-uart-flow-control": null,
463+
```
464+
As a reference, with mbed-trace and console output disabled alltogether, release as build profile, and SPIF/QSPIF as secondary block device, the final image size of bootloader amounts to about 45KB. In theory 48KB reserved for bootloader should be enough, but compiler will complain if `target.restrict_size' is set at 0xC000. For budgeting purpose, a minimum 64KB or 0x10000 is needed for bootloader.

mbed_app.json5

+10-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,16 @@
5252
// "mcuboot.read-granularity": 1,
5353
// "qspif.QSPI_MIN_PROG_SIZE": 1
5454
// },
55-
55+
"DISCO_F746NG": {
56+
"target.restrict_size": "0x18000",
57+
"mcuboot.primary-slot-address": "0x8018000",
58+
"mcuboot.slot-size": "0xA8000",
59+
"mcuboot.scratch-address": "0x80C0000",
60+
"mcuboot.scratch-size": "0x40000",
61+
"mcuboot.max-img-sectors": "0x180",
62+
"mcuboot.read-granularity": 1,
63+
"qspif.QSPI_MIN_PROG_SIZE": 1
64+
},
5665
"K64F": {
5766
// Configure bootloader to live in the first sector of flash
5867
"target.memory_bank_config": {

0 commit comments

Comments
 (0)