つれづれなるまゝに

単なる作業メモ。主に、Linux, arduino, raspberry piとか?

MacBook AirでのSTMicro Nucleoのデバッグ環境構築

2014-07-11 23:23:45 | mac
MacBook Airでマイコンの環境を構築してみる。

ターゲットボードとしては、STMicroのSTM32F401 Nucleoを選択。
最初としては、情報が多いDiscoveryにしておくのが無難だったかもしれないが、Nucleoは
1. mbed対応
2. Arduino互換
ということだったので。。。

mbedは使うかどうかわからない。(mbed対応のFRDM-KL25Zを持っていたが手をだしてない)
が、Arduino互換が決め手。とりあえず、SPI制御の勉強をしてみようとおもったので、WIZ550ioioShield for Arduinoを一緒に購入。

コアをCortex-M3にするかM4にするか悩んだが、持ってないM4を選んだ。DSPやMMUまで使う機会があるかはわからないが。。。

基本、以下のサイトを参考にした。
STM32F3DISCOVERY on Mac OS X using Eclipse, GCC ARM and OpenOCD

で、問題になってくるのはopenocdの設定。
こちらについては、以下のサイトを参考。
Openocd meets a NUCLEO-F030R8 board
上記サイトでは、M0のNUCLEOボードだが、基本接続はSTLink/V2-1経由なのでその辺りは流用でるかなと。

cfgファイルは以下のようにした。

stm32f4nucleo.cfg
--------------------
# Script for connecting with the STM32F4NCLEO board
source [find interface/stlink-v2-1.cfg]

# SRAM 96KB version chip
set WORKAREASIZE 0x18000
source [find target/stm32f4x_stlink.cfg]

reset_config srst_only srst_nogate
--------------------

変更点は、
1. SRAMサイズをF401用に96KBに変更
2. targetをSTM32F4に変更

まずは、openocdで接続

$ sudo openocd -f stm32f4nucleo.cfg
Open On-Chip Debugger 0.8.0 (2014-07-11-17:35)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : This adapter doesn't support configurable speed
Info : STLINK v2 JTAG v19 API v2 SWIM v3 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.266094
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints

で、gdbを動作させてみる。

$ arm-none-eabi-gdb -ex 'target extended-remote :3333'
GNU gdb (GDB) 7.5.1
Copyright (C) 2012 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=x86_64-apple-darwin13.3.0 --target=arm-none-eabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Remote debugging using :3333
0x00000000 in ?? ()
(gdb) monitor reset init
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08001f58 msp: 0x20002160
(gdb) monitor flash info 0
#0 : stm32f2x at 0x08000000, size 0x00080000, buswidth 0, chipwidth 0
# 0: 0x00000000 (0x4000 16kB) not protected
# 1: 0x00004000 (0x4000 16kB) not protected
# 2: 0x00008000 (0x4000 16kB) not protected
# 3: 0x0000c000 (0x4000 16kB) not protected
# 4: 0x00010000 (0x10000 64kB) not protected
# 5: 0x00020000 (0x20000 128kB) not protected
# 6: 0x00040000 (0x20000 128kB) not protected
# 7: 0x00060000 (0x20000 128kB) not protected
STM32F4xx (Low Power) - Rev: A
(gdb)

ということで、動いてる感じ。

今日はここまで