2018-06-19 15:12:01 +00:00
|
|
|
|
2019-03-14 06:49:52 +00:00
|
|
|
#include "macros.h"
|
|
|
|
|
2018-06-19 15:12:01 +00:00
|
|
|
#include "uf2.h"
|
2018-09-28 09:27:58 +00:00
|
|
|
#include "flash_nrf5x.h"
|
2018-06-19 15:12:01 +00:00
|
|
|
#include <string.h>
|
2018-08-07 17:41:41 +00:00
|
|
|
|
2018-08-08 08:19:02 +00:00
|
|
|
#include "boards.h"
|
2018-06-20 06:18:14 +00:00
|
|
|
#include "tusb.h"
|
2018-06-19 15:12:01 +00:00
|
|
|
|
2018-06-23 18:28:02 +00:00
|
|
|
#include "bootloader_settings.h"
|
|
|
|
#include "bootloader.h"
|
|
|
|
|
2018-06-19 15:12:01 +00:00
|
|
|
typedef struct {
|
|
|
|
uint8_t JumpInstruction[3];
|
|
|
|
uint8_t OEMInfo[8];
|
|
|
|
uint16_t SectorSize;
|
|
|
|
uint8_t SectorsPerCluster;
|
|
|
|
uint16_t ReservedSectors;
|
|
|
|
uint8_t FATCopies;
|
|
|
|
uint16_t RootDirectoryEntries;
|
|
|
|
uint16_t TotalSectors16;
|
|
|
|
uint8_t MediaDescriptor;
|
|
|
|
uint16_t SectorsPerFAT;
|
|
|
|
uint16_t SectorsPerTrack;
|
|
|
|
uint16_t Heads;
|
|
|
|
uint32_t HiddenSectors;
|
|
|
|
uint32_t TotalSectors32;
|
|
|
|
uint8_t PhysicalDriveNum;
|
|
|
|
uint8_t Reserved;
|
|
|
|
uint8_t ExtendedBootSig;
|
|
|
|
uint32_t VolumeSerialNumber;
|
|
|
|
uint8_t VolumeLabel[11];
|
|
|
|
uint8_t FilesystemIdentifier[8];
|
|
|
|
} __attribute__((packed)) FAT_BootBlock;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char name[8];
|
|
|
|
char ext[3];
|
|
|
|
uint8_t attrs;
|
|
|
|
uint8_t reserved;
|
|
|
|
uint8_t createTimeFine;
|
|
|
|
uint16_t createTime;
|
|
|
|
uint16_t createDate;
|
|
|
|
uint16_t lastAccessDate;
|
|
|
|
uint16_t highStartCluster;
|
|
|
|
uint16_t updateTime;
|
|
|
|
uint16_t updateDate;
|
|
|
|
uint16_t startCluster;
|
|
|
|
uint32_t size;
|
|
|
|
} __attribute__((packed)) DirEntry;
|
|
|
|
STATIC_ASSERT(sizeof(DirEntry) == 32);
|
|
|
|
|
|
|
|
struct TextFile {
|
2018-10-02 11:57:50 +00:00
|
|
|
char const name[11];
|
|
|
|
char const *content;
|
2018-06-19 15:12:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define NUM_FAT_BLOCKS UF2_NUM_BLOCKS
|
|
|
|
|
|
|
|
#define STR0(x) #x
|
|
|
|
#define STR(x) STR0(x)
|
2019-03-14 01:27:11 +00:00
|
|
|
|
2018-06-19 15:12:01 +00:00
|
|
|
const char infoUf2File[] = //
|
|
|
|
"UF2 Bootloader " UF2_VERSION "\r\n"
|
|
|
|
"Model: " PRODUCT_NAME "\r\n"
|
2018-06-21 05:28:52 +00:00
|
|
|
"Board-ID: " BOARD_ID "\r\n"
|
2018-08-30 19:35:59 +00:00
|
|
|
"Bootloader: " BOOTLOADER_ID "\r\n"
|
2019-03-19 07:37:53 +00:00
|
|
|
"Date: " __DATE__ "\r\n";
|
2018-06-19 15:12:01 +00:00
|
|
|
|
|
|
|
const char indexFile[] = //
|
|
|
|
"<!doctype html>\n"
|
|
|
|
"<html>"
|
|
|
|
"<body>"
|
|
|
|
"<script>\n"
|
|
|
|
"location.replace(\"" INDEX_URL "\");\n"
|
|
|
|
"</script>"
|
|
|
|
"</body>"
|
|
|
|
"</html>\n";
|
|
|
|
|
2019-03-14 01:45:44 +00:00
|
|
|
// WARNING -- code presumes only one NULL .content for .UF2 file
|
|
|
|
// and requires it be the last element of the array
|
2018-10-02 11:57:50 +00:00
|
|
|
static struct TextFile const info[] = {
|
2018-06-19 15:12:01 +00:00
|
|
|
{.name = "INFO_UF2TXT", .content = infoUf2File},
|
|
|
|
{.name = "INDEX HTM", .content = indexFile},
|
|
|
|
{.name = "CURRENT UF2"},
|
|
|
|
};
|
2019-03-14 01:27:11 +00:00
|
|
|
|
|
|
|
// WARNING -- code presumes each non-UF2 file content fits in single sector
|
|
|
|
// Cannot programmatically statically assert .content length
|
|
|
|
// for each element above.
|
|
|
|
STATIC_ASSERT(ARRAY_SIZE2(indexFile) < 512);
|
|
|
|
|
|
|
|
|
|
|
|
#define NUM_FILES (ARRAY_SIZE2(info))
|
|
|
|
#define NUM_DIRENTRIES (NUM_FILES + 1) // Code adds volume label as first root directory entry
|
|
|
|
|
2018-06-19 15:12:01 +00:00
|
|
|
|
2018-12-21 05:17:14 +00:00
|
|
|
#define UF2_SIZE (current_flash_size() * 2)
|
2018-06-23 18:28:02 +00:00
|
|
|
#define UF2_SECTORS (UF2_SIZE / 512)
|
2019-03-14 01:27:11 +00:00
|
|
|
#define UF2_FIRST_SECTOR (NUM_FILES + 1) // WARNING -- code presumes each non-UF2 file content fits in single sector
|
2018-06-23 18:28:02 +00:00
|
|
|
#define UF2_LAST_SECTOR (UF2_FIRST_SECTOR + UF2_SECTORS - 1)
|
2018-06-19 15:12:01 +00:00
|
|
|
|
2018-06-23 18:28:02 +00:00
|
|
|
#define RESERVED_SECTORS 1
|
|
|
|
#define ROOT_DIR_SECTORS 4
|
|
|
|
#define SECTORS_PER_FAT ((NUM_FAT_BLOCKS * 2 + 511) / 512)
|
2018-06-19 15:12:01 +00:00
|
|
|
|
2018-06-23 18:28:02 +00:00
|
|
|
#define START_FAT0 RESERVED_SECTORS
|
|
|
|
#define START_FAT1 (START_FAT0 + SECTORS_PER_FAT)
|
|
|
|
#define START_ROOTDIR (START_FAT1 + SECTORS_PER_FAT)
|
|
|
|
#define START_CLUSTERS (START_ROOTDIR + ROOT_DIR_SECTORS)
|
2018-06-19 15:12:01 +00:00
|
|
|
|
2019-03-13 22:20:42 +00:00
|
|
|
// all directory entries must fit in a single sector
|
|
|
|
// because otherwise current code overflows buffer
|
2019-03-14 01:45:44 +00:00
|
|
|
#define DIRENTRIES_PER_SECTOR (512/sizeof(DirEntry))
|
|
|
|
|
|
|
|
STATIC_ASSERT(NUM_DIRENTRIES < DIRENTRIES_PER_SECTOR * ROOT_DIR_SECTORS);
|
2019-03-13 22:20:42 +00:00
|
|
|
|
|
|
|
|
2018-10-02 11:57:50 +00:00
|
|
|
static FAT_BootBlock const BootBlock = {
|
2018-06-23 18:28:02 +00:00
|
|
|
.JumpInstruction = {0xeb, 0x3c, 0x90},
|
|
|
|
.OEMInfo = "UF2 UF2 ",
|
|
|
|
.SectorSize = 512,
|
|
|
|
.SectorsPerCluster = 1,
|
|
|
|
.ReservedSectors = RESERVED_SECTORS,
|
|
|
|
.FATCopies = 2,
|
2019-03-14 01:45:44 +00:00
|
|
|
.RootDirectoryEntries = (ROOT_DIR_SECTORS * DIRENTRIES_PER_SECTOR),
|
2018-06-23 18:28:02 +00:00
|
|
|
.TotalSectors16 = NUM_FAT_BLOCKS - 2,
|
|
|
|
.MediaDescriptor = 0xF8,
|
|
|
|
.SectorsPerFAT = SECTORS_PER_FAT,
|
|
|
|
.SectorsPerTrack = 1,
|
|
|
|
.Heads = 1,
|
2019-03-12 19:09:49 +00:00
|
|
|
.PhysicalDriveNum = 0x80, // to match MediaDescriptor of 0xF8
|
2018-06-23 18:28:02 +00:00
|
|
|
.ExtendedBootSig = 0x29,
|
|
|
|
.VolumeSerialNumber = 0x00420042,
|
|
|
|
.VolumeLabel = VOLUME_LABEL,
|
2018-06-19 15:12:01 +00:00
|
|
|
.FilesystemIdentifier = "FAT16 ",
|
|
|
|
};
|
|
|
|
|
2018-06-20 06:18:14 +00:00
|
|
|
#define NRF_LOG_DEBUG(...)
|
2018-06-25 09:00:42 +00:00
|
|
|
#define NRF_LOG_WARNING(...)
|
2018-06-20 06:18:14 +00:00
|
|
|
|
2018-12-21 05:17:14 +00:00
|
|
|
// get current.uf2 flash size in bytes, round up to 256 bytes
|
|
|
|
static uint32_t current_flash_size(void)
|
2018-06-23 18:28:02 +00:00
|
|
|
{
|
2018-06-24 09:43:13 +00:00
|
|
|
static uint32_t flash_sz = 0;
|
2019-03-12 20:41:33 +00:00
|
|
|
uint32_t result = flash_sz; // presumes atomic 32-bit read/write and static result
|
2018-06-24 09:43:13 +00:00
|
|
|
|
|
|
|
// only need to compute once
|
2019-03-12 20:41:33 +00:00
|
|
|
if ( result == 0 )
|
2018-06-24 09:43:13 +00:00
|
|
|
{
|
|
|
|
// return 1 block of 256 bytes
|
|
|
|
if ( !bootloader_app_is_valid(DFU_BANK_0_REGION_START) )
|
|
|
|
{
|
2019-03-12 20:41:33 +00:00
|
|
|
result = 256;
|
2018-06-24 09:43:13 +00:00
|
|
|
}else
|
|
|
|
{
|
2018-10-02 11:57:50 +00:00
|
|
|
bootloader_settings_t const * boot_setting;
|
2018-06-24 09:43:13 +00:00
|
|
|
bootloader_util_settings_get(&boot_setting);
|
|
|
|
|
2019-03-12 20:41:33 +00:00
|
|
|
result = boot_setting->bank_0_size;
|
2018-12-21 05:17:14 +00:00
|
|
|
|
|
|
|
// Copy size must be multiple of 256 bytes
|
|
|
|
// else we will got an issue copying current.uf2
|
2019-03-12 20:41:33 +00:00
|
|
|
if (result & 0xff)
|
2018-12-21 05:17:14 +00:00
|
|
|
{
|
2019-03-12 20:41:33 +00:00
|
|
|
result = (result & ~0xff) + 256;
|
2018-12-21 05:17:14 +00:00
|
|
|
}
|
|
|
|
|
2018-08-16 12:27:27 +00:00
|
|
|
// if bank0 size is not valid, happens when flashed with jlink
|
|
|
|
// use maximum application size
|
2019-03-12 20:41:33 +00:00
|
|
|
if ( (result == 0) || (result == 0xFFFFFFFFUL) )
|
2018-08-16 12:27:27 +00:00
|
|
|
{
|
2019-03-12 20:41:33 +00:00
|
|
|
result = FLASH_SIZE;
|
2018-08-16 12:27:27 +00:00
|
|
|
}
|
2018-06-24 09:43:13 +00:00
|
|
|
}
|
2019-03-12 20:41:33 +00:00
|
|
|
flash_sz = result; // presumes atomic 32-bit read/write and static result
|
2018-06-24 09:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return flash_sz;
|
2018-06-23 18:28:02 +00:00
|
|
|
}
|
|
|
|
|
2018-10-02 11:57:50 +00:00
|
|
|
void padded_memcpy (char *dst, char const *src, int len)
|
|
|
|
{
|
2018-06-19 15:12:01 +00:00
|
|
|
for (int i = 0; i < len; ++i) {
|
|
|
|
if (*src)
|
|
|
|
*dst = *src++;
|
|
|
|
else
|
|
|
|
*dst = ' ';
|
|
|
|
dst++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-20 06:18:14 +00:00
|
|
|
|
2018-06-25 09:00:42 +00:00
|
|
|
/*------------------------------------------------------------------*/
|
2018-06-25 09:36:50 +00:00
|
|
|
/* Read
|
2018-06-25 09:00:42 +00:00
|
|
|
*------------------------------------------------------------------*/
|
2018-06-19 15:12:01 +00:00
|
|
|
void read_block(uint32_t block_no, uint8_t *data) {
|
|
|
|
memset(data, 0, 512);
|
|
|
|
uint32_t sectionIdx = block_no;
|
|
|
|
|
2019-03-12 19:29:05 +00:00
|
|
|
if (block_no == 0) { // Requested boot block
|
2018-06-19 15:12:01 +00:00
|
|
|
memcpy(data, &BootBlock, sizeof(BootBlock));
|
|
|
|
data[510] = 0x55;
|
|
|
|
data[511] = 0xaa;
|
|
|
|
// logval("data[0]", data[0]);
|
2019-03-12 19:29:05 +00:00
|
|
|
} else if (block_no < START_ROOTDIR) { // Requested FAT table sector
|
2018-06-19 15:12:01 +00:00
|
|
|
sectionIdx -= START_FAT0;
|
|
|
|
// logval("sidx", sectionIdx);
|
|
|
|
if (sectionIdx >= SECTORS_PER_FAT)
|
2019-03-12 19:29:05 +00:00
|
|
|
sectionIdx -= SECTORS_PER_FAT; // second FAT is same as the first...
|
2018-06-19 15:12:01 +00:00
|
|
|
if (sectionIdx == 0) {
|
2019-03-19 07:57:24 +00:00
|
|
|
data[0] = 0xf8; // first FAT entry must match BPB MediaDescriptor
|
2019-03-14 01:45:44 +00:00
|
|
|
// WARNING -- code presumes only one NULL .content for .UF2 file
|
|
|
|
// and all non-NULL .content fit in one sector
|
|
|
|
// and requires it be the last element of the array
|
2019-03-14 01:27:11 +00:00
|
|
|
for (int i = 1; i < NUM_FILES * 2 + 4; ++i) {
|
2019-03-14 01:45:44 +00:00
|
|
|
data[i] = 0xff;
|
2018-06-19 15:12:01 +00:00
|
|
|
}
|
|
|
|
}
|
2019-03-12 19:29:05 +00:00
|
|
|
for (int i = 0; i < 256; ++i) { // Generate the FAT chain for the firmware "file"
|
2018-06-19 15:12:01 +00:00
|
|
|
uint32_t v = sectionIdx * 256 + i;
|
|
|
|
if (UF2_FIRST_SECTOR <= v && v <= UF2_LAST_SECTOR)
|
|
|
|
((uint16_t *)(void *)data)[i] = v == UF2_LAST_SECTOR ? 0xffff : v + 1;
|
|
|
|
}
|
2019-03-19 07:57:24 +00:00
|
|
|
} else if (block_no < START_CLUSTERS) { // Requested root directory sector
|
2019-03-14 01:45:44 +00:00
|
|
|
|
2018-06-19 15:12:01 +00:00
|
|
|
sectionIdx -= START_ROOTDIR;
|
2019-03-14 01:45:44 +00:00
|
|
|
|
|
|
|
DirEntry *d = (void *)data;
|
|
|
|
int remainingEntries = DIRENTRIES_PER_SECTOR;
|
|
|
|
if (sectionIdx == 0) { // volume label first
|
|
|
|
// volume label is first directory entry
|
2018-10-02 11:57:50 +00:00
|
|
|
padded_memcpy(d->name, (char const *) BootBlock.VolumeLabel, 11);
|
2018-06-19 15:12:01 +00:00
|
|
|
d->attrs = 0x28;
|
2019-03-14 05:05:57 +00:00
|
|
|
d++;
|
2019-03-14 01:45:44 +00:00
|
|
|
remainingEntries--;
|
2018-06-19 15:12:01 +00:00
|
|
|
}
|
2019-03-14 01:45:44 +00:00
|
|
|
|
|
|
|
for (int i = DIRENTRIES_PER_SECTOR * sectionIdx;
|
|
|
|
remainingEntries > 0 && i < NUM_FILES;
|
|
|
|
i++, d++) {
|
2019-03-14 05:05:57 +00:00
|
|
|
|
|
|
|
// WARNING -- code presumes all but last file take exactly one sector
|
|
|
|
uint16_t startCluster = i + 2;
|
|
|
|
|
2019-03-14 01:45:44 +00:00
|
|
|
struct TextFile const * inf = &info[i];
|
2019-03-14 05:05:57 +00:00
|
|
|
padded_memcpy(d->name, inf->name, 11);
|
|
|
|
d->createTimeFine = __SECONDS_INT__ % 2 * 100;
|
|
|
|
d->createTime = __DOSTIME__;
|
|
|
|
d->createDate = __DOSDATE__;
|
|
|
|
d->lastAccessDate = __DOSDATE__;
|
|
|
|
d->highStartCluster = startCluster >> 8;
|
|
|
|
// DIR_WrtTime and DIR_WrtDate must be supported
|
|
|
|
d->updateTime = __DOSTIME__;
|
|
|
|
d->updateDate = __DOSDATE__;
|
|
|
|
d->startCluster = startCluster & 0xFF;
|
2019-03-14 01:45:44 +00:00
|
|
|
// WARNING -- code presumes only one NULL .content for .UF2 file
|
|
|
|
// and requires it be the last element of the array
|
|
|
|
d->size = inf->content ? strlen(inf->content) : UF2_SIZE;
|
|
|
|
}
|
|
|
|
|
2018-06-19 15:12:01 +00:00
|
|
|
} else {
|
|
|
|
sectionIdx -= START_CLUSTERS;
|
2019-03-14 01:27:11 +00:00
|
|
|
if (sectionIdx < NUM_FILES - 1) {
|
2018-06-19 15:12:01 +00:00
|
|
|
memcpy(data, info[sectionIdx].content, strlen(info[sectionIdx].content));
|
|
|
|
} else {
|
2019-03-14 01:27:11 +00:00
|
|
|
sectionIdx -= NUM_FILES - 1;
|
2018-06-21 04:28:04 +00:00
|
|
|
uint32_t addr = USER_FLASH_START + sectionIdx * 256;
|
2018-06-21 13:53:24 +00:00
|
|
|
if (addr < USER_FLASH_START+FLASH_SIZE) {
|
2018-06-19 15:12:01 +00:00
|
|
|
UF2_Block *bl = (void *)data;
|
|
|
|
bl->magicStart0 = UF2_MAGIC_START0;
|
|
|
|
bl->magicStart1 = UF2_MAGIC_START1;
|
|
|
|
bl->magicEnd = UF2_MAGIC_END;
|
|
|
|
bl->blockNo = sectionIdx;
|
2018-12-21 05:17:14 +00:00
|
|
|
bl->numBlocks = current_flash_size() / 256;
|
2018-06-19 15:12:01 +00:00
|
|
|
bl->targetAddr = addr;
|
|
|
|
bl->payloadSize = 256;
|
2018-08-10 17:19:01 +00:00
|
|
|
bl->flags = UF2_FLAG_FAMILYID;
|
|
|
|
bl->familyID = UF2_FAMILY_ID;
|
2018-06-19 15:12:01 +00:00
|
|
|
memcpy(bl->data, (void *)addr, bl->payloadSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-25 09:36:50 +00:00
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/* Write UF2
|
|
|
|
*------------------------------------------------------------------*/
|
|
|
|
|
2018-06-25 09:00:42 +00:00
|
|
|
/** Write an block
|
|
|
|
*
|
|
|
|
* @return number of bytes processed, only 3 following values
|
|
|
|
* -1 : if not an uf2 block
|
|
|
|
* 512 : write is successful
|
|
|
|
* 0 : is busy with flashing, tinyusb stack will call write_block again with the same parameters later on
|
|
|
|
*/
|
2019-02-21 17:21:34 +00:00
|
|
|
int write_block(uint32_t block_no, uint8_t *data, bool quiet, WriteState *state) {
|
2018-06-19 15:12:01 +00:00
|
|
|
UF2_Block *bl = (void *)data;
|
|
|
|
|
2018-06-25 09:00:42 +00:00
|
|
|
NRF_LOG_DEBUG("Write magic: %x", bl->magicStart0);
|
2018-06-19 15:12:01 +00:00
|
|
|
|
|
|
|
if (!is_uf2_block(bl)) {
|
2018-06-25 09:00:42 +00:00
|
|
|
return -1;
|
2018-06-19 15:12:01 +00:00
|
|
|
}
|
|
|
|
|
2018-08-08 12:52:51 +00:00
|
|
|
// only accept block with same family id
|
|
|
|
if ( UF2_FAMILY_ID && !((bl->flags & UF2_FLAG_FAMILYID) && (bl->familyID == UF2_FAMILY_ID)) ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-06-19 15:12:01 +00:00
|
|
|
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
|
|
|
|
if (!quiet)
|
|
|
|
logval("invalid target addr", bl->targetAddr);
|
|
|
|
#endif
|
|
|
|
NRF_LOG_WARNING("Skip block at %x", bl->targetAddr);
|
|
|
|
// this happens when we're trying to re-flash CURRENT.UF2 file previously
|
|
|
|
// copied from a device; we still want to count these blocks to reset properly
|
|
|
|
} else {
|
|
|
|
// logval("write block at", bl->targetAddr);
|
|
|
|
NRF_LOG_DEBUG("Write block at %x", bl->targetAddr);
|
2018-09-28 06:37:01 +00:00
|
|
|
|
|
|
|
static bool first_write = true;
|
|
|
|
if ( first_write ) {
|
|
|
|
first_write = false;
|
2018-12-04 21:45:55 +00:00
|
|
|
led_state(STATE_WRITING_STARTED);
|
2018-09-28 06:37:01 +00:00
|
|
|
}
|
2018-12-04 21:45:55 +00:00
|
|
|
|
2018-10-02 11:57:50 +00:00
|
|
|
flash_nrf5x_write(bl->targetAddr, bl->data, bl->payloadSize, true);
|
2018-06-19 15:12:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (state && bl->numBlocks) {
|
|
|
|
if (state->numBlocks != bl->numBlocks) {
|
|
|
|
if (bl->numBlocks >= MAX_BLOCKS || state->numBlocks)
|
|
|
|
state->numBlocks = 0xffffffff;
|
|
|
|
else
|
|
|
|
state->numBlocks = bl->numBlocks;
|
|
|
|
}
|
|
|
|
if (bl->blockNo < MAX_BLOCKS) {
|
|
|
|
uint8_t mask = 1 << (bl->blockNo % 8);
|
|
|
|
uint32_t pos = bl->blockNo / 8;
|
|
|
|
if (!(state->writtenMask[pos] & mask)) {
|
|
|
|
// logval("incr", state->numWritten);
|
|
|
|
state->writtenMask[pos] |= mask;
|
|
|
|
state->numWritten++;
|
|
|
|
}
|
|
|
|
if (state->numWritten >= state->numBlocks) {
|
2018-09-28 06:37:01 +00:00
|
|
|
// flush last blocks
|
2018-10-02 11:57:50 +00:00
|
|
|
flash_nrf5x_flush(true);
|
2018-06-19 15:12:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
NRF_LOG_DEBUG("wr %d=%d (of %d)", state->numWritten, bl->blockNo, bl->numBlocks);
|
|
|
|
}
|
|
|
|
|
2018-06-25 09:00:42 +00:00
|
|
|
return 512;
|
2018-06-19 15:12:01 +00:00
|
|
|
}
|