[[FrontPage]]

#contents

2013/10/13からのアクセス回数 &counter;

** Stellaris LM4F120 LaunchPadがMacOSXでも開発できる [#y1376eb8]
インタフェース2013年6月号で紹介されたTiのStellaris LM4F120 LaunchPad評価ボード(以下LM4F120 PaunchPadと記す)にOpenOCDが正式に対応したのを知り、試してみました。

LM4F120 PaunchPadは、純正のデバッガを搭載し、信号処理に必要なDSP命令に加え、浮動小数点演算ユニットPFUを搭載した高機能のマイコンです。しかも価格は1620円と低価格にて提供されています。

&ref(LM4F120_LaunchPad.png);


** 開発環境を整える [#lc03b74b]
MacOSXでのコンパイルには、MacPortsとXCodeを使用しました。
ころころ変わるXCodeの無償問題ですが、XCode 5で無償に戻った?みたいですね。
https://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12


分かりづらいのは、XCodeをダウンロードしてコマンドラインのツールをインストール方法です。
環境の関係上Version 4 のXCodeで説明します。
XCodeメニューからPreferencesを選択します。Downloadsアイコンを選択し、Componentsタブを選択します。
ここで、Command Line Toolsをインストールします。

&ref(Downloads.jpg);

MacPortsは、[[MacPortsのサイト>http://www.macports.org/install.php]] からMac OS X Package(.pkg) Installerをダウンロードしてインストールして下さい。

** OpenOCDのコンパイル [#mde9a7f4]
準備ができたので、LM4F120 PaunchPad用のOpenOCDを作成しましょう。

最初にOpenOCDで使用するLIBUSBをインストールします。

ターミナルソフトを起動して、以下のコマンドを入力します。
#pre{{
$ sudo port install libusb-legacy +universe
}}

続いて、OpenOCDのダウンロードとコンパイルです。

#pre{{
$ mkdir ~/LM4F120/; cd ~/LM4F120
$ git clone git://git.code.sf.net/p/openocd/code openocd-code
$ cd openocd-code
$ ./bootstrap
$ ./configure --enable-maintainer-mode  --enable-ti-icdi \
CFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib -lusb-1.0"
$ make
}}

MacPortsでは、インストールしたライブラリやインクルードファイルが/opt/local以下になっているので、
CFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib -lusb-1.0"の指定が必要となります。


** StellarisWareのインストール [#cd72132b]
StellarisWareは、LM4F120 PaunchPadを簡単に使えるようにしたライブラリーです。
StellarisWareは、以下のURLからダウンロードします。
http://www.tij.co.jp/tool/jp/SW-EK-LM4F120XL


詳しくは、同ページの「StellarisWareのダウンロード・インストール方法」を見てください。

Windowsユーザなら、開発環境を含んだものをダウンロードして使われると良いでしょう。

以下では、ダウンロードしたStellarisWareを~/~/LM4F120/stellaris/以下に置いてあるとして説明します。

** 動作確認 [#x8aa09fc]
動作確認用のプロジェクトを作成します。

#pre{{
$ mkdir ~/LM4F120/stellaris/project; 
$ cd ~/LM4F120/stellaris/project
$ git clone https://github.com/scompo/stellaris-launchpad-template-gcc.git 
}}

Makefileの以下の部分を変更
STELLARISWARE_PATH=~/LM4F120/stellaris/StellarisWare


プロジェクトをmakeします。
#pre{{
$ make
}}


*** OpenOCDの起動 [#c7b4f8b6]
ボード用にOpenOCDコンフィグファイルとしてLM4F120XL.cfgを作成します。

#pre{{
$ cat >LM4F120XL.cfg <<EOF
# TI Stellaris Launchpad ek-lm4f120xl Evaluation Kits
#
# http://www.ti.com/tool/ek-lm4f120xl
#
#
# NOTE: using the bundled ICDI interface is optional!
# This interface is not ftdi based as previous board were
#
source [find interface/ti-icdi.cfg]
set WORKAREASIZE 0x4000
set CHIPNAME lm4f120h5qr
source [find target/stellaris_icdi.cfg]
EOF
}}


以下の様に新しく作成したopenocdを起動し、以下の様なメッセージが出力されるのを確認します。
#pre{{
$ sudo ../../../openocd-code/src/openocd -s ../../../openocd-code/tcl -f LM4F120XL.cfg
Open On-Chip Debugger 0.8.0-dev-00131-gf4943ac (2013-09-08-17:38)
Licensed under GNU GPL v2
For bug reports, read
     http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : This adapter doesn't support configurable speed
Info : ICDI Firmware version: 9270
Info : lm4f120h5qr.cpu: hardware has 6 breakpoints, 4 watchpoints
}}


別のターミナルウィンドウを開いて、gdbを起動してopenocdの動作を確認します。
- target extended-remote :3333 → openedを使ってデバッグできるようにします
- monitor reset halt →  LM4F120を停止します
- load → プログラムをLM4F120にダウンロードします
- monitor reset init → LM4F120をリセットします
- b main.c:51  → ブレークポイントをmain.cの51行にセットします 
- display count  → 変数countの値を表示します

#pre{{
$ arm-none-eabi-gdb main.axf
GNU gdb (GDB) 7.0.50.20100218-cvs
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i386-apple-darwin10.3.0 --target=arm-none-eabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /Users/take/proj/LM4F120_LaunchPad/stellaris/projects/stellaris-launchpad-template-gcc/main.axf...done.
(gdb) target extended-remote :3333
Remote debugging using :3333
0x00000000 in myvectors ()
(gdb) monitor reset halt
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0000334c msp: 0x20001000
(gdb) load
Loading section .text, size 0x7ac lma 0x0
Loading section .data, size 0x800 lma 0x7ac
Start address 0x0, load size 4012
Transfer rate: 9 KB/sec, 2006 bytes/write.
(gdb) monitor reset init
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0000026c msp: 0x20007ffc
(gdb) b main.c:51
Breakpoint 1 at 0x300: file main.c, line 51.
(gdb) b Timer1A_ISR
Breakpoint 2 at 0x3b8: file main.c, line 69.
(gdb) display count
1: count = 2
(gdb) c
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, main () at main.c:52
52          SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
1: count = 0
(gdb) c
Continuing.

Breakpoint 2, Timer1A_ISR () at main.c:69
69          TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
1: count = 3
}}


この時、LM4F120 LaunchPadは、USBモデルとしても認識されます。
#pre{{
$ ls /dev/cu.*
cu.Bluetooth-Modem     cu.Bluetooth-PDA-Sync  cu.usbmodem0E10BDE1
}}

以上で、OpenOCDの動作確認は終了です。

LPCXpresso 6を使ったデバッグについては、lbed関連のページ作成する予定です。

** コメント [#k24faf5c]
#vote(おもしろかった,そうでもない,わかりずらい)
#vote(おもしろかった[1],そうでもない[0],わかりずらい[0])

皆様のご意見、ご希望をお待ちしております。
#comment_kcaptcha

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
SmartDoc