Write Data in flash and use same data address in secure bootloader file

Hello, 

I am working on nRF52832 with using SDK nRF5 15.3.0 version in Segger Embedded Studio.

I  have one application in which I have 64byte data received from BLE and store it in flash. This stored data I needs to use in secure bootloader project using stored data's flash address.

I sucessfully done data storing part in flash with reference to flashwrite example code. I am using last 2 page of my application area to store data (0x0007e000 starting address). Now I needs to use this data in secure bootloader file fatching from flash address. But In debugging time, I can see only 0x00 or 0xFF written in this area. Also I checked application data reserved area in secure bootloader file but not able to identify perticular range.

So kindly help me out which address range needs to use as a flash to store data and how to fetch data from flash in secure bootloader file. 

Parents
  • Hi,

    You can read any part of the flash from the bootloader, and that can be as simple as dereferencing a pointer. If for instance you wrote your 64 byte array at 0x00040000, that is where you would read it from. For instance, print the first bye like this:

    NRF_LOG_INFO("First byte: 0x%x", *(volatile uint8_t*)0x00040000);
    This should be straight-forward.
    There is another issue here, though. You write that you are using two pages starting at 0x0007e000, and that will not work with the bootloader. The last two pages are used for MBR params (second to last) and bootloader settings (very last), and cannot be used for anything else. You need to pick a page that is actually unused. See memory layout in the bootloader documentation for details.
  • Thank you for response. I tried same thing and I changed address. Now using 0x00071000 address everythings working fine and stored data from application file and read from bootloader. But I am getting another problem here is when I initialize flash and write the data at the begining of the code from application file(in main using flashwrite example), It is working well but as I said about my application previously, I want to use data comes from BLE So if I am receiving  64 byte data from BLE and after receiving data I am calling this function in main while loop and it is getting stuck at enabling flash write.

    NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen;      <<-- code get stuck here

    what is the cause of the problem?

  • You are not allowed to access the NVCM directly when using the SoftDevice. Instead, you have to use the SotDevice APIs for writing to flash. Either directly (sd_flash_write() / sd_flash_page_erase()) or fstorage, which abstracts away the differences between using a SoftDevice or not.

Reply Children
Related