Hi,
I try to reconfigure SDK example project "driver_examples/csi/csi_rgb565" to use different memory layout. I can not do this and I need help.
My target configuration is to have majority of code in internal ITC memory, all read only data in internal DTC memory, stack in internal DTC memory, global variables in internal OC memory, big camera RBB565 buffers in external SDRAM, heap in external SDRAM. I am following steps in manual "MCUXpresso IDE User Guide>Memory Configuration and Linker Scripts>FreeMarker Linker Script Template Examples/Relocating majority of application into RAM".
This is my MCU settings:
This is my managed linker script configuration:
I also create "linkscripts" folder with three files:
data.ldt
<#if memory.alias=="RAM2">
*(.text*)
. = ALIGN(${text_align});
</#if>
<#if memory.alias=="RAM">
*(.rodata .rodata.* .constdata .constdata.*)
. = ALIGN(${text_align});
</#if>
*(.data.$${memory.alias}*)
*(.data.$${memory.name}*)
main_rodata.ldt
*startup_*.o (.rodata .rodata.* .constdata .constdata.*)
. = ALIGN(${text_align});
main_text.ldt
*startup_*.o (.text.*)
*(.text.main)
*(.text.__main)
I am able to compile my project:
Memory region Used Size Region Size %age Used
BOARD_FLASH: 41336 B 64 MB 0.06%
SRAM_DTC: 8604 B 128 KB 6.56%
SRAM_ITC: 25596 B 128 KB 19.53%
SRAM_OC: 436 B 256 KB 0.17%
BOARD_SDRAM: 1 MB 32 MB 3.13%
Finished building target: evkbimxrt1050_csi_rgb565_2.axf
But after I upload program binary it to my IMXRT1050-EVKB board it stop with this error:
What I am doing wrong?
If I use the same configuration but without this:
<#if memory.alias=="RAM2">
*(.text*)
. = ALIGN(${text_align});
</#if>
Then it is working. So, the only problem is ITC memory, rest of my memory layout seems to be functional.
In original linker script file "MIMXRT1052xxxxx_flexspi_nor.ld" is the SDRAM memory splited into two regions. First have 30MB and second 2MB. Camera RGB565 buffer is in smaller 2MB region.
Why is SDRAM splitted into two regions?
So the main issue here is that the function SystemInit() which called from near the start of the reset handler is being relocated into RAM, but is called before the copy from flash to RAM takes place (so the code isn't actually in the RAM yet to excute).
You can fix this by changing main_text.ldt and main_rodata.ldt such that SystemInit() is left to run from flash, thus:
main_text.ldt:
*startup_*.o (.text.*)
*system_*.o (.text.*)
*(.text.main)
*(.text.__main)
main_rodata.ldt:
*startup_*.o (.rodata .rodata.* .constdata .constdata.*) *system_*.o (.rodata .rodata.* .constdata .constdata.*) . = ALIGN(${text_align});
After making this change, do a full clean before then doing a build - to make sure that the changes to the template files are picked up by the managed linker script system (and you might want to check the generate .ld files afterwards - just to make sure).
I would also suggest mass erasing the flash and powering the board down and back up again before debugging the rebuilt project.
Finally, if you haven't already read it, I would suggest looking through our blog article for hints and tips on using this device with MCUXpresso IDE : Overview of using the MIMXRT1050-EVK(B) with MCUXpresso IDE
Regards,
MCUXpresso IDE Support
It is working!
Thanks!
Please can you clean your project, then export it and attach to this thread [using "Quickstart Panel -> Export project(s) to archive (.zip)"].
If not, please at least post the actual linker scripts generated for your project, along with the map file.
The reason that SDRAM is probably split in two is because the two sections are set up different in the MPU settings (one part cached, the other not cached).
Regards,
MCUXpresso IDE Support
Hi,
I did not figure out how to attach zip file directly into this thread.
Here is my project:
https://ulozto.net/!ZHNug52GAJai/project-zip
Regards,
Peter.
Hello Peter Janco,
- I also refer to the manual "MCUXpresso IDE User Guide" relocate majority of application to RAM,
it failed , I have reported it to expert team . I will reply you .ASAP after get the answer.
- "Why is SDRAM splitted into two regions?" -> Use a stand alone space placing the two buffers
"s_cameraBuffer" and "s_lcdBuffer".
BR
Alice