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

FDS after Init show ok,but always waitting for ready

Hi,

I  want to add FDS basedon  dimming_serve example ,However,after fds_init(); it  not jump to fds_evt_handler but stop wait .

The below is my code:

static void initialize(void)
{
    __LOG_INIT(LOG_SRC_APP | LOG_SRC_ACCESS | LOG_SRC_BEARER, LOG_LEVEL_INFO, LOG_CALLBACK_DEFAULT);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "----- BLE Mesh Dimming Server Demo -----\n");

    ERROR_CHECK(app_timer_init());
    hal_leds_init();

    ble_stack_init();

#if MESH_FEATURE_GATT_ENABLED
    gap_params_init();
    conn_params_init();
#endif

    //mesh_init();

    uint32_t status = app_pwm_init(&PWM0, &m_pwm0_config, NULL);
    APP_ERROR_CHECK(status);
    m_pwm0_max = app_pwm_cycle_ticks_get(&PWM0);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "PWM max ticks: %d\n", m_pwm0_max);

    #if 1
    //FDS
    /* Register first to receive an event when initialization is complete. */
    status=fds_register(fds_evt_handler);//(void) fds_register(fds_evt_handler);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Status fds register is : %d\n",status);

    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Initializing fds...\n");

    status=fds_init();
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Status fds init is : %d\n",status);
    APP_ERROR_CHECK(status);

    /* Wait for fds to initialize. */
    wait_for_fds_ready();
    #if 0
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Available commands:\n");
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "- print all\t\tprint records\n");
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "- print config\tprint configuration\n");
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "- update\t\tupdate configuration\n");
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "- stat\t\tshow statistics\n");
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "- write\t\twrite a new record\n");
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "- delete\t\tdelete a record\n");
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "- delete_all\tdelete all records\n");
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "- gc\t\trun garbage collection\n");
    #endif

    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Reading flash usage statistics...\n");

    fds_stat_t stat = {0};

    status = fds_stat(&stat);
    APP_ERROR_CHECK(status);

    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Found %d valid records.\n", stat.valid_records);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Found %d dirty records (ready to be garbage collected).\n", stat.dirty_records);

    fds_record_desc_t desc = {0};
    fds_find_token_t  tok  = {0};

    status = fds_record_find(CONFIG_FILE, CONFIG_REC_KEY, &desc, &tok);

    if (status == FDS_SUCCESS)
    {
        /* A config file is in flash. Let's update it. */
        fds_flash_record_t config = {0};

        /* Open the record and read its contents. */
        status = fds_record_open(&desc, &config);
        APP_ERROR_CHECK(status);

        /* Copy the configuration from flash into m_dummy_cfg. */
        memcpy(&m_dummy_cfg, config.p_data, sizeof(configuration_t));

        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Config file found, updating boot count to %d\n", m_dummy_cfg.boot_count);

        /* Update boot count. */
        m_dummy_cfg.boot_count++;

        /* Close the record when done reading. */
        status = fds_record_close(&desc);
        APP_ERROR_CHECK(status);

        /* Write the updated record to flash. */
        status = fds_record_update(&desc, &m_dummy_record);
        APP_ERROR_CHECK(status);
    }
    else
    {
        /* System config not found; write a new one. */
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Writing config file...\n");

        status = fds_record_write(&desc, &m_dummy_record);
        APP_ERROR_CHECK(status);
    }

   #endif
}

And The Bellow is Log:

<t: 0>, main.c, 558, ----- BLE Mesh Dimming Server Demo -----
<t: 17925>, ble_softdevice_support.c, 124, RAM Start is 0x20002DA0
<t: 17945>, main.c, 575, PWM max ticks: 1600
<t: 17948>, main.c, 581, Status fds register is : 0
<t: 17950>, main.c, 583, Initializing fds...

How To solve this ? TKS in anvance.

Best Regards

Panda

