Hello,
I am trying several memory mapping strategies for an application I developed using MCUXpresso and evmimxrt1170_new_project_cm7 as a template. When I tried to use the external SDRAM for global data allocation (first screenshot), I got some memory-related faults even before main() could run.
I took a look at evkmimxrt1170_semc_cm7 and, while it worked, it configures SDRAM inside main() and I suppose I need it configured inside ResetISR(), before .data is copied to their assigned location and .bss space is cleared. I tried to change SEMC and SDRAM configuration functions for them to run in ResetISR() but, given my lack of experience, this did not work, either - some memory writes (the first or the last of each provided memory test function) get corrupted for some reason.
Is there any available example where the SDRAM is already set up in ResetISR(), so that I can simply link desired sections to it?
Thanks,
Ricardo
Hi,
I enable 'link to RAM', but it works well. please see below comments.
SEMC SDRAM Example Start!
SEMC SDRAM Memory 32 bit Write Start, Start Address 0x80000000, Data Length 4096 !
SEMC SDRAM Read 32 bit Data Start, Start Address 0x80000000, Data Length 4096 !
SEMC SDRAM 32 bit Data Write and Read Compare Start!
SEMC SDRAM 32 bit Data Write and Read Compare Succeed!
SEMC SDRAM Memory 16 bit Write Start, Start Address 0x80000000, Data Length 4096 !
SEMC SDRAM Read 16 bit Data Start, Start Address 0x80000000, Data Length 4096 !
SEMC SDRAM 16 bit Data Write and Read Compare Start!
SEMC SDRAM 16 bit Data Write and Read Compare Succeed!
SEMC SDRAM Memory 8 bit Write Start, Start Address 0x80000000, Data Length 4096 !
SEMC SDRAM Read 8 bit Data Start, Start Address 0x80000000, Data Length 4096 !
SEMC SDRAM 8 bit Data Write and Read Compare Start!
SEMC SDRAM 8 bit Data Write and Read Compare Succeed!
SEMC SDRAM Example End.
Hello,
I noticed that "Link to RAM" will map code and data sections to the TCMs and I can link data to BOARD_SDRAM if I choose it for "Global data placement". I have a few questions on this:
- When main() is called, a global I declared is already mapped to BOARD_SDRAM. Since APP_ConfigMPU() and BOARD_InitSEMC() are called inside main(), how was this global copied to BOARD_SDRAM before main() was called?
- How can I specify memory placement for my .text and .rodata sections without manually modifying the linker script?
Thanks,
Ricardo
Sorry for the delay, please kindly see below comments.
1. You can refer to 'startup/startup_mimxrt1176_cm4.c' to find how it works before main function, e.g,
void ResetISR(void) {
// Disable interrupts
SystemInit();
//
// Copy the data sections from flash to SRAM.
//
// Copy the data sections from flash to SRAM.
while (SectionTableAddr < &__data_section_table_end) {
LoadAddr = *SectionTableAddr++;
ExeAddr = *SectionTableAddr++;
SectionLen = *SectionTableAddr++;
data_init(LoadAddr, ExeAddr, SectionLen);
}
...
__main();
...
}
2. If you don't want to modify linker manually, please try with below.
a. By using __attribute__((section("...")))
For example:
__attribute__((section(".text.SRAM"))) void myFunction(void) {
// Function implementation
}
__attribute__((section(".rodata.SRAM"))) const int myConstArray[] = {1, 2, 3, 4};
b. By using #pragma
#pragma location=".text.SRAM"
__code void myFunction(void)
{
// Function implementation
}
#pragma location=".rodata.SRAM"
__code const int myConstArray[] = {1, 2, 3, 4};