RXマイコンでAndroid Open Accessory

2011年5月のInterfaceについてたRXマイコン基板のUSB HOSTで遊んでいました。
RX62Nマイコン基板特設ページ|Interface

Interface (インターフェース) 2011年 05月号 [雑誌]

Interface (インターフェース) 2011年 05月号 [雑誌]


まずルネサスさんからサンプルコードをダウンロードして
ルネサスUSB デバイス USB Basic Firmware

RTOSはInterfaceでも紹介されていたTOPPERS ASPをつかって
TOPPERSプロジェクト/ASPカーネル

開発環境はHEWにしようと思ったけど、最近はCubeSuite+らしいので
統合開発環境 CubeSuite+ | ルネサス エレクトロニクス

デバッガ無いと何もできないのでE1
E1 | ルネサス エレクトロニクス

やったこと

  1. TOPPERS ASPをCubeSuite+でビルドできるようにプロジェクトを変更
  2. USB Basic FirmwareをPORT0でUSB HOSTが使えるように変更
  3. USB Basic FirmwareTOPPERS ASPで動くようにコンフィグレーションなど作成
  4. Android Open Accessory用ドライバの作成

はまったところ

  1. CubeSuite+がよく止まる...
  2. TOPPERS ASPのビルドで必要なアセンブラソースを出力する方法がCubeSuite+のGUIで見つからなかった コマンド引数の追加でできたけど
  3. USB Basic Firmwareのソースにセクションの設定がしてあって、そのせいで初期化が必要な変数がすべてROMにマップされてた
  4. TOPPERS ASPのRX62N対応にはいくつか修正が必要な箇所があった

MAPファイル

ログとかも入ってるデバッグ

*** Total Section Size ***
RAMDATA SECTION:  00006f3f Byte(s)    28,479Byte
ROMDATA SECTION:  00005061 Byte(s)    20,577Byte
PROGRAM SECTION:  0000f329 Byte(s)    62,249Byte

動作ログ

Accessoryモードに対応しているか確認後、コマンドを送ってAccessoryモードに切り替える

TOPPERS/ASP Kernel Release 1.6.1 for FRK_RX62N (Mar 20 2012, 12:47:15)
Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
                            Toyohashi Univ. of Technology, JAPAN
Copyright (C) 2004-2010 by Embedded and Real-Time Systems Laboratory
            Graduate School of Information Science, Nagoya Univ., JAPAN
Copyright (C) 2010 by Witz Corporation, JAPAN

System logging task is started on port 1.
*** Install USB-MGR ***

*** Install USB-HCD ***

*** Registration driver 0xff

*** Registration driver 0x08

*** Registration driver 0x09

 Detect FS-J

main_task

 [Attach Device port0] 

 Full-Speed Device

*** FRDY wait pipe = 0

*** FRDY wait pipe = 0

*** FRDY wait pipe = 0

*** Interface class is 0x08 (not 0xff)

  Device Descriptor.

   idVendor : 18d1 idProduct : 4e21 

  Configuration Descriptor.

   wTotalLength : 32 bNumInterface : 1 

  Interface Descriptor.

   bInterfaceNumber : 0 bAlternateSetting : 0  bNumEndpoints : 2 

   bInterfaceClass : 8 bInterfaceSubClass : 6  bInterfaceProtocol : 50 

Check AccessoryMode

*** FRDY wait pipe = 0

Switch AccessoryMode

*** Interface class is 0x08 (not 0x09)

*** FRDY wait pipe = 0

 Configured Device

DTTCH int port0

*** Device address 1 clear.

hINT_UNKNOWN

 [Detach Device port0] 

 Detect FS-J

 [Attach Device port0] 

 Full-Speed Device

*** FRDY wait pipe = 0

*** FRDY wait pipe = 0


*** FRDY wait pipe = 0

*** FRDY wait pipe = 0

  Device Descriptor.

   idVendor : 18d1 idProduct : 2d00 

  Configuration Descriptor.

   wTotalLength : 32 bNumInterface : 1 

  Interface Descriptor.

   bInterfaceNumber : 0 bAlternateSetting : 0  bNumEndpoints : 2 

   bInterfaceClass : ff bInterfaceSubClass : ff  bInterfaceProtocol : 0 

AccessoryMode

  Endpoint Descriptor.

   bEndpointAddress : 1 : 5 bmAttributes : 2  wMaxPacketSize : 64 bInterval : 0 

 BULK 
 pipe1 configuration 4085 0040 0000

  Endpoint Descriptor.

   bEndpointAddress : 0 : 7 bmAttributes : 2  wMaxPacketSize : 64 bInterval : 0 

 BULK 
 pipe2 configuration 4017 0040 0000

*** FRDY wait pipe = 0

 Configured Device

*** Install Accessory driver ***

DTTCH int port0

*** Device address 1 clear.

hINT_UNKNOWN

 [Detach Device port0] 

*** Release Accessory driver ***


まだ認識したところまでで通信はたぶんできるはず
Androidの方にもダイアログが表示されます。