File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -376,7 +376,9 @@ void RAMFUNCTION hal_flash_dualbank_swap(void)
376376 stm32h5_reboot ();
377377}
378378
379- static uint8_t bootloader_copy_mem [BOOTLOADER_SIZE ];
379+
380+ #define BOOTLOADER_COPY_MEM_SIZE 0x1000
381+ static uint8_t bootloader_copy_mem [BOOTLOADER_COPY_MEM_SIZE ];
380382
381383static void fork_bootloader (void )
382384{
@@ -395,13 +397,17 @@ static void fork_bootloader(void)
395397 if (memcmp ((void * )data , (const char * )dst , BOOTLOADER_SIZE ) == 0 )
396398 return ;
397399
398- /* Read the wolfBoot image in RAM */
399- memcpy (bootloader_copy_mem , (void * )data , BOOTLOADER_SIZE );
400-
401- /* Mass-erase */
402400 hal_flash_unlock ();
401+ /* Mass-erase second block */
403402 hal_flash_erase (dst , BOOTLOADER_SIZE );
404- hal_flash_write (dst , bootloader_copy_mem , BOOTLOADER_SIZE );
403+ /* Read the wolfBoot image in RAM */
404+ for (i = 0 ; i < BOOTLOADER_SIZE ;
405+ i += BOOTLOADER_COPY_MEM_SIZE ) {
406+ memcpy (bootloader_copy_mem , (void * )(data + i ),
407+ BOOTLOADER_COPY_MEM_SIZE );
408+ hal_flash_write (dst + i , bootloader_copy_mem ,
409+ BOOTLOADER_COPY_MEM_SIZE );
410+ }
405411 hal_flash_lock ();
406412}
407413#endif
Original file line number Diff line number Diff line change 326326#define FLASHMEM_ADDRESS_SPACE (0x08000000)
327327#define FLASH_PAGE_SIZE (0x2000) /* 8KB */
328328#define FLASH_BANK2_BASE (0x08100000) /*!< Base address of Flash Bank2 */
329- #define BOOTLOADER_SIZE (0x8000 )
329+ #define BOOTLOADER_SIZE (WOLFBOOT_PARTITION_BOOT_ADDRESS - FLASHMEM_ADDRESS_SPACE )
330330#define FLASH_TOP (0x081FFFFF) /*!< FLASH end address (sector 127) */
331331
332332#define FLASH_KEY1 (0x45670123U)
You can’t perform that action at this time.
0 commit comments