SAM4E custom board with SAM-BA

Discussion around product based on ARM Cortex M4 core.

Moderators: nferre, ncollot

Posts: 6
Joined: Fri Jun 27, 2014 10:45 pm

SAM4E custom board with SAM-BA

Fri Jun 27, 2014 11:04 pm

Hi All,

I plan to design a custom board utilizing ATSAM4E16CA uC. I do not need debugging feature. Datasheet for SAM4E says, that all devices are shipped with SAM-BA bootloader in ROM. I want to use SAM-BA in USB mode, so board will contain 16,000MHz crystal. 
What is the boot sequence for SAM4E? Do I need any other button on the board (except ERASE, NRST and TST buttons)?

I have read this (applies to SAM4L) : ... T03454.pdf

and also this (applies to SAM7 and SAM9): 
linux4sam/pub/Linux4SAM/GettingStarted/ ... tegies.ppt

but none talks a word about SAM4E on custom board (not SAM4E-EK evaluation board). Where are the differences?

Thanks for any suggestions in advance.
Posts: 6
Joined: Fri Jun 27, 2014 10:45 pm

Re: SAM4E custom board with SAM-BA

Sat Aug 23, 2014 2:45 pm

Well, just for record.

I have built custom board with components stated above (SAM4E16C, 16MHz xtal, RST button, TST and ERASE jumpers).
SAM-BA v2.12 with Patch works in this sequence:

1. Power-up board.

2. Activate ERASE signal (by jumper). This clears GPNVM1 bit.

3. After few seconds remove ERASE jumper.

4. Reset board.

5. Connect board to PC with SAM-BA 2.12 installed. In "Devices" we should see new hardware (AT91 USB to Serial Converter(COMx)). If new device is found but has different name (Like GPS camera something), we need to install atm6124 CDC driver found at Atmel website. If no device found, check wiring & power.

6. Launch SAM-BA. 

7. Select connection (USBserial\COMx)

8. Select board: For SAM4E16 select atsam4e16-ek (even if you have custom board).

9. Check checkbox "Customize lowlevel" and press "Connect".

10. Select your crystal frequency (my case 16000000) and press "Set". Invalid frequency setting will cause connection failure. 

11. Using "Flash" tab we can program / read / verify flash content. Usage is finally straight-forward. After successful flashing, we have to execute script "Boot from Flash (GPNVM1)" to switch from bootloader to flashed program.

12. Close SAM-BA and reset board. Now, our application is running. 

If we want to change anything in program, whole sequence from 1. to 12. is needed. 

Hope this will help someone My previous question was seen about 17k times without response, so I am wondering, if the question was so hard or so stupid :D
Posts: 5
Joined: Tue May 18, 2010 4:26 pm

Re: SAM4E custom board with SAM-BA

Mon Aug 25, 2014 3:13 pm

In fact I am facing the same problem even after going through the details :(

1. I am using SAM4SD32C - SAM4S-XPLAINED PRO board.

2. I can flash my code using the on board USB connector

3. I am trying to use the SAM-BA as I will be using it in final - custom board (with SAM4S8BA).

4. Before the experiment - I had some prints, which appears in serial port (in UART1 - PB2/PB3).

5. Connected the ERASE (pin 87) to 3.3V and reset the board - kept in this configuration for ~20 secs.

6. Now power off and power on the board - I do not see any thing on the serial port (and I assume the chip is erased).

7. Connected RX0 and TX0 of dev board (PA9 and PA10) to laptop (via FTDI USB to serial converter).

8. Open the SAM-BA, tried selecting SAM4S (I tried all these variants at91sam4s16-ek/ at91sam4s4-ek/ at91sam4s8-ek/at91sam4s32-ek/ Sam4s-xpld) and set the frequency to 12MHz as that is what being used by dev board.

9. In all these experiments I see "No valid processor ID found".

10. Completely lost and not sure if I am missing any thing.

11. Please let me know if you have any comments/ suggestions. Not sure, if there are any other way of programming the chip (as in the final board, I will not have the USB/ debugger used in the development board).

With best regards,
Posts: 6
Joined: Fri Jun 27, 2014 10:45 pm

Re: SAM4E custom board with SAM-BA

Wed Sep 03, 2014 9:07 pm

Hi phanids,

first: very very stupid question: did you tied ERASE pin low after erasing the chip? External pull-down resistor is recommended by schematic checklist.

second(guessing): There might be a problem with FTDI UART to USB converter (FTDI is using own USB CDC driver, maybe there are delay issues). I suggest you to put USB connector to your custom board (if possible  :wink: ) and use USB instead of serial port. It may be a great advantage when programming from PC without serial port. 
Is there a way to bypass onboard debugger of SAM4S-EXPLAINED PRO and connect directly to USB port of ARM in order to try programming via SAM-BA USB?


Posts: 1
Joined: Fri Nov 07, 2014 12:24 pm

Re: SAM4E custom board with SAM-BA

Fri Nov 07, 2014 12:41 pm

Hi phanids,
 I am in exactly same situation, could you tell me how you solved the problem?

brg Miras
Posts: 2
Joined: Tue Nov 11, 2014 7:49 pm

Re: SAM4E custom board with SAM-BA

Tue Nov 11, 2014 10:16 pm


Thanks for taking the time to post such a detailed solution. I have created a custom board that works well. I want to use USB to update the firmware on the board. I would like to use software to initiate and complete the firmware process. I can currently communicate with the board from a custom application (using the Atmel USB DLL) on the PC.

Here is what I envision...

1. A new version of firmware is released.
2. The PC application notifies the board via the USB connection that new firmware is available.
3. The PC transfers the firmware to the board. The firmware is stored in flash memory and verified for authenticity and errors.
4. The board needs to do something at this point... change the boot vector? Boot from ROM and copy the new firmware to the correct flash memory?

Do you have any experience with this?
Do you have any suggestions?

Thanks again for your expertise.
Posts: 5
Joined: Wed Nov 23, 2016 11:10 pm

Re: SAM4E custom board with SAM-BA

Thu Nov 24, 2016 5:36 am

Yes, very useful thank you Daredevil2.

phanids, what you're doing sounds fine. A FTDI USB to serial works here on a SAM4E16E. You do have to make sure you get the low level details right (including "bypass" if that's what your board does). A great way to troubleshoot is to use a terminal program to connect to the COM port. If you send "V#" (without the quotes) followed by a carriage return, SAM-BA Boot should return a version string. Only once you get that happening should you worry about the beast that is sam-ba.exe.

TekLord, I'm trying to get something along these lines going. I'm working with sam-ba.dll but not getting far - it crashes when you call AT91Boot_Scan() (even from the example project, which didn't compile at first).

If I ever get that part going, I intend to have the firmware capable of putting itself into a state ready to receive new firmware. Usually that amounts to clearing GPNVM bit 1 (boot mode selection) and then doing a self reset. The MCU then boots into SAM-BA Boot, ready for firmware update. If you have the security bit set then you have to erase the firmware first.

Return to “SAM4 Cortex-M4 MCU”

Who is online

Users browsing this forum: No registered users and 3 guests