I am using the MIMXRT1050 board with the Keilv5 Pro IDE. I am having problems attempting to create a secondary bootloader which will copy the binary file of a second project to external RAM then jump to RAM to continue execution. I am using QSPI flash which starts at address 0x6000_0000 and external SDRAM starting at address 0x8000_0000.
My goal is to create two projects, one will be my bootloader project and the second is my application project. The bootloader project will be run in flash just like the demo examples. My bootloader project will test the external RAM using a write and read test, then if there are no errors, the bootloader will use memcpy to copy the application binary located in flash at 0x6010_0000 to RAM at 0x8000_0000 and jump to that address to continue execution.
I am currently manually programming the flash using the JFlash app and JTAG flasher. First I build my bootloader project and create a binary file of the project, I do the same with my application project. Now, using the two binary files, I place the bootloarder binary file at 0x6000_0000 and the application project binary at 0x6010_0000. Once I reset the board, the bootloader project starts and copies the application binary from 0x6010_0000 to external RAM at 0x8000_0000 then jumps to 0x8000_0000 to continue execution. Currently, my bootloader is working fine and I confirmed all the data is copied correctly.
Once I jump to the external RAM for my application project, the board seems to hang. If I make my application project very small (7kB) the whole application project works fine. When I add code to the application project making it (11kB), the program hangs. I am using blinky demo project to debug my problem. If I edit the blinky project to blink 5 times (7kB bin size) the whole application project works. If I edit the blinky project to blink 8 times (11kB bin size) the application project hangs after the 4th set of blinks. Any print statements causes the hang, so it is hard to debug.
Another note, if I leave the board off for a few minutes and try to run the 8 blink application project again it works and does not hang anywhere. My debugging has not been consistent, sometimes the application will run without errors and hanging then other times it keeps hanging in the same spot. I also tried to clear the RAM by writing zeros to every location before copying my application project but it did not affect anything.
1) Are there any demo or example projects that accomplish similar ideas to my project?
2) Why is making the application project bigger causing an issue with execution in external RAM?
3) What are the required steps and code to jump from flash to external RAM for execution?