disable compare and write tinyuf2 to flash since it is not really neccessary

This commit is contained in:
hathach 2023-02-07 20:37:51 +07:00
parent 146d7edba0
commit cc82d65d41

View file

@ -57,10 +57,13 @@ static flexspi_nor_config_t* flash_cfg = (flexspi_nor_config_t*) &qspiflash_conf
static uint32_t _flash_page_addr = NO_CACHE;
static uint8_t _flash_cache[SECTOR_SIZE] __attribute__((aligned(4)));
// compare and write tinyuf2 to flash every time it is running
#define COMPARE_AND_WRITE_TINYUF2 0
// Check if TinyUF2 running in SRAM matches the on flash contents
static bool compare_tinyuf2_ram_vs_flash(void)
{
#if COMPARE_AND_WRITE_TINYUF2
uint8_t const* image_data = (uint8_t const *) &qspiflash_config;
uint32_t flash_addr = FCFB_START_ADDRESS;
@ -68,6 +71,9 @@ static bool compare_tinyuf2_ram_vs_flash(void)
uint32_t const end_addr = FLEXSPI_FLASH_BASE + FCFB_LENGTH + BOARD_BOOT_LENGTH;
return 0 == memcmp((void const*) flash_addr, image_data, end_addr-flash_addr);
#else
return true;
#endif
}
// Write TinyUF2 from SRAM to Flash
@ -97,7 +103,7 @@ void board_flash_init(void)
// TinyUF2 will copy its image to flash if one of conditions meets:
// - Boot Mode is '01' i.e Serial Download Mode (BootRom)
// - Flash FCFB is invalid e.g blank flash
// - Flash contents does not match running tinyuf2 in SRAM
// - Flash contents does not match running tinyuf2 in SRAM (depending on COMPARE_AND_WRITE_TINYUF2)
uint32_t const boot_mode = (SRC->SBMR2 & SRC_SBMR2_BMOD_MASK) >> SRC_SBMR2_BMOD_SHIFT;
bool const fcfb_valid = (*(uint32_t*) FCFB_START_ADDRESS == FLEXSPI_CFG_BLK_TAG);
bool const matched_flash = compare_tinyuf2_ram_vs_flash();