Sunday, October 9, 2011

EvalBot and Android Open Accessory Dev Kit source code under GPL v2


It is now official the EvalBotADK code is available like promised on GitHub and it is open source using GPL v2.

It is the public release of USB Host Driver for Android Open Accessory on EvalBot (it should work also with any other Stellaris ARM chipset supporting USB OTG with minor changes).

About Hardware Hack: 
The EvalBot USB Host Power Supply has been hacked because by default it does not work with Usb Host which require more than 100/150mA (due to limitation of hardware) and so I have modified USB Power supply to use external power in order to connect any USB Host compliant with USB specification which allow current until 500mA.
This Hack also work with any hardware because it's done on a Usb Extension and a BreadBoard with External PowerSupply.

Hardware hack schematic details:

Hardware Hack USB Extension External Power


About Software:
For Android software I have used DemoKit which is just a rebuild of sample in official Android NDK package see http://developer.android.com/guide/topics/usb/adk.html and download package here https://dl-ssl.google.com/android/adk/adk_release_0512.zip.
Later we could develop our own Android Application but for this release i just used existing DemoKit.

For EvalBot I have developed the Usb Host driver for Open Accessory and an example which communicate with DemoKit.
In order to build the code you should download and install following Texas Instrument packages (requires registration which is free):
  1. The code requires TI Code Composer v4 (I use Version: 4.2.4.00033) see http://www.ti.com/tool/ccstudio or directly http://processors.wiki.ti.com/index.php/Download_CCS#Download_latest_production_CCSv4_DVD_image and choose "Download latest production CCSv4 DVD image" for the Licence see "Getting a License:" just after, it is totally free and there is no limitation in time or removed options. See http://processors.wiki.ti.com/index.php/Licensing_-_CCSv4#Free_Licenses_bundle
  2.  Usb Library: http://www.ti.com/tool/sw-usbl => I use SW-USBL-8049.exe which is installed in my example in F:/TI_EvalBot/SW-USBL-8049 3)
  3. EvalBot Firmare: http://www.ti.com/tool/sw-ek-evalbot => I use SW-EK-EVALBOT-7611.exe which is installed in my example in F:/TI_EvalBot/SW-EK-EVALBOT-7611 
 It is maybe possible to rebuild all under a gcc version for ARM M3 with minor changes but I have not tried it and Code Composer is very cool for that with a complete IDE+Compiler and all is free for personal use.

To simplify the development you can mount a virtual drive to F:\ using subst F:\ yourdrive\ or you will need to change paths defined hereafter.

Following Linked resource are required in Code Composer Project(file .project):
F:/TI_EvalBot/SW-USBL-8049/usblib
F:/TI_EvalBot/SW-EK-EVALBOT-7611/driverlib
F:/TI_EvalBot/SW-EK-EVALBOT-7611/inc
F:/TI_EvalBot/SW-EK-EVALBOT-7611/boards/ek-evalbot/drivers
F:/TI_EvalBot/SW-EK-EVALBOT-7611/utils

Following Include Options are required in Code Composer Project(file .cdtbuild):
F:\TI_EvalBot\SW-EK-EVALBOT-7611
F:\TI_EvalBot\SW-EK-EVALBOT-7611\boards\ek-evalbot
F:\TI_EvalBot\SW-USBL-8049

What feature included for this new demo:
  1. With EvalBot if you press Button Switch1, 2 or Bumper Left/Right it send the button/bumper state to DemoKit.
  2. With DemoKit you can send command (Relay1 or 2) to switch On/Off EvalBot Leds(Led1 & 2).
  3. With DemoKit Servo1=Speed for MotorLeft and Relay1=MotorLeft ON/OFF.
  4. With DemoKit Servo2=Speed for MotorRight and Relay2=MotorRight ON/OFF.

All the code is under GPLv2 and available on GitHub: See WebPage https://github.com/TitanMKD/EvalBotADK

