You are viewing an older revision! See the latest version

Arduino Due

Arduino Due mBed Support

This page is documentation of my efforts to add mBed support for the Arduino Due board, which is based on the Atmel SAM3X8E chip. That chip is a Cortex M3 which runs at 84 MHz with 512 kB of flash and 100 kB of SRAM.

You might ask why I would want to do this, given the huge range of cheaper mBed platforms that already exist. The main reason is that the SAM3X8E is one of the very few (perhaps only?) chips that supports USB High Speed (480 MHz). As far as I can tell all existing mBed platforms only support USB Full Speed (12 MHz).

How the SAM3X8E is programmed

Traditional mBed boards feature an "interface chip" which provides the USB Mass Storage interface to the computer to receive your program binary, and then programs the target chip (e.g. LPC11U24) via SWD. The Arduino Due does not have an mBed interface chip and must be programmed in a different way.

The Arduino Due actually has two methods for programming the chip. There are details about them here. The SAM3X8E comes with a factory-programmed ROM containing a bootloader called SAM-BA which is run when the ERASE pin is asserted during a reset. This can be done by pressing the erase button on the Due, or via software (described later).

Once the SAM-BA bootloader is running it starts a USB CDC (USB serial) device up on the serial port (the "native USB" port on the Due), and also monitors its UART for connections. Either of those can be used to program the chip. The UART is connected to an assistant chip on the Due - an ATMEGA16U2, which provides the "programming" port on the Due. The SAM3X8E can be programmed via either communication channel.

To reset the chip without having to press the button, there are two software methods. The first is to use the programming port - when the ATMEGA16U2's USB serial port is opened and closed at 1200 baud it asserts the ERASE pin. The second is using the native port - when you compile an Arduino program it links in extra code which monitors for a 1200 baud rate on the native port's USB serial port and reboots into the SAM-BA bootloader so it acts identically to the programming port. Since we will not be using Arduino's code, this method will not work with mBed (without extra effort at least). But little is lost so it doesn't really matter.

Of course, in addition to these methods, you can use JTAG or SWD to program the chip directly, but this requires a JTAG or SWD programmer and extra connections which is more of a pain. It does allow debugging though.

Software to program the chip

Once you have the SAM-BA bootloader started, and can talk to it either through the native USB port directly to the SAM3X8E, or via the programming port with the ATMEGA16U2 acting as a USB-to-serial adapter, you need some software that sends your binary to the chip in an appropriate format.

The "official" software is also called SAM-BA, and is a large complicated TCL/TK application. Fortunately some clever people have written a simpler open source alternative called BOSSA (yeay contrived acronyms!). This is the program used by the Arduino "IDE" behind the scenes. It serves the same purpose as avrdude.

CMSIS code & drivers

The essential code (the CMSIS ARM stuff, and drivers for the peripherals) can be retrieved either from the Arduino software, or directly from Atmel (it's the same code really). In Arduino on Windows after you install the board, the code is in C:\Users\<you>\AppData\Roaming\Arduino15\packages\arduino (yeah really obvious). If you get it from Atmel, you want the Atmel Software Framework (ASF).


All wikipages