Arduino Forum

Products => Arduino Due => Topic started by: ardroid on Dec 27, 2012, 04:47 am

Title: Arduino Due and ADK 2012
Post by: ardroid on Dec 27, 2012, 04:47 am
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.

http://youtu.be/XJgN1gAwGQY (http://youtu.be/XJgN1gAwGQY)   
Title: Re: Arduino Due and ADK 2012
Post by: nwscfox1 on Dec 31, 2012, 05:33 pm
Did you make changes to the code on the Due that you can share?
Title: Re: Arduino Due and ADK 2012
Post by: ardroid on Jan 04, 2013, 07:02 pm

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.

Code: [Select]

void ADK::adkInit(void){

    //board init
    ::fwkInit();
    ::coopInit();
    ::ledsInit();
    ::i2cInit(1, 400000);
    ::rtcInit();
    ::rtcSet(2012, 3, 28, 19, 8, 50);
    ::audioInit();
    ::usbh_init();

    //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)
Code: [Select]

switch (usbh.state) {

case USBH_DISABLED:
break;

case USBH_INIT:

Usb_unfreeze_clock();

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

Disable_global_interrupt();

(void)Is_usb_enabled();
Enable_global_interrupt();

Usb_enable_otg_pad();
Usb_enable();

TRACE_OTG("USB_INIT\n");

Usb_set_vbof_active_low();
Usb_disable_vbus_hw_control();

Host_enable_device_disconnection_interrupt();


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

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




Simple Arduino Terminal App Sample for ADK 2012,

Code: [Select]

#include "Arduino.h"
#include "variant.h"
#include <ADK.h>


ADK L;

// ADK1 usb accessory strings
#define ACCESSORY_STRING_VENDOR "Google, Inc."
#define ACCESSORY_STRING_NAME   "DemoKit"
#define ACCESSORY_STRING_LONGNAME "ADK2012 Arduino Due Board"
#define ACCESSORY_STRING_VERSION  "1.0"
#define ACCESSORY_STRING_URL    "http://www.android.com"
#define ACCESSORY_STRING_SERIAL "0000000012345678"

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



void setup(void)
{


   
  Serial.begin(115200);

  L.adkSetPutchar(adkPutchar);
  L.adkInit();
 
  // set the old accessory strings
  L.usbSetAccessoryStringVendor(ACCESSORY_STRING_VENDOR);
  L.usbSetAccessoryStringName(ACCESSORY_STRING_NAME);
  L.usbSetAccessoryStringLongname(ACCESSORY_STRING_LONGNAME);
  L.usbSetAccessoryStringVersion(ACCESSORY_STRING_VERSION);
  L.usbSetAccessoryStringUrl(ACCESSORY_STRING_URL);
  L.usbSetAccessoryStringSerial(ACCESSORY_STRING_SERIAL);
 
  L.usbStart();
}


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]);
}
                                           
printf("\r\n");
     
    }
  }
  L.adkEventProcess(); //let the adk framework do its thing
}



Your android device will recognized as accessory device like this,
http://www.flickr.com/photos/picolink/8345855859/ (http://www.flickr.com/photos/picolink/8345855859/)

-Kevin

Title: Re: Arduino Due and ADK 2012
Post by: aleu on Jan 06, 2013, 03:04 pm
Great. That works for me. Thanks!

Title: Re: Arduino Due and ADK 2012
Post by: jangofei on Jan 06, 2013, 03:13 pm
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?
Title: Re: Arduino Due and ADK 2012
Post by: aleu on Jan 06, 2013, 09:00 pm

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.
Title: Re: Arduino Due and ADK 2012
Post by: amberjack1394 on Jan 07, 2013, 11:35 pm
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
Title: Re: Arduino Due and ADK 2012
Post by: aleu on Jan 07, 2013, 11:36 pm
There's an erase button on the Due. Press it for a few seconds before you upload a new sketch.
Title: Re: Arduino Due and ADK 2012
Post by: amberjack1394 on Jan 08, 2013, 01:16 am
Hi aleu,
Thanks a lot! It works.
Now I can enjoy the sound.
Title: Re: Arduino Due and ADK 2012
Post by: jangofei on Jan 08, 2013, 10:00 am
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.
Title: Re: Arduino Due and ADK 2012
Post by: aleu on Jan 08, 2013, 10:02 am
Ensure you selected the right com port and read above about the erase button.
Title: Re: Arduino Due and ADK 2012
Post by: jangofei on Jan 08, 2013, 10:23 am
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.
Title: Re: Arduino Due and ADK 2012
Post by: jangofei on Jan 08, 2013, 09:14 pm
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!!
Title: Re: Arduino Due and ADK 2012
Post by: jangofei on Jan 08, 2013, 11:16 pm
Another question:
I just use left channel or right channel to DAC0. Is it possible to use both of left and right channel? Thanks.
Title: Re: Arduino Due and ADK 2012
Post by: ardroid on Jan 09, 2013, 06:26 am
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.

