I can now program the flash successfully every time, but now I am trapping on faults that I never experienced when running out of RAM. I have tracked the problem down to the SP being set to a location in flash, which doesn't work very well ! If I get it figured out, I'll post here.
By the way, my problem with not being able to flash repeatedly came down to the fact I needed to set SCB->VTOR = 0x08000000. I had mistakenly assumed this should be 0, but figured it out last night.
Yes, the stack is being set correctly by the linker. My problem now is that after flashing my application and doing a reset, I can see the first line of code is _start, as expected. However, when I try to single step, a hard fault is generated. The registers indicate the source is a line of code that is in a separate routine that has not come close to being executed by the single step I tried to execute. Prior to fixing the stack info at the base of the interrupt table, the hard fault was indicating the stack was the problem, and this was correct at the time. Now that I have fixed the stack, this new problem has me scratching my head.
__ghsend_stack ; 0x00000000 Stack top address would place the correct stack address (RAM). I did run into an issues a few months ago where ghsend_stack was returning an addresss that was in flash and not RAM. I though it was a bug that has since been resolved.
I am using a standard GH Probe. My the current error that I am receiving is the same one you were seeing (i believe). The verification failure after flashing the board.
While support was/is working on this, I wanted to get some basic interrupts to function while running out of RAM. The first thing I realized is that I didn’t have a vector table. I had the ISRs from the ST Firmware lib by since I didn’t have a vector table the handlers weren’t being hit. Then I started to wonder how the reset exception was being handled and started poking around in the startup code. Since then I haven’t had much time to go any further. I am doing this on the side more for self interest than for an actual project at work. [ This message was edited by: jrubis on 29-02-2008 19:45 ]
Can you post some specifics of the errors you are seeing with the GHS tools? Are you using the Probe, Slingshot, or SuperTrace? I am pushing to get in contact with the developers, so any additional info I can provide might be helpful.
It's funny you mention linking to _start_T instead of _start for the reset vector. I just got an e-mail from GHS telling me to do that. The difference is that _start is in ARM mode, which of course is not allowed on the Cortex M3, while _start_T is in Thumb mode, which is *required*. Also, the vector table entries are one byte higher than the actual handler routine addresses. This also indicates Thumb mode. If you linked to _start instead of _start_T, your reset vector would be incorrect. I have rebuilt my application with _start_T, but won't get a chance to test it until Monday. I'll let you know how things work.
I now have a program running out of flash. The program is the EXTI (External Interrupt) example that is part of the STM32 firmware lib.
I am running it on my STM32EVB. Looks like the code is handling the interrupt call okay. The only issues I currently have are: 1. Some times I need to press the reset on the EVB before I flash the board. I think there is an issue with the probe being able to halt the target. 2. For some reason I needed to define _start_T instead of _start in my vector table. Not sure what the difference is. I need to research this. [ This message was edited by: jrubis on 02-03-2008 00:06 ]
I have changed my vector table to jump to _start_T instead of _start, and my app now runs fine out of flash. Pointing to _start generates a hard fault every time when running out of flash because it points to ARM code, which does not execute on the Thumb2 Cortex. Anyway, this is the final solution to my problem. Let me know if you have any more issues, although it sounds as though you are now running without problems also.