27 comments:

  1. Any progress in getting the OLED to display anything from the phone?

    ReplyDelete
  2. All is ready in the code you can do what you want even with the OLED display.
    That will just need a modification of Android ADK Java Apps to fill a field to send it to the EvalBot which will display it on OLED for example ...

    ReplyDelete
  3. That's awesome! I'm working on getting this compiled right now.

    ReplyDelete
  4. The licence will move from GPL to LGPL next time, If you have any problems or fin any bug tell me it and I will fix it at same time.

    ReplyDelete
  5. Okay, I finally got it compiled and uploaded to the Evalbot. So I'm guessing it doesn't work until the USB power supply is fixed? Can you explain how you did that? I don't understand where the 9 Ohm, and 1K Ohm resistor connect to. I don't suppose you could provide a schematic? Thanks.

    ReplyDelete
  6. I have just updated it with a cool schematic of the Hardware Hack on USB Extension cable.
    I hope that will help you.
    Nota: I have not added 9/10 Ohm resistor to protect against shortcut for simplicity and because some Power Supply already have such feature.

    ReplyDelete
  7. That's very clear now, thank you for taking the time to add that. I'll let you know how this all work for me when I finish putting the hardware all together.

    ReplyDelete
  8. Ok, I made the cable and everything works fine now! Thanks a lot for your help. I connected the power for the phone right
    to the batteries on the Stellaris, and it seems to work fine. Is there any reason why that isn't a good idea? Will it drain out the batteries much faster?

    ReplyDelete
  9. I'm happy for you all work fine.
    Yes it will drain lot of power in fact the maximum can be 500mA at 5V.
    You can also connect it to an external Low Cost Battery, but becareful to have the same GND on Eval Bot and your external power.
    Best Regards
    Benjamin

    ReplyDelete
  10. just linked this article on my facebook account. it’s a very interesting article for all.

    Embedded Software Development

    ReplyDelete
  11. Hi, it's possible to get already compiled android app for th evalbot? I would like just to try your code and I don't want to install Android sdk. Thanks

    ReplyDelete
  12. Hi Martin,

    It is now in official GitHub Repository
    https://github.com/TitanMKD/EvalBotADK/tree/master/adk_release_0512_build

    Best Regards
    Benjamin

    ReplyDelete
  13. Hi TitanMKD,

    I'm trying to implement this project but I've a problem and I dont know how I can solve it. I loaded the program EVALBOT and Android. I created the USB cable properly because my phone detects the input of a USB when I connect it to EVALBOT. The problem is that none of the programs does nothing, It is as if there weren't detected. Do you know what I can do to detect the problem?

    Thanks

    Javier

    ReplyDelete
  14. Hi Javier,

    I will need to know more about which hardware you used like:
    Do you use EvalBot ?
    Which phone are you using ?
    A link with full hardware connected with photo could help as there is lot of things which could be wrong.

    Best Regards
    Benjamin

    ReplyDelete
  15. I use Stellaris EvalBot (lm3s9b92). I've a Bq 5 HD with Android 4.2.1. and Sony Ericsson Xperia Neo V with Android 4.0.4
    Maybe this can help u, my Code Composer Studio is the CCSv5 and I only can found the SW-EK-EVALBOT-10007 and
    SW-USBL-10636 (the latest version).

    Thanks for everything
    Javier

    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. Sorry, I forgot to upload the photo before, here it is. I did it just after connecting evalbot to he mobile phone.
      https://imageshack.com/i/mus8ovj

      Delete
    2. The problem could be due to Android version you are using or newest SW-USBL, the best will be to add breakpoint in code and also to trace each step.
      Warning there is a short timeout during selection of Accessory Mode, so this part shall be not done in step by step.

      Best Regards
      Benjamin

      Delete
  17. I'm trying to port this to the Tiva C Launchpad (EK-TM4C123GXL). Was there any reason you used USB_OTG mode instead of simply using USB_HOST operation? I've tied my USB VBus to +5V, consequently I don't have the ability monitor/control it. Is this a cause for concern?

    ReplyDelete
    Replies
    1. This could be a cause of problem but I imagine you can disable the USB VBus detection by software too.

      Delete
    2. Presently, I've removed the call to USBHCDPowerConfigInit() on another program where I'm able to mount and read a fat formated usb stick and it seems to be working fine.

      I haven't attempted OTG mode on the board though. It's always been either Host or Device mode. In any case, I'll have to give it a shot and see how it goes.

      Delete
    3. Hi Krithik,

      Very interesting project if you have some photo, video or other news about you are welcome to post the links here.

      Best Regards
      Benjamin Vernoux

      Delete
  18. Hi Benjamin,

    Will definitely post code/pictures as soon as I have it working smoothly. I'm pretty close to finishing the port. I'm able to trigger USB Accessory mode and also print the Device Descriptor correctly.

    I had a question, in your code you have calls to USBHCDControlTransfer(). But the parameters being passed are slightly different from the definition, and the compiler throws a warning:

    Example, in getDeviceDesc(): USBHCDControlTransfer(0, &SetupPacket, pDevice->ulAddress, (unsigned char *)&devDesc[0], sizeof(tDeviceDescriptor), MAX_PACKET_SIZE_EP0);

    But the actual method uses
    USBHCDControlTransfer(uint32_t ui32Index,tUSBRequest *psSetupPacket, tUSBHostDevice *psDevice, uint8_t *pui8Data, uint32_t ui32Size, uint32_t ui32MaxPacketSize);

    So, the difference is pDevice -> ulAddress instead of pDevice. Any particular reason for this? Also, the new Tivaware does not have a definition for tUSBHostDevice, as of now I stuck in the old Stelarrisware definition. Open to suggestions for improving this.

    Apologies in advance if I'm spamming your comment thread, but I'm happy to send an email regarding this.

    ReplyDelete
    Replies
    1. Hi Krithik,

      the API of USBHCDControlTransfer() have changed in new library,
      so and in my code
      ulBytes = USBHCDControlTransfer(0, &SetupPacket, pDevice->ulAddress,
      (t_u8 *)&configDesc[0],
      SetupPacket.wLength,
      pDevice->DeviceDescriptor.bMaxPacketSize0);
      "pDevice->ulAddress" shall be replaced by "pDevice"

      Best Regards
      Benjamin

      Delete
  19. Nevermind,the struct's new definition was in usbhostpriv.h. I'm now able to communicate to the Tiva board :)

    ReplyDelete
    Replies
    1. Great news !!
      I will be happy to accept your modifications for Tiva boards or any other board, as my code is a bit old (for old lib).

      Delete