-Kevin   
Title: Re: Arduino Due and ADK 2012
Post by: ardroid on Jan 09, 2013, 06:35 am

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,  http://labs.arduino.cc/uploads/ADK/ArduinoTerminal/ThibaultTerminal_ICS_0001.apk
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.
Title: Re: Arduino Due and ADK 2012
Post by: jangofei on Jan 09, 2013, 07:19 am
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.
Title: Re: Arduino Due and ADK 2012
Post by: amberjack1394 on Jan 09, 2013, 05:09 pm
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  :)

Sho
Title: Re: Arduino Due and ADK 2012
Post by: jangofei on Jan 09, 2013, 06:20 pm
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.
Title: Re: Arduino Due and ADK 2012
Post by: mikepparks on Jan 10, 2013, 10:03 am
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.

Code: [Select]
#include "Arduino.h"
#include "variant.h"
#include <stdio.h>
#include <adk.h>

// ADK1 usb accessory strings
#define ACCESSORY_STRING_VENDOR "Google, Inc."
#define ACCESSORY_STRING_NAME   "DemoKit"
#define ACCESSORY_STRING_LONGNAME "DemoKit Arduino Board"
#define ACCESSORY_STRING_VERSION  "2.0"
#define ACCESSORY_STRING_URL    "http://www.android.com"
#define ACCESSORY_STRING_SERIAL "0000000012345678"

#define RCVSIZE 128

USBHost Usb;
ADK adk(&Usb,ACCESSORY_STRING_VENDOR,ACCESSORY_STRING_NAME,ACCESSORY_STRING_LONGNAME,ACCESSORY_STRING_VERSION,ACCESSORY_STRING_URL,ACCESSORY_STRING_SERIAL);

void setup(void)
{
  Serial.begin(115200);
  cpu_irq_enable();
  printf("\r\nADK demo start\r\n");
  delay(200);
}


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

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


If you're trying to duplicate the hardware for some reason, it might be worth checking this (https://android.googlesource.com/device/google/accessory/adk2012_demo/+/master) out.
Title: Re: Arduino Due and ADK 2012
Post by: jangofei on Jan 10, 2013, 04:05 pm
Thanks.
Is it possible to output Audio from ADK2011 board?
Title: Re: Arduino Due and ADK 2012
Post by: jangofei on Jan 10, 2013, 05:16 pm
Got following error when I compiled your code above on ADK2012 IDE or Arduino 1.5.1r2.

C:\Users\user\AppData\Local\Temp\build5437525985664053003.tmp\sketch_jan11a.cpp.o
sketch_jan11a.ino:4: fatal error: ADK.H: No such file or directory
compilation terminated.
Title: Re: Arduino Due and ADK 2012
Post by: mikepparks on Jan 10, 2013, 07:29 pm
It looks like it might be a file name issue. Try changing "ADK.H" to "adk.h". If that doesn't work, check your "hardware/arduino/sam/libraries/USBHost/" directory. If the "adk.h" exists, something else might be wrong.
Title: Re: Arduino Due and ADK 2012
Post by: djjoshuad on Jan 15, 2013, 12:00 am
Please pardon the ignorance, as I'm just now getting started with this piece of the Arduino world (ADK on Due).

