2013-09-16 01:20 PM
Hi all!
I am wondering if anyone has tried jumping from flash code to an entire project in internal SRAM without resetting (so no memory remap / boot0/boot1 config is required). I am working on the STM32F417, and have managed to jump from flash code to the main( ) function of the SRAM project. The main code works fine, however no interrupts are being generated.Here are my observations:- vector table is in place (address 0 of SRAM) and points to correct locations in SRAM for where the individual IRQ_Handlers are placed (which I confirm with the .map file from the linker).- the interrupt bit is being set properly.- the NVIC active bit is also being set for the interrupt, e.g. TIM3 interrupt, however the code never enters TIM3_IRQHandler( ).Has anyone had experience with such a situation? With an older ARM7 core, it was easier to set the boot mode to ''from internal SRAM'' and simply reset the core. However, I don't seem to have the same facility in this case (unless I physically set the boot0/boot1 pins high in hardware). #code-in-ram #memory-remap2013-09-16 01:27 PM
You don't need to remap RAM to zero, you can compile your code to reside at 0x20000000, and have it set the vector table (SCB->VTOR) to that address. VTOR can be any 512-byte boundary address.
On ARM 7 and 9 parts you had to remap at zero because you COULDN'T change the addresses the processor vectored through. This is not the case for Cortex-M3/M4 parts. On a Cortex-M0 (STM32F0) part, you also can't change the vector table, and the trick there is to either map FLASH at zero, or copy a small vector table into RAM, and then map RAM at zero.2013-09-16 01:58 PM
Thanks for replying Clive1.
Infact, the first thing I do in the main( ) of the RAM project once it loads is to set the VTOR. I call the STM library function as follows:NVIC_SetVectorTable( NVIC_VectTab_RAM, 0 );This should map all vectors properly, and it does. I check register values and they are appropriate. I see that the location where the linker places my IRQHandler( ) is also correctly listed in the vector table which is now at base address of RAM (0x20000000).2013-09-16 02:16 PM
How are you debugging your IRQHandler issue?
Can you toggle a GPIO, or breakpoint it?2013-09-16 02:43 PM
Yes, I am toggling an output pin (driving an LED). I even thought that maybe the flash IRQHandler is still being called, but that's not the case either.
2013-09-16 02:45 PM
And when I load the RAM application independently into RAM I can debug it and it all runs correctly. It's just when I jump from the flash application that the ISRs don't run.
2013-09-16 03:53 PM
Something else going on here, try to create a very simple test example.
How are you partitioning RAM between the app, statics, heap, and stack?What board are you using, what pins for USART, LED, etc?2013-09-17 05:48 AM
I simplified my code to just have a timer (TIM3) and three USARTs (USART1/3/6) and then copy to RAM and jump to the RAM application, which has the same timer along with USART3 being initialised again. Nothing changed - the timer interrupt is being set, but it's not going anywhere.
I am using IAR's toolchain, and I've set the ROM and RAM areas in the linker file to SRAM base address. Also, I've limited the end of ROM/RAM to 0x2001FF7F, so that I can reserve 0x80 bytes for some shared variables between the two projects. There is zero heap size, and the stack is being placed at a much higher location in SRAM so I don't think it is being corrupted.I'm using a custom-designed board with the STM32F417IG. I've already had some trouble with the I2C2 peripheral, which turned out to be listed in the errata too. The pins I'm using for USART1 are PA9/10, for USART3 are PC10/11, and for USART6 are PG9/14.I must also mention that I'm using an RTOS, which I do disable before jumping to the RAM application. Thanks for your input!2013-09-17 07:39 PM
2013-09-18 08:35 AM
Hi
The problem is that you do not just 'jump to main' in the ram application. Both the Program counter AND the Stack Pointer need to be changed. This is done at boot up by the first 2 entries in the vector table. Entry 0 is the stack pointer address Entry 1 is the Program counter address I was trying to do a similar thing, I wanted to have a Bootloader program and an application program, both in Flash. For the bootloader to start the application, the bootloader has to effective load both the stack pointer and program counter. I searched for example bootloader code to do this and got my answer.