move uf2 led blink fast to ghostfat
This commit is contained in:
parent
89c547f0cc
commit
50dec0e77a
14
src/flash.c
14
src/flash.c
@ -46,23 +46,11 @@
|
|||||||
|
|
||||||
static uint32_t _fl_addr = FLASH_CACHE_INVALID_ADDR;
|
static uint32_t _fl_addr = FLASH_CACHE_INVALID_ADDR;
|
||||||
static uint8_t _fl_buf[FLASH_PAGE_SIZE] __attribute__((aligned(4)));
|
static uint8_t _fl_buf[FLASH_PAGE_SIZE] __attribute__((aligned(4)));
|
||||||
static bool _first_flush = true;
|
|
||||||
|
|
||||||
|
|
||||||
void flash_flush(void)
|
void flash_flush(void)
|
||||||
{
|
{
|
||||||
if ( _fl_addr == FLASH_CACHE_INVALID_ADDR ) return;
|
if ( _fl_addr == FLASH_CACHE_INVALID_ADDR ) return;
|
||||||
|
|
||||||
if ( _first_flush )
|
|
||||||
{
|
|
||||||
_first_flush = false;
|
|
||||||
|
|
||||||
// disable softdevice
|
|
||||||
sd_softdevice_disable();
|
|
||||||
|
|
||||||
led_blink_fast(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( memcmp(_fl_buf, (void *) _fl_addr, FLASH_PAGE_SIZE) != 0 )
|
if ( memcmp(_fl_buf, (void *) _fl_addr, FLASH_PAGE_SIZE) != 0 )
|
||||||
{
|
{
|
||||||
nrf_nvmc_page_erase(_fl_addr);
|
nrf_nvmc_page_erase(_fl_addr);
|
||||||
@ -72,7 +60,7 @@ void flash_flush(void)
|
|||||||
_fl_addr = FLASH_CACHE_INVALID_ADDR;
|
_fl_addr = FLASH_CACHE_INVALID_ADDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void flash_write (uint32_t dst, const void *src, int len)
|
void flash_write (uint32_t dst, void const *src, int len)
|
||||||
{
|
{
|
||||||
uint32_t newAddr = dst & ~(FLASH_PAGE_SIZE - 1);
|
uint32_t newAddr = dst & ~(FLASH_PAGE_SIZE - 1);
|
||||||
|
|
||||||
|
@ -280,6 +280,13 @@ int write_block(uint32_t block_no, uint8_t *data, bool quiet/*, WriteState *stat
|
|||||||
} else {
|
} else {
|
||||||
// logval("write block at", bl->targetAddr);
|
// logval("write block at", bl->targetAddr);
|
||||||
NRF_LOG_DEBUG("Write block at %x", bl->targetAddr);
|
NRF_LOG_DEBUG("Write block at %x", bl->targetAddr);
|
||||||
|
|
||||||
|
static bool first_write = true;
|
||||||
|
if ( first_write ) {
|
||||||
|
first_write = false;
|
||||||
|
led_blink_fast(true);
|
||||||
|
}
|
||||||
|
|
||||||
flash_write(bl->targetAddr, bl->data, bl->payloadSize);
|
flash_write(bl->targetAddr, bl->data, bl->payloadSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,13 +306,7 @@ int write_block(uint32_t block_no, uint8_t *data, bool quiet/*, WriteState *stat
|
|||||||
state->numWritten++;
|
state->numWritten++;
|
||||||
}
|
}
|
||||||
if (state->numWritten >= state->numBlocks) {
|
if (state->numWritten >= state->numBlocks) {
|
||||||
// wait a little bit before resetting, to avoid Windows transmit error
|
// flush last blocks
|
||||||
// https://github.com/Microsoft/uf2-samd21/issues/11
|
|
||||||
if (!quiet) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// flush last blocks if needed
|
|
||||||
flash_flush();
|
flash_flush();
|
||||||
|
|
||||||
uf2_write_complete(state->numBlocks);
|
uf2_write_complete(state->numBlocks);
|
||||||
|
Loading…
Reference in New Issue
Block a user