I noticed that in http://arduino.cc/blog/category/arduino/adk/ the author mentions: "The ADK2012 is based on the upcoming Arduino Due platform" - This seems to imply that ADK2012 should be directly compatible with the Due... has this not proven to be true?
Title: Re: Arduino Due and ADK 2012
Post by: mikepparks on Jan 15, 2013, 09:21 am

Please pardon the ignorance, as I'm just now getting started with this piece of the Arduino world (ADK on Due).

I noticed that in http://arduino.cc/blog/category/arduino/adk/ the author mentions: "The ADK2012 is based on the upcoming Arduino Due platform" - This seems to imply that ADK2012 should be directly compatible with the Due... has this not proven to be true?


I'm by no means an expert on that so someone with more knowledge of the matter should feel free to correct me.

The Due hardware is close to, if not exactly, identical to the ADK2012 kit if you take away all the bells and whistles. I've managed to get the Due working with the ADK2012 app, albeit with some latency issues. This is probably due to the 1.5.1r2 libs not supporting the newer ADK features.

The problem I've had, to my limited understanding, is that the version of the Arduino IDE that they're using for the ADK2012 resources doesn't take into account some of the quirks of the Due (eg. the 1200bps pulse prior to flashing). With the standard Arduino IDE (1.5.1r2), the libs are currently supporting the 2011 protocol. They're similar but there may be some extra functionality that will need to be added in. Trying to use Google's libs in the beta IDE fails since the ADK class names conflict and, fixing that, there's some issues with the conflicting of UOTGHS_Handler to be handled.

I know it's not meant to be exactly 1:1 functional with the ADK hardware but being able to use some of the functionality of that kit would be handy, especially the USB Audio parts. I've tried making some attempts at it but I don't know enough about the hardware to make any sort of real effort at porting all of the functionality over. Some idea about how the ADK libs function would be helpful to those of us wanting to attempt this.
Title: Re: Arduino Due and ADK 2012
Post by: djjoshuad on Jan 15, 2013, 01:27 pm
Thanks for the reply.  I may put some effort into this as well, although I'm (obviously) less in-the-know than you are.  I have two Due boards on my bench that are just begging to become android-controlled thermostats for my house.  There has been some great work done over at androidthermostat.com and while they have focused on the IOIO, I plan to port the accessory interface of their app to ADK2012 and (hopefully) the Due. 
Title: Re: Arduino Due and ADK 2012
Post by: djjoshuad on Jan 15, 2013, 05:53 pm
After doing a bit of digging around, it looks like a successful and familiar way to do this would be to use Processing for both the android side and the arduino side.  Have you tried this combo or had any luck getting it to work?
Title: Re: Arduino Due and ADK 2012
Post by: jangofei on Jan 15, 2013, 06:08 pm
Thanks. I resoved it. I should choose correct board--Arduino Due. Compiled successfully after I choosed board--Arduino Due.
Title: Re: Arduino Due and ADK 2012
Post by: jangofei on Jan 20, 2013, 09:18 am
Succeeded to upload your code into the Due. But the Nexus 7 or GS3 can't recognize the Due with ADK 2012/2011. Can you do it? Thanks.
Title: Re: Arduino Due and ADK 2012
Post by: djjoshuad on Jan 20, 2013, 09:48 am
The GS3 and the Nexus 7 can both recognize the Due with ADK 2012, I've tested with both. Are you running a custom ROM or kernel?  Perhaps one that leaves out USB accessory mode?
Title: Re: Arduino Due and ADK 2012
Post by: jangofei on Jan 20, 2013, 10:09 am

The GS3 and the Nexus 7 can both recognize the Due with ADK 2012, I've tested with both. Are you running a custom ROM or kernel?  Perhaps one that leaves out USB accessory mode?


I use stock rom with rooted.
The GS3/Nexus 7 recognized the Due as "connected to a USB accessory". But ADK 2012 couldn't recognize the Due.
Connection:
PC-->USB Cable-->Programming Port on Due
Nexus 7/GS3-->USB Cable-->OTG-->Native Port on Due.
Title: Re: Arduino Due and ADK 2012
Post by: djjoshuad on Jan 20, 2013, 09:06 pm
In that case it must be the way the Due is representing itself.  What sketch have you loaded on the Due?
Title: Re: Arduino Due and ADK 2012
Post by: jangofei on Jan 21, 2013, 03:58 am

