Linkscripts and how to put all data from a specific object file into a specific part of memory

cancel
Showing results for 
Search instead for 
Did you mean: 

Linkscripts and how to put all data from a specific object file into a specific part of memory

Jump to solution
978 Views
nxp16
Contributor III

Hi,

I have at least two object files whose data (.data and .bss) needs to go into SRAM_DTC, and not just their globals.  I have an app that uses USDHC.  If I build a version of this app with all data put in SRAM_DTC by default (using C/C++ Build >Settings > Linker > Managed Linker Script settings), it works perfectly.  However, if I build a version that puts all data into SRAM_OC by default, it doesn't work at all.  I think it's due to some things being accessed via DMA that need to be in DTC.  I know I can use __attribute__ section tags inside my code, but this is not helping.  I need to be able to be able to tell the linker to put an entire .o file of .data/.bss into DTC using a linker file (unless there is another way).  I tried this using the flexspi nor example as a base and modifying it thusly:

linkscripts/bss.ldt:

<#if memory.name=="SRAM_DTC">
*esp_sdio.o(.bss*)
*esp_slave.o(.bss*)
</#if>

data.ldt:

<#if memory.name=="SRAM_DTC">
*esp_sdio.o(.data*)
*esp_slave.o(.data*)
</#if>

main_bss.ldt:

*(EXCLUDE_FILE(*esp_sdio.o *esp_slave.o) .bss*)

main_data.ldt:

*(EXCLUDE_FILE(*esp_sdio.o *esp_slave.o) .data*)

But unfortunately, this causes problems with any other data where I've specifically used __attribute__ section to put things into DTC (they end up in OC instead!) in other object modules.

Can anyone help me with this?

Thanks!

0 Kudos
1 Solution
973 Views
nxp16
Contributor III

It turns out, that it's not just my code.  The sdmmc drivers provided with the sdk do NOT work at all if you default global data placement to SRAM_OC (which I have to do because my full app uses too much ram for DTC).  I was somewhat able to get this working by adding sections to the link settings but not fully yet:

sdio-ram-stuff-10-22-2020 6-14-02 PM.jpg

I will update here when I've figured it out fully.  I wonder if the same problem happens using SDRAM as the default?

View solution in original post

0 Kudos
2 Replies
957 Views
nxp16
Contributor III

I also had to add fsl_usdhc.o to the list.  Now I just have problems in my own code (well, ESP32's code).  Some of this code uses "buffers" on the stack/heap (uint32_ts and such).  I just have to figure out a good way to make those end up in DTC (because the stack/heap is in OC by default).

0 Kudos
974 Views
nxp16
Contributor III

It turns out, that it's not just my code.  The sdmmc drivers provided with the sdk do NOT work at all if you default global data placement to SRAM_OC (which I have to do because my full app uses too much ram for DTC).  I was somewhat able to get this working by adding sections to the link settings but not fully yet:

sdio-ram-stuff-10-22-2020 6-14-02 PM.jpg

I will update here when I've figured it out fully.  I wonder if the same problem happens using SDRAM as the default?

0 Kudos