LoginSignup
7
7

More than 5 years have passed since last update.

OSX上のopenocdから FM3スティックに繋がらない時の対処法

Last updated at Posted at 2014-05-07

Spansion社が販売している SK-FM3-48PMC-USBSTICK (以下 FM3スティックと略記)は,値段も手頃で入手性も悪くない評価ボードです.

しかし,どんな評価ボードにも難点はあるもので,このFM3スティックの場合は,オンボードのJTAGアダプタが鬼門です.

問題の背景

FM3スティックのオンボードJTAGアダプタは,FTDI社のFT2232という,廉価帯のJTAGアダプタではお馴染みのチップが使われています.
このチップは多機能で,シリアルポートにもなりますし,パラレルポートにもなりますし,JTAGアダプタとしても使えます.

FT2232はは,USB の個体識別に必要な VID/PID を,外部の SPIフラッシュメモリに保存します.フラッシュメモリが実装されていなければ,FTDI社が所有している VID/PID (0403:6010) が割り振られます.

OSX 側は,FM3スティックが挿さったとき,VID/PID (0403:6010) を認識して,デバイスドライバをロードします.このとき,OSXは VID/PID が 0404:6010 のデバイスをシリアルポートとして認識し,シリアルポート用のドライバを選択します.

そのため,openocd では JTAG デバイスとして認識できなくなります.例えば下記のようなメッセージが出ます.

$ openocd 
Open On-Chip Debugger 0.8.0 (2014-05-08-01:30)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
jtag_ntrst_delay: 500
trst_only separate trst_push_pull
adapter speed: 500 kHz
   TapName             Enabled  IdCode     Expected   IrLen IrCap IrMask
-- ------------------- -------- ---------- ---------- ----- ----- ------
 0 mb9bfxx2.cpu           Y     0x00000000 0x4ba00477     4 0x01  0x0f
#0 : mb9bfxx2.flash (fm3) at 0x00000000, size 0x00000000, buswidth 0, chipwidth 0
cortex_m reset_config sysresetreq
Error: libusb_claim_interface() failed with -3
Error: unable to open ftdi device with vid 0403, pid 6010, description 'Dual RS232' and serial '*'
in procedure 'init'
$

上のログで, $ は,コマンドプロンプトです.(下記も同様)

解決

最もシンプルな方法は,デバイスをアンロードする解決法です.
まず,FTDI 関連のドライバで,ロードされているものを探します.

$ kextstat|grep FTDI
  227    0 0xffffff7f82650000 0x8000     0x8000     com.FTDI.driver.FTDIUSBSerialDriver (2.2.17) <105 37 5 4 3 1>

私の手元では,com.FTDI.driver.FTDIUSBSerialDriver しか出てきませんが,環境によっては,いくつかのドライバが出てきます.

それらをアンロードします.管理者権限が必要です.

$ sudo kextunload -bundle com.FTDI.driver.FTDIUSBSerialDriver
Password:

そののち,openocd を起動します.openocd.cfg は,bitbucket にあるリポジトリが参考になります.

$ openocd 
Open On-Chip Debugger 0.8.0 (2014-05-08-01:30)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
jtag_ntrst_delay: 500
trst_only separate trst_push_pull
adapter speed: 500 kHz
   TapName             Enabled  IdCode     Expected   IrLen IrCap IrMask
-- ------------------- -------- ---------- ---------- ----- ----- ------
 0 mb9bfxx2.cpu           Y     0x00000000 0x4ba00477     4 0x01  0x0f
#0 : mb9bfxx2.flash (fm3) at 0x00000000, size 0x00000000, buswidth 0, chipwidth 0
cortex_m reset_config sysresetreq
Info : clock speed 500 kHz
Info : JTAG tap: mb9bfxx2.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
Info : mb9bfxx2.cpu: hardware has 6 breakpoints, 4 watchpoints

繋がりました.

参考資料

OSX と FTDI ドライバの関係については,Oversea Publishing のサイトで詳しく紹介されています.

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7