In that case it must be the way the Due is representing itself.  What sketch have you loaded on the Due?


ADK 2012 should recognize the Due on Nexus 7. But waited a long time more than 5 minutes, ADK 2012 could not start correctly, it was forced stopped.
GS3 still could not recoginze the Due. I have loaded the sketch from Ardroid on this post.
Title: Re: Arduino Due and ADK 2012
Post by: djjoshuad on Jan 21, 2013, 04:40 am
ADK2012 is looking for a specific device, namely the ADK demo board that they handed out at I/O.  The device identifies itself by sending strings to android.  If you use the constants in the example from mikepparks, adk2012 should "see" the board... although of course none of the testing features will work by default since none of those circuits exist (unless you put them there).
Title: Re: Arduino Due and ADK 2012
Post by: nwscfox1 on Jan 23, 2013, 10:35 pm

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.


Why don't the mac/windows tools use the same port for programming?
Title: Re: Arduino Due and ADK 2012
Post by: djjoshuad on Jan 30, 2013, 08:45 pm
they do.  rather, they can.  This is just how he did it.
Title: Re: Arduino Due and ADK 2012
Post by: nwscfox1 on Feb 01, 2013, 06:46 pm
I have my Due working with sound from a Galaxy Nexus but the quality is pretty poor. I put a 1KHz tone on my phone and played it through the Due and it quickly becomes apparent that there is something wrong. There are gaps in the audio which don't seem to be periodic. On the scope I see small gaps about a millisecond long. The gaps happen about every 100msec (or so). After the gap, the output continues at the same voltage which makes me think the dac might be sending the same value during the gap until more data is available. Anyone else observe this?
Title: Re: Arduino Due and ADK 2012
Post by: jangofei on Feb 16, 2013, 08:23 am

I have my Due working with sound from a Galaxy Nexus but the quality is pretty poor. I put a 1KHz tone on my phone and played it through the Due and it quickly becomes apparent that there is something wrong. There are gaps in the audio which don't seem to be periodic. On the scope I see small gaps about a millisecond long. The gaps happen about every 100msec (or so). After the gap, the output continues at the same voltage which makes me think the dac might be sending the same value during the gap until more data is available. Anyone else observe this?


Can you control volume when audio out via Due?  I could not adjust volume when output audio via Due.
Title: Re: Arduino Due and ADK 2012
Post by: nwscfox1 on Feb 18, 2013, 03:43 pm
The volume over the usb seems to be fixed but there is a line in the code on Due that claims to be a volume adjustment; after combining the left and right channel, they multiply by a value and the comment is something about volume adjustment.
Title: Re: Arduino Due and ADK 2012
Post by: lier on Apr 22, 2013, 04:26 am


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,  http://labs.arduino.cc/uploads/ADK/ArduinoTerminal/ThibaultTerminal_ICS_0001.apk
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.


When use ADK2012 IDE for Due, do you copy board definition from Arduino IDE 1.5.1 to ADK2012 IDE? Since pin array of Arduino Due is different from Google ADK2. For example, Blink sketch will not blink LED if you choose board Google ADK2, because Google ADK2 define PC9 as pin 13, Arduino Due use PB27 as pin 13. I copy directory hardware/arduino/sam/variants/arduino_due_x from Arduino IDE 1.5.2 to ADK2012 IDE and select it as board, but some errors happen during compiling. Do you know have any idea or experience about this issues? Thanks.
Title: Re: Arduino Due and ADK 2012
Post by: nolanator19 on May 05, 2013, 04:31 am
I am in the same boat as lier. Can someone describe the process for compiling and uploading sketches from the ADK 2012 IDE to the Due? Uploading from Arduino IDE works fine for me but not the ADK.
Title: Re: Arduino Due and ADK 2012
Post by: iRoboticist on May 09, 2013, 06:46 am
Hi,

I am trying the ADK2012 code on Due and facing the following Compiling Error. I saw someone mention the problem, but could not find a way to resolve it.

