3
\$\begingroup\$

I recently bought an Arduino DUE. I was going through the technical details and realized that the DUE acts a a virtual USB device (COM port). I was wondering whether I could upgrade the Board Support Package to my own custom one. Basically I want to make it act like a true USB device or HID device. This would include rewriting the bootloader and the device drivers (on my computer).

So before I get started with my own bootloader and software, I want to know how the booting currently happens on the DUE. Do they use the same Arduino bootloader? because I read that the SAM processor has an inbuilt bootloader from the factory. Where can I find more information regarding all this? any way how does the uploading of code from Arduino IDE happen if there is no Arduino bootloader on the chip? Any kind of pointers appreciated.

\$\endgroup\$
1

2 Answers 2

2
\$\begingroup\$

You shouldn't have to rewrite the Arduino Due bootloader - you just need to write a program that can act as USB HID using the native USB port, and upload the program to the Arduino Due. You can use the Due's programming USB port to do the upload.

But here's info on the Arduino Due boot process:

The Due has a ROM bootloader that listens to the USB native port and Serial port 0. You can talk to the ROM bootloader via USB directly by resetting the SAM3X8E and using the native port. But I've not found that method to be very reliable. The more frequently used programming port is connected to an Atmel AVR 16U2 microprocessor acting as a USB-serial converter, connected to the SAM3X8E serial port 0. The Arduino 1.5 IDE can talk to the 16U2 using the Bossa command (bossac), reset the SAM3X8E, and upload new programs to it it. This page explains the Arduino Due's bootloader in detail.

If you're interested, here's the source code for the 16U2 AVR USB-serial converter.

And here's Bossa - the Due's command that corresponds to avrdude.

Using bossac (the Bossa commandline tool), you can upload code the SAM3X8E, using the builtin ROM bootloader.


On creating HID devices:

Here's a link to an Atmel application note that has example code for creating a program that can act as a USB HID keyboard:

http://asf.atmel.com/docs/latest/common.services.usb.class.hid.device.keyboard.example.sam3x_ek/html/index.html

The source code to this example is the in the Atmel ASF packages - unfortunately, a large download. Here's where to get it:

http://asf.atmel.com/docs/latest/download.html

Once you download it, the source code the HID keyboard example is in this folder:

common/services/usb/class/hid/device/kbd/example/sam3x8e_arduino_due_x

Here's a list of the other app notes, with examples of other kinds of USB and HID devices. Look for the ones that are for the Arduino Due:

http://asf.atmel.com/docs/latest/applications.html

\$\endgroup\$
4
  • \$\begingroup\$ Just wondering, the arduino IDE uploads the program onto the board (in case of uno/others) using avr dude itself. This is possible because there is the arduino bootloader which communicates with the avr dude on the comp side. how is this achieved in the due? other than the SAM bootloader, is there another arduino bootloader? \$\endgroup\$
    – deepak
    Nov 23, 2013 at 5:47
  • \$\begingroup\$ The Arduino Due has a ROM bootloader that listens to the USB native port and a serial port. You can talk to the ROM bootloader via USB directly by resetting the SAM3X8E and using the native port. But I've not found that method to be very reliable. The more frequently used programming port is connected to an Atmel AVR 16U2 microprocessor acting as a USB-serial converter, connected to one of the SAM3X8E's serial ports. The Arduino 1.5 IDE can talk to the 16U2, reset the SAM3X8E, and upload new programs to it it. The link from user141072 above explains it in detail- \$\endgroup\$
    – Adam F
    Nov 24, 2013 at 20:19
  • \$\begingroup\$ If you're interested, here's the link to the source code for the 16U2 AVR USB-serial converter: github.com/arduino/Arduino/tree/ide-1.5.x/hardware/arduino/sam/… \$\endgroup\$
    – Adam F
    Nov 24, 2013 at 20:21
  • \$\begingroup\$ And here's Bossa - the command that corresponds to avdude: shumatech.com/web/products/bossa Using bossac (the commandline bossa tool), you can upload code the SAM3X8E, using the builtin ROM bootloader. \$\endgroup\$
    – Adam F
    Nov 24, 2013 at 20:41
1
\$\begingroup\$

I have also investigated to use the native USB port. With the Arduino IDE, it seems unreliable but I am using a utility C program to trigger the reboot by configuring the USB COM port at 1200bps.

Hack to use the SAM3X8E bootloader with the native USB port on the Arduino Due or on the Taijiuino (variant of the Due):

  • configure the USB native COM port at 1200bps to reboot the application
  • in that case, the system restarts in BOSSA mode
  • after the reboot, wait until the BOSSA COM port is ready
  • then, the BOSSA firmware uses the USB port with a different VID/PID so it reconfigures the USB link to a another COM port

You can use REGEDIT to monitor the assigned USB COM ports:

  • the COM19 to COM17 transition can be observed in the registry: HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM\

    "\\Device\\USBSER001"="COM19"
    
    "\\Device\\USBSER000"="COM17"
    
  • after the reset on COM19 the VID/PID change from "Arduino" to "Bossa":

    HKLM\SYSTEM\CurrentControlSet\Enum\USB\Vid_2341&Pid_003e&MI_00 "FriendlyName"="Arduino Due (COM19)"

    HKLM\SYSTEM\CurrentControlSet\Enum\USB\Vid_03eb&Pid_6124 "FriendlyName"="Bossa Program Port (COM17)"

Observed timing:

  • there is an empirical delay of 2.5s between

    • the linkdown on COM19 (USB stack of the application program)

    • the linkup on COM17 (USB stack of the BOSSA bootloader)

  • on another PC the COM17/COM19 assignment may be different for

    • the Vid 2341 Pid 003e (the Arduino Due COM port)

    • the Vid 03eb Pid 6124 (the Bossa Program COM port)

  • I have noticed that the wait loop with a sleep delay of 1 second is reliable:

    • after 4s, the BOSSA firmware is ready (in case of crash, timeout after 6s)

    • then, the bossac command can be executed:

    bossac -p COM17 -U true -e -w -b $OBJ_DIR/$APP.bin -R

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.