Disabling all interrupts

Discussion around product based on ARM Cortex M3 core.

Moderators: nferre, ncollot

ngoncalves
Posts: 9
Joined: Tue Apr 03, 2012 3:34 pm

Disabling all interrupts

Thu Apr 05, 2012 4:37 pm

Hi,

I am implementing a firmware upgrade procedure where the new firmware is copied to the top half of the flash. After the full download, the new
firmware is copied into the bottom half of the flash and the processor is reseted. I am using a SAM3S4C and IAR.

During the firmware copy, I need to disable all interrupts (and exceptions) since the old reset vector will be erased and the new is only valid
after the copy is completed.

Is there a way to it ? I was looking at the datasheet and it says some exceptions cannot be masked. In any case I will the watchdog running
during the copy because I need to reset the processor. But all others must be disabled.

Nelson
CptTitanic
Posts: 871
Joined: Sat Oct 30, 2010 6:04 pm

Re: Disabling all interrupts

Thu Apr 05, 2012 5:06 pm

You could presumably reset and perform the update prior to setting up or using peripherals and interrupts. ie insert flashing code in the ResetHandler, copies flashing code to RAM, erases, copies new flash.

You could also presumably change/relocate the vector table address that the Cortex-M3 uses, to some ram/flash that you control and isn't erased. ie SCB VTOR

You might also consider partitioning your boot code and application code separately so you don't need to erase the boot code or primary vectors. The application code can always have it's vector table anywhere it wants (on a 512 byte boundary, or whatever).

See also forum/viewtopic.php/f,24/t,19993/
ngoncalves
Posts: 9
Joined: Tue Apr 03, 2012 3:34 pm

Re: Disabling all interrupts

Thu Apr 05, 2012 6:52 pm

Tanks for your reply.
CptTitanic wrote:You could presumably reset and perform the update prior to setting up or using peripherals and interrupts. ie insert flashing code in the ResetHandler, copies flashing code to RAM, erases, copies new flash.
Did not think about this one, seems a good idea.
CptTitanic wrote:You could also presumably change/relocate the vector table address that the Cortex-M3 uses, to some ram/flash that you control and isn't erased. ie SCB VTOR
I don't think the problem is relocating the vector table, instead that the entries are no longer valid since I am erasing the flash code.
CptTitanic wrote:You might also consider partitioning your boot code and application code separately so you don't need to erase the boot code or primary vectors. The application code can always have it's vector table anywhere it wants (on a 512 byte boundary, or whatever).
I thought about this one, but for some reason I ignored it. This is actually very similar to what I did, except that I use a function to move the two firmwares around. With a bootloader this seems much better because if the copy fails, it can always try again.

Thanks again

Return to “SAM3 Cortex-M3 MCU”

Who is online

Users browsing this forum: No registered users and 6 guests