Skip to content

Commit ab62eea

Browse files
committed
Updated code to match new secondary_bd API
1 parent 5e44125 commit ab62eea

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ By default, the secondary memory region is provided by the `mbed::BlockDevice::g
3737
mbed::BlockDevice* get_secondary_bd(void);
3838
```
3939

40+
See the example file in this repository, `default_bd.cpp`.
41+
4042
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` to give mcuboot access to a certain region of your external flash.
4143

4244
The Mbed-OS mcuboot port also has an additional function that the application can define if needed: `void mbed_mcuboot_user_init(void)`. This is provided as a `weak` symbol so the application can perform any necessary initialization before the rest of the boot process begins.

default_bd.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,11 @@ BlockDevice *BlockDevice::get_default_instance()
6868

6969
}
7070

71+
/**
72+
* You can override this function to suit your hardware/memory configuration
73+
* By default it simply returns what is returned by BlockDevice::get_default_instance();
74+
*/
75+
//mbed::BlockDevice* get_secondary_bd(void) {
76+
// return mbed::BlockDevice::get_default_instance();
77+
//}
78+

user_main.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,8 @@ using namespace std::chrono;
2323

2424
#endif // MBED_CONF_APP_SERIAL_BOOTLOADER_ENABLE
2525

26-
mbed::BlockDevice* mcuboot_secondary_bd;
27-
2826
void mbed_mcuboot_user_init(void) {
2927

30-
mbed::BlockDevice* mcuboot_secondary_bd = mbed::BlockDevice::get_default_instance();
31-
32-
// Initialize the secondary/update candidate block device
33-
mcuboot_secondary_bd->init();
34-
3528
#if MBED_CONF_APP_SERIAL_BOOTLOADER_ENABLE
3629

3730
// Set up the serial bootloader

0 commit comments

Comments
 (0)