Skip to content

Add MIMXRT1060_EVK and NUCLEO_H743ZI2 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
mbed_target:
# Change the below to match the target(s) you want to compile the project for.
- K64F
- MIMXRT1060_EVK
- NUCLEO_H743ZI2

steps:
- name: Checkout
Expand All @@ -36,5 +38,5 @@ jobs:
- name: Build project for ${{ matrix.mbed_target }}
run: |
mkdir build && cd build
cmake .. -GNinja -DMBED_TARGET=${{ matrix.mbed_target }} -DMCUBOOT_SIGNING_KEY=signing-keys.pem
cmake .. -GNinja -DMBED_TARGET=${{ matrix.mbed_target }} -DUPLOAD_METHOD=NONE -DMCUBOOT_SIGNING_KEY=signing-keys.pem
ninja
7 changes: 6 additions & 1 deletion SimpleApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ int main()
mbed_trace_include_filters_set("SimpleApp,MCUb,BL");

DigitalIn btn(DEMO_BUTTON);

#ifdef LED1
DigitalOut led(LED1);
#endif

// Check if an update has been performed
int swap_type = boot_swap_type();
Expand Down Expand Up @@ -60,7 +63,6 @@ int main()
if (ret == 0)
{
tr_info("Current firmware set as confirmed");
return 0;
}
else
{
Expand All @@ -81,12 +83,15 @@ int main()
{
ThisThread::sleep_for(1s);
printf("Simple app is running...\n");

#ifdef LED1
led = 1;
ThisThread::sleep_for(250ms);
led = 0;
ThisThread::sleep_for(250ms);
led = 1;
ThisThread::sleep_for(250ms);
led = 0;
#endif
}
}
21 changes: 20 additions & 1 deletion UpdaterApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ int main()
tr_error("Cannot init secondary BlockDevice: %d", ret);
}

tr_info(" ");
tr_info("mcuboot configuration: -----------------------------------");
tr_info("- Primary slot: start address 0x%x, size %ukiB", MCUBOOT_PRIMARY_SLOT_START_ADDR, MCUBOOT_SLOT_SIZE/1024);
tr_info(" - Header size: 0x%x", MCUBOOT_HEADER_SIZE);
tr_info(" - Max flash sectors per slot: %u", MCUBOOT_MAX_IMG_SECTORS);
tr_info("- Scratch area: start address 0x%x, size %ukiB", MCUBOOT_SCRATCH_START_ADDR, MCUBOOT_SCRATCH_SIZE/1024);
tr_info("- Secondary BD: size %" PRIu64 "kiB", secondary_bd->size()/1024);
tr_info(" - Program (block) size %" PRIu64 " bytes", secondary_bd->get_program_size());
tr_info(" - Erase (sector) size %" PRIu64 " bytes", secondary_bd->get_erase_size());
tr_info(" ");

// Erase secondary slot
// On the first boot, the secondary BlockDevice needs to be clean
// If the first boot is not normal, please run the erase step, then reboot
Expand Down Expand Up @@ -80,7 +91,12 @@ int main()
}

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

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

// Give user time to react, as programming can be pretty fast
ThisThread::sleep_for(250ms);

// Activate the image in the secondary BlockDevice
tr_info("> Image copied to secondary BlockDevice, press button to activate");

Expand Down
2 changes: 1 addition & 1 deletion mbed-os
Submodule mbed-os updated 49 files
+6 −1 TESTS/configs/greentea_full.json5
+4 −0 connectivity/drivers/emac/TARGET_STM/mbed_lib.json
+161 −3 connectivity/drivers/emac/TARGET_STM/stm32xx_emac.cpp
+11 −0 connectivity/drivers/emac/TARGET_STM/stm32xx_emac.h
+9 −2 connectivity/netsocket/tests/TESTS/netsocket/README.md
+0 −5 drivers/tests/TESTS/mbed_drivers/reset_reason/CMakeLists.txt
+0 −5 drivers/tests/TESTS/mbed_drivers/watchdog_reset/CMakeLists.txt
+1 −12 drivers/usb/tests/TESTS/host_tests/usb_device_hid.py
+5 −3 features/frameworks/utest/source/utest_harness.cpp
+0 −5 hal/tests/TESTS/mbed_hal/reset_reason/CMakeLists.txt
+0 −5 hal/tests/TESTS/mbed_hal/rtc_reset/CMakeLists.txt
+3 −0 platform/mbed_lib.json
+1 −1 platform/tests/TESTS/mbed_platform/crash_reporting/CMakeLists.txt
+0 −2 platform/tests/TESTS/mbed_platform/crash_reporting/main.cpp
+12 −4 rtos/tests/TESTS/mbed_rtos/heap_and_stack/main.cpp
+10 −10 targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_GCC_ARM/MK64FN1M0xxx12.ld
+5 −3 targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT105x/TARGET_EVK/PinNames.h
+2 −2 .../TARGET_MCUXpresso_MCUS/TARGET_MIMXRT105x/TARGET_EVK/TARGET_1050_EVK/xip/evkbimxrt1050_flexspi_nor_config.c
+5 −22 ...TARGET_MCUXpresso_MCUS/TARGET_MIMXRT105x/TARGET_EVK/TARGET_1060_EVK/xip/evkbmimxrt1060_flexspi_nor_config.c
+4 −4 targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT105x/TARGET_EVK/flash_api.c
+1 −1 targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT105x/TARGET_EVK/flash_defines.h
+1 −1 targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT105x/TARGET_EVK/fsl_flexspi_nor_boot.h
+0 −16 targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT105x/TARGET_EVK/mimxrt_memory_info.h
+0 −13 .../TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT105x/TARGET_TEENSY_4X/TARGET_TEENSY_40/mimxrt_memory_info.h
+0 −13 .../TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT105x/TARGET_TEENSY_4X/TARGET_TEENSY_41/mimxrt_memory_info.h
+120 −62 targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT105x/device/TOOLCHAIN_GCC_ARM/MIMXRT1052xxxxx.ld
+3 −0 targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT105x/mbed_overrides.c
+51 −1 targets/targets.json5
+4 −0 targets/upload_method_cfg/MIMXRT1050_EVK.cmake
+5 −3 targets/upload_method_cfg/MIMXRT1060_EVK.cmake
+34 −45 tools/cmake/mbed_generate_configuration.cmake
+4 −5 tools/cmake/mbed_set_linker_script.cmake
+4 −1 tools/cmake/upload_methods/UploadMethodPYOCD.cmake
+1 −1 tools/python/mbed_os_tools/test/host_tests_logger/ht_logger.py
+5 −1 tools/python/mbed_tools/build/_internal/cmake_file.py
+28 −5 tools/python/mbed_tools/build/_internal/config/assemble_build_config.py
+6 −0 tools/python/mbed_tools/build/_internal/config/config.py
+12 −9 tools/python/mbed_tools/build/_internal/templates/mbed_config.tmpl
+1 −1 tools/python/mbed_tools/build/config.py
+0 −140 tools/python/mbed_tools/cli/build.py
+7 −10 tools/python/mbed_tools/cli/configure.py
+0 −2 tools/python/mbed_tools/cli/main.py
+10 −2 tools/python/mbed_tools/cli/sterm.py
+3 −4 tools/python/mbed_tools/project/_internal/project_data.py
+8 −7 tools/python/mbed_tools/project/mbed_program.py
+0 −338 tools/python/python_tests/mbed_tools/cli/test_build.py
+7 −18 tools/python/python_tests/mbed_tools/cli/test_configure.py
+8 −8 tools/python/python_tests/mbed_tools/project/test_mbed_program.py
+2 −1 tools/python/python_tests/mbed_tools/regression/test_configure.py
69 changes: 63 additions & 6 deletions mbed_app.json5
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@
"macro_name": "DEMO_BUTTON_ACTIVE_LOW",
"required": false
},
"secondary-slot-in-flash": {
"help": "If enabled, store the secondary slot in the application flash immediately after the primary slot.",
"value": false
},
"secondary-slot-flash-start-addr": {
"help": "If secondary-slot-in-flash is enabled, this sets the start address of the secondary slot.",
"value": null
}
},

"macros": [
"MBEDTLS_CIPHER_MODE_CTR"
],

"target_overrides": {
"*": {
"mcuboot.bootloader-build": 0,
Expand Down Expand Up @@ -81,8 +85,61 @@
"mcuboot.scratch-address": "0xE0000",
"mcuboot.scratch-size": "0x20000",

"mcuboot.max-img-sectors": "0x180",
"mcuboot.max-img-sectors": "1536", // External SD card has smaller sector size, so divide slot size by read granularity
"mcuboot.read-granularity": 512 // External SD card used as block device, this is its read size.
},

"MIMXRT1060_EVK": {
"target.memory_bank_config": {
"EXT_FLASH": {
"start": 0x60021000, // mcuboot.primary-slot-address + mcuboot.header-size
"size": 0x2FF000 // mcuboot.slot-size - mcuboot.header-size
}
},

// Primary slot is 3MiB and begins right after the bootloader
"mcuboot.primary-slot-address": "0x60020000",
"mcuboot.slot-size": "0x300000",

// Use flash for secondary slot as well
"secondary-slot-in-flash": true,
"secondary-slot-flash-start-addr": "0x60320000",

// Store the scratch space at the end of flash
"mcuboot.scratch-address": "0x60620000",
"mcuboot.scratch-size": "0x20000",

"mcuboot.read-granularity": 1, // Flash is byte addressable

"mcuboot.max-img-sectors": 768, // Maximum flash sectors per slot. 3MiB/4kiB = 768.
"mcuboot.flash-block-size": 256,

"demo-button-active-low": true
},

"MCU_STM32H743xI": {
"target.memory_bank_config": {
"IROM1": {
"start": 0x08021000, // mcuboot.primary-slot-address + mcuboot.header-size
"size": 0xDF000 // mcuboot.slot-size - mcuboot.header-size
}
},

// Since STM32H743 boards have no external block device, keep everything in the MCU flash.
"app.secondary-slot-in-flash": true,
"app.secondary-slot-flash-start-addr": "0x08100000",

// Slot size can be as big as 896k, since we need to reserve the first flash sector for the bootloader
// and the last flash sector for scratch space
"mcuboot.primary-slot-address": "0x08020000",
"mcuboot.max-img-sectors": "7", // 7 flash sectors per slot
"mcuboot.slot-size": "0xE0000",
"mcuboot.flash-block-size": 32, // Flash program size is 32

// STM32H7 flash sector size is 128k, so we need to make the scratch region at least that big
"mcuboot.scratch-address": "0x081E0000",
"mcuboot.scratch-size": "0x20000"

}
}
},
}
14 changes: 9 additions & 5 deletions secondary_bd.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* default_bd.cpp
* default_bd.cpp
*
* Created on: Jul 30, 2020
* Author: gdbeckstein
Expand All @@ -15,9 +15,13 @@

mbed::BlockDevice* get_secondary_bd(void) {

// Use a section of FlashIAP immediately after the secondary slot
static FlashIAPBlockDevice flashBD(MCUBOOT_PRIMARY_SLOT_START_ADDR + MCUBOOT_SLOT_SIZE, MCUBOOT_SLOT_SIZE);
return &flashBD;
// Use FlashIAP for the secondary BD.
static FlashIAPBlockDevice flashBD(MBED_CONF_APP_SECONDARY_SLOT_FLASH_START_ADDR, MCUBOOT_SLOT_SIZE);

// Our UpdaterApp needs to be able to program the flash with single-byte granularity
static mbed::BufferedBlockDevice bufferedBD(&flashBD);

return &bufferedBD;
}

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

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

// mcuboot assumes that the read size of the secondary block device is the same as the read size
Expand Down
Loading