自作のJTAG書き込みツール oocdJTAG を使ってsw4stm32とOpenOCDでデバッグ、書き込みが出来るようになりました。
タイトルの たぶんOK? というのはeclipseの設定がややこしいので再現性に自信がないからです
とりあえず文章だけで手順をメモしておきます。
sw4stm32は英語バージョンのままです、日本語化して使っている人はメニューの部分を読み替えてください。
OpenOCDのバージョン
sw4stm32のバージョンはinstall_sw4stm32_win_64bits-v2.4.exeです。
OpenOCDはsw4stm32に含まれているものでOKでした。
oocdJTAG
oocdJTAGはftdiのft2232Dを使ってJTAG書き込みとシリアル通信が出来るようにしたJTAG書き込みツールです。
書き込みだけならSTLinkを使えば簡単に出来ますがデバッグ時にシリアルポートが使えると何かと便利なので自製書き込みツールを使っています。
oocdJTAGを使えるようにするための手順
oocdJTAG用定義ファイルをコピー
下記の定義ファイル2つを次のディレクトリにコピーします
Ac6\SystemWorkbench\plugins\fr.ac6.mcu.debug_2.1.4.201801121207\resources\openocd\st_scripts\interface
このでぃくとりはシステム環境変数を使うと ${openstm32_openocd_script_root_path}\interface となります
oocdjtag-ftdi.cfg
# # oocdJTAG # interface ftdi ftdi_device_desc "oocdJTAG" ftdi_vid_pid 0x0403 0x6010 transport select jtag ftdi_layout_init 0x0c08 0x0f1b ftdi_layout_signal nTRST -data 0x0100 -noe 0x0400 ftdi_layout_signal nSRST -data 0x0200 -noe 0x0800
oocdjtag-swd-ftdi.cfg
# # oocdJTAG # interface ftdi #interface ft2232 ftdi_device_desc "oocdJTAG" ftdi_vid_pid 0x0403 0x6010 transport select swd ftdi_layout_init 0x0c08 0x0f1b ftdi_layout_signal nTRST -data 0x0100 -noe 0x0400 ftdi_layout_signal nSRST -data 0x0200 -noe 0x0800 source [find interface/ftdi/swd-resistor-hack.cfg] #source [find interface/ftdi/swd-resistor-hack.cfg] # # Connect TDI to SWDIO via a suitable series resistor (220-470 Ohm or # so depending on the drive capability of the target and adapter); # connect TDO directly to SWDIO. # # You also need to have reliable GND connection between the target and # adapter. Vref of the adapter should be supplied with a voltage equal # to the target's (preferrably connect it to Vcc). You can also # optionally connect nSRST. Leave everything else unconnected. # # FTDI Target # ---- ------ # 1 - Vref ----------------- Vcc # 3 - nTRST - # 4 - GND ----------------- GND # 5 - TDI ---/\470 Ohm/\--- SWDIO # 7 - TMS - # 9 - TCK ----------------- SWCLK # 11 - RTCK - # 13 - TDO ----------------- SWDIO # 15 - nSRST - - - - - - - - - nRESET # ftdi_layout_signal SWD_EN -data 0
ボード定義ファイルの作成
ProjectExplorerでプロジェクトを右クリックしてDebug Asを実行すると [プロジェクト名 Debug]という名前のファイルがプロジェクトディレクトリに作成されるのでこれをベースにボード定義ファイルを作成します。
ボード定義ファイルの修正
source [find interface/stlink.cfg]
の部分を
source [find interface/oocdjtag-swd-ftdi.cfg]
に置き換えます
# This is an Lantern board with a single STM32F051C8Tx chip # # Generated by System Workbench for STM32 # Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s) #source [find interface/stlink.cfg] source [find interface/oocdjtag-swd-ftdi.cfg] set WORKAREASIZE 0x2000 ...
ボード定義ファイルを 指定する
Debug Configurations の DebuggerタブでConfiguration scriptの設定を User Definedに変更して修正したボード定義ファイルを指定します。
以上でoocdJTAGボードでデバッグとプログラム書き込みが使えるはずです。