Custom SAM3X8E CAN bus bootloader

Discussion around product based on ARM Cortex M3 core.

Moderators: nferre, ncollot

YogiBear
Posts: 5
Joined: Tue Nov 24, 2015 4:55 pm

Custom SAM3X8E CAN bus bootloader

Thu Nov 17, 2016 7:55 pm

I am developing a custom bootloader (downloading firmware over CAN bus) for a custom SAM3X8E board. I have code written that downloads the program into Flash1. I am using the Single Bank method as described in the application note, Safe and Secure Bootloader Implementation for SAM3/4. The tricky part is that you have to copy code from Flash1 (new firmware) over Flash0 (where you are currently executing). You cannot directly write to a Flash bank when you are executing from it.

Section 3.2.1.1 Single Banked Flash Programming shows a solution using the __ramfunc attribute to load a generic flash_cmd() function into RAM and execute it from there. You cannot use any of the ASF driver functions in this routine since they cannot run from RAM. It has to be done with low level EFC programming. I am looking for some actual application code that shows how to do this.

The only code example I can find for a SAM3X8E bootloader was designed in 2011 for IAR 5.5. I am using IAR 7.4 and this code is not compatible and won’t compile. Instead of using __ramfunc, it uses the FlashD driver code. This is not a trivial piece of code to port to the new compiler. I does not appear to part of the latest ASF driver code base. I am hoping that someone can point me an updated driver or example code that will work under IAR 7.4.

Originally I wanted to use the simpler Dual Bank method described in the App note, but there is a bug in the chip (confirmed by Atmel) that prevents this from working for programs over 64Kb.

Can someone show me a working example of how to do the Flash copy with code that can actually compiles under the latest compiler? Is there an easier way to do this? Is there an ASF function to do this?
YogiBear
Posts: 5
Joined: Tue Nov 24, 2015 4:55 pm

Re: Custom SAM3X8E CAN bus bootloader

Sat Dec 03, 2016 4:41 pm

I found the flash code. It is located in the ASF EFC flash example. There is a flash_write that uses the EFC functions built into the ROM. It is now working! :D

Return to “SAM3 Cortex-M3 MCU”

Who is online

Users browsing this forum: No registered users and 1 guest