Parents
  • Hi, 

    When adding fds (and fstorage) care should be taken to avoid overlapping the flash area occupied by the mesh flash manager module. We have a guide here about integrating Mesh into nRF5 SDK and vice versa. 

    How do you configure the fds module ? and fstorage module ? 

    Do you need to use fds or it's possible to use flash manager from mesh instead ? 

  • Hi Hung,

       I have read the guide and The bellow is what i did:

          1)set the Heap Size to 8192 bytes in project option

          2)in nrf_mesh_config_app.h file add include and define

          3)for the "optional changes"and "Flash palcement project files"part ,the code has alreadly been existed.

      I have enable FDS_ENABLED 1 in file sdk_config.h

      My purpose is to storage data  which  power on again after user's setting.

     The new Log:

     0> <t:          0>, main.c,  597, ----- BLE Mesh Dimming Server Demo -----
     0> <t:       8648>, ble_softdevice_support.c,  133, RAM Start is 0x20002DA0
     0> <t:       9257>, main.c,  570, Initializing and adding models
     0> <t:      14086>, main.c,  614, PWM max ticks: 1600
     0> <t:      14089>, main.c,  620, Status fds register is : 0
     0> <t:      14091>, main.c,  622, Initializing fds...
     0> <t:      14107>, main.c,  625, Status fds init is : 0
     0> <t:          0>, main.c,  597, ----- BLE Mesh Dimming Server Demo -----
     0> <t:       8656>, ble_softdevice_support.c,  133, RAM Start is 0x20002DA0
     0> <t:       9271>, main.c,  570, Initializing and adding models
     0> <t:      14092>, main.c,  614, PWM max ticks: 1600
     0> <t:      14095>, main.c,  620, Status fds register is : 0
     0> <t:      14097>, main.c,  622, Initializing fds...
     0> <t:      14107>, main.c,  625, Status fds init is : 0
     0> <t:          0>, main.c,  597, ----- BLE Mesh Dimming Server Demo -----
     0> <t:       8649>, ble_softdevice_support.c,  133, RAM Start is 0x20002DA0
     0> <t:       9272>, main.c,  570, Initializing and adding models
     0> <t:      14107>, main.c,  614, PWM max ticks: 1600
     0> <t:      14109>, main.c,  620, Status fds register is : 0
     0> <t:      14111>, main.c,  622, Initializing fds...
     0> <t:      14114>, main.c,  266, Event: FDS_EVT_INIT received (FDS_SUCCESS)
     0> <t:      14116>, main.c,  625, Status fds init is : 0
     0> <t:      14119>, main.c,  642, Reading flash usage statistics...
     0> <t:      14121>, main.c,  649, Found 0 valid records.
     0> <t:      14123>, main.c,  650, Found 0 dirty records (ready to be garbage collected).
     0> <t:      14127>, main.c,  686, Writing config file...
     0> <t:      14131>, main.c,  689, Write Status is : 0
     0> <t:          0>, main.c,  597, ----- BLE Mesh Dimming Server Demo -----
     0> <t:       8649>, ble_softdevice_support.c,  133, RAM Start is 0x20002DA0
     0> <t:       9237>, main.c,  570, Initializing and adding models
     0> <t:      14067>, main.c,  614, PWM max ticks: 1600
     0> <t:      14069>, main.c,  620, Status fds register is : 0
     0> <t:      14071>, main.c,  622, Initializing fds...
     0> <t:      14074>, main.c,  266, Event: FDS_EVT_INIT received (FDS_SUCCESS)
     0> <t:      14077>, main.c,  625, Status fds init is : 0
     0> <t:      14079>, main.c,  642, Reading flash usage statistics...
     0> <t:      14082>, main.c,  649, Found 0 valid records.
     0> <t:      14084>, main.c,  650, Found 1 dirty records (ready to be garbage collected).
     0> <t:      14087>, main.c,  686, Writing config file...
     0> <t:      14092>, main.c,  689, Write Status is : 0
    

    I have pressed  RESET Button four times. The process stopped after 'fds_record_write' this time.

    Could you give me some advices.Thanks.

    Best Regars,

    Panda

  • Hi Panda, 

    Could you provide the full project so I can test here ? I assume you are testing using SDK v3.2 ? 

    Which value you used for FDS_PHY_PAGES ? 

    Please make sure you erase full flash before testing. 

    Which backend for fstorage you used ? NRF_FSTORAGE_SD or NRF_FSTORAGE_NVMC ?

  • Hi Hung,

       I send you main codedimming_server_DFU.rar   ,Just extract it and place path :...\nrf5_SDK_for_Mesh_v3.2.0_src\examples\experimental_dimming .

       nRF SDK:     nRF5_SDK_15.3.0_59ac345

       mseh SDK:  nrf5_SDK_for_Mesh_v3.2.0_src 

       I used NRF_FSTORAGE_SD  fstorage (example default) .FDS_PHY_PAGES=3*1024/1024=3 (fds_internal_defs.h and sdk_config.h)

      If anything else is needed,Please tell me .Thank you for you help.

    Best Regards,

    Panda

  • Hi Panda, 

    I think we found what's wrong with the code.  You forgot to include INITIALIZE_USER_SECTIONS in the preprocessor definition. 

    Without that the section variable will not be initialized with the value defined in the section register. 

  • Hi Hung,

        I do as you said to include INITIALIZE_USER_SECTIONS , But it does not work ,the result just like before .Could you return back full project work well your side? Thanks in advance.

    Best Regards,

    Panda

       

  • Hi Panda, 

    Please find the .zip here. Make sure you trigger a reset after programming. 

    dimming_server_DFU.zip

Reply Children
  • Hi Hung,

      I tried just now .It sames that FDS write not ready..the log is bellow.

      RTT View:

      

     

     0> <t:          0>, main.c,  597, ----- BLE Mesh Dimming Server Demo -----
     0> <t:      12957>, ble_softdevice_support.c,  133, RAM Start is 0x20002DA0
     0> <t:      13494>, main.c,  570, Initializing and adding models
     0> <t:      18360>, main.c,  620, Status fds register is : 0
     0> <t:      18363>, main.c,  622, Initializing fds...
     0> <t:      18384>, main.c,  625, Status fds init is : 0
     0> <t:          0>, main.c,  597, ----- BLE Mesh Dimming Server Demo -----
     0> <t:       8406>, ble_softdevice_support.c,  133, RAM Start is 0x20002DA0
     0> <t:       8949>, main.c,  570, Initializing and adding models
     0> <t:      13812>, main.c,  620, Status fds register is : 0
     0> <t:      13815>, main.c,  622, Initializing fds...
     0> <t:      13831>, main.c,  625, Status fds init is : 0
     0> <t:          0>, main.c,  597, ----- BLE Mesh Dimming Server Demo -----
     0> <t:       8408>, ble_softdevice_support.c,  133, RAM Start is 0x20002DA0
     0> <t:       8941>, main.c,  570, Initializing and adding models
     0> <t:      13808>, main.c,  620, Status fds register is : 0
     0> <t:      13811>, main.c,  622, Initializing fds...
     0> <t:      13821>, main.c,  625, Status fds init is : 0
     0> <t:          0>, main.c,  597, ----- BLE Mesh Dimming Server Demo -----
     0> <t:       8408>, ble_softdevice_support.c,  133, RAM Start is 0x20002DA0
     0> <t:       8955>, main.c,  570, Initializing and adding models
     0> <t:      13810>, main.c,  620, Status fds register is : 0
     0> <t:      13812>, main.c,  622, Initializing fds...
     0> <t:      13815>, main.c,  266, Event: FDS_EVT_INIT received (FDS_SUCCESS)
     0> <t:      13818>, main.c,  625, Status fds init is : 0
     0> <t:      13820>, main.c,  642, Reading flash usage statistics...
     0> <t:      13823>, main.c,  649, Found 0 valid records.
     0> <t:      13825>, main.c,  650, Found 0 dirty records (ready to be garbage collected).
     0> <t:      13828>, main.c,  686, Writing config file...
     0> <t:      13833>, main.c,  689, Write Status is : 0
    

       I try another example using Keil5 IDE,It does work.However ,My project is based on SES ,So I have to solve it.Could you help me to find any other issues maybe without attention? Thank You. 

     Best Regards,

    Panda

  • Hi Panda, 
    Did you test with the light_switch_dimming_server_DFU_nrf52832_xxAA_s132_6_1_1.emProject project ? 

    I suspect there could be an issue that your ses doesn't use the flash_placement.xml for section. Could you try erasing the file and check if it built ? 

    I attached the .hex file please try testing this hex. Please make sure to do an erase all (nrfjprog --eraseall) before testing

    light_switch_dimming_server_DFU_nrf52832_xxAA_s132_6.1.1.hex

  • Hi Hung,

      I Used your giving hex file to program with nrfutil tool as follow:

     Then I pressed reset button two times,The Log shows it works ok.

     0> <t:          0>, main.c,  597, ----- BLE Mesh Dimming Server Demo -----
     0> <t:      13096>, main.c,  570, Initializing and adding models
     0> <t:      17869>, main.c,  620, Status fds register is : 0
     0> <t:      17872>, main.c,  622, Initializing fds...
     0> <t:      17893>, main.c,  625, Status fds init is : 0
     0> <t:      17939>, main.c,  266, Event: FDS_EVT_INIT received (FDS_SUCCESS)
     0> <t:          0>, main.c,  597, ----- BLE Mesh Dimming Server Demo -----
     0> <t:       8743>, main.c,  570, Initializing and adding models
     0> <t:      13522>, main.c,  620, Status fds register is : 0
     0> <t:      13525>, main.c,  622, Initializing fds...
     0> <t:      13527>, main.c,  266, Event: FDS_EVT_INIT received (FDS_SUCCESS)
     0> <t:      13530>, main.c,  625, Status fds init is : 0
     0> <t:      13533>, main.c,  642, Reading flash usage statistics...
     0> <t:      13535>, main.c,  649, Found 0 valid records.
     0> <t:      13538>, main.c,  650, Found 0 dirty records (ready to be garbage collected).
     0> <t:      13541>, main.c,  686, Writing config file...
     0> <t:      13546>, main.c,  689, Write Status is : 0
     0> <t:      13611>, main.c,  266, Event: FDS_EVT_WRITE received (FDS_SUCCESS)
     0> <t:      13614>, main.c,  286, Record ID:	0x0001<t:      13616>, main.c,  287, File ID:	0xF010<t:      13618>, main.c,  288, Record key:	0x7010<t:          0>, main.c,  597, ----- BLE Mesh Dimming Server Demo -----
     0> <t:       8734>, main.c,  570, Initializing and adding models
     0> <t:      13506>, main.c,  620, Status fds register is : 0
     0> <t:      13508>, main.c,  622, Initializing fds...
     0> <t:      13511>, main.c,  266, Event: FDS_EVT_INIT received (FDS_SUCCESS)
     0> <t:      13514>, main.c,  625, Status fds init is : 0
     0> <t:      13516>, main.c,  642, Reading flash usage statistics...
     0> <t:      13519>, main.c,  649, Found 1 valid records.
     0> <t:      13521>, main.c,  650, Found 0 dirty records (ready to be garbage collected).
     0> <t:      13525>, main.c,  669, Config file found, updating boot count to 0
     0> <t:      13618>, main.c,  266, Event: FDS_EVT_UPDATE received (FDS_SUCCESS)
    
    .

       However,when I rebuild the project you return back with above method using rebuild hex and test again ,It does not work right even i change the flash_placement.xml/flash_placement1.xml .

       I check my SEGGER Embedded Studio ,the version is 3.12  .Does it matter?

      If there are anyother advises,please tell me. Thank you.

    Best Regards,

    Panda

      

      

  • Hi Hung,

        A good news,I use SES Version  4.16a to rebuild the project,then erase and program  ,It does work OK now.I think this is where the problem exist.Thanks for your help all the time.

    Best Regards,

    Panda

  • Good to hear that it works now. I'm not sure why SES v3.12 didn't work, might be that it doesn't support Section or has the flash/section configuration slightly different. 

Related