rt1050 load text code to sdram ok, but execute fail in main()!

cancel
Showing results for 
Search instead for 
Did you mean: 

rt1050 load text code to sdram ok, but execute fail in main()!

744 Views
echozeng
Contributor III

Hi,
I want to exec text code on SDRAM,but fail!
Import SDK emwin example from Mcuxpresso IDE, modify MIMXRT1052xxxxx_flexspi_nor.ld:
//relocate text code to sdram
/* MAIN TEXT SECTION */
.text : ALIGN(4)
{
FILL(0xff)
__vectors_start__ = ABSOLUTE(.) ;
KEEP(*(.isr_vector))
/* Global Section Table */
. = ALIGN(4) ;
__section_table_start = .;
__data_section_table = .;
LONG(LOADADDR(.data));
LONG( ADDR(.data));
LONG( SIZEOF(.data));
LONG(LOADADDR(.data_non_cache_init));
LONG( ADDR(.data_non_cache_init));
LONG( SIZEOF(.data_non_cache_init));
LONG(LOADADDR(.data_RAM2));
LONG( ADDR(.data_RAM2));
LONG( SIZEOF(.data_RAM2));
LONG(LOADADDR(.data_RAM3));
LONG( ADDR(.data_RAM3));
LONG( SIZEOF(.data_RAM3));
LONG(LOADADDR(.data_RAM4));
LONG( ADDR(.data_RAM4));
LONG( SIZEOF(.data_RAM4));

LONG(LOADADDR(.TEXT_MOVE));
LONG( ADDR(.TEXT_MOVE));
LONG( SIZEOF(.TEXT_MOVE));

__data_section_table_end = .;
__bss_section_table = .;
LONG( ADDR(.bss));
LONG( SIZEOF(.bss));
LONG( ADDR(.bss_non_cache));
LONG( SIZEOF(.bss_non_cache));
LONG( ADDR(.bss_RAM2));
LONG( SIZEOF(.bss_RAM2));
LONG( ADDR(.bss_RAM3));
LONG( SIZEOF(.bss_RAM3));
LONG( ADDR(.bss_RAM4));
LONG( SIZEOF(.bss_RAM4));
__bss_section_table_end = .;
__section_table_end = . ;

/* End of Global Section Table */

*(.after_vectors*)
} >BOARD_FLASH
......
.TEXT_MOVE : ALIGN(4)
{
FILL(0xff)
PROVIDE(__start_text_section = .) ;
*(.text*)
*(.rodata .rodata.* .constdata .constdata.*)
. = ALIGN(4) ;
PROVIDE(__end_text_section = .) ;
} > BOARD_SDRAM_LOWER AT>BOARD_FLASH
......
Modify Startup_mimxrt1052.c ResetISR function:
Cut blow codes and paste them after line "__asm volatile ("cpsid i");" :
//
// Copy the data sections from flash to SRAM.
//
unsigned int LoadAddr, ExeAddr, SectionLen;
unsigned int *SectionTableAddr;

// Load base address of Global Section Table
SectionTableAddr = &__data_section_table;

// 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);
}

// At this point, SectionTableAddr = &__bss_section_table;
// Zero fill the bss segment
while (SectionTableAddr < &__bss_section_table_end) {
ExeAddr = *SectionTableAddr++;
SectionLen = *SectionTableAddr++;
bss_init(ExeAddr, SectionLen);
}
download app to hyper flash and run it, application puased(halted) automatically when execute to function BOARD_ConfigMPU() which is first executed function in function main.

0 Kudos
7 Replies

287 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Echo,

       Thank you for your interest in NXP I.MX RT product, I would like to provide service for you.

       Do you want to run the code from the external qspi flash, but define some data in the SDRAM?

       Do you define the SDRAM sector range in the MCU Setting?

pastedImage_2.png

   If you still have question about it, you also can upload your modified project, then I would like to help you to check it.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

287 Views
echozeng
Contributor III

谢谢,Kerry周!

先回答你的问题:1,目前跑在hyper flash xip下(IMXRT1050-EVKB),想把text部分和部分数据放在SDRAM里面跑。

                             2,使用的ld脚本为:sdk example导入的基础上修改。

                             3,我用的mcuexpresso,mcu设置如下:mcu.png

                             4,如果把上述帖子中的:> BOARD_SDRAM_UPPER AT>BOARD_FLASH  改成 :“SRAM_ITC AT>BOARD_FLASH”,运行正常。

                             5,memory:

 MEMORY
{
/* Define each memory region */
BOARD_FLASH (rx) : ORIGIN = 0x60000000, LENGTH = 0x4000000 /* 64M bytes (alias Flash) */
BOARD_SDRAM_UPPER (rwx) : ORIGIN = 0x81E00000, LENGTH = 0x00200000 /* 2M bytes (alias RAM) */
BOARD_SDRAM_LOWER (rwx) : ORIGIN = 0x80000000, LENGTH = 0x01E00000 /* 30M bytes (alias RAM) */
SRAM_ITC (rwx) : ORIGIN = 0x0, LENGTH = 0x20000 /* 128K bytes (alias RAM2) */
SRAM_DTC (rwx) : ORIGIN = 0x20000000, LENGTH = 0x20000 /* 128K bytes (alias RAM3) */
SRAM_OC (rwx) : ORIGIN = 0x20200000, LENGTH = 0x40000 /* 256K bytes (alias RAM4) */
}

0 Kudos

287 Views
kerryzhou
NXP TechSupport
NXP TechSupport

楼主你好。

你要把代码段也放到SDRAM吗? 我记得这样是没有XIP功能的。

你如果代码段还放在hyper flash,就把数据段放到SDRAM,是否能够成功?


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

287 Views
echozeng
Contributor III

Kerry你好!

      我的需求是:想把代码段存在flash上,flash跑在xip下,开机后把text搬到sdram上执行。

只要将.text加载到SDRAM上,执行到BOARD_ConfigMPU() debug就无响应了,请教问题在哪里?

你要把代码段也放到SDRAM吗? 我记得这样是没有XIP功能的。”不是将代码段直接下载到sdram上跑,而是想将代码段从flash上加载到sdram上跑。

你如果代码段还放在hyper flash,就把数据段放到SDRAM,是否能够成功?”正常,MCUexpresso导入的example就是这样的。

x.png

谢谢!

0 Kudos

287 Views
wandongli
Contributor I

你好,我使用sdk里面的sdram支持xip的脚本,用gcc编译,代码不能运行,可以把你的脚本发我一下吗 ?

0 Kudos

287 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi wangdong,

  Please check this post.

  Overview of using the MIMXRT1050-EVK(B) with MCUXpresso IDE 

  If you still have question about it, you can create your own question post, we will help you in your new question post.


Have a great day,
Kerry

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

287 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi echo,

     如果你要把代码段放到flash上,那么你就不能把.text定义到SDRAM, 这样代码的地址就被分配在SDRAM了,所以你还是需要把text定义在flash上,可以在启动后再用代码把flash的代码拷贝到SDRAM。

    你可以看看map文件,如果你那样定义,text的段地址是不是就不在flash了。


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos