2014-10-23 12:17 PM
2014-10-23 01:34 PM
I'm not using Atollic, perhaps you can seek advice on their forum?
This does all look rather tortured, have you considered just making a small loader in flash that just copies a firmware payload (binary) in to RAM and then jumps to that? And then have Atollic build the app with a 0x20000000[0x10000] FLASH and 0x20010000[0x10000] RAM without all the redirection of load regions? SystemInit() tends to change the vector table, and is generally designed to be called PRIOR to main() and the C runtime initialization, per CMSIS. If SystemInit() or things it calls are situated in RAM then the copy needs to occur prior to that. If it's crashing upon returning it's probably pushing everything including LR on the stack, so watch for stack corruption. Check also the region that CTORS is initializing.2014-10-23 03:05 PM
Thanks Clive,
Have you done this in any other environment? I just need to see the kind of branch instructions used on the start-up file (which is in Flash) when calling the RAM routines. I can get some ideas from there.Thanks.2014-10-23 03:32 PM
I've worked on lots of things, in lots of environments. I've worked with/on ARM parts since the late 1980's.
Perhaps you should be using ''BLX R4'' ? LDR R0, =SystemInit
BLX R0
LDR R0, =main
BX R0
2014-10-23 03:40 PM
I did try the blx instruction and did not work. I think am going to start with a small assembly program and then move to C and finally to C++.
I'm not sure why the call and return to SystemInit() is fine but executing the next instruction crashes the CPU.2014-10-23 06:14 PM
I guess you'd need to pay specific attention to the registers and memory content, and perhaps set up a Hard Fault Handler which outputs details. I'm not an Atollic user so can't speak to the efficacy of their debugger.
You might want to partition some of the code into FLASH. I'm not clear about what the purpose of copying to RAM is here. A significant amount of the complexity you've introduced could be removed with a relatively simple loader.2014-10-24 01:12 AM
Hi
''I have been trying to place all code in RAM'' From what you have said, I think you are doing it the hard way! ''I have been trying to place all code in RAM as follows: 1. Create a normal project with code in FLASH (Atollic) 2. Modify linker command file'' You are making things hard for yourself by linking your program to run in Flash and then trying to modify it. Start by linking your program to run in RAM . Then you tell the linker to copy the whole thing into Flash. Then you only need a simple assembler routine which just copies the whole thing into RAM and loads the SP and PC.