Skip to content

Commit b569909

Browse files
Start on MIMXRT1060_EVK support. App boots but won't update yet...
1 parent 137d067 commit b569909

File tree

6 files changed

+64
-12
lines changed

6 files changed

+64
-12
lines changed

SimpleApp.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ int main()
2626
mbed_trace_include_filters_set("SimpleApp,MCUb,BL");
2727

2828
DigitalIn btn(DEMO_BUTTON);
29+
30+
#ifdef LED1
2931
DigitalOut led(LED1);
32+
#endif
3033

3134
// Check if an update has been performed
3235
int swap_type = boot_swap_type();
@@ -81,12 +84,15 @@ int main()
8184
{
8285
ThisThread::sleep_for(1s);
8386
printf("Simple app is running...\n");
87+
88+
#ifdef LED1
8489
led = 1;
8590
ThisThread::sleep_for(250ms);
8691
led = 0;
8792
ThisThread::sleep_for(250ms);
8893
led = 1;
8994
ThisThread::sleep_for(250ms);
9095
led = 0;
96+
#endif
9197
}
9298
}

UpdaterApp.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ int main()
4545
tr_error("Cannot init secondary BlockDevice: %d", ret);
4646
}
4747

48+
tr_info(" ");
49+
tr_info("mcuboot configuration: -----------------------------------");
50+
tr_info("- Primary slot: start address 0x%x, size %ukiB", MCUBOOT_PRIMARY_SLOT_START_ADDR, MCUBOOT_SLOT_SIZE/1024);
51+
tr_info(" - Header size: 0x%x", MCUBOOT_HEADER_SIZE);
52+
tr_info(" - Max flash sectors per slot: %u", MCUBOOT_MAX_IMG_SECTORS);
53+
tr_info("- Scratch area: start address 0x%x, size %ukiB", MCUBOOT_SCRATCH_START_ADDR, MCUBOOT_SCRATCH_SIZE/1024);
54+
tr_info("- Secondary BD: size %" PRIu64 "kiB", secondary_bd->size()/1024);
55+
tr_info(" - Program (block) size %" PRIu64 " bytes", secondary_bd->get_program_size());
56+
tr_info(" - Erase (sector) size %" PRIu64 " bytes", secondary_bd->get_erase_size());
57+
tr_info(" ");
58+
4859
// Erase secondary slot
4960
// On the first boot, the secondary BlockDevice needs to be clean
5061
// If the first boot is not normal, please run the erase step, then reboot
@@ -89,6 +100,9 @@ int main()
89100
tr_error("Cannot deinit secondary BlockDevice: %d", ret);
90101
}
91102

103+
// Give user time to react, as programming can be pretty fast
104+
ThisThread::sleep_for(250ms);
105+
92106
// Activate the image in the secondary BlockDevice
93107
tr_info("> Image copied to secondary BlockDevice, press button to activate");
94108

mbed-os

Submodule mbed-os updated 49 files

mbed_app.json5

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010
"macro_name": "DEMO_BUTTON_ACTIVE_LOW",
1111
"required": false
1212
},
13+
"secondary-slot-in-flash": {
14+
"help": "If enabled, store the secondary slot in the application flash immediately after the primary slot.",
15+
"value": false
16+
},
17+
"secondary-slot-flash-start-addr": {
18+
"help": "If secondary-slot-in-flash is enabled, this sets the start address of the secondary slot.",
19+
"value": null
20+
}
1321
},
1422

15-
"macros": [
16-
"MBEDTLS_CIPHER_MODE_CTR"
17-
],
18-
1923
"target_overrides": {
2024
"*": {
2125
"mcuboot.bootloader-build": 0,
@@ -81,8 +85,36 @@
8185
"mcuboot.scratch-address": "0xE0000",
8286
"mcuboot.scratch-size": "0x20000",
8387

84-
"mcuboot.max-img-sectors": "0x180",
88+
"mcuboot.max-img-sectors": "1536", // External SD card has smaller sector size, so divide slot size by read granularity
8589
"mcuboot.read-granularity": 512 // External SD card used as block device, this is its read size.
90+
},
91+
92+
"MIMXRT1060_EVK": {
93+
"target.memory_bank_config": {
94+
"EXT_FLASH": {
95+
"start": 0x60021000, // mcuboot.primary-slot-address + mcuboot.header-size
96+
"size": 0x2FF000 // mcuboot.slot-size - mcuboot.header-size
97+
}
98+
},
99+
100+
// Primary slot is 3MiB and begins right after the bootloader
101+
"mcuboot.primary-slot-address": "0x60020000",
102+
"mcuboot.slot-size": "0x300000",
103+
104+
// Use flash for secondary slot as well
105+
"secondary-slot-in-flash": true,
106+
"secondary-slot-flash-start-addr": "0x60320000",
107+
108+
// Store the scratch space at the end of flash
109+
"mcuboot.scratch-address": "0x60620000",
110+
"mcuboot.scratch-size": "0x20000",
111+
112+
"mcuboot.read-granularity": 1, // Flash is byte addressable
113+
114+
"mcuboot.max-img-sectors": 768, // Maximum flash sectors per slot. 3MiB/4kiB = 768.
115+
"mcuboot.flash-block-size": 256,
116+
117+
"demo-button-active-low": true
86118
}
87-
}
119+
},
88120
}

secondary_bd.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* default_bd.cpp
2+
* default_bd.cpp
33
*
44
* Created on: Jul 30, 2020
55
* Author: gdbeckstein
@@ -15,8 +15,8 @@
1515

1616
mbed::BlockDevice* get_secondary_bd(void) {
1717

18-
// Use a section of FlashIAP immediately after the secondary slot
19-
static FlashIAPBlockDevice flashBD(MCUBOOT_PRIMARY_SLOT_START_ADDR + MCUBOOT_SLOT_SIZE, MCUBOOT_SLOT_SIZE);
18+
// Use FlashIAP for the secondary BD.
19+
static FlashIAPBlockDevice flashBD(MBED_CONF_APP_SECONDARY_SLOT_FLASH_START_ADDR, MCUBOOT_SLOT_SIZE);
2020
return &flashBD;
2121
}
2222

@@ -33,7 +33,7 @@ mbed::BlockDevice* get_secondary_bd(void) {
3333
// Otherwise it will return the flash IAP block device.
3434
mbed::BlockDevice* default_bd = mbed::BlockDevice::get_default_instance();
3535

36-
// If this assert fails, there is no block def
36+
// If this assert fails, there is no default block device defined for your board.
3737
MBED_ASSERT(default_bd != nullptr);
3838

3939
// mcuboot assumes that the read size of the secondary block device is the same as the read size

0 commit comments

Comments
 (0)