5656
5757// Flash Configuration Structure
5858extern flexspi_nor_config_t const qspiflash_config ;
59+ static flexspi_nor_config_t flash_cfg ; // local copy since ROM API may modify it
5960
6061#if defined(MIMXRT1176_cm7_SERIES )
62+ #define USE_BLHOST
6163extern const flexspi_nor_config_t qspiflash_config_copy ;
6264extern const BOOT_DATA_T g_boot_data_copy ;
6365extern const ivt image_vector_table ;
64-
65- // SDP ivt0 image has ivt at address 0, no FCFB in RAM, cooked boot data use the copies in .text
66- const uint8_t * fcfb_data = (const uint8_t * )& qspiflash_config_copy ;
67- const uint8_t * boot_data = (const uint8_t * )& g_boot_data_copy ;
68-
69- #else
70- const uint8_t * fcfb_data = (const uint8_t * )& qspiflash_config ;
71- const uint8_t * boot_data = (const uint8_t * )& g_boot_data ;
72-
7366#endif
7467
75- static flexspi_nor_config_t flash_cfg ;
76-
7768static uint32_t _flash_page_addr = FLASH_CACHE_INVALID_ADDR ;
7869static uint8_t _flash_cache [SECTOR_SIZE ] __attribute__((aligned (4 )));
7970
@@ -85,16 +76,24 @@ static uint8_t _flash_cache[SECTOR_SIZE] __attribute__((aligned(4)));
8576static void write_tinyuf2_to_flash (void ) {
8677 TUF2_LOG1 ("Writing TinyUF2 image to flash.\r\n" );
8778
79+ #ifdef USE_BLHOST
80+ // BLHOST load-image with ivt at address 0, no FCFB in RAM, manual write it using copies
8881 // Write FCFB
89- board_flash_write (FLASH_FCFB_ADDR , fcfb_data , sizeof (flexspi_nor_config_t ));
82+ board_flash_write (FLASH_FCFB_ADDR , & qspiflash_config_copy , sizeof (flexspi_nor_config_t ));
9083
9184 // Write IVT (image vector table + boot data)
9285 board_flash_write (FLASH_IVT_ADDR , & image_vector_table , sizeof (ivt ));
93- board_flash_write (FLASH_IVT_ADDR + sizeof (ivt ), boot_data , sizeof (BOOT_DATA_T ));
86+ board_flash_write (FLASH_IVT_ADDR + sizeof (ivt ), & g_boot_data_copy , sizeof (BOOT_DATA_T ));
87+ // DCD is not used, skip writing it
9488
9589 // Write Interrupts + Text
9690 const uint8_t * image_data = (const uint8_t * )((uint32_t )_interrupts_origin );
9791 uint32_t flash_addr = FLASH_IVT_ADDR + ((uint32_t )_ivt_length );
92+ #else
93+ // SDPHost write from fcfb to end of bootloader
94+ const uint8_t * image_data = (const uint8_t * )& qspiflash_config ;
95+ uint32_t flash_addr = FLASH_FCFB_ADDR ;
96+ #endif
9897 const uint32_t flash_end = FLEXSPI_FLASH_BASE + BOARD_BOOT_LENGTH ;
9998
10099 while (flash_addr < flash_end ) {
0 commit comments