Skip to content

Commit 72902e6

Browse files
committed
finalize fixed readback current.uf2 size
1 parent 6adf981 commit 72902e6

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

src/usb/uf2/ghostfat.c

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ STATIC_ASSERT(ARRAY_SIZE(indexFile) < 512);
9999
#define NUM_FILES (ARRAY_SIZE(info))
100100
#define NUM_DIRENTRIES (NUM_FILES + 1) // Code adds volume label as first root directory entry
101101

102-
#define UF2_SIZE (uf2current_flash_sz * 2)
102+
#define UF2_SIZE ((USER_FLASH_END-USER_FLASH_START) * 2)
103103
#define UF2_SECTORS (UF2_SIZE / 512)
104104
#define UF2_FIRST_SECTOR (NUM_FILES + 1) // WARNING -- code presumes each non-UF2 file content fits in single sector
105105
#define UF2_LAST_SECTOR (UF2_FIRST_SECTOR + UF2_SECTORS - 1)
@@ -169,31 +169,10 @@ static inline bool in_uicr_space(uint32_t addr)
169169
//--------------------------------------------------------------------+
170170
//
171171
//--------------------------------------------------------------------+
172-
static uint32_t uf2current_flash_sz = 0;
173-
174-
175-
// get current.uf2 flash size in bytes, round up to 256 bytes
176-
static uint32_t current_flash_size(void)
177-
{
178-
uint32_t flash_sz = 0;
179-
180-
// return 1 block of 256 bytes
181-
if ( !bootloader_app_is_valid() )
182-
{
183-
flash_sz = 256;
184-
}else
185-
{
186-
// Use full application size for simplicity
187-
flash_sz = (USER_FLASH_END-USER_FLASH_START);
188-
}
189-
190-
return flash_sz;
191-
}
192172

193173
void uf2_init(void)
194174
{
195-
uf2current_flash_sz = current_flash_size();
196-
PRINT_INT(uf2current_flash_sz);
175+
// nothing to do
197176
}
198177

199178
/*------------------------------------------------------------------*/
@@ -289,7 +268,7 @@ void read_block(uint32_t block_no, uint8_t *data) {
289268
bl->magicStart1 = UF2_MAGIC_START1;
290269
bl->magicEnd = UF2_MAGIC_END;
291270
bl->blockNo = sectionIdx;
292-
bl->numBlocks = uf2current_flash_sz / 256;
271+
bl->numBlocks = (UF2_SIZE/2) / 256;
293272
bl->targetAddr = addr;
294273
bl->payloadSize = 256;
295274
bl->flags = UF2_FLAG_FAMILYID;

0 commit comments

Comments
 (0)