Storing firmware on DDR external memory

Hi, i’m trying to store a firmware on DDR external memory address so i’m typing the following commands:

Colibri iMX7 # ubi part ubi
Colibri iMX7 # fatload mmc 0:1 ${loadaddr} rpmsg_demo.elf
reading rpmsg_demo.elf
2763212 bytes read in 154 ms (17.1 MiB/s)
Colibri iMX7 # ubi write ${loadaddr} m4firmware ${filesize}
size > volume size! Aborting!
Colibri iMX7 # print filesize

Obviusly, the size of the file exceed the TCM memory (32KB). What is going wrong?? How can i change the destiny of the m4firmware to DDR address??

Thank you for your help.


Dear @vmoya

The destination where the .elf file gets loaded is defined in the .elf file itself. To move the code into DDR, you need to adjust the linker configuration file, before building the application.

Please note that moving the code to DDR will have a huge impact on performance. You might consider splitting the code and move critical parts into TCM.

Regards, Andy

Thank you Andy. I changed de linker configuration to MCIMX7D_M4_ddr.ld on properties of the project on eclipse and then i rebuild the project but the error persist. What can i do to resolve this problem??

Colibri iMX7 # fatload mmc 0:1 ${loadaddr} rpmsg_demo.elf
reading rpmsg_demo.elf
2828880 bytes read in 156 ms (17.3 MiB/s)
Colibri iMX7 # ubi write ${loadaddr} m4firmware ${filesize}
size > volume size! Aborting!

Thank you.

Dear @vmoya

Please analyze your .elf file with a tool such as the elfparser.
In the list of segment headers you see all memory ranges that your code and data will occupy.

Regards, Andy

Hi, thank you for your help. I analyzed the .elf file with elfparser and the memory addresses seems to be correct, i let you a capture.
Regards, Victor

Dear @vmoya

ubi write saves the whole .elf file into the UBI volume m4firmware. The size of this volume is defined in the image.json file, the default size is 896kB.

Solution 1: Brute Force

So what you could do is

  1. downloading the Linux demo image from our developer page,
  2. Modify the image.json file in order to increase the volume size for m4firmware
  3. flash this package using the Toradex Easy Installer.

After theses steps, you should be able to load your 2.7MB .elf file into the UBI volume.

Solution 2: Smart

The vast majority of your .elf file’s contents is just debug information which is not required to reside on the target.

apply the following command to your .elf file: [edit: this is the approach for the for DS-5 / ARM toolchain]

fromelf --strip=debug --elf --output=small.elf original.elf
fromelf --strip=debug --elf --output=small.elf original.axf

and you will end up with an .elf file of about 20kB.
This will easily fit into the UBI partition. It will also easily fit into the TCM memory at a much higher performance.

Side Note:
There is only one little mistery I cannot explain: the sections listed in your screenshot above sum up to a size of 474kB, while the U-Boot log reports a total size of 2.7MB. Maybe the screenshot just does not show the whole list.

Regards, Andy

Hi, I tried the the second solution typing in the post-build steps the fromelf command, but i receive this error:

make --no-print-directory post-build
fromelf --strip=debug --elf --output=small.elf iMX7D_M4_FreeRTOS_UNIVERSAL.elf
makefile:93: recipe for target 'post-build' failed
process_begin: CreateProcess(NULL, fromelf --strip=debug --elf --output=small.elf iMX7D_M4_FreeRTOS_UNIVERSAL.elf, ...) failed.
make (e=2): The system can't find the especified file
make[1]: [post-build] Error 2 (ignored)

I tried changing the output and input file and usingthe full path of files.

Considering to use the first option where i can find the image.json on the Colibri-iMX7_LXDE-Image_2.7.4 image?

Thank you.

Regards, Victor

Hi, Andy

It’s solved with the realease version. Thank you, you help me a lot.

Regards, Victor

Dear @vmoya

For Solution 1:

The image.json file is part of the Linux image download package for use with Toradex Easy Installer.

For Solution 2:

I still recommend to go for solution 2. There’s various ways to generate an .elf image without debug symbols. They also depend on the OS you are using on your development PC.

  • Build a release version (instead of the debug version) of the M4 firmware from beginning on. The linker flags are typically setup correctly in order to not include excessive debug symbols.
  • The fromelf tool is part of the (non-free) DS-5 / ARM compiler toolchain. If you have it on your PC, you can also run it manually, instead of inserting the command as an automated post-build-step.
  • The GNU toolchain contains the utilities objcopy and strip which can be used to remove debug symbols from the .axf / .elf file.

Regards, Andy