This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nrf_fstorage_write issue

Hi.

I have an issue that, If I power off Master and do save flash at Slave side together, the nrf_fstorage_is_busy(p_fs) return value always true .

When BLE is connectting, or is connectted, do save flash operation have no issue. Only power off Master will lead to the problem.

I can't understand how this occur, can you help to check this?

----------------------------------------------------------

step:

1.use 2 nrf52840-DK to test BLE

2. 1 board as Master(demo ble_central/ble_app_uart_c ) and another as Slave,

3. debug Slave. 

4. link Master to Slave via BLE, power off Master manually(switch), together do save flash(nrf_fstorage_write(), len maybe 100bytes) at Slave side

5. the Slave will hung up, because the nrf_fstorage_is_busy(p_fs) return value always true. My code is like below:

ret_val = nrf_fstorage_write(p_fs, page_addr, num_pages, p_param);// this return value is 0
while(nrf_fstorage_is_busy(p_fs));  // it will hung up here

Other information:

softdevice version: s140_nrf52_7.2.0_softdevice. or s140_nrf52_6.1.1_softdevice.

nordic SDK version: nRF5_SDK_15.3.0_59ac345 or nRF5_SDK_17.1.0_ddde560

BLE configuration:

#define MIN_CONN_INTERVAL_TICKS MSEC_TO_UNITS(20, UNIT_1_25_MS)
#define MAX_CONN_INTERVAL_TICKS MSEC_TO_UNITS(75, UNIT_1_25_MS)
#define SLAVE_LATENCY 0
#define CONN_SUP_TIMEOUT_TICKS MSEC_TO_UNITS(4000, UNIT_10_MS)

Parents
  • Hi

    Did you look at example?

    First you should erase page

    static void fs_event_handler(nrf_fstorage_evt_t * evt)
    {
        if (evt->result != NRF_SUCCESS){
            NRF_LOG_ERROR("Flash error");
    
        } else {
            NRF_LOG_INFO("Flash event success");
        }
    }
    
    NRF_FSTORAGE_DEF(nrf_fstorage_t m_fs) =
    {
        .evt_handler = fs_event_handler,
        .start_addr = 0x0007F000,
        .end_addr   = 0x000FF000,
    };
    
    void main(){	
    	nrf_fstorage_init(&m_fs, &nrf_fstorage_sd, NULL);
    	static uint32_t pages_to_erase = 1;
    	nrf_fstorage_erase( &m_fs, m_fs.start_addr, pages_to_erase, NULL);       						
    	uint16_t len = BYTE_NUM_WRITE;
    	static uint8_t bytes_to_flash[BYTE_NUM_WRITE] = {0};
    	nrf_fstorage_write(&m_fs, m_fs.start_addr, bytes_to_flash, len, NULL);
    }

Reply
  • Hi

    Did you look at example?

    First you should erase page

    static void fs_event_handler(nrf_fstorage_evt_t * evt)
    {
        if (evt->result != NRF_SUCCESS){
            NRF_LOG_ERROR("Flash error");
    
        } else {
            NRF_LOG_INFO("Flash event success");
        }
    }
    
    NRF_FSTORAGE_DEF(nrf_fstorage_t m_fs) =
    {
        .evt_handler = fs_event_handler,
        .start_addr = 0x0007F000,
        .end_addr   = 0x000FF000,
    };
    
    void main(){	
    	nrf_fstorage_init(&m_fs, &nrf_fstorage_sd, NULL);
    	static uint32_t pages_to_erase = 1;
    	nrf_fstorage_erase( &m_fs, m_fs.start_addr, pages_to_erase, NULL);       						
    	uint16_t len = BYTE_NUM_WRITE;
    	static uint8_t bytes_to_flash[BYTE_NUM_WRITE] = {0};
    	nrf_fstorage_write(&m_fs, m_fs.start_addr, bytes_to_flash, len, NULL);
    }

Children
  • Yes. I did erase first.

    Actually, it will hung up when erasing, because of the nrf_fstorage_is_busy(p_fs) return value always true.

    Here is the normal process log.

    But if I power off Master and do save flash at Slave promptly, it will error.

    Here is the error log.

    My erase and write function like below picture.

    The point is that if BLE is not connectted, or is connectting, or is connectted, do erase or write operation has no issue. Only power off Master then do erase and write operation promptly will lead to the problem.

Related