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

Flash write

Hello,

I'm trying to write value to a specified address with ble_flash_page_write .

I'm using ble_flash_page_write after ble disconnect event. I've tested different page address to be sure i'm not writing on application or s110 areas and page address are multiples of 4.

At execution, an Hard fault occur at the ble_flash_page_write line... Any idea about this error ? Is there others solutions to write values to a precise flash address ?

int32_t page = 200;
uint8_t word_count = 1;
uint32_t data_array[2]={0x81ABACAB};
data_array[1] = 0x81ABACAB;
		
err_code = ble_flash_page_write(page,(uint32_t *) &data_array,1);
APP_ERROR_CHECK(err_code);
  • Hi,

    I'm using finally pstorage Raw mode. My app (bluetooth modules) works fine( no err_code, no crash, no hard fault)... But my pstorage callback is never executed...(debug led 1 never set). Does anyone know were it can come from ?

    
    uint32_t		err_code;
    uint8_t		ota_code[4]; 	
    		
    ota_code[0] = 0x81;
    ota_code[1] = 0xAB;
    ota_code[2] = 0xAC;
    ota_code[3] = 0xAB;
    		
    		
    pstorage_handle_t            handle;
    pstorage_module_param_t            param;
    uint32_t page_number = NRF_FICR->CODESIZE-30;
    uint32_t page_base_address = (uint32_t) (page_number * NRF_FICR->CODEPAGESIZE);
    		
    param.block_size = 0x0010 ;
    param.block_count = 1;
    param.cb = ota_cb_handler;
    		
    handle.block_id = page_base_address; //bloc address
    		
    //registration
    err_code = pstorage_raw_register(¶m, &handle);
    APP_ERROR_CHECK(err_code);
    
    handle.block_id = page_base_address; //definition de l'adresse du bloc
    
    //clear
    err_code = pstorage_raw_clear(&handle,0x0010);
    APP_ERROR_CHECK(err_code);
    				
    //store
    err_code = pstorage_raw_store(&handle,ota_code,4,0);
    APP_ERROR_CHECK(err_code);
    
    nrf_gpio_pin_set(LED_0); // debug led
    
    
    
    
    static void ota_cb_handler(pstorage_handle_t  * handle,
                                 uint8_t          	op_code,
                                 uint32_t         	result,
                                 uint8_t         		* p_data,
                                 uint32_t         	data_len)
    {
    		
    	APP_ERROR_CHECK(result);
    	nrf_gpio_pin_set(LED_1);	//debug led													 
     }
    
    
  • I've tested with classic pstorage mode ( without raw mode) My pstorage callback is never executed .

  • Hi Thomas,

    Can you confirm you have registered for system events and are passing it on to pstorage module?

    Below the code that may be useful you..!

    
    
    
    /**@brief Function for dispatching a system event to interested modules.
     *
     * @details This function is called from the System event interrupt handler after a system
     *          event has been received.
     *
     * @param[in]   sys_evt   System stack event.
     */
    static void sys_evt_dispatch(uint32_t sys_evt)
    {
        pstorage_sys_event_handler(sys_evt);
    }
    
    /**@brief BLE stack initialization.
     *
     * @details Initializes the SoftDevice and the stack event interrupt.
     */
    static void ble_ant_stack_init(void)
    {
        // Initialize SoftDevice
        SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);
        
        // Subscribe for BLE events.
        uint32_t err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
        APP_ERROR_CHECK(err_code);
        
        // Register with the SoftDevice handler module for BLE events.
        err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
        APP_ERROR_CHECK(err_code);
    }
    
    
    

    Hope this helps!

    Regards, Krishna

Related