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