File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -223,11 +223,12 @@ static FAT_BootBlock const BootBlock = {
223223 .ReservedSectors = RESERVED_SECTORS,
224224 .FATCopies = 2 ,
225225 .RootDirectoryEntries = (ROOT_DIR_SECTORS * DIRENTRIES_PER_SECTOR),
226- .TotalSectors16 = NUM_FAT_BLOCKS - 2 ,
226+ .TotalSectors16 = 0 ,
227227 .MediaDescriptor = 0xF8 ,
228228 .SectorsPerFAT = SECTORS_PER_FAT,
229229 .SectorsPerTrack = 1 ,
230230 .Heads = 1 ,
231+ .TotalSectors32 = NUM_FAT_BLOCKS - 2 ,
231232 .PhysicalDriveNum = 0x80 , // to match MediaDescriptor of 0xF8
232233 .ExtendedBootSig = 0x29 ,
233234 .VolumeSerialNumber = 0x00000000 ,
@@ -284,6 +285,9 @@ static uint32_t current_flash_size(void)
284285 if (is_firmware_valid (fw_desc)) {
285286 // round up to 256 bytes
286287 result = (fw_desc->length + BOOTLOADER_SIZE + 255U ) & (~255U );
288+ // Sometime corrupted firmware return very large size, leave not enough space to flash a fix
289+ if (result >= UF2_MAX_FW_SIZE)
290+ result = UF2_MAX_FW_SIZE;
287291 } else {
288292 result = UF2_MAX_FW_SIZE;
289293 }
Original file line number Diff line number Diff line change 2323
2424#include <stdint.h>
2525
26- #define UF2_NUM_BLOCKS 32768 // at least 16MB
26+ #define UF2_NUM_BLOCKS 65536 // at least 32MB
2727#define UF2_INVALID_NUM_BLOCKS 0xFFFFFFFF
2828
2929typedef struct {
You can’t perform that action at this time.
0 commit comments