Begin UF2 board-specific family ID

Per @hathach's comments, uses the USB
vendorID and productID.
This commit is contained in:
Henry Gabryjelski
2020-07-25 17:18:45 -07:00
parent 0b3c515d9e
commit b3a2afa5c5
2 changed files with 13 additions and 3 deletions
+9 -2
View File
@@ -363,7 +363,13 @@ void read_block(uint32_t block_no, uint8_t *data) {
bl->targetAddr = addr;
bl->payloadSize = UF2_FIRMWARE_BYTES_PER_SECTOR;
bl->flags = UF2_FLAG_FAMILYID;
bl->familyID = CFG_UF2_FAMILY_APP_ID;
bool useBoardId = false; // BUGBUG -- how to detect which familyID to use?
if (useBoardId) {
bl->familyID = CFG_UF2_BOARD_APP_ID;
} else {
bl->familyID = CFG_UF2_FAMILY_APP_ID;
}
memcpy(bl->data, (void *)addr, bl->payloadSize);
}
}
@@ -390,7 +396,8 @@ int write_block (uint32_t block_no, uint8_t *data, WriteState *state)
switch ( bl->familyID )
{
case CFG_UF2_FAMILY_APP_ID:
case CFG_UF2_BOARD_APP_ID: // board-specific app ... may not be usable on other nrf52 boards
case CFG_UF2_FAMILY_APP_ID: // legacy, or where app uses bootloader configuration to discover pins
/* Upgrading Application
*
* SoftDevice is considered as part of application and can be (or not) included in uf2.
+4 -1
View File
@@ -1,9 +1,12 @@
#include "boards.h"
#include "dfu_types.h"
// Family ID for updating Application
// Legacy Family ID for updating Application
#define CFG_UF2_FAMILY_APP_ID 0xADA52840
// Family ID for board-specific Application
#define CFG_UF2_BOARD_APP_ID ((USB_DESC_VID << 16) | USB_DESC_UF2_PID)
// Family ID for updating Bootloader
#define CFG_UF2_FAMILY_BOOT_ID 0xd663823c