implemennt uf2 family option #10

This commit is contained in:
hathach 2018-08-08 19:52:51 +07:00
parent 31e5f77af8
commit c176894075
3 changed files with 9 additions and 1 deletions

View File

@ -297,6 +297,11 @@ int write_block(uint32_t block_no, uint8_t *data, bool quiet/*, WriteState *stat
return -1;
}
// only accept block with same family id
if ( UF2_FAMILY_ID && !((bl->flags & UF2_FLAG_FAMILYID) && (bl->familyID == UF2_FAMILY_ID)) ) {
return -1;
}
if ((bl->flags & UF2_FLAG_NOFLASH) || bl->payloadSize > 256 || (bl->targetAddr & 0xff) ||
bl->targetAddr < USER_FLASH_START || bl->targetAddr + bl->payloadSize > USER_FLASH_END) {
#if USE_DBG_MSC

View File

@ -51,6 +51,7 @@ extern bool sdRunning;
// If set, the block is "comment" and should not be flashed to the device
#define UF2_FLAG_NOFLASH 0x00000001
#define UF2_FLAG_FAMILYID 0x00002000
#define MAX_BLOCKS (FLASH_SIZE / 256 + 100)
typedef struct {
@ -68,7 +69,7 @@ typedef struct {
uint32_t payloadSize;
uint32_t blockNo;
uint32_t numBlocks;
uint32_t reserved;
uint32_t familyID;
// raw data;
uint8_t data[476];

View File

@ -13,3 +13,5 @@
#define USER_FLASH_END 0xAD000 // Fat Fs start here
#define FLASH_PAGE_SIZE 4096
#define UF2_FAMILY_ID 0xADA52840