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

unabale to erase/write a flash memory after ble_stack_init()

Dear !!

Good day!!

unable to erase/write a flash memory after ble_stack_init() if writ e the event to flash memory , <error> app: Fatal error is coming kindly suggest me what is the that problem, and if it is write flash memory before the ble_stack_init(), it writing succefully. 

Note; Im using ble_app_templet projects for nrf52840 

Regards

Chandru.A

Parents
  • Hi,

    Could you share the code that shows how you write to flash?

    Also, specify where in your program the error is returned?

    regards

    Jared

  • Dear sir,

    FYR,

    Sir here Im getting


    NRF_BREAKPOINT_COND; fatal error
    // On assert, the system can only recover with a reset.

    here the code

    Note: When i call before call it is working as fine . plz tell me sir what is the solutions for it


    nvm_write();

    ble_stack_init();

    int main(void)
    {

    //nrf_delay_ms(2000);
    bool erase_bonds;
    // uint8_t ble_name[20]="WELCOME GYUS";
    // p_addr =(uint8_t *)l_addr; // retrive thge data 1byte

    uint32_t l_addr = 0x000ff000; // Last page start address 255

    uint8_t * p_addr =(uint8_t *)l_addr; // retrive thge data 1byte

    //uint8_t k[MAX_BUFF];
    uint8_t k[] ="GOOD_DAY!!";

    log_init();
    timers_init();
    buttons_leds_init(&erase_bonds);
    power_management_init();


    ble_stack_init();
    nvm_write();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();
    peer_manager_init();

    nrf_gpio_cfg_output(RED_LED);
    nrf_gpio_cfg_output(GREEN_LED);
    nrf_gpio_cfg_output(BLUE_LED);
    nrf_gpio_pin_set(BLUE_LED);
    nrf_gpio_pin_set(GREEN_LED);
    nrf_gpio_pin_set(RED_LED);

    saadc_init();


    // Start execution.
    NRF_LOG_INFO("BLE_APPLICATIONS_STARTED.");
    /* application_timers_start(); // for other service
    for (uint32_t i = 0; i < strlen(tx_data); i++) // tx_data conatains the welcome message
    {
    while (app_uart_put(*(tx_data+i)) != NRF_SUCCESS); // transimit to PC this NRF success will be wait for '1' byte transmitted.
    nrf_delay_ms(100);
    //printf("\r\n Transmitted=%c\n\r",tx_data[i]);
    //nrf_delay_ms(500);
    }*/

    advertising_start(erase_bonds);
    // Enter main loop.
    for (;;)
    {
    idle_state_handle();
    }
    }

    // called fun

    void nvm_write()
    {
    NRF_LOG_INFO("Application started");
    NRF_LOG_INFO("Erasing page 255...");
    nrf_nvmc_page_erase(l_addr); // erase the page
    nrf_delay_ms(500);
    // show the message
    NRF_LOG_INFO("Page erased successfully");
    // inform user about the step being taken
    NRF_LOG_INFO("Writing the value to the given address");
    // nrf_nvmc_write_words(l_addr,k, sizeof(k));
    nrf_nvmc_write_bytes(l_addr,k, sizeof(k));
    nrf_delay_ms(500);
    // show the message
    NRF_LOG_INFO("Word is written to the flash");
    // Read the flash word by word and display the data over log
    for(int i = 0; i<sizeof(k); i++)
    {
    NRF_LOG_INFO("The Data read from flash is: %c", *(p_addr + i)); //using an arithmatic pointer

    }
    }

  • Hello.

    A bit late but still.

    This problem may happen if you use Bootloader, which sets protection on some memory regions, like MBR, SD and Bootloader itself. It sets protection - and you can not clear those bits any more, until new reset happens.

    Solution: got to the Bootloader's source code, eliminate setting this protection, re-build, flash new bootloader.

    Registers: BPROT

Reply Children
No Data
Related