improve uf2 get flash size
This commit is contained in:
parent
cef0d2a962
commit
c989d9c4ba
@ -126,13 +126,25 @@ bool hadWrite = false;
|
|||||||
|
|
||||||
static uint32_t get_flash_size(void)
|
static uint32_t get_flash_size(void)
|
||||||
{
|
{
|
||||||
// return 1 block of 256 bytes
|
static uint32_t flash_sz = 0;
|
||||||
if ( !bootloader_app_is_valid(DFU_BANK_0_REGION_START) ) return 256;
|
|
||||||
|
|
||||||
|
// only need to compute once
|
||||||
|
if ( flash_sz == 0 )
|
||||||
|
{
|
||||||
|
// return 1 block of 256 bytes
|
||||||
|
if ( !bootloader_app_is_valid(DFU_BANK_0_REGION_START) )
|
||||||
|
{
|
||||||
|
flash_sz = 256;
|
||||||
|
}else
|
||||||
|
{
|
||||||
const bootloader_settings_t * boot_setting;
|
const bootloader_settings_t * boot_setting;
|
||||||
bootloader_util_settings_get(&boot_setting);
|
bootloader_util_settings_get(&boot_setting);
|
||||||
|
|
||||||
return boot_setting->bank_0_size;
|
flash_sz = boot_setting->bank_0_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return flash_sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
Loading…
Reference in New Issue
Block a user