"C:\Users\xyz\Desktop\arduino-1.5.2-windows\arduino-1.5.2\hardware\arduino\sam\variants\arduino_due_x/libsam_sam3x8e_gcc_rel.a(uotghs.o): In function `UOTGHS_Handler':
uotghs.c:(.text.UOTGHS_Handler+0x0): multiple definition of `UOTGHS_Handler'
ADK2\usbh.c.o:C:\Users\xyz\Desktop\arduino-1.5.2-windows\arduino-1.5.2\libraries\ADK2/usbh.c:684: first defined here
collect2: ld returned 1 exit status"

Title: Re: Arduino Due and ADK 2012
Post by: newhobby on Jun 30, 2013, 07:31 am
So, did anyone got around the UOTGHS_Handler conflict yet?
I was able to compile and upload just fine with the ADK2012 IDE version, but not with 1.5.2
I had to use the native port, which requires me to press erase before the upload and also requires me to disconnect the usb cable to plug the OTG cable.
I'd love to be able to upload through the programming port instead and use bossac instead of adk2install.
So, if anyone was able to get around the UOTGHS_Handler issue, please let me know or pm me.
Thanks in advance.
Title: Re: Arduino Due and ADK 2012
Post by: newhobby on Jul 08, 2013, 08:25 pm
Ok, I just wanted to post my progress.
I was able to compile and upload the terminal code posted on the original thread to a Due board using IDE 1.5.2 using the programming port.
The original ADK2012 IDE required the native port.
After digging for a few days and comparing with the Google released ADK2012, I realized the problem is with the arduino reset code built-in on the libs to erase the flash when native port is used for programming (AKA open serial at 1200bps).
By having this code enabled all the time will disable the native port from ever being able to act as OTG port.
But the trick is that if this code is not enabled, you won't be able to erase flash and upload using native port on a single shot. You will need to press the ERASE button.
In my case, I'm never planning on using the native port for uploading code anyway, so my solution works out great for me.
My solution was to create a new board reference in the boards.txt file and remove the flags for the CDC serial on native port.

Code: [Select]


New_Board.name=My Own Board
New_Board.upload.tool=bossac
New_Board.upload.protocol=sam-ba
New_Board.upload.maximum_size=524288
New_Board.upload.use_1200bps_touch=true
New_Board.upload.wait_for_upload_port=false
New_Board.upload.native_usb=false
New_Board.build.mcu=cortex-m3
New_Board.build.f_cpu=84000000L
New_Board.build.core=arduino
New_Board.build.extra_flags=-D__SAM3X8E__ -mthumb
New_Board.build.ldscript=linker_scripts/gcc/flash.ld
New_Board.build.variant=arduino_due_x
New_Board.build.variant_system_lib=libsam_sam3x8e_gcc_rel.a



And add an ifdef on the USBCore.cpp to disable the CDC code.

Code: [Select]

#ifdef USBCON

Original USBCore.cpp code goes inside the ifdef. I can't add or the post is too long and exceeds the maximum allowed length of forum, which is 9500 characters.

#endif // USBCON
Title: Re: Arduino Due and ADK 2012
Post by: asheeshs on Aug 26, 2013, 09:25 pm
Thanks for your post, its really helpful for a newbie like me. I just need to know how did you connect speaker. I have this speaker as shown in the attached image. Can I directly connect it to DAC0 and GND pins of Arduino? if not please suggest.
Title: Re: Arduino Due and ADK 2012
Post by: Palliser on Aug 26, 2013, 10:05 pm
DO NOT connect directly your speaker to the DAC pin.
Please, read and follow the following updated tutorial.

http://arduino.cc/en/Tutorial/SimpleAudioPlayer (http://arduino.cc/en/Tutorial/SimpleAudioPlayer)

Regards!
Title: Re: Arduino Due and ADK 2012
Post by: andreuc on Sep 07, 2013, 07:14 pm

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.


Guys, I'm trying to use a MEGA ADK and I arrived at the same point: troubles  in  detecting the MEGA on the COM. Any suggestions?
tnx!
a
Title: Re: Arduino Due and ADK 2012
Post by: newhobby on Sep 07, 2013, 07:15 pm
You must use native port
Title: Re: Arduino Due and ADK 2012
Post by: andreuc on Sep 07, 2013, 07:16 pm
Thanks, I'll try!
a
Title: Re: Arduino Due and ADK 2012
Post by: andreuc on Sep 07, 2013, 10:19 pm
@newhobby, connecting the MEGA ADK using  native usb, windows doesn't see anything on the usb. Is there any driver to install to make the pc see the port?
Title: Re: Arduino Due and ADK 2012
Post by: newhobby on Sep 07, 2013, 10:51 pm
I think you are in the wrong thread.
This is for a Due board and not Mega.
Also, maybe you ought to start with blink code before you start trying to use Goodle ADK stuff.
Title: Re: Arduino Due and ADK 2012
Post by: andreuc on Sep 08, 2013, 02:46 pm
I'm sorry but i didn't found any mega adk thread. If you know where is it, would you be so kind to tell me? No problem with adk 2011 so far, but as i read through the forums adk 2012 is not so immediate.
Thanks
Andrea
Title: Re: Arduino Due and ADK 2012
Post by: atoy40 on Oct 11, 2013, 10:23 am
Hello,

i'm trying to use a Due with a Nexus4 phone. I've compiled an loaded the sample successfully (thanks to your code modifications tips  :)), but when i plug the Due on the Phone, the phone battery charge status start to blink, and i get a repeated "disconnected" message in the arduino serial console. (the phone detect an adk accessory sometimes, somtimes not...)
I use a USB-A female <-> micro-B male on the phone side (not referenced as OTG), is it a problem ?

Another question, has anyone tested a blutooth shield on the Due ? and the ADK2-over-BT feature ?

Thanks.

Anthony.
Title: Re: Arduino Due and ADK 2012
Post by: Yoshi0351 on Oct 13, 2013, 06:32 am
Have you tried using an external power source? I was fighting trying to get this to work with my Galaxy S4,  had no luck til I plugged in a wall wart.

I am using an OTG adapter though...
Title: Re: Arduino Due and ADK 2012
Post by: atoy40 on Oct 14, 2013, 08:48 am
Yes, i've tried this weekend with a power supply and it's now working perfectly :D
Title: Re: Arduino Due and ADK 2012
Post by: brnyza on Feb 10, 2014, 07:27 pm
Hi all,

I've tried this example and it worked:  http://arduino-er.blogspot.com.br/2013/04/arduino-due-android-adk-change-led.html?view=classic
Is this example use "ADK 2012"?

Just another question, someone know what's the advantage to use processing (http://stream.tellart.com/controlling-arduino-with-android/)
Someone built the communication of Arduino due + Android app developed with processing?

Thank you.

------------------

Processing + Eclipse + Android + Arduino Due (USB and adk.h)

The video example working: http://goo.gl/FGmYLe

based on example: http://android-er.blogspot.com.br/2013/03/adk-example-control-arduino-due-led.html

Phone: 4.1.2 GT-S6812B

-------------------

Title: Re: Arduino Due and ADK 2012
Post by: destroyer85 on Feb 10, 2014, 11:35 pm


And add an ifdef on the USBCore.cpp to disable the CDC code.

Code: [Select]

#ifdef USBCON

Original USBCore.cpp code goes inside the ifdef. I can't add or the post is too long and exceeds the maximum allowed length of forum, which is 9500 characters.

#endif // USBCON


Hello and thanks to everybody in this thread now i'm able to upload a working sketch to my arduino that can communicates with my android mobile phone. I have one question about programming arduino DUE. Until now i was able to upload working sketch only with native port. i read that there is a solution to use the programming port and the native port. I unaderstand almost everything escept the part tha i quoted. Anybody can explain me this part?

Thanks in advance.
Title: Re: Arduino Due and ADK 2012
Post by: bt_noobie on Sep 09, 2015, 03:23 am
Hi everyone!
Thank you to everyone in this thread. Special thanks to ardroid.
I have finally made arduino due usb audio work.
I would like to make BT audio work too. Has anyone here succeeded on it?
Google's adk2012 was using custom ckt and stack with TI cc2564. It's not available in the country I'm in and it's also smd which is difficult for me to solder some pins into.
I tried using HC-06 but it only supports serial communication.
If you were able to succeed BT audio, could you share what BT module or chip you used and some code maybe?