Hi,
I'm trying to do (customized / simplified) dual bank DFU on NRF52832 as simple as possible, without any complicated checks.
Assume I succeeded into storing the new firmware in a free Flash bank (bank1, e.g. @ 0x50000), I need to know which functions should be used to to move the new SW from bank1 to bank0, or directly boot from bank1.
Assuming my current application runs at address 0x23000 after SD132, If I try to use pstorage functions to move the image from bank1 to this address, the chip hangs as soon as I start with the clear flash page command (which is successfully executed after checking Flash contents with nrfjprog).
- Is that normal? I thought the application is running in RAM and not affected if application area is erased in flash without doing a reset. Is there any way to solve this?
- If not (& I'm not using a DFU bootloader), is it possible to just set the application start address in UICR to the start address of bank1 (0x50000) to boot new SW?
from UICR dump I see the 0x00023000 is stored:
:020000041000EA
:1010000000300200FFFFFFFFFFFFFFFFFFFFFFFFBA
- If all this is not possible, is it possible to just use the code snippet in nrf_dfu_postvalidate() in dfu_req_handling.c :
switch (p_init->type)
{
case DFU_FW_TYPE_APPLICATION:
p_bank->bank_code = NRF_DFU_BANK_VALID_APP;
// If this update is in bank 1, invalidate bank 0 before starting copy routine.
if (s_dfu_settings.bank_current == NRF_DFU_CURRENT_BANK_1)
{
NRF_LOG_INFO("Invalidating old application in bank 0.");
s_dfu_settings.bank_0.bank_code = NRF_DFU_BANK_INVALID;
}
break;
p_bank->bank_code = NRF_DFU_BANK_INVALID;
// Calculate CRC32 for image
p_bank->image_crc = 0;
p_bank->image_size = 0;
// Set the progress to zero and remove the last command
memset(&s_dfu_settings.progress, 0, sizeof(dfu_progress_t));
memset(s_dfu_settings.init_command, 0xFF, DFU_SIGNED_COMMAND_SIZE);
s_dfu_settings.write_offset = 0;
// Store the settings to flash and reset after that
m_dfu_last_settings_write_started = true;
if (nrf_dfu_settings_write(on_dfu_complete) != NRF_SUCCESS)
{
res_code = NRF_DFU_RES_CODE_OPERATION_FAILED;
}
Thx & KR