This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Write firmware to bank 1 from application

Hello.

I would like to know if its possible to preform a firmware update from the application itself like so:

1. Getting the firmware via UART in chunks of 2k (from a GSM modem).

2. Writing each chunk to Bank1.

3. Reset to DFU mode that will check if the data in Bank1 is valid.

4. If so, copy it to Bank0 and start the application.

If its possible, I would like to know how to write directly to bank1 from my application and how to reset to that DFU mode.

We are currently using SDK15.

Thanks and all the best,

Ofer.

Parents Reply Children
  • Hi Vidar,

    I'm trying to write my .bin file to bank1 but I get an error.

    Here is what I did:

    Init: 

    nrf_dfu_flash_init(true)
    uint32_t bank1_addr_offset = nrf_dfu_bank1_start_addr();

    Getting first 4096 bytes chunk:

    nrf_dfu_flash_erase(bank1_addr_offset, 1, NULL);
    nrf_dfu_flash_store(bank1_addr_offset, chunk, chunk_len, NULL);
    bank1_addr_offset += chunk_len;

    The nrf_dfu_flash_erase prints: nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x00026000, len=1 pages), queue usage: 0

    And the error happens in nrf_dfu_flash_store: <error> app: SOFTDEVICE: INVALID MEMORY ACCESS

    Can you please tell me what I'm doing wrong?

    My main goal is that once all the chunks are written to bank1 is to update the settings with the .dat file and reboot.

    Thank you,

    Ofer.

  • Hi Ofer,

    Your current application is starting at address 0x26000 in flash (ie bank 0 start address), so Bank 1 should have been placed higher up in flash.

    Have you programmed the Bootloader settings page? The s_dfu_settings.bank_0.image_size field should contain the size of your app so nrf_dfu_bank1_start_addr() can correctly determine the bank 1 address.

  • Hi Vidar,

    I'm note sure I understand what you mean. I didn't programmed the Bootloader setting page yet. I get bank1 address from: 

    uint32_t nrf_dfu_bank1_start_addr(void)
    {
        uint32_t bank0_addr = nrf_dfu_bank0_start_addr();
        return ALIGN_TO_PAGE(bank0_addr + s_dfu_settings.bank_0.image_size);
    }

    Doesn't this already pointing to the start location of bank1?

  • I've added:

     

      <MemorySegment name="bootloader_settings_page" start="0x000FF000" size="0x1000">
    	<ProgramSection alignment="4" keep="Yes" load="No" name=".bootloader_settings_page" address_symbol="__start_bootloader_settings_page" end_symbol="__stop_bootloader_settings_page" start = "0x000FF000" size="0x1000" />
      </MemorySegment>
      <MemorySegment name="mbr_params_page" start="0x000FE000" size="0x1000">
    	<ProgramSection alignment="4" keep="Yes" load="No" name=".mbr_params_page" address_symbol="__start_mbr_params_page" end_symbol="__stop_mbr_params_page" start = "0x000FE000" size="0x1000" />
      </MemorySegment>
      <MemorySegment name="ot_flash_data" start="0xdc000" size="0x4000">
    	<ProgramSection alignment="4" keep="Yes" load="Yes" name=".ot_flash_data" address_symbol="__start_ot_flash_data" end_symbol="__stop_ot_flash_data" start = "0xdc000" size="0x4000" />
      </MemorySegment>
      <MemorySegment name="uicr_bootloader_start_address" start="0x00000FF8" size="0x4">
    	<ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_bootloader_start_address" address_symbol="__start_uicr_bootloader_start_address" end_symbol="__stop_uicr_bootloader_start_address" start = "0x00000FF8" size="0x4" />
      </MemorySegment>
      <MemorySegment name="uicr_mbr_params_page" start="0x00000FFC" size="0x4">
    	<ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_mbr_params_page" address_symbol="__start_uicr_mbr_params_page" end_symbol="__stop_uicr_mbr_params_page" start = "0x00000FFC" size="0x4" />
      </MemorySegment>
    </Root>
    

    To flash_placement.xml and and bootloader_settings_page RX 0x000FF000 0x1000;uicr_mbr_params_page RX 0x00000FFC 0x4;mbr_params_page RX 0x000FE000 0x1000

    to the Memory segments.

    Now the bank1 address is 0x72000 but the error: <error> app: SOFTDEVICE: INVALID MEMORY ACCESS still appears.

Related