clean up
This commit is contained in:
parent
4d39caa0f7
commit
69ff86ffd2
@ -307,7 +307,7 @@ uint32_t softdev_teardown(void)
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
// SD is already Initialized in case of BOOTLOADER_DFU_OTA_MAGIC
|
// SD is already Initialized in case of BOOTLOADER_DFU_OTA_MAGIC
|
||||||
bool sd_inited = (NRF_POWER->GPREGRET == BOOTLOADER_DFU_OTA_MAGIC);
|
bool const sd_inited = (NRF_POWER->GPREGRET == BOOTLOADER_DFU_OTA_MAGIC);
|
||||||
|
|
||||||
// Start Bootloader in BLE OTA mode
|
// Start Bootloader in BLE OTA mode
|
||||||
_ota_update = (NRF_POWER->GPREGRET == BOOTLOADER_DFU_OTA_MAGIC) ||
|
_ota_update = (NRF_POWER->GPREGRET == BOOTLOADER_DFU_OTA_MAGIC) ||
|
||||||
@ -322,8 +322,7 @@ int main(void)
|
|||||||
// Save bootloader version to pre-defined register, retrieved by application
|
// Save bootloader version to pre-defined register, retrieved by application
|
||||||
BOOTLOADER_VERSION_REGISTER = (MK_BOOTLOADER_VERSION);
|
BOOTLOADER_VERSION_REGISTER = (MK_BOOTLOADER_VERSION);
|
||||||
|
|
||||||
// This check ensures that the defined fields in the bootloader corresponds with actual
|
// This check ensures that the defined fields in the bootloader corresponds with actual setting in the chip.
|
||||||
// setting in the chip.
|
|
||||||
APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
|
APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
|
||||||
|
|
||||||
board_init();
|
board_init();
|
||||||
|
@ -155,24 +155,6 @@ static uint32_t get_flash_size(void)
|
|||||||
return flash_sz;
|
return flash_sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
void uf2_timer(void *p_context) {
|
|
||||||
UNUSED_PARAMETER(p_context);
|
|
||||||
if (hadWrite) {
|
|
||||||
flushFlash();
|
|
||||||
s_dfu_settings.bank_0.bank_code = NRF_DFU_BANK_VALID_APP;
|
|
||||||
int32_t start = SD_MAGIC_OK() ? MAIN_APPLICATION_START_ADDR : MBR_SIZE;
|
|
||||||
int32_t sz = s_dfu_settings.bank_0.image_size - start;
|
|
||||||
if (sz > 0)
|
|
||||||
s_dfu_settings.bank_0.image_size = sz;
|
|
||||||
nrf_dfu_settings_write(NULL);
|
|
||||||
}
|
|
||||||
NVIC_SystemReset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void uf2_timer_start(int ms);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void padded_memcpy(char *dst, const char *src, int len) {
|
void padded_memcpy(char *dst, const char *src, int len) {
|
||||||
for (int i = 0; i < len; ++i) {
|
for (int i = 0; i < len; ++i) {
|
||||||
if (*src)
|
if (*src)
|
||||||
@ -375,8 +357,6 @@ int write_block(uint32_t block_no, uint8_t *data, bool quiet/*, WriteState *stat
|
|||||||
// flash_write cause a flush to write previous cached data, this write data is not consumed yet
|
// flash_write cause a flush to write previous cached data, this write data is not consumed yet
|
||||||
if ( _is_flashing ) return 0;
|
if ( _is_flashing ) return 0;
|
||||||
|
|
||||||
// bool isSet = false;
|
|
||||||
|
|
||||||
if (state && bl->numBlocks) {
|
if (state && bl->numBlocks) {
|
||||||
if (state->numBlocks != bl->numBlocks) {
|
if (state->numBlocks != bl->numBlocks) {
|
||||||
if (bl->numBlocks >= MAX_BLOCKS || state->numBlocks)
|
if (bl->numBlocks >= MAX_BLOCKS || state->numBlocks)
|
||||||
@ -396,8 +376,7 @@ int write_block(uint32_t block_no, uint8_t *data, bool quiet/*, WriteState *stat
|
|||||||
// wait a little bit before resetting, to avoid Windows transmit error
|
// wait a little bit before resetting, to avoid Windows transmit error
|
||||||
// https://github.com/Microsoft/uf2-samd21/issues/11
|
// https://github.com/Microsoft/uf2-samd21/issues/11
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
// uf2_timer_start(30);
|
|
||||||
// isSet = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// flush last blocks
|
// flush last blocks
|
||||||
@ -405,16 +384,14 @@ int write_block(uint32_t block_no, uint8_t *data, bool quiet/*, WriteState *stat
|
|||||||
|
|
||||||
// no flashing due to last blocks is the same to contents on the flash already
|
// no flashing due to last blocks is the same to contents on the flash already
|
||||||
// complete the write
|
// complete the write
|
||||||
if (!_is_flashing) uf2_write_complete();
|
if (!_is_flashing) {
|
||||||
|
uf2_write_complete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NRF_LOG_DEBUG("wr %d=%d (of %d)", state->numWritten, bl->blockNo, bl->numBlocks);
|
NRF_LOG_DEBUG("wr %d=%d (of %d)", state->numWritten, bl->blockNo, bl->numBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (!isSet && !quiet) {
|
|
||||||
// // uf2_timer_start(500);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return 512;
|
return 512;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user