What about the bootloader?

Will it be easy for tinkerers to eventually make their own Arduino Due, in barebones/breadboard/stripboard/PCB form? I see no provided bootloader.

It was great the way it was for the Atmega328 and Atmega2560, where I could burn the provided bootloaders via another Arduino using ArduinoISP or else using some other ICSP...

Bootloader's are provided by atmel, and seems Arduino hasn't replaced them.
Weather or not you can get only a binary file or the full source is a guess.

The bootloaders have a usb option too, custom boards / field updates may be easier.

@pyro_65:
What do you mean, "bootloaders have a USB option" ?
I was under the impression that bootloader could only be burned via ICSP; and that only by reading the bootloader in the first section of the flash, the computer is then able to load firmware into the memory via serial.

The bootloader can upload new binary files from a mass storage device.

The bootloader is overwritten presumably through a ISP, Arduino Due Mini/Nano - #7 by pYro_65 - Arduino Due - Arduino Forum

On the SAM the bootloader resides in silicon, you cannot erase it and it doesn't take any flash space. I would think it could be disabled somehow but can't see any reference to doing so.

It will boot from either USB or the UART so there's no need for Arduino to supply another bootloader.

That said with ARMs (or at least LPCs) you can write a "secondary" bootloader if you want to do your own thing, I assume that would reside in flash but I can't see any reference to doing that in the SAM data sheet.

EDIT: It does look like the GPNVM bits can be used to select the boot options.


Rob

@Graynomad, So do you mean that, if you buy a SAM3X8E from Atmel, it already comes with the necessary bootloader, and you can USB-upload Arduino sketches to it as purchased (assuming the UART interfacing in between is taken care of) ?

(Now if only it were in a hobbyist-friendly package!)

giantsfan3:
@Graynomad, So do you mean that, if you buy a SAM3X8E from Atmel, it already comes with the necessary bootloader, and you can USB-upload Arduino sketches to it as purchased (assuming the UART interfacing in between is taken care of) ?

(Now if only it were in a hobbyist-friendly package!)

(I think)
Or you can use the Atmel SAM3X-EK as well with the Arduino IDE.

if you buy a SAM3X8E from Atmel, it already comes with the necessary bootloader

Yep, AFAIK you can hook a terminal program to the UART pins and away you go. Same with USB.


Rob

The bootloader is preburned in ROM from Atmel and is called SAM-BA. There is no way to change it.

The desktop application that Atmel uses for uploading is called also SAM-BA, you can download it from the Atmel website, there is a version for Windows and Linux (no Mac). It works well, has a nice GUI, but its too big to include in Arduino distribution.

We used an open source alternative called 'bossac', written by Scott Shumate. This is a super-light tool, that supports a lot of SAM* cpu (from SAM3 to SAM9), that can be called by command line (like avrdude) and best of all, it runs on Linux, Windows and Mac.

http://www.shumatech.com/web/products/bossa
(actually the site is down, i think its a temporary problem)

I did a lot of patches to Bossac in order to allow autoreset, and to do some workaround for os-specific problems during upload.
Scott Shumate helped a lot in this phase of development, he was very kind and responsive.
The Arduino patches can be found in the "arduino" branch of bossac github:

hopefully these patch would be included in the upstream bossac in the coming weeks.

Great, thank you @cmaglie and @Graynomad.
So the conclusions are:

(1) Atmel has pre-burned bootloader into ROM for all SAM3X8E ic's as sold, so no such thing as "Arduino bootloader" any more as was the case for previous Arduino boards.

(2) USB/Serial uploading of "sketches"/firmware (or the corresponding hex files to be specific) can be done via SAM-BA software, or via Arduino 1.5 IDE (which uses bossac tool by Scott Shumate)

(3) And as @pyro_65 states, firmware uploads may also potentially be done from a mass-storage device via the USB host (?).

Yes for (1) and (2)

The answer for (3) is: no, you can't with SAM-BA bootloader.

Using SAM-BA bootloader you can upload a file in two way:

  • from UART (pins RX0/TX0 on the Due Board at 115200bps N81).
  • using USB, if you connect the board to a PC the board is seen as a virtual serial port. SAMBA has a little USB Device driver for serial port emulation.

So, forget mass storage devices, unless you write your own bootloader that handles USB Host OTG, but this is another story...

1 and 2 yes.

3 I don't think so, the BL would be expecting a particular protocol, how does it get that from an SD card and there's no mention of it in the BL flow chart which goes like this

start:
is USB enumeration successful?
yes - run SAM-BA
is char # received from UART?
yes - run SAM-BA
goto start

no mention of SD cards.

Looking at the above, how does code execute when you are plugged into the USB, surely it goes into the BL and you would have to manually run the code from there.

cmaglie, do you know?


Rob

how does code execute when you are plugged into the USB,

I think I've answered my own question, if there is no user code the BL is entered, if the is user code that's entered instead. This is good because you no longer have an delay while the BL decides if it should run or not as is currently the case with Arduinos.

For this reason you have to clear the flash before you can get access to the BL.

The Due board does have an ERASE button that can be used for this purpose, but that would be a pain to do every time so I looked at the schematic.

There's a FET across the switch that is controlled by ATMEGA16U2, so the USB chip can erase the SAM before programming. This is part of the standard download procedure as I understand it.

Mystery solved.


Rob

Can someone please post the verbose output when uploading a sketch to the Arduino Due with bossac?

Thanks!

Binary sketch size: 9,660 bytes (of a 524,288 byte maximum)
Forcing reset using 1200bps open/close on port COM12
C:\Documents and Settings\randalm\My Documents\My Stuff\Arduino\arduino-1.5/hardware/tools/bossac.exe --port=COM12 -U false -e -w -v -b C:\DOCUME~1\randalm\LOCALS~1\Temp\build4692706267932093131.tmp/Blink.cpp.bin -R 
Erase flash
Write 9740 bytes to flash

[                              ] 0% (0/39 pages)
[=======                       ] 25% (10/39 pages)
[===============               ] 51% (20/39 pages)
[=======================       ] 76% (30/39 pages)
[==============================] 100% (39/39 pages)
Verify 9740 bytes of flash

[                              ] 0% (0/39 pages)
[=======                       ] 25% (10/39 pages)
[===============               ] 51% (20/39 pages)
[=======================       ] 76% (30/39 pages)
[==============================] 100% (39/39 pages)
Verify successful
Set boot flash true
CPU reset.

Thanks!

I tried uploading using TX0/RX0, but wasn't able to.
What needs to be done for this to work?
Here is what I did:

  1. Press Erase button
  2. Press Reset button
  3. On Arduino IDE 1.5.2, I click upload.
    This is what I get:

Binary sketch size: 9,860 bytes (of a 524,288 byte maximum) - 1% used
Forcing reset using 1200bps open/close on port COM3
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
PORTS {COM3, COM9, COM35, COM39, COM40, COM47, } / {COM3, COM9, COM35, COM39, COM40, COM47, } => {}
Uploading using selected port: COM3
D:\Software\arduino-1.5.2/hardware/tools/bossac.exe --port=COM3 -U true -e -w -v -b C:\Users\Owner\AppData\Local\Temp\build7113222333597006268.tmp/Blink.cpp.bin -R
No device found on COM3

Well, nevermind.
I was able to use bossa command line tool just fine.
Then I went back to Arduino IDE and was able to upload too. So, maybe it was just bad connection in one of the jumper wires when I was trying before.

so where do i find the bootloader for ATMGEGA 16U2 in order to reproduce the exact function it does onto the Artduino DUE? i mean to load code from arduino IDE to SAM3X.