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

cant access flash when bootloader is present

i am trying to use flash to store and read data. I am able to do that when there is only softdevice and application. but when there is bootloader code get stuck. softdevice using is s130 2.0.1. i used keil to generate hex . softdevice and bootloader(buttonless) hex are loaded with nrfgo then app is loaded using nrfconnect(dfu). to give command to flash data given by uart(pin 0.1 and p0.2) . ble_flash.c function i am using to access flash.

NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Een << NVMC_CONFIG_WEN_Pos);

this is line used before erasing the page. i had put two led turn on instructions before and after this line and came to the conclusion that after this line execute code seem stuck somewhere.

cant figure out why?. because without bootloader ,code works.

Parents Reply
  • added this in ble_stack_init

    err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
    APP_ERROR_CHECK(err_code);

    then,

    static void sys_evt_dispatch(uint32_t sys_evt)
    {
    if(sys_evt == NRF_EVT_FLASH_OPERATION_SUCCESS)
    {
    printf("\r\nerased\r\n");
    }
    else if(sys_evt == NRF_EVT_FLASH_OPERATION_ERROR)
    {
    printf("\r\nerror\r\n");
    }

    }

    when erase execute,

    err_code_ = sd_flash_page_erase(NRF_FICR->CODESIZE - 20);

    i get, 

    err_code = NRF_SUCCESS  and  event of NRF_EVT_FLASH_OPERATION_SUCCESS

    but at   

    err_code = sd_flash_write((uint32_t *)(NRF_FICR->CODESIZE) - 20,data_32_1,2);

    i get,

    err_code = NRF_ERROR_FORBIDDEN and no event in sys_evt_dispatch

    why i get forbidden error while writing and not in erase?

    for source i am using  

    uint32_t const data_32_1[6] = {'@','@','@','@','@','@'};

Children
Related