Skip to content

Commit f7505f8

Browse files
committed
Update README and create update build flag
1 parent 30d36f6 commit f7505f8

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ Briefly, the bootloader has a maximum size set by `target.restrict_size` when bu
1313

1414
### Application Header Info
1515

16-
When deciding what to boot/update, the mcuboot bootloader looks at an installed application's header info (type-length-value formatted data that is prepended to the application binary before the application's start address). It uses this header info to validate there is a bootable image installed in the "slot" and optionally to verify the image's digital signature before booting.
16+
When deciding what to boot/update, the mcuboot bootloader looks at an installed application's header info, which is a special struct prepended to the application binary. It uses this header info to validate there is a bootable image installed in the "slot". There are also type-length-value (TLV) encoded pieces of information following the application binary called the "application trailer". These TLV encoded values include things like a digital signature and SHA hash, among other things. See mcuboot documentation for more information.
1717

18-
By default, this header is configured to be 1kB in size. This is probably way more than needed in most cases and can be adjusted using the configuration parameter `mcuboot.header_size`. This value should be aligned on 4-byte boundaries.
18+
By default, this header is configured to be 4kB in size. ~~This is probably way more than needed in most cases and can be adjusted using the configuration parameter `mcuboot.header_size`. This value should be aligned on 4-byte boundaries.~~ **NOTE:** 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!
1919

20-
This header prepended to the application hex during the signing process (explained later).
20+
This header prepended to the application hex during the signing process (explained later). The trailer is also appended to the application hex during signing.
2121

22-
Please note: the bootloader size should be restricted to ensure it does not collide with the application header info. For example, if the application start address is set to `0x20000` and the header size is `0x400`, the bootloader size should be restricted to at most `0x20000 - 0x400 = 0x1FC00`.
22+
~~Please note: the bootloader size should be restricted to ensure it does not collide with the application header info. For example, if the application start address is set to `0x20000` and the header size is `0x400`, the bootloader size should be restricted to at most `0x20000 - 0x400 = 0x1FC00`.~~ **NOTE:** Currently, the bootloader size should be restricted to match the application start address. This could cause issues if the bootloader fills this space exactly (and overwrites the application header area). Potential solution: Add `MBED_CONF_MCUBOOT_HEADER_SIZE` to `POST_APPLICATION_ADDR` to get the actual start address of the application...
2323

2424
### Primary Application
2525

@@ -59,8 +59,6 @@ Additionally, the application start location and maximum allowed size should be
5959
}
6060
```
6161

62-
63-
6462
The example project contains an application that repeatedly blinks an LED on supported [Mbed boards](https://os.mbed.com/platforms/).
6563

6664
You can build the project with all supported [Mbed OS build tools](https://os.mbed.com/docs/mbed-os/latest/tools/index.html). However, this example project specifically refers to the command-line interface tool [Arm Mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).

main.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,31 @@
55

66
#include "mbed.h"
77

8+
#include "bootutil.h"
89

9-
// Blinking rate in milliseconds
10-
#define BLINKING_RATE 500ms
11-
10+
// Change which LED and how fast we blink it for update binary
11+
#ifndef MCUBOOT_UPDATE
12+
#define LED LED1
13+
#define BLINKING_RATE 1000ms
14+
#else
15+
#define LED LED2
16+
#define BLINKING_RATE 250ms
17+
#endif
1218

1319
int main()
1420
{
21+
22+
/**
23+
* Do whatever is needed to verify the firmware is okay
24+
* (eg: self test, connect to server, etc)
25+
*
26+
* And then mark that the update succeeded
27+
*/
28+
//run_self_test();
29+
boot_set_confirmed();
30+
1531
// Initialise the digital pin LED1 as an output
16-
DigitalOut led(LED1);
32+
DigitalOut led(LED);
1733

1834
while (true) {
1935
led = !led;

mbed_app.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
"mcuboot.bootloader-build": 0,
55
"target.mbed_app_start": "0x20000",
66
"target.mbed_app_size": "0xDC000"
7+
},
8+
"NRF52840_DK": {
9+
"mcuboot.max-img-sectors": 256
10+
},
11+
"EP_AGORA": {
12+
"mcuboot.max-img-sectors": 256
713
}
814
}
915
}

mcuboot.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/AGlass0fMilk/mcuboot/#d3ebeac565b822ba52653d1065eb6616652eee10
1+
https://github.com/AGlass0fMilk/mcuboot/#aff9bd34ceb8e4fb1f0697045e2f09764e738844

0 commit comments

Comments
 (0)