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

reading a pre-programmed key from flash

Hi,

Reading from flash, an already programmed key, returns zero. Using sdk 12.1, sd s132_nrf52_3.0.0, nrf52832, and pstorage. The key is programmed after uploading the fw, image using jlink. Please advise if I am missing any other api calls or if pstorage api would be the recommended way (please provide pstorage sample to register two pages).

Thanks in advanced.

void read_key_from_flash(void)
{
    uint32_t err_code;
    uint32_t page = 118;            //offset 0x76000
    uint8_t  word_count = 8;        //number of 32 bits words read
    uint32_t data_array[8]={0x0};   //pointer to a RAM area where the found data will be written (32 bits aligned)

    err_code = ble_flash_page_read(page, data_array, &word_count);  //does not seem to update the buffer
    SEGGER_RTT_printf(0, "err_code=%d\n", err_code);                //error code is 5
    //APP_ERROR_CHECK(err_code);

    for (int i=0; i<8; i+=4)
    {
        SEGGER_RTT_printf(0, "Page %2d, data_array[%2d] = %.4X %.4X %.4X %.4X\r\n",
        page, i,
        data_array[i + 0],
        data_array[i + 1],
        data_array[i + 2],
        data_array[i + 3]);
    }
}
Related