Skip to content

Commit 241db77

Browse files
authored
Merge pull request #1 from mbed-ce/dev/add-mimxrt1060-evk
Add MIMXRT1060_EVK and NUCLEO_H743ZI2
2 parents 137d067 + abcebdd commit 241db77

File tree

7 files changed

+103
-16
lines changed

7 files changed

+103
-16
lines changed

.github/workflows/compile.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
mbed_target:
1515
# Change the below to match the target(s) you want to compile the project for.
1616
- K64F
17+
- MIMXRT1060_EVK
18+
- NUCLEO_H743ZI2
1719

1820
steps:
1921
- name: Checkout
@@ -36,5 +38,5 @@ jobs:
3638
- name: Build project for ${{ matrix.mbed_target }}
3739
run: |
3840
mkdir build && cd build
39-
cmake .. -GNinja -DMBED_TARGET=${{ matrix.mbed_target }} -DMCUBOOT_SIGNING_KEY=signing-keys.pem
41+
cmake .. -GNinja -DMBED_TARGET=${{ matrix.mbed_target }} -DUPLOAD_METHOD=NONE -DMCUBOOT_SIGNING_KEY=signing-keys.pem
4042
ninja

SimpleApp.cpp

Lines changed: 6 additions & 1 deletion
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();
@@ -60,7 +63,6 @@ int main()
6063
if (ret == 0)
6164
{
6265
tr_info("Current firmware set as confirmed");
63-
return 0;
6466
}
6567
else
6668
{
@@ -81,12 +83,15 @@ int main()
8183
{
8284
ThisThread::sleep_for(1s);
8385
printf("Simple app is running...\n");
86+
87+
#ifdef LED1
8488
led = 1;
8589
ThisThread::sleep_for(250ms);
8690
led = 0;
8791
ThisThread::sleep_for(250ms);
8892
led = 1;
8993
ThisThread::sleep_for(250ms);
9094
led = 0;
95+
#endif
9196
}
9297
}

UpdaterApp.cpp

Lines changed: 20 additions & 1 deletion
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
@@ -80,7 +91,12 @@ int main()
8091
}
8192

8293
// Copy the update image from internal flash to secondary BlockDevice
83-
secondary_bd->program(&_binary_SimpleApp_update_image_bin_start, 0, SimpleApp_update_image_bin_length);
94+
ret = secondary_bd->program(&_binary_SimpleApp_update_image_bin_start, 0, SimpleApp_update_image_bin_length);
95+
if (ret == 0) {
96+
tr_info("Image copied.");
97+
} else {
98+
tr_error("Cannot copy image: %d", ret);
99+
}
84100

85101
ret = secondary_bd->deinit();
86102
if (ret == 0) {
@@ -89,6 +105,9 @@ int main()
89105
tr_error("Cannot deinit secondary BlockDevice: %d", ret);
90106
}
91107

108+
// Give user time to react, as programming can be pretty fast
109+
ThisThread::sleep_for(250ms);
110+
92111
// Activate the image in the secondary BlockDevice
93112
tr_info("> Image copied to secondary BlockDevice, press button to activate");
94113

mbed-os

Submodule mbed-os updated 49 files

mbed_app.json5

Lines changed: 63 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,61 @@
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
118+
},
119+
120+
"MCU_STM32H743xI": {
121+
"target.memory_bank_config": {
122+
"IROM1": {
123+
"start": 0x08021000, // mcuboot.primary-slot-address + mcuboot.header-size
124+
"size": 0xDF000 // mcuboot.slot-size - mcuboot.header-size
125+
}
126+
},
127+
128+
// Since STM32H743 boards have no external block device, keep everything in the MCU flash.
129+
"app.secondary-slot-in-flash": true,
130+
"app.secondary-slot-flash-start-addr": "0x08100000",
131+
132+
// Slot size can be as big as 896k, since we need to reserve the first flash sector for the bootloader
133+
// and the last flash sector for scratch space
134+
"mcuboot.primary-slot-address": "0x08020000",
135+
"mcuboot.max-img-sectors": "7", // 7 flash sectors per slot
136+
"mcuboot.slot-size": "0xE0000",
137+
"mcuboot.flash-block-size": 32, // Flash program size is 32
138+
139+
// STM32H7 flash sector size is 128k, so we need to make the scratch region at least that big
140+
"mcuboot.scratch-address": "0x081E0000",
141+
"mcuboot.scratch-size": "0x20000"
142+
86143
}
87-
}
144+
},
88145
}

secondary_bd.cpp

Lines changed: 9 additions & 5 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,9 +15,13 @@
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);
20-
return &flashBD;
18+
// Use FlashIAP for the secondary BD.
19+
static FlashIAPBlockDevice flashBD(MBED_CONF_APP_SECONDARY_SLOT_FLASH_START_ADDR, MCUBOOT_SLOT_SIZE);
20+
21+
// Our UpdaterApp needs to be able to program the flash with single-byte granularity
22+
static mbed::BufferedBlockDevice bufferedBD(&flashBD);
23+
24+
return &bufferedBD;
2125
}
2226

2327
#else
@@ -33,7 +37,7 @@ mbed::BlockDevice* get_secondary_bd(void) {
3337
// Otherwise it will return the flash IAP block device.
3438
mbed::BlockDevice* default_bd = mbed::BlockDevice::get_default_instance();
3539

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

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

0 commit comments

Comments
 (0)