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

  • It's hard - I did it for Crossworks which is basically the same thing, you really need to follow all the instructions including the map, crt0, or it's not going to work.

    This is a bit of a problem with the named sections introduced in the latest SDK. It feels as though they were designed by someone used to Keil which basically writes all the map file and code for you to implement them. There's been loads of issues with the gcc version, wrong linker scripts in abundance and the crt0 for that does work but it relies on the ordering of sections and I think that's going to break.

    For SES/Crossworks, you really have to implement the entire thing yourself for every named section you want.

    You can copy crt0.s into your project, just like you copy the flash placement scripts, and edit them and tell your project to use those. I've used Crossworks for ~3 years and it was hard to get right.

  • Hi RK, yes I amended the thumb_crt0.s since my original post, still no luck.

      ldr r2, =__rodata_end__
      bl memory_copy
      ldr r0, =__tdata_load_start__
      ldr r1, =__tdata_start__
      ldr r2, =__tdata_end__
      bl memory_copy
      ldr r0, =__fs_data_load_start__
      ldr r1, =__fs_data_start__
      ldr r2, =__fs_data_end__
      bl memory_copy
    

    It's a shame, it feels that SES is a little behind the curve to make it an IDE worth sticking with unless you want to become a real expert in it, which I don't really. So while it is quick and easy to get it up and running you quickly run into its limitations and it starts to feel it may have been better just to stick with Eclipse all along.

  • I think that's a bit unfair actually. Every IDE has a learning curve, they are all powerful IDEs, you have to spend time to get to know them. That's true with Visual Studio, it's true with Keil, it's true with Eclipse (which I detest) and it's true with this one. SES beats Eclipse hands down in just about every department, especially debugging which is native instead of that ridiculous gdbserver nonsense.

    The problem you're really facing here is that named sections like this are not a normal feature. It happens to be a 'cute trick' you can do with Keil easily but it doesn't translate well to other IDEs. I don't know, for instance, how easy it would be to do in native Eclipse, I suspect it wouldn't be much fun there either.

    The error message you're getting is telling you the fsdata is being placed in an unnamed section, so it's quite likely you have a mismatch between the section

  • (bloody comments resticted to 900 chars!) name in the code and the name in the placement file. They changed between the alpha and the release .. let me go find the last version I have, which works fine, it's around here somewhere.

  • Yes, you are right I am being a bit unfair. I was hoping SES would be a lot simpler right now. I know they are supporting SES more just recently and fstorage is in the experimental stage. I'm just throwing my toys out of the pram in a fit of pique.

Related