Skip to content

Commit dc90457

Browse files
committed
Expose UF2 file using board-specific familyID
Where the board has a defined USB VID/PID, allow that as a family ID when flashing a UF2 file, and also use the VID/PID for the familyID in the UF2 file that is exposed via ghostfat.
1 parent b3a2afa commit dc90457

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/usb/uf2/ghostfat.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,11 @@ void read_block(uint32_t block_no, uint8_t *data) {
364364
bl->payloadSize = UF2_FIRMWARE_BYTES_PER_SECTOR;
365365
bl->flags = UF2_FLAG_FAMILYID;
366366

367-
bool useBoardId = false; // BUGBUG -- how to detect which familyID to use?
368-
if (useBoardId) {
369-
bl->familyID = CFG_UF2_BOARD_APP_ID;
370-
} else {
371-
bl->familyID = CFG_UF2_FAMILY_APP_ID;
372-
}
367+
#if defined(CFG_UF2_BOARD_APP_ID) && CFG_UF2_BOARD_APP_ID
368+
bl->familyID = CFG_UF2_BOARD_APP_ID;
369+
#else
370+
bl->familyID = CFG_UF2_FAMILY_APP_ID;
371+
#endif
373372
memcpy(bl->data, (void *)addr, bl->payloadSize);
374373
}
375374
}
@@ -396,7 +395,11 @@ int write_block (uint32_t block_no, uint8_t *data, WriteState *state)
396395

397396
switch ( bl->familyID )
398397
{
398+
399+
#if defined(CFG_UF2_BOARD_APP_ID) && CFG_UF2_BOARD_APP_ID
399400
case CFG_UF2_BOARD_APP_ID: // board-specific app ... may not be usable on other nrf52 boards
401+
#endif
402+
400403
case CFG_UF2_FAMILY_APP_ID: // legacy, or where app uses bootloader configuration to discover pins
401404
/* Upgrading Application
402405
*

src/usb/uf2/uf2cfg.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
#define CFG_UF2_FAMILY_APP_ID 0xADA52840
66

77
// Family ID for board-specific Application
8-
#define CFG_UF2_BOARD_APP_ID ((USB_DESC_VID << 16) | USB_DESC_UF2_PID)
8+
#if defined(USB_DESC_VID) && defined(USB_DESC_UF2_PID) && USB_DESC_VID && USB_DESC_UF2_PID
9+
#define CFG_UF2_BOARD_APP_ID ((USB_DESC_VID << 16) | USB_DESC_UF2_PID)
10+
#endif
11+
912

1013
// Family ID for updating Bootloader
1114
#define CFG_UF2_FAMILY_BOOT_ID 0xd663823c

0 commit comments

Comments
 (0)