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

FDS module with Mesh 4.0 issue

Hi,

I am trying to store data to flash with the support of FDS module while using Mesh. I'm currently using NRF52832 with NRF5 SDK 15.0 and Mesh 4.0.

I have tested flash_fds example from NRF5 SDK and everything looks good.

But when I integrate this example to lightswitch example in Mesh 4.0, I can't even init the module.

Please follow the code below for more details:

Initialize fds module before initializing mesh

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, "----- TouchPods V2.0 started -----\n");

    ERROR_CHECK(app_timer_init());

#if BUTTON_BOARD
    // ERROR_CHECK(hal_buttons_init(button_event_handler));
#endif

    ble_stack_init();
    bsp_fds_init();

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

    mesh_init();
}

Initialize fds function

void bsp_fds_init(void)
{
  ret_code_t rc;

  //NRF_LOG_INFO("FDS example started.")

  /* Register first to receive an event when initialization is complete. */
    (void) fds_register(fds_evt_handler);

    rc = fds_init ();
    APP_ERROR_CHECK(rc);

    /* Wait for fds to initialize. */
    wait_for_fds_ready();

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

  //NRF_LOG_INFO("Initializing fds...");

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

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

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

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

//      NRF_LOG_INFO("Config file found, updating boot count to %d.", m_dummy_cfg.boot_count);

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

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

      /* Write the updated record to flash. */
      rc = fds_record_update(&desc, &m_dummy_record);
      if ((rc != NRF_SUCCESS) && (rc == FDS_ERR_NO_SPACE_IN_FLASH))
      {
//          NRF_LOG_INFO("No space in flash, delete some records to update the config file.");
      }
      else
      {
          APP_ERROR_CHECK(rc);
      }
  }
  else
  {
      /* System config not found; write a new one. */
//      NRF_LOG_INFO("Writing config file...");

      rc = fds_record_write(&desc, &m_dummy_record);
      if ((rc != NRF_SUCCESS) && (rc == FDS_ERR_NO_SPACE_IN_FLASH))
      {
//          NRF_LOG_INFO("No space in flash, delete some records to update the config file.");
      }
      else
      {
          APP_ERROR_CHECK(rc);
      }
  }
}

Build config

FLASH_PH_START=0x0
FLASH_PH_SIZE=0x78000
RAM_PH_START=0x20000000
RAM_PH_SIZE=0xf000
FLASH_START=0x26000
RAM_START=0x20002df0

Even when I try to initialize fds module after mesh setup, everything is stopped at  wait_for_fds_ready() function in bsp_fds_init().

Thank you!

Parents Reply Children
Related