Skip to content

Commit fa3faff

Browse files
authored
chore: drop the 64-bit division and keep INFO_UF2.TXT text in flash only (#74)
* fix(dfu): compute the startup timeout ticks in 32 bits APP_TIMER_TICKS is 64-bit and pulls __udivmoddi4 into the image for one call site. The 32-bit form gives the same tick count for any timeout under 131 s. * chore: keep INFO_UF2.TXT text in flash only and build the file in bss
1 parent 22f4736 commit fa3faff

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎lib/sdk11/components/libraries/bootloader_dfu/bootloader.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms, bool cancel_timeout
345345
dfu_startup_packet_received = false;
346346

347347
app_timer_create(&_dfu_startup_timer, APP_TIMER_MODE_SINGLE_SHOT, dfu_startup_timer_handler);
348-
app_timer_start(_dfu_startup_timer, APP_TIMER_TICKS(timeout_ms), NULL);
348+
// APP_TIMER_TICKS is 64-bit and pulls __udivmoddi4 into the image; this is the same rounding for timeout_ms < 131 s.
349+
app_timer_start(_dfu_startup_timer, ((timeout_ms * 32768u + 500u) / 1000u), NULL);
349350
}
350351

351352
err_code = dfu_transport_serial_update_start();

‎src/usb/uf2/ghostfat.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ STATIC_ASSERT(FAT_ENTRIES_PER_SECTOR == 256); // FAT
132132
"Date: " __DATE__ "\r\n" \
133133
"Factory-Erase: UF2 family 0x4D455348\r\n"
134134

135-
char infoUf2File[128*3] = INFO_UF2_TEXT;
135+
static const char infoUf2Text[] = INFO_UF2_TEXT;
136+
char infoUf2File[128*3];
136137
// uf2_init() appends "SoftDevice: S140 7.3.0\r\n" at runtime; 40 covers the
137138
// widest values the id/version fields can print
138139
STATIC_ASSERT(sizeof(INFO_UF2_TEXT) + 40 <= sizeof(infoUf2File));
@@ -309,6 +310,7 @@ static inline bool in_uicr_space(uint32_t addr)
309310

310311
void uf2_init(void)
311312
{
313+
strcpy(infoUf2File, infoUf2Text);
312314
strcat(infoUf2File, "SoftDevice: ");
313315

314316
if ( is_sd_existed() )

0 commit comments

Comments
 (0)