File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -123,35 +123,37 @@ static FAT_BootBlock const BootBlock = {
123
123
static uint32_t current_flash_size (void )
124
124
{
125
125
static uint32_t flash_sz = 0 ;
126
+ uint32_t result = flash_sz ; // presumes atomic 32-bit read/write and static result
126
127
127
128
// only need to compute once
128
- if ( flash_sz == 0 )
129
+ if ( result == 0 )
129
130
{
130
131
// return 1 block of 256 bytes
131
132
if ( !bootloader_app_is_valid (DFU_BANK_0_REGION_START ) )
132
133
{
133
- flash_sz = 256 ;
134
+ result = 256 ;
134
135
}else
135
136
{
136
137
bootloader_settings_t const * boot_setting ;
137
138
bootloader_util_settings_get (& boot_setting );
138
139
139
- flash_sz = boot_setting -> bank_0_size ;
140
+ result = boot_setting -> bank_0_size ;
140
141
141
142
// Copy size must be multiple of 256 bytes
142
143
// else we will got an issue copying current.uf2
143
- if (flash_sz & 0xff )
144
+ if (result & 0xff )
144
145
{
145
- flash_sz = (flash_sz & ~0xff ) + 256 ;
146
+ result = (result & ~0xff ) + 256 ;
146
147
}
147
148
148
149
// if bank0 size is not valid, happens when flashed with jlink
149
150
// use maximum application size
150
- if ( (flash_sz == 0 ) || (flash_sz == 0xFFFFFFFFUL ) )
151
+ if ( (result == 0 ) || (result == 0xFFFFFFFFUL ) )
151
152
{
152
- flash_sz = FLASH_SIZE ;
153
+ result = FLASH_SIZE ;
153
154
}
154
155
}
156
+ flash_sz = result ; // presumes atomic 32-bit read/write and static result
155
157
}
156
158
157
159
return flash_sz ;
You can’t perform that action at this time.
0 commit comments