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

Migrating from Keil to SES - Error with DFU INIT service

Hello Guys,,

I am trying to migrate my project form keil to segger embedded studio. My product is based on sdk 12.2.0, using softdevice s130 on nrf51822.
I searched for all the posts that helped in migrating to SES and able to successfully build my application project. But when flashing the build to my board
it is getting stuck at nrf_dfu_flash_erase function in dfu_init

I tried debugging and it is giving the error FS_ERR_INVALID_CFG in check_config(p_config) function. searched for the solution in the forum posts but nothing helped so far.
please help us to resolve as we are nearing production.


I am attaching my flash placement file for your reference

<!DOCTYPE Linker_Placement_File>
<Root name="Flash Section Placement">
  <MemorySegment name="$(FLASH_NAME:FLASH)">
    <ProgramSection alignment="0x100" load="Yes" name=".vectors" start="$(FLASH_START:)" />
    <ProgramSection alignment="4" load="Yes" name=".fs_data" />
    <ProgramSection alignment="4" load="Yes" name=".init" />
    <ProgramSection alignment="4" load="Yes" name=".init_rodata" />
    <ProgramSection alignment="4" load="Yes" name=".text" />
    <ProgramSection alignment="4" load="Yes" name=".dtors" />
    <ProgramSection alignment="4" load="Yes" name=".ctors" />
    <ProgramSection alignment="4" load="Yes" name=".rodata" />
    <ProgramSection alignment="4" load="Yes" name=".ARM.exidx" address_symbol="__exidx_start" end_symbol="__exidx_end" />
    <ProgramSection alignment="4" load="Yes" runin=".fast_run" name=".fast" />
    <ProgramSection alignment="4" load="Yes" runin=".data_run" name=".data" />
    <ProgramSection alignment="4" load="Yes" name=".bootloaderSettings" />
    <ProgramSection alignment="4" load="Yes" runin=".tdata_run" name=".tdata" />
    <ProgramSection alignment="4" keep="Yes" load="Yes" runin=".fs_data_run" name=".fs_data" />
  </MemorySegment>
  <MemorySegment name="$(RAM_NAME:RAM);SRAM">
    <ProgramSection alignment="0x100" load="No" name=".vectors_ram" start="$(RAM_START:$(SRAM_START:))" />
    <ProgramSection alignment="4" load="No" name=".fast_run" />
    <ProgramSection alignment="4" load="No" name=".data_run" />
    <ProgramSection alignment="4" load="No" name=".bss" />
    <ProgramSection alignment="4" load="No" name=".tbss" />
    <ProgramSection alignment="4" load="No" name=".tdata_run" />
    <ProgramSection alignment="4" load="No" name=".non_init" />
    <ProgramSection alignment="4" size="__HEAPSIZE__" load="No" name=".heap" />
    <ProgramSection alignment="8" size="__STACKSIZE__" load="No" place_from_segment_end="Yes" name=".stack" />
    <ProgramSection alignment="8" size="__STACKSIZE_PROCESS__" load="No" name=".stack_process" />
    <ProgramSection alignment="4" size="__STACKSIZE__" load="No" name=".fs_data_run" address_symbol="__start_fs_data"  end_symbol="__stop_fs_data" />
    <ProgramSection alignment="4" keep="Yes" load="No" name=".fs_data_run" address_symbol="__start_fs_data"  end_symbol="__stop_fs_data" />
  </MemorySegment>
  <MemorySegment name="$(FLASH2_NAME:FLASH2)">
    <ProgramSection alignment="4" load="Yes" name=".text2" />
    <ProgramSection alignment="4" load="Yes" name=".rodata2" />
    <ProgramSection alignment="4" load="Yes" runin=".data2_run" name=".data2" />
  </MemorySegment>
  <MemorySegment name="$(RAM2_NAME:RAM2)">
    <ProgramSection alignment="4" load="No" name=".data2_run" />
    <ProgramSection alignment="4" load="No" name=".bss2" />
  </MemorySegment>
</Root>

  • Thanks for the screenshots. 

    In the disassembly I can see that the FS_SECTION_VARS_START_ADDR, which is loaded into r3 is 0x20005010 (  __fs_data_run_start__) and that FS_SECTION_VARS_END_ADDR is 0x20005430 ( __fs_data_run_load_end__). The config variable is 0x0001b0c0, which is flash and not RAM. 

    The fs_dfu_config variable of type fs_config_t should be a static and should be placed in RAM, not flash. 

     You need change

     <ProgramSection alignment="4" load="Yes" name=".fs_data" />

    under FLASH MemorySegment to the following to ensure that in runs in RAM

      <ProgramSection alignment="4" keep="Yes" load="Yes" name=".fs_data"  inputsections="*(.fs_data*)" runin=".fs_data_run"/>

    I also see that you have two sections with name fs_data_run in the RAM memory Segments

    <ProgramSection alignment="4" size="__STACKSIZE__" load="No" name=".fs_data_run" address_symbol="__start_fs_data" end_symbol="__stop_fs_data" />
    <ProgramSection alignment="4" keep="Yes" load="No" name=".fs_data_run" address_symbol="__start_fs_data" end_symbol="__stop_fs_data" />

    Can you try to remove the first one?

    -Bjørn

  • Thanks for the quick reply Bjorn.

    I made all the changes you have mentioned and debugged. This time it is giving FDS_ERR_NO_PAGES in the pages_init function.

    i am attaching the screenshot of the debug trace for your reference.

    Waiting for your quick reply.

    Best,

    Krish

  • /**@brief   Function for initializing the module.
     *
     * This function initializes the module and installs the file system (unless it is installed
     * already).
     *
     * This function is asynchronous. Completion is reported through an event. Make sure to call
     * @ref fds_register before calling @ref fds_init so that you receive the completion event.
     *
     * @retval  FDS_SUCCESS         If the operation was queued successfully.
     * @retval  FDS_ERR_NO_PAGES    If there is no space available in flash memory to install the
     *                              file system.
     */
    ret_code_t fds_init(void);

    See function brief above: FDS_ERR_NO_PAGES -  If there is no space available in flash memory to install the file system.

    How large is your application? There needs to be atleast two empty flash pages at the end of flash (if no bootloader is used) or two empty flash pages below the bootloader if a bootloader is present. 

  • Ok, i got it. It it is the case, then what will be the solution, my application uses bootloader to support DFU. please suggest what i can do to resolve this?

    But does compiling the application in SES adds to the storage?

    because the same code is working fine on my board when compiled in keil and flashed on to the device.

    Thanks in advance.

    Best,

    Krish

  • KrishNa said:

    Ok, i got it. It it is the case, then what will be the solution, my application uses bootloader to support DFU. please suggest what i can do to resolve this?

    But does compiling the application in SES adds to the storage?

    That depends on the compiler settings used.  Can you upload the .map file for your application as well as post the Code > Linker > Section Placement Macros you are using in your project?

Related