Skip to content

Commit b3a2afa

Browse files
committed
Begin UF2 board-specific family ID
Per @hathach's comments, uses the USB vendorID and productID.
1 parent 0b3c515 commit b3a2afa

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/usb/uf2/ghostfat.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,13 @@ void read_block(uint32_t block_no, uint8_t *data) {
363363
bl->targetAddr = addr;
364364
bl->payloadSize = UF2_FIRMWARE_BYTES_PER_SECTOR;
365365
bl->flags = UF2_FLAG_FAMILYID;
366-
bl->familyID = CFG_UF2_FAMILY_APP_ID;
366+
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+
}
367373
memcpy(bl->data, (void *)addr, bl->payloadSize);
368374
}
369375
}
@@ -390,7 +396,8 @@ int write_block (uint32_t block_no, uint8_t *data, WriteState *state)
390396

391397
switch ( bl->familyID )
392398
{
393-
case CFG_UF2_FAMILY_APP_ID:
399+
case CFG_UF2_BOARD_APP_ID: // board-specific app ... may not be usable on other nrf52 boards
400+
case CFG_UF2_FAMILY_APP_ID: // legacy, or where app uses bootloader configuration to discover pins
394401
/* Upgrading Application
395402
*
396403
* SoftDevice is considered as part of application and can be (or not) included in uf2.

src/usb/uf2/uf2cfg.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#include "boards.h"
22
#include "dfu_types.h"
33

4-
// Family ID for updating Application
4+
// Legacy Family ID for updating Application
55
#define CFG_UF2_FAMILY_APP_ID 0xADA52840
66

7+
// Family ID for board-specific Application
8+
#define CFG_UF2_BOARD_APP_ID ((USB_DESC_VID << 16) | USB_DESC_UF2_PID)
9+
710
// Family ID for updating Bootloader
811
#define CFG_UF2_FAMILY_BOOT_ID 0xd663823c
912

0 commit comments

Comments
 (0)