Atmel SAM3X8E dual bank switching for booting different behaviour

907 views Asked by At

I’m currently working with an Arduino Due board which has an Atmel SAM3X8E processor embedded. I’m programming it using the Atmel Studio (version 7.0.1645) and the provided Atmel Software Framework (version 3.28.1). The purpose of the program running on the SAM is to gain reprogramming functionality. Therefore the program gets the image from a host PC, flashes it block by block in the unused flash bank and verifies the image. All that is working fine, but I’m running into the same issue as this post (Atmel SAM3X dual bank switching not working).

The Atmel SAM3X8E has two 256-kByte flash banks, Flash0 and Flash1. My application easily fits in the Flash0 and is programming the received image to Flash1. My idea is to use the features of the SAM3X to boot from the other flash bank (default is Flash0). The datasheet of the SAM3X states at page 35 that GPNVM Bits can be used not only to choose the boot memory (ROM or Flash) but also to choose the bank to boot from (Flash0 or Flash1). If GPNVM2 is set the µC will boot from Flash1. This is achieved by remapping the memory layout. Therefore if GPNVM2 is set the Flash1 is mapped at address 0x0008_0000 (while Flash1 and Flash0 are continuous). If GPNVM2 is cleared Flash0 is mapped at address 0x0008_0000 (now Flash0 and Flash1 are continuous).

What I’ve done is to manipulate the GPNVM2 bit before resetting the processor, but it did not work (the memory was not remapped properly). I was also playing around with the Atmel Studio’s options. Atmel Studio can program an application to Bank0 or Bank1 using the “Project Options” -> “Tool” -> “Program Settings”. I tried to program my application with these settings to Bank1. It is only possible if the checkbox “Override Vector Table Offset Register (exception_table)” is checked and if the device is programmed using “Start Debugging”. If the device is programmed using “Start without Debugging” it does not boot at all, to get it booting (remember the application was flashed to Bank1, if the remapping was successful Bank1 should be located at the address 0x0008_0000 where originally Bank0 is mapped to) I had to change the GPNVM bits manually (using the “Tools” -> “Device programming” Tool) to ‘boot from bank0’. Then it worked.

The described behaviour taught me that I must have missed to manipulate some registers. Obviously the “Override Vector Table Offset Register (exception_table)” is important therefore I also set the “Vector Offset Table Register (VTOR)” to the start address of Flash1 which didn’t help either. I’ve got the feeling I’m missing some functions or register that I have to call/manipulate.

To reprogram the processor it is normally necessary to have some kind of bootloader running which I hoped to avoid using the bank switching mechanics. Has anybody any experience about this bank switching using the ASF functions or in general about the bank switching on a SAM3X?

Thank you in advance!

0

There are 0 answers