2007-02-15 08:45 PM
Help on In-Application Programming an STR711
2007-02-13 01:02 AM
I'd appreciate some help here, please.
I have a Front Panel PCB based on an STR711FR0T6 and interfaced via USB. I have developed the code with the IAR ARM Kickstart Kit version 4.41. Everything has been trouble free until I began to add support for in-application reprogramming. The entire applcation will be well under 32KB, so the strategy is to erase the top 32KB of flash 0, gradually programme the top half from USB, then finally erase the bottom half and copy the top half to the bottom half. Clearly I can't run the code from flash 0 while it's doing any of this, so I have used IAR's keyword __ramfunc to locate all the necessary functions (and all the functions they call) to RAM. The problem is that even an attempt to erase the top 32KB of flash 0 stops the device responding over USB until it is power cycled. I have disabled interrupts at the start of the procedure by a call to EIC_IRQConfig (DISABLE), because there are interrupts from USB and from the timer (the timer is only used to flash LEDs) and clearly the interrupt vectors and handlers are all in flash 0. I re-enable interrupts at the end by a call to EIC_IRQConfig (ENABLE). Can anyone suggest what I've failed to do or done wrong? Dave2007-02-13 09:47 PM
I'm not using the ST standard software library for the STR71x, so I could be wrong about some things.
You only need to make a function __ramfunc if it's executed while a flash erase or write operation is in progress. I looked at the source code for the ST standard software library, and I found only two functions that run during sector erase: FLASH_SectorErase() and FLASH_WaitForLastTask(). Those must be __ramfunc. Besides, don't forget about flash module initialization ('STR7 family Flash programming', revision 4, section 2.3.1 'Executing the first Write operation from RAM'), although it shouldn't affect you. Try setting some breakpoints with the debugger to see where it goes astray. Regards, - mike2007-02-15 08:32 PM
I found the answer a couple of days ago, but my attempts to reply failed.
The problem was that I kicked off the erase, then used WaitForLastTask to see if it had finished. WaitForLastTask boils down to checking FLASH_CR)'s BSY0 bit. Of course, while the erase is going on, the BSY bits aren't readable; if you try, the result you get is equivalent to not busy! So I returned from the function, to memory that wasn't readable. Bang. My solution was to use: while (FLASHR->FCR0 & (FLASH_LOCK_Mask | FLASH_BSYA1_Mask | FLASH_BSYA2_Mask)); When I single stepped it under the debugger, there was no problem, because I single stepped slowly enough that the erase operation had completed. Thanks for your help! Dave [ This message was edited by: DaveHigton on 16-02-2007 10:02 ]