Skip to content

Commit 791906c

Browse files
authored
Merge pull request #152 from henrygab/more_family_ids
Enable board-specific UF2 family IDs
2 parents cb04d53 + 2e5b45e commit 791906c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/usb/uf2/ghostfat.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ 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+
bl->familyID = CFG_UF2_BOARD_APP_ID;
367367
memcpy(bl->data, (void *)addr, bl->payloadSize);
368368
}
369369
}
@@ -390,7 +390,9 @@ int write_block (uint32_t block_no, uint8_t *data, WriteState *state)
390390

391391
switch ( bl->familyID )
392392
{
393-
case CFG_UF2_FAMILY_APP_ID:
393+
394+
case CFG_UF2_BOARD_APP_ID: // board-specific app ... may not be usable on other nrf52 boards
395+
case CFG_UF2_FAMILY_APP_ID: // legacy, or where app uses bootloader configuration to discover pins
394396
/* Upgrading Application
395397
*
396398
* SoftDevice is considered as part of application and can be (or not) included in uf2.

src/usb/uf2/uf2cfg.h

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

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

7+
// Board-specific ID for board-specific Application
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+
12+
713
// Family ID for updating Bootloader
814
#define CFG_UF2_FAMILY_BOOT_ID 0xd663823c
915

0 commit comments

Comments
 (0)