From f7a209325292e938c465dd5d9b17ae78f4d95ffe Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 3 Dec 2024 19:08:44 +0700 Subject: [PATCH] change flash boot size for h503 to 24KB, H52x/6x/7x to 32KB. Correct protect mask for h52x/6x/7x --- ports/stm32h5/README.md | 18 +- ports/stm32h5/board_flash.c | 242 ++++++------------ ports/stm32h5/boards.c | 133 +++++----- .../boards/stm32h503_nucleo/board.cmake | 1 + .../stm32h5/boards/stm32h503_nucleo/board.mk | 1 + .../boards/stm32h563_nucleo/board.cmake | 1 + .../stm32h5/boards/stm32h563_nucleo/board.mk | 1 + ports/stm32h5/family.cmake | 2 - ports/stm32h5/port.mk | 4 +- 9 files changed, 154 insertions(+), 249 deletions(-) diff --git a/ports/stm32h5/README.md b/ports/stm32h5/README.md index c0e645c3..f22b2e9c 100644 --- a/ports/stm32h5/README.md +++ b/ports/stm32h5/README.md @@ -1,7 +1,8 @@ # TinyUF2 for STM32H5 -TinyUF2 occupies 24KB. Therefore application should start at `0x08006000` - +TinyUF2 occupies around 16Kb + 1KB for CF2 in flash. Since H5 has uniform sector size of 8KB, ideally we would have bootloader size set to 24KB. However, due to the fact that only H503 can protect/secure individual sector, the rest of H5 family (H52x, H56x) can only secure flash in 4-sector (group) unit. Therefore application should start at +- H503: `0x08006000`, boot size is 24KB +- H52x, H56x, H57x: `0x08008000`, boot size is 32KB To create a UF2 image from a .bin file, either use family option `STM32H5` or its magic number as follows: From hex @@ -11,9 +12,16 @@ uf2conv.py -c -f 0x4e8f1c5d firmware.hex uf2conv.py -c -f STM32H5 firmware.hex ``` -From bin +From bin for H503 + +``` +uf2conv.py -c -b 0x08006000 -f STM32H5 firmware.bin +uf2conv.py -c -b 0x08006000 -f 0x4e8f1c5d firmware.bin +``` + +From bin for H52x, H56x, H57x ``` -uf2conv.py -c -b 0x08010000 -f STM32H5 firmware.bin -uf2conv.py -c -b 0x08010000 -f 0x4e8f1c5d firmware.bin +uf2conv.py -c -b 0x08008000 -f STM32H5 firmware.bin +uf2conv.py -c -b 0x08008000 -f 0x4e8f1c5d firmware.bin ``` diff --git a/ports/stm32h5/board_flash.c b/ports/stm32h5/board_flash.c index 6b385eb1..8a660366 100644 --- a/ports/stm32h5/board_flash.c +++ b/ports/stm32h5/board_flash.c @@ -34,185 +34,98 @@ #define FLASH_BASE_ADDR 0x08000000UL +// H503 is 1 bit per sector, the rest of the family H523/33/62/63 is 1 bit per 4 sectors // TinyUF2 resides in the first 8 flash sectors on STM32H5s, therefore these are write protected -#define BOOTLOADER_SECTOR_MASK 0x3UL - -/* flash parameters that we should not really know */ -static const uint32_t sector_size[] = -{ - // First 8 sectors are for bootloader (64KB) - 8 * 1024, - 8 * 1024, - 8 * 1024, - 8 * 1024, - 8 * 1024, - 8 * 1024, - 8 * 1024, - 8 * 1024, - // Application (BOARD_FLASH_APP_START) 64kB - 8 * 1024, - 8 * 1024, - 8 * 1024, - 8 * 1024, - 8 * 1024, - 8 * 1024, - 8 * 1024, - 8 * 1024, -}; +#ifdef STM32H503xx +#define BOARD_FLASH_PROTECT_MASK 0x7u // protect 3 sector +#else +#define BOARD_FLASH_PROTECT_MASK 0x1u // protect 1 group of sector 0-3 +#endif -enum -{ - SECTOR_COUNT = sizeof(sector_size)/sizeof(sector_size[0]) +// H5 has uniform sector size of 8KB, max is 2MB +enum { + SECTOR_COUNT = (2*1024*1024) / FLASH_SECTOR_SIZE }; - -static uint8_t erased_sectors[SECTOR_COUNT] = { 0 }; +static uint8_t erased_sectors[SECTOR_COUNT]; //--------------------------------------------------------------------+ // Internal Helper //--------------------------------------------------------------------+ - -static inline uint32_t flash_sector_size(uint32_t sector) -{ - return sector_size[sector]; -} - -static bool is_blank(uint32_t addr, uint32_t size) -{ - for ( uint32_t i = 0; i < size; i += sizeof(uint32_t) ) - { - if ( *(uint32_t*) (addr + i) != 0xffffffff ) - { +static bool is_blank(uint32_t addr, uint32_t size) { + for (uint32_t i = 0; i < size; i += sizeof(uint32_t)) { + if (*(uint32_t*)(addr + i) != 0xffffffff) { return false; } } return true; } -static uint32_t flash_get_bank(uint32_t addr) -{ - uint32_t bank = 0; - - if (READ_BIT(FLASH->OPTSR_CUR, FLASH_OPTSR_SWAP_BANK) == 0) - { - /* No Bank swap */ - if (addr < (FLASH_BASE + FLASH_BANK_SIZE)) - { - bank = FLASH_BANK_1; - } - else - { - bank = FLASH_BANK_2; - } - } - else - { - /* Bank swap */ - if (addr < (FLASH_BASE + FLASH_BANK_SIZE)) - { - bank = FLASH_BANK_2; - } - else - { - bank = FLASH_BANK_1; - } - } - - return bank; -} +static bool flash_erase(uint32_t addr) { + TUF2_ASSERT(addr < FLASH_BASE_ADDR + BOARD_FLASH_SIZE); -static uint32_t flash_get_sector(uint32_t addr) -{ - uint32_t sector = 0; + const uint32_t sector_addr = addr & ~(FLASH_SECTOR_SIZE - 1); + const uint32_t sector_id = (sector_addr - FLASH_BASE_ADDR) / FLASH_SECTOR_SIZE; - if((addr >= FLASH_BASE) && (addr < FLASH_BASE + FLASH_BANK_SIZE)) - { - sector = (addr & ~FLASH_BASE) / FLASH_SECTOR_SIZE; - } - else if ((addr >= FLASH_BASE + FLASH_BANK_SIZE) && (addr < FLASH_BASE + FLASH_SIZE)) - { - sector = ((addr & ~FLASH_BASE) - FLASH_BANK_SIZE) / FLASH_SECTOR_SIZE; - } - else - { - sector = 0xFFFFFFFF; /* Address out of range */ - } + const uint8_t erased = erased_sectors[sector_id]; + erased_sectors[sector_id] = 1; // mark as erased - return sector; -} +#ifndef TINYUF2_SELF_UPDATE + // skip erasing bootloader + TUF2_ASSERT(sector_addr >= BOARD_FLASH_APP_START); +#endif -static bool flash_erase(uint32_t addr) -{ - // starting address from 0x08000000 - uint32_t sector_addr = FLASH_BASE_ADDR; - bool erased = false; - - uint32_t sector = 0; - uint32_t size = 0; - uint32_t bank; - uint32_t sector_to_erase; - uint32_t sector_error = 0; - FLASH_EraseInitTypeDef erase_struct; - - for ( uint32_t i = 0; i < SECTOR_COUNT; i++ ) - { - TUF2_ASSERT(sector_addr < FLASH_BASE_ADDR + BOARD_FLASH_SIZE); + if ( !erased && !is_blank(sector_addr, FLASH_SECTOR_SIZE) ) { + uint32_t bank; + uint32_t sector_to_erase; + const uint32_t sector_per_bank = FLASH_BANK_SIZE / FLASH_SECTOR_SIZE; - size = flash_sector_size(i); - if ( sector_addr + size > addr ) - { - sector = i; - erased = erased_sectors[i]; - erased_sectors[i] = 1; // don't erase anymore - we will continue writing here! - break; + if (sector_id < sector_per_bank) { + sector_to_erase = sector_id; + bank = FLASH_BANK_1; + } else { + sector_to_erase = sector_id - sector_per_bank; + bank = FLASH_BANK_2; } - sector_addr += size; - } -#ifndef TINYUF2_SELF_UPDATE - // skip erasing sector0 if not self-update - TUF2_ASSERT(sector); -#endif - - if ( !erased && !is_blank(sector_addr, size) ) - { - bank = flash_get_bank(sector_addr); - sector_to_erase = flash_get_sector(sector_addr); - TUF2_LOG1("Erase: %08lX size = %lu KB, bank = %lu ... ", sector_addr, size / 1024, bank); + // bank swap + if (READ_BIT(FLASH->OPTSR_CUR, FLASH_OPTSR_SWAP_BANK)) { + bank = FLASH_BANK_BOTH - bank; + } - erase_struct.TypeErase = FLASH_TYPEERASE_SECTORS; - erase_struct.Banks = bank; - erase_struct.Sector = sector_to_erase; - erase_struct.NbSectors = 1; + FLASH_EraseInitTypeDef erase_struct= { + .TypeErase = FLASH_TYPEERASE_SECTORS, + .Banks = bank, + .Sector = sector_to_erase, + .NbSectors = 1 + }; // FLASH_Erase_Sector(sector, bank); // FLASH_WaitForLastOperation(HAL_MAX_DELAY); - - HAL_FLASHEx_Erase(&erase_struct, §or_error); + uint32_t sector_error; + TUF2_LOG1("Erase: %08lX size = %lu KB, bank = %lu ... ", sector_addr, FLASH_SECTOR_SIZE / 1024, bank); + TUF2_ASSERT(HAL_OK ==HAL_FLASHEx_Erase(&erase_struct, §or_error)); + (void) sector_error; TUF2_LOG1("OK\r\n"); - TUF2_ASSERT( is_blank(sector_addr, size) ); + TUF2_ASSERT( is_blank(sector_addr, FLASH_SECTOR_SIZE) ); } return true; } -static void flash_write(uint32_t dst, const uint8_t *src, int len) -{ +static void flash_write(uint32_t dst, const uint8_t* src, int len) { flash_erase(dst); TUF2_LOG1("Write flash at address %08lX\r\n", dst); - for ( int i = 0; i < len; i += 16 ) - { - if ( HAL_FLASH_Program(FLASH_TYPEPROGRAM_QUADWORD, dst + i, (uint32_t) src + i) != HAL_OK ) - { + for (int i = 0; i < len; i += 16) { + if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_QUADWORD, dst + i, (uint32_t)src + i) != HAL_OK) { TUF2_LOG1("Failed to write flash at address %08lX\r\n", dst + i); break; } } // verify contents - if ( memcmp((void*) dst, src, len) != 0 ) - { + if (memcmp((void*)dst, src, len) != 0) { TUF2_LOG1("Failed to write\r\n"); } } @@ -220,43 +133,35 @@ static void flash_write(uint32_t dst, const uint8_t *src, int len) //--------------------------------------------------------------------+ // Board API //--------------------------------------------------------------------+ -void board_flash_init(void) -{ - HAL_FLASH_Unlock(); +void board_flash_init(void) { + memset(erased_sectors, 0, sizeof(erased_sectors)); } -uint32_t board_flash_size(void) -{ +uint32_t board_flash_size(void) { return BOARD_FLASH_SIZE; } -void board_flash_read(uint32_t addr, void* buffer, uint32_t len) -{ - memcpy(buffer, (void*) addr, len); +void board_flash_read(uint32_t addr, void* buffer, uint32_t len) { + memcpy(buffer, (void*)addr, len); } -void board_flash_flush(void) -{ +void board_flash_flush(void) { } -// TODO not working quite yet -bool board_flash_write(uint32_t addr, void const* data, uint32_t len) -{ - // TODO skip matching contents +bool board_flash_write(uint32_t addr, void const* data, uint32_t len) { + // TODO skip matching contents need to compare a whole sector HAL_FLASH_Unlock(); flash_write(addr, data, len); HAL_FLASH_Lock(); - return true; } -void board_flash_erase_app(void) -{ - // TODO implement later +void board_flash_erase_app(void) { + // erase 1st sector of app region is enough to invalid the app + flash_erase(BOARD_FLASH_APP_START); } -bool board_flash_protect_bootloader(bool protect) -{ +bool board_flash_protect_bootloader(bool protect) { bool ret = true; HAL_FLASH_OB_Unlock(); @@ -265,24 +170,21 @@ bool board_flash_protect_bootloader(bool protect) HAL_FLASHEx_OBGetConfig(&ob_current); // Flash sectors are protected if the bit is cleared - bool const already_protected = (ob_current.WRPSector & BOOTLOADER_SECTOR_MASK) == 0; + bool const already_protected = (ob_current.WRPSector & BOARD_FLASH_PROTECT_MASK) == 0; TUF2_LOG1("Protection: current = %u, request = %u\r\n", already_protected, protect); // request and current state mismatched --> require ob program - if (protect != already_protected) - { - FLASH_OBProgramInitTypeDef ob_update = {0}; + if (protect != already_protected) { + FLASH_OBProgramInitTypeDef ob_update = { 0 }; ob_update.OptionType = OPTIONBYTE_WRP; - ob_update.Banks = FLASH_BANK_1; - ob_update.WRPSector = BOOTLOADER_SECTOR_MASK; - ob_update.WRPState = protect ? OB_WRPSTATE_ENABLE : OB_WRPSTATE_DISABLE; + ob_update.Banks = FLASH_BANK_1; + ob_update.WRPSector = BOARD_FLASH_PROTECT_MASK; + ob_update.WRPState = protect ? OB_WRPSTATE_ENABLE : OB_WRPSTATE_DISABLE; - if (HAL_FLASHEx_OBProgram(&ob_update) == HAL_OK) - { + if (HAL_FLASHEx_OBProgram(&ob_update) == HAL_OK) { HAL_FLASH_OB_Launch(); - }else - { + } else { ret = false; } } diff --git a/ports/stm32h5/boards.c b/ports/stm32h5/boards.c index b4509dfc..1f9bc0ea 100644 --- a/ports/stm32h5/boards.c +++ b/ports/stm32h5/boards.c @@ -36,20 +36,37 @@ #define STM32_UUID ((volatile uint32_t *) UID_BASE) -//--------------------------------------------------------------------+ -// Forward USB interrupt events to TinyUSB IRQ Handler -//--------------------------------------------------------------------+ -void USB_DRD_FS_IRQHandler(void) { - tud_int_handler(0); -} //--------------------------------------------------------------------+ // MACRO TYPEDEF CONSTANT ENUM //--------------------------------------------------------------------+ -UART_HandleTypeDef UartHandle; +#if defined(UART_DEV) && CFG_TUSB_DEBUG + #define USE_UART 1 +#else + #define USE_UART 0 +#endif + +#if USE_UART +UART_HandleTypeDef UartHandle = { + .Instance = UART_DEV, + .Init.BaudRate = BOARD_UART_BAUDRATE, + .Init.WordLength = UART_WORDLENGTH_8B, + .Init.StopBits = UART_STOPBITS_1, + .Init.Parity = UART_PARITY_NONE, + .Init.HwFlowCtl = UART_HWCONTROL_NONE, + .Init.Mode = UART_MODE_TX_RX, + .Init.OverSampling = UART_OVERSAMPLING_16, + .AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT +}; +#endif void board_init(void) { +#ifdef BUILD_APPLICATION + // system_stm32h5xx.c: SystemInit() will reset vector table, set it here if we are building application + SCB->VTOR = (uint32_t) BOARD_FLASH_APP_START; +#endif + HAL_Init(); // required for HAL_RCC_Osc TODO check with freeRTOS SystemClock_Config(); // implemented in board.h SystemCoreClockUpdate(); @@ -64,24 +81,13 @@ void board_init(void) #ifdef __HAL_RCC_GPIOE_CLK_ENABLE __HAL_RCC_GPIOE_CLK_ENABLE(); #endif + #ifdef __HAL_RCC_GPIOG_CLK_ENABLE - __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); #endif - #ifdef __HAL_RCC_GPIOI_CLK_ENABLE - __HAL_RCC_GPIOE_CLK_ENABLE(); - #endif - - UART_CLOCK_ENABLE(); - - #if CFG_TUSB_OS == OPT_OS_NONE - // 1ms tick timer - SysTick_Config(SystemCoreClock / 1000); - #elif CFG_TUSB_OS == OPT_OS_FREERTOS - // Explicitly disable systick to prevent its ISR runs before scheduler start - SysTick->CTRL &= ~1U; - // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) - NVIC_SetPriority(USB_DRD_FS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY); + #ifdef __HAL_RCC_GPIOI_CLK_ENABLE + __HAL_RCC_GPIOI_CLK_ENABLE(); #endif GPIO_InitTypeDef GPIO_InitStruct; @@ -102,7 +108,8 @@ void board_init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct); - #ifdef UART_DEV + #if USE_UART + UART_CLOCK_ENABLE(); // UART GPIO_InitStruct.Pin = UART_TX_PIN | UART_RX_PIN; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -110,36 +117,8 @@ void board_init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Alternate = UART_GPIO_AF; HAL_GPIO_Init(UART_GPIO_PORT, &GPIO_InitStruct); - - UartHandle = (UART_HandleTypeDef) { - .Instance = UART_DEV, - .Init.BaudRate = BOARD_UART_BAUDRATE, - .Init.WordLength = UART_WORDLENGTH_8B, - .Init.StopBits = UART_STOPBITS_1, - .Init.Parity = UART_PARITY_NONE, - .Init.HwFlowCtl = UART_HWCONTROL_NONE, - .Init.Mode = UART_MODE_TX_RX, - .Init.OverSampling = UART_OVERSAMPLING_16, - .AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT - }; HAL_UART_Init(&UartHandle); #endif - - // USB Pins TODO double check USB clock and pin setup - // Configure USB DM and DP pins. This is optional, and maintained only for user guidance. - GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12); - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* Peripheral clock enable */ - __HAL_RCC_USB_CLK_ENABLE(); - - /* Enable VDDUSB */ - #if defined (PWR_USBSCR_USB33DEN) - HAL_PWREx_EnableVddUSB(); - #endif } void board_dfu_init(void) @@ -192,12 +171,7 @@ bool board_app_valid(void) return true; } -void board_app_jump(void) -{ - volatile uint32_t const * app_vector = (volatile uint32_t const*) BOARD_FLASH_APP_START; - uint32_t sp = app_vector[0]; - uint32_t app_entry = app_vector[1]; - +void board_teardown(void) { #ifdef BUTTON_PIN HAL_GPIO_DeInit(BUTTON_PORT, BUTTON_PIN); #endif @@ -210,30 +184,54 @@ void board_app_jump(void) HAL_GPIO_DeInit(NEOPIXEL_PORT, NEOPIXEL_PIN); #endif -#if defined(UART_DEV) && CFG_TUSB_DEBUG +#if USE_UART HAL_UART_DeInit(&UartHandle); HAL_GPIO_DeInit(UART_GPIO_PORT, UART_TX_PIN | UART_RX_PIN); UART_CLOCK_DISABLE(); #endif +#if defined (PWR_USBSCR_USB33DEN) + HAL_PWREx_DisableVddUSB(); +#endif + __HAL_RCC_USB_CLK_DISABLE(); + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11 | GPIO_PIN_12); // USB + __HAL_RCC_GPIOA_CLK_DISABLE(); __HAL_RCC_GPIOB_CLK_DISABLE(); __HAL_RCC_GPIOC_CLK_DISABLE(); -#ifdef __HAL_RCC_GPIOD_CLK_DISABLE __HAL_RCC_GPIOD_CLK_DISABLE(); + __HAL_RCC_GPIOH_CLK_DISABLE(); + +#ifdef __HAL_RCC_GPIOE_CLK_DISABLE + __HAL_RCC_GPIOE_CLK_DISABLE(); +#endif + +#ifdef __HAL_RCC_GPIOG_CLK_DISABLE + __HAL_RCC_GPIOG_CLK_DISABLE(); +#endif + +#ifdef __HAL_RCC_GPIOI_CLK_DISABLE + __HAL_RCC_GPIOI_CLK_DISABLE(); #endif HAL_RCC_DeInit(); + HAL_DeInit(); SysTick->CTRL = 0; SysTick->LOAD = 0; SysTick->VAL = 0; +} + +void board_app_jump(void) +{ + volatile uint32_t const * app_vector = (volatile uint32_t const*) BOARD_FLASH_APP_START; + uint32_t sp = app_vector[0]; + uint32_t app_entry = app_vector[1]; // Disable all Interrupts - NVIC->ICER[0] = 0xFFFFFFFF; - NVIC->ICER[1] = 0xFFFFFFFF; - NVIC->ICER[2] = 0xFFFFFFFF; - NVIC->ICER[3] = 0xFFFFFFFF; + for (uint8_t i=0; iICER)/sizeof(NVIC->ICER[0]); i++) { + NVIC->ICER[i] = 0xFFFFFFFFu; + } /* switch exception handlers to the application */ SCB->VTOR = (uint32_t) BOARD_FLASH_APP_START; @@ -354,27 +352,24 @@ void board_timer_stop(void) SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; } -void SysTick_Handler(void) -{ +void SysTick_Handler(void) { board_timer_handler(); } int board_uart_write(void const * buf, int len) { -#if defined(UART_DEV) && CFG_TUSB_DEBUG +#if USE_UART HAL_UART_Transmit(&UartHandle, (uint8_t*) buf, len, 0xffff); return len; #else (void) buf; (void) len; - (void) UartHandle; return 0; #endif } #ifndef BUILD_NO_TINYUSB // Forward USB interrupt events to TinyUSB IRQ Handler -void OTG_FS_IRQHandler(void) -{ +void USB_DRD_FS_IRQHandler(void) { tud_int_handler(0); } #endif diff --git a/ports/stm32h5/boards/stm32h503_nucleo/board.cmake b/ports/stm32h5/boards/stm32h503_nucleo/board.cmake index 151124fa..d5305ef4 100644 --- a/ports/stm32h5/boards/stm32h503_nucleo/board.cmake +++ b/ports/stm32h5/boards/stm32h503_nucleo/board.cmake @@ -1,3 +1,4 @@ +set(LD_FLASH_BOOT_SIZE 24K) set(LD_RAM_SIZE 32K) set(JLINK_DEVICE stm32h503rb) diff --git a/ports/stm32h5/boards/stm32h503_nucleo/board.mk b/ports/stm32h5/boards/stm32h503_nucleo/board.mk index 58721eda..6f846819 100644 --- a/ports/stm32h5/boards/stm32h503_nucleo/board.mk +++ b/ports/stm32h5/boards/stm32h503_nucleo/board.mk @@ -1,3 +1,4 @@ +LD_FLASH_BOOT_SIZE = 24K LD_RAM_SIZE = 32K CFLAGS += \ -DSTM32H503xx \ diff --git a/ports/stm32h5/boards/stm32h563_nucleo/board.cmake b/ports/stm32h5/boards/stm32h563_nucleo/board.cmake index 9fdff839..d2a54e29 100644 --- a/ports/stm32h5/boards/stm32h563_nucleo/board.cmake +++ b/ports/stm32h5/boards/stm32h563_nucleo/board.cmake @@ -1,3 +1,4 @@ +set(LD_FLASH_BOOT_SIZE 32K) set(LD_RAM_SIZE 640K) set(JLINK_DEVICE stm32h563zi) diff --git a/ports/stm32h5/boards/stm32h563_nucleo/board.mk b/ports/stm32h5/boards/stm32h563_nucleo/board.mk index e621fe7e..2fc28db1 100644 --- a/ports/stm32h5/boards/stm32h563_nucleo/board.mk +++ b/ports/stm32h5/boards/stm32h563_nucleo/board.mk @@ -1,3 +1,4 @@ +LD_FLASH_BOOT_SIZE = 32K LD_RAM_SIZE = 640K CFLAGS += \ -DSTM32H563xx \ diff --git a/ports/stm32h5/family.cmake b/ports/stm32h5/family.cmake index 40606d33..fce6d3f1 100644 --- a/ports/stm32h5/family.cmake +++ b/ports/stm32h5/family.cmake @@ -20,8 +20,6 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/cmake/toolchain/arm_${TOOLCHAIN}.cmake) # increase flash size if debug build if (CMAKE_BUILD_TYPE STREQUAL "Debug") set(LD_FLASH_BOOT_SIZE 64K) -else () - set(LD_FLASH_BOOT_SIZE 24K) endif () #------------------------------------ diff --git a/ports/stm32h5/port.mk b/ports/stm32h5/port.mk index 47e90e38..b233e34d 100644 --- a/ports/stm32h5/port.mk +++ b/ports/stm32h5/port.mk @@ -31,9 +31,7 @@ else endif ifeq (DEBUG,1) -LD_FLASH_BOOT_SIZE = 64K -else -LD_FLASH_BOOT_SIZE = 24K +LD_FLASH_BOOT_SIZE := 64K endif LDFLAGS += \