Hello,
I bought a APF28 board from www.armadeus.com which has iMX286. It has 128KB of on-chip RAM (OCRAM) (from address 0x00000000) and 128MB of External RAM (from address 0x40000000).
I have been writing some bare-metal applications on it (timer interrupt, serial port, IO) using GNU ARM toolschain. These applications work fine in OCRAM and now I want to run them in External RAM. These programs will run through following steps:
1. Load binary to Externl RAM at 0x40000000
2. A piece of code in startup will copy 64 bytes of exception vectors from 0x40000000 to 0x00000000, here is the code to do this task:
/* Copy vector table from RAM to OCRAM */
mov r8, #0x40000000
mov r9, #0x0
ldmia r8!, {r0-r7}
stmia r9!, {r0-r7}
ldmia r8!, {r0-r7}
stmia r9!, {r0-r7}
3. Initialize stacks and load main function
However, I face a problem of unstable execution. I means, some time, it works properly but some time it work wrong or does not work at all.
Could you suggest me any idea to solve this problem?
(Please find attached for startup code and linker script that I use for two cases: run in On-chip RAM and run in External-RAM)
Thank you.
Original Attachment has been moved to: linker_OCRAM.lds.zip
Original Attachment has been moved to: startup_OCRAM.s.zip
Original Attachment has been moved to: startup_RAM.s.zip
Original Attachment has been moved to: linker_RAM.lds.zip
It seems you are missing to initialize the external RAM.
I would also suggest that you use U-boot, which already takes care of this and launch your application from U-boot.
DDR is initialized at this file:
git.denx.de Git - u-boot.git/blob - arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c
Thank you, Fabio. The source code for initializing DDR is really useful. Normally, I use U-boot to launch the application using the following command:
tftp 0x40000000 app.bin; go 0x40000000
If you use mainline U-boot, then DDR initialization is taken care by U-boot and you don't need to be concerned about it.
If you use the mx28 U-boot from Freescale, the DDR initialization is done by the bootlets code.
I suggest you to look and the uboot code for using External-RAM. do you enable the cache?
Thank you, Yong Huang. I will check the code of Uboot. Normally, I don't configure the cache. When I use the J-Link to check, my configuration is: MMU off, I-cache on and D-cache off. Could you explain me more about the role of Cache in my case?
I just meet similiar problem with cache enabled before, as the virtual space maybe cahced, so in a not well protect environment, this will cause random abnormal operation.