Hello,
I am using KDS 3.0 with SDK 1.3.
We have an external SRAM connect to MK60F120M device.
I follow the notes in the following link: External Ram and Nand flash , Relocating Code and Data Using the KDS GCC Linker File for Kinetis, https://community.nxp.com/message/546255?commentID=546255#comment-546255
When i declared the pointer to 0x60000000 to read / write raw data, the entire SRAM memory works fine. No issue.
Then, i decide to put a data structure on the external RAM.
I follow this example to relocate data to external RAM Relocating Code and Data Using the KDS GCC Linker File for Kinetis .
here is what i have on my linker file .ld:
MEMORY {
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x000001E8
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x000FFBF0
m_data (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000
m_data_20000000 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00010000
m_cfmprotrom (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_data_60000000 (RW) : ORIGIN = 0x60000000, LENGTH = 0x0200000
}
...
.mysection :
{
KEEP (*(.ExtRam))
} > m_data_60000000
Here is what i did in my example codes:
union TYPE {
uint8_t bArray[SRAMTESTBYTE];
uint64_t dWord[SRAMTESTBYTE >> 3];
};
__attribute__ ((section(".ExtRam"))) union TYPE TestSram;
After compiling it, i see the TestSram got assigned to external RAM space in the .map file as:
.m_data_20000000
0x20000000 0x0 load address 0x000021b8
0x20000000 . = ALIGN (0x4)
0x20000000 ___m_data_20000000_RAMStart = .
*(.m_data_20000000)
0x20000000 ___m_data_20000000_RAMEnd = .
0x20000000 . = ALIGN (0x4)
0x00000000 ___m_data_20000000_ROMSize = (___m_data_20000000_RAMEnd - ___m_data_20000000_RAMStart)
.mysection 0x60000000 0x960
*(.ExtRam)
.ExtRam 0x60000000 0x960 ./Sources/main.o
0x60000000 TestSram
0x60000960 . = ALIGN (0x4)
.bss 0x1fff0068 0x130c load address 0x000021c0
0x1fff0068 __START_BSS = .
0x1fff0068 PROVIDE (__bss_start__, __START_BSS)
Looks like it does what i told it to do.
When i connected the Segger debugger, it failed to connect and the program went straight ahead to run without able to stop.
please note that the program runs ok, just can not be break pointed.
I can see these failed message on KDS console:
WARNING: Failed to reset CPU. VECTRESET has confused core.
WARNING: CPU did not halt after reset.
WARNING: CPU did not halt after reset.
WARNING: S_RESET_ST not cleared
WARNING: Failed to reset CPU. VECTRESET has confused core.
WARNING: CPU did not halt after reset.
WARNING: CPU did not halt after reset.
WARNING: S_RESET_ST not cleared
ERROR: DAP error while reading AHB-AP IDR.
Resetting target
Halting target CPU...
If i removed this declaration: __attribute__ ((section(".ExtRam"))) union TYPE TestSram;, the program can halt right after main() function.
can someone please help me figure out what i have done wrong? I searched the forum but could not find a good example or a straight answer. This has been very frustrated.
Thanks,
Henry
Hello,
Finally, i think i figured out what happened after reading on the GNU GCC linker description. I post my answer here for someone who got stuck like me.
I tried to declared the external RAM similar to the internal lower RAM including the loading option. it seems to work ok. But once i put a large structure in the external RAM, the linker choked because it checked the size of total data larger than .text size.
Reading further, i concluded that the external RAM with large data structure can not be part of the .text that got loaded at initialization. I need (NOLOAD) as part of the external memory declaration. if i don't put it there, the CPU will try to load it and it seems that it can not find it and somehow messed up. The NOLOAD solve the problem.
/* ___m_data_60000000_ROMStart = ___ROM_AT + SIZEOF(.data) + SIZEOF(.m_data_20000000); */
.m_data_60000000 (NOLOAD) : /* AT(___m_data_60000000_ROMStart) */
{
. = ALIGN(4);
/* ___m_data_60000000_RAMStart = .; */
KEEP (*(.ExtRam)) /* This is an User defined section */
/* ___m_data_60000000_RAMEnd = .; */
. = ALIGN(4);
} > m_data_60000000
/* ___m_data_60000000_ROMSize = ___m_data_60000000_RAMEnd - ___m_data_60000000_RAMStart; */
Henry