Arduino Due and ADK 2012

I've successfully loaded Google's ADK 2012 demo onto DUE board. Changed code to disabling BT interface and also updated USB VSB pin control portion.

Did you make changes to the code on the Due that you can share?

nwscfox1: Did you make changes to the code on the Due that you can share?

Yes, I did. ADK 2012 will not run as is on DUE board.

First, you have to comment out BT and some init parts in ADK.cpp file as below.

void ADK::adkInit(void){

    //board init
    ::i2cInit(1, 400000);
    ::rtcSet(2012, 3, 28, 19, 8, 50);

    //bt init
    static const BtFuncs myBtFuncs = {this, btVerboseScanCbkF, btConnReqF, btConnStartF, btConnEndF, btPinRequestF, btLinkKeyRequest, btLinkKeyCreated, btAclDataRxF, btSspShowF};

//  btInit(&myBtFuncs);              //BT UART & HCI driver
//    btSdpRegisterL2capService();     //SDP daemon
//    btRfcommRegisterL2capService();  //RFCOMM framework
    eliza();                         //easter egg
//    btA2dpRegister();                //A2DP profile

    uint8_t mac[BT_MAC_SIZE];

//    if(::btLocalMac(mac)) dbgPrintf("BT MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]);

    //i2c devices init
//    if(!hygroInit()) dbgPrintf("ADK i2c init failure: hygrometer\n");   
//    if(!baroInit()) dbgPrintf("ADK i2c init failure: barometer\n");
//    if(!capSenseInit()) dbgPrintf("ADK i2c init failure: capsense\n");
//    if(!alsInit()) dbgPrintf("ADK i2c init failure: ALS\n");
//    if(!accelInit()) dbgPrintf("ADK i2c init failure: accelerometer\n");
//    if(!magInit())  dbgPrintf("ADK i2c init failure: magnetometer\n");

    dbgPrintf("BT iniit end\n");


And, also you have to change code in usbh.c code as below, (It's in usbhwork(void) function's switch command)

    switch (usbh.state) {

        case USBH_DISABLED:

        case USBH_INIT:


            //Wr_bitfield(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_SPDCONF_Msk, 1, UOTGHS_HSTCTRL_SPDCONF_Pos); // force full/low speed







            Wr_bitfield(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_SPDCONF_Msk, 3, UOTGHS_HSTCTRL_SPDCONF_Pos); // force full speed mode
            usbh.state = USBH_DEVICE_UNATTACHED;

            // clear all ints
            UOTGHS->UOTGHS_SCR = 0xf;
            UOTGHS->UOTGHS_HSTICR = 0xf;

Simple Arduino Terminal App Sample for ADK 2012,

#include "Arduino.h"
#include "variant.h"


// ADK1 usb accessory strings
#define ACCESSORY_STRING_VENDOR "Google, Inc."
#define ACCESSORY_STRING_LONGNAME "ADK2012 Arduino Due Board"
#define ACCESSORY_STRING_SERIAL "0000000012345678"

void adkPutchar(char c){Serial.write(c);}
extern "C" void dbgPrintf(const char *, ... );

void setup(void)


  // set the old accessory strings

void loop()

  char helloWorld[] = "Hello World! \r\n";
  uint8_t buf[128];

  if (L.accessoryConnected()) {
    int res = L.accessoryReceive(buf, sizeof(buf));
   if (res > 0) {
     L.accessorySend((uint8_t *)helloWorld, strlen(helloWorld));
      for (uint32_t i = 0; i < res; ++i)
                printf("%c", (char)buf[i]);
  L.adkEventProcess(); //let the adk framework do its thing

Your android device will recognized as accessory device like this,


Great. That works for me. Thanks!

Great! I have the following questions:

  1. Which Arduino IDE do you use? arduino-1.5.1r2? or adk2012_ide-win32-20120629?
  2. What app do you use on Nexus 7 to transfer data to Due?
  3. Is DC to supply power a must? Arduino Due can't work when I use a DC--3.3V & 2.0A. What DC do you use?
  1. adk2012 ide / mac. Please note that the libraries/core contained in the adk2012 ide differs significantly from the arduino ide. Thus the adk2012 sources are probably not compatible with the arduino ide.

  2. None. I just tested audio output. The adk2012 audio feature automatically reroutes all audio output to the adk hardware if activated. I.e. you can use every app that makes some noise (youtube, one of my virtual instrument apps ("Opus #1" / "Grand Piano" / "Keyboard Sounds"), ...). BTW: if audio stutters, you may want to adjust the size of audrecvbuf in accessory.c to the buffer size of the audio endpoint.

  3. I powered the Due via the usb cable from my mac -> due programming port. A usb power supply on the programming port seems to work too. However, a power supply on the power connector does not work for me.

Hi aleu, Great work!

I try to do same things in my environment with MacBook pro. After finish compule, ADK2012 says adk2tool /dev/tty.usbmodemfa131 erase bossac --port=tty.usbmodemfa131 -w -b ****usbaccessory.cpp.bin "No device found on tty.usbmodemfa131" adk2tool /dev/tty.usbmodemfa131 reset

Do you have any suggestion? Sho

There's an erase button on the Due. Press it for a few seconds before you upload a new sketch.

Hi aleu, Thanks a lot! It works. Now I can enjoy the sound.

It still can't work. PC-->Programming port, Nexus 7-->OTG-->Native port. Due can't be reconginzed by Nexus 7 or i9300. OS: Android 4.2.1 on Nexus 7 or i9300.

I got error when I was uploading sketch into Due board. What is wrong I did?

C:\ADK2012_IDE_0/hardware/tools/adk2tool.exe COM3 erase erasing...done. C:\ADK2012_IDE_0/hardware/tools/bossac.exe --port=COM3 -w -b C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\build5785210613214747736.tmp/Arduino_Terminal_App_Sample.cpp.bin No device found on COM3 C:\ADK2012_IDE_0/hardware/tools/adk2tool.exe COM3 reset resetting...done.

Ensure you selected the right com port and read above about the erase button.

Thanks Aleu!

It should be correct com port(Arduino Due programming port on PC). And I pressed the erase button before uploading.

It seems that Due was not recognized by ADK2012 IDE after erasing (erasing done).

IDE should prompt like below if it uploads successfully? ..... Verify successful Set boot flash true CPU reset.

Hello, All
I did it!!!
I changed port to Native USB for uploading sketch into Due. Now I am enjoying the music from Nexus 7.

Thanks Aleu, Ardroid and all!!

Another question: I just use left channel or right channel to DAC0. Is it possible to use both of left and right channel? Thanks.

Google's ADK2012 sample actually merge left/right channel into one and output to DAC0. Yes it is possible separate L/R to DAC0/1. I am thinking about actually doing so. However, I am currently woking on attaching bluetooth HCI module. I will let you know once it done.


jangofei: Great! I have the following questions:

  1. Which Arduino IDE do you use? arduino-1.5.1r2? or adk2012_ide-win32-20120629?
  2. What app do you use on Nexus 7 to transfer data to Due?
  3. Is DC to supply power a must? Arduino Due can't work when I use a DC--3.3V & 2.0A. What DC do you use?
  1. Used ADK2012 IDE from Google
  2. This Terminal App,
  3. You can use computer's USB power and I've tested 12V DC external power also. It works either way. (Arduino DUE has some issue with USBVSB (USB Master power control) That's why usbh.c needs to updated to work properly on DUE.

I appreciate your sharing! I couldn't do it if no your help. Is it possible to share BT if you have done? I am interested everything in ADK2012. Thanks.

Hi all, I just confirmed upload of modified ADK2012 to DUE on both Mac and Win in my desk. Mac: Macbook Pro 10.6 with JDK 6 DUE: program port Win: Windows7 64bit DUE: native port (BOSSA Program port (COM**)) Thanks to aleu and jamgofei and all.

For 2ch playback, "process audio" in accessory.c seems starting point to understand and modify. Never forget erase button :)


Thanks your summary.

New question: Can’t change the volume on Nexus 7 when output audio via MicroUSB. The default volume is max volume. Do you have any ideas about it? Thanks.

Not nearly impressive but I managed to get the ADK 2012 app and the 2011 DemoKit to recognize Kevin/ardroid's sketch. This might be handy to someone or it might be completely useless. Having a control app already developed might be useful to someone.

It is worth noting, however, that this is working with the default ADK implementation that comes with Arduino 1.5.1r2 and is missing pretty much every feature available in the ADK 2012 libraries (BT, LEDs, etc). Some work would need to be done to get this library working on a vanilla Due rather than the ADK device.

Changing the version number between 1.0 and 2.0 while keeping ACCESSORY_STRING_NAME set to "DemoKit" will allow you to use the 2011 and 2012 ADK test apps, if you so desire.

#include "Arduino.h"
#include "variant.h"

// ADK1 usb accessory strings
#define ACCESSORY_STRING_VENDOR "Google, Inc."
#define ACCESSORY_STRING_LONGNAME "DemoKit Arduino Board"
#define ACCESSORY_STRING_SERIAL "0000000012345678"

#define RCVSIZE 128

USBHost Usb;

void setup(void)
  printf("\r\nADK demo start\r\n");

void loop()
  uint8_t buf[RCVSIZE];
  uint32_t nbread = 0;
  char helloworld[] = "Hello World!\r\n";

  if (adk.isReady()) {
    adk.write(strlen(helloworld), (uint8_t *)helloworld);
    delay(1000);, RCVSIZE, buf);
    if (nbread > 0) {
      printf("RCV: ");
      for (uint32_t i = 0; i < nbread; ++i) {
        printf("%c", (char)buf[i]);

If you're trying to duplicate the hardware for some reason, it might be worth checking this out.