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

fstorage memory allocation in Segger Embedded Studio

On fds_init() I am getting back an "Invalid Data" error code and I'm not sure why.

This is on pca10040, SDK11 and S132 v 2.0

I lifted the example mentioned here -> devzone.nordicsemi.com/.../ and put this in my UART example.

I am using Segger Embedded Studio and I amended the flash placement xml with address symbol and end symbols to enable it to compile.

I have also registered by event handler with fds_register which seems fine but moving to the next step of fds_init yields the error code 0x0000000b or Invalid Data. Tracing the cause back to fds.c this part is causing the fault:

  fds_init_opts_t init_opts = pages_init();

if (init_opts == NO_PAGES)
{
    return FDS_ERR_NO_PAGES;
}

I haven't looked beyond here as I thought I would pause and ask a question since it must be something simple I am missing.

Thanks a lot

[Update on above issue]

Ok, I think the issue is the allocation of memory in flash_placement.xml for Segger Embedded Studio. I have read RK's comment here -> devzone.nordicsemi.com/.../

Since the post above, I started a brand new project just focusing on fstorage using the example here as a base -> devzone.nordicsemi.com/.../ . I got the error "region `UNPLACED_SECTIONS' overflowed by 17 bytes" message

I then amended the flash_placement_xml as follows:

    <MemorySegment name="$(FLASH_NAME:FLASH)">
....
    <ProgramSection alignment="4" load="Yes" runin=".fs_data_run" name="fs_data" />
</MemorySegment>

<MemorySegment name="$(RAM_NAME:RAM);SRAM">
....
    <ProgramSection alignment="4" load="No" name=".fs_data_run" address_symbol="__start_fs_data"  end_symbol="__stop_fs_data" />
</MemorySegment>

[Update] I also updated thumb_crt0.o as RK suggested in the comment in the forum linked above. Unfortunately after making all of those changes I am still getting

> /Applications/SEGGER Embedded Studio 2.16a/gcc/arm-none-eabi/bin/ld: region `UNPLACED_SECTIONS' overflowed by 17 bytes

Is there any guidance on how to set up the flash placement when using fstorage? There are snippets in the forum, but it would be good if there was one "OK, this is what you need to do...", perhaps added to the tutorial on setting up Segger Embedded Studio. It seems the only thing holding SES back from being really good are issues around memory allocation.

Thanks

  • Thanks RK, useful stuff. When I looked at fds.o I saw .fs_data like this..

    section .fs_data
     00 00 00 00 00 00 00 00 00 00 00 00 03 FF 00 00  ................
    

    Is this setting the memory placement or is it doing something else?

  • yes that's the data for the section .fs_data. Except it isn't QUITE the data for that section, elsewhere, and you can't see it looking at the .o file in that viewer, you need to run one of the gnu utilities on it there's a hint for the linker to put the address of a function in there, the fs event handler function. So if you find that in the actual elf file (which takes a bit of hunting and following the addresses in the assembler) you'll see the data is something like

    00 00 00 00 00 00 00 00 xx xx xx xx 03 ff 00 00
    

    where xx xx xx xx is the address of the event handler which the linker hooked up before it wrote it. So the .o file is about 90% of the story.

    If you ever really get into this stuff it's worth buying 'Hopper' which is a disassembler. It's one of the few tools I've bought in recent years, it's great at pulling ELF files apart and seeing what they do.

Related