Reading application area of flash

I am trying to implement BLE DFU protocol on my nrf52840 MCU to FOTA  the nrf52 devices nearby. I was able to do firmware update by reading the firmware hex stored in RAM and updating the nearby devices by doing device-to-device BLE DFU.

I now want to read application area of flash to read each byte and transmit over BLE to do DFU. Is it possible to read application area of flash in application or bootloader mode?

  • Hi

    You can read the flash directly, simply by creating a const pointer with a value in the flash address region (0x0-0x100000) and dereferencing the pointer. 

    Small example:

    // Copy 16 words from flash into RAM, starting at flash address 0x10000
    const uint32_t *flash_ptr = 0x10000;
    uint32_t data_from_flash[16];
    for(int i = 0; i < 16; i++)
    {
        data_from_flash[i] = *flash_ptr++;
    }

    Best regards
    Torbjørn

Related