rename flash_ to flash_nrf5x_
This commit is contained in:
parent
f9532acaf8
commit
f14aebba1d
@ -185,8 +185,8 @@ static void bootloader_settings_save(bootloader_settings_t * p_settings)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flash_write(BOOTLOADER_SETTINGS_ADDRESS, p_settings, sizeof(bootloader_settings_t));
|
flash_nrf5x_write(BOOTLOADER_SETTINGS_ADDRESS, p_settings, sizeof(bootloader_settings_t));
|
||||||
flash_flush();
|
flash_nrf5x_flush();
|
||||||
|
|
||||||
pstorage_callback_handler(&m_bootsettings_handle, PSTORAGE_STORE_OP_CODE, NRF_SUCCESS, (uint8_t *) p_settings, sizeof(bootloader_settings_t));
|
pstorage_callback_handler(&m_bootsettings_handle, PSTORAGE_STORE_OP_CODE, NRF_SUCCESS, (uint8_t *) p_settings, sizeof(bootloader_settings_t));
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,13 @@ static void dfu_prepare_func_app_erase(uint32_t image_size)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flash_erase(DFU_BANK_0_REGION_START, m_image_size);
|
uint32_t page_count = m_image_size/CODE_PAGE_SIZE;
|
||||||
|
if ( m_image_size%CODE_PAGE_SIZE ) page_count++;
|
||||||
|
|
||||||
|
for(uint32_t i=0; i<page_count; i++)
|
||||||
|
{
|
||||||
|
nrf_nvmc_page_erase(DFU_BANK_0_REGION_START + i*CODE_PAGE_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
// simulate complete call
|
// simulate complete call
|
||||||
pstorage_callback_handler(&m_storage_handle_app, PSTORAGE_CLEAR_OP_CODE, NRF_SUCCESS, NULL, 0);
|
pstorage_callback_handler(&m_storage_handle_app, PSTORAGE_CLEAR_OP_CODE, NRF_SUCCESS, NULL, 0);
|
||||||
@ -427,9 +433,8 @@ uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flash_write(DFU_BANK_0_REGION_START+m_data_received, p_data, data_length);
|
flash_nrf5x_write(DFU_BANK_0_REGION_START+m_data_received, p_data, data_length);
|
||||||
|
pstorage_callback_handler(mp_storage_handle_active, PSTORAGE_STORE_OP_CODE, NRF_SUCCESS, (uint8_t *) p_data, data_length);
|
||||||
// Adafruit: transport serial, no need to call pstorage complete
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data_received += data_length;
|
m_data_received += data_length;
|
||||||
@ -441,7 +446,7 @@ uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( !is_ota() ) flash_flush();
|
if ( !is_ota() ) flash_nrf5x_flush();
|
||||||
|
|
||||||
// The entire image has been received. Return NRF_SUCCESS.
|
// The entire image has been received. Return NRF_SUCCESS.
|
||||||
err_code = NRF_SUCCESS;
|
err_code = NRF_SUCCESS;
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
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)));
|
||||||
|
|
||||||
void flash_flush(void)
|
void flash_nrf5x_flush(void)
|
||||||
{
|
{
|
||||||
if ( _fl_addr == FLASH_CACHE_INVALID_ADDR ) return;
|
if ( _fl_addr == FLASH_CACHE_INVALID_ADDR ) return;
|
||||||
|
|
||||||
@ -64,20 +64,20 @@ void flash_flush(void)
|
|||||||
_fl_addr = FLASH_CACHE_INVALID_ADDR;
|
_fl_addr = FLASH_CACHE_INVALID_ADDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void flash_write (uint32_t dst, void const *src, int len)
|
void flash_nrf5x_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);
|
||||||
|
|
||||||
if ( newAddr != _fl_addr )
|
if ( newAddr != _fl_addr )
|
||||||
{
|
{
|
||||||
flash_flush();
|
flash_nrf5x_flush();
|
||||||
_fl_addr = newAddr;
|
_fl_addr = newAddr;
|
||||||
memcpy(_fl_buf, (void *) newAddr, FLASH_PAGE_SIZE);
|
memcpy(_fl_buf, (void *) newAddr, FLASH_PAGE_SIZE);
|
||||||
}
|
}
|
||||||
memcpy(_fl_buf + (dst & (FLASH_PAGE_SIZE - 1)), src, len);
|
memcpy(_fl_buf + (dst & (FLASH_PAGE_SIZE - 1)), src, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void flash_erase(uint32_t addr, uint32_t bytes)
|
void flash_nrf5x_erase(uint32_t addr, uint32_t bytes)
|
||||||
{
|
{
|
||||||
uint32_t page_count = bytes/FLASH_PAGE_SIZE;
|
uint32_t page_count = bytes/FLASH_PAGE_SIZE;
|
||||||
if ( bytes%FLASH_PAGE_SIZE ) page_count++;
|
if ( bytes%FLASH_PAGE_SIZE ) page_count++;
|
||||||
|
@ -47,8 +47,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//void flash_erase(uint32_t page_addr);
|
//void flash_erase(uint32_t page_addr);
|
||||||
void flash_write (uint32_t dst, void const *src, int len);
|
void flash_nrf5x_write (uint32_t dst, void const *src, int len);
|
||||||
void flash_flush(void);
|
void flash_nrf5x_flush(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ int write_block(uint32_t block_no, uint8_t *data, bool quiet/*, WriteState *stat
|
|||||||
led_blink_fast(true);
|
led_blink_fast(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
flash_write(bl->targetAddr, bl->data, bl->payloadSize);
|
flash_nrf5x_write(bl->targetAddr, bl->data, bl->payloadSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state && bl->numBlocks) {
|
if (state && bl->numBlocks) {
|
||||||
@ -307,7 +307,7 @@ int write_block(uint32_t block_no, uint8_t *data, bool quiet/*, WriteState *stat
|
|||||||
}
|
}
|
||||||
if (state->numWritten >= state->numBlocks) {
|
if (state->numWritten >= state->numBlocks) {
|
||||||
// flush last blocks
|
// flush last blocks
|
||||||
flash_flush();
|
flash_nrf5x_flush();
|
||||||
|
|
||||||
uf2_write_complete(state->numBlocks);
|
uf2_write_complete(state->numBlocks);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user