Bootloader with Custom DFU

We have an existing DFU to deliver the pending firmware in flash.  I need to develop a custom bootloader that copies the pending firmware and activates it.  I am close but getting stuck. 

Issue:

- When app_activate() is called, it just skips over it.  Even when I add __root to it.  The function exists in the .map file, but I can't enter it in debugger.

Specs:

- nRF52840, SDK15.0.0, SD140, using IAR compiler

My memory layout is

  

My Steps to processing the hex files

1) To fake a pending firmware update, I offset the main application to place it in Bank-1:

- srec_cat.exe app.hex -Intel -offset 0x5F000 -o appOffset.hex -Intel

2) To create the bootloader settings, I use the nrfutil:

- `nrfutil.exe” settings generate --family NRF52840 --application appOffset.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 settings.hex

3) I use the NRF programmer to merge and program the MBR/SoftDevices, Pending FW, Bootloader, and Bootloader Settings

Debugging

I'm trying to reuse as much of the example bootloader.  

int main(void)
{		

	NOT_USED ret_code_t ret_val;
	
	/* Copy pending update then reboot
	1. Check if there is a pending fw update:
		- nrf_bootloader_fw_activate() checks 
		p_bank->bank_code == NRF_DFU_BANK_VALID_APP, then calls app_activate()
	2. Copies pending firmware to slot 0 via app_activate(), then checks the CRC
	3. If successful, bootloader_reset();
	*/
	
    ret_val = nrf_bootloader_init(NULL);
	
    // Should never be reached.
    NRF_LOG_INFO("After main");
    NRF_LOG_FLUSH();
}

When debugging, I have to manually write to the s_dfu_settings.  I assume this would typically be set by the DFU.

- When I created the bootloader settings, I used an offset copy of the app.  So here, I copied the info from Bank 0 to Bank 1 to tell the firmware that there is a pending update to handle.

This works in getting me to app_activate(), the function that copies the pending firmware to the target address (0x26000).  However, in the debugger, it just skips over this function.  I checked the map file and the function is linked.  What am I doing wrong?

I am manually setting s_dfu_settings.  Can I write to this in the application?  Is there a preferred way to do this?

Parents Reply Children
No Data
Related