LoginSignup
0
0

CLion + NucleoF303K + openOCDでデバッグする話

Last updated at Posted at 2023-09-05

brewで入れたopneOCDに付属しているnucleo用のコンフィグファイルだと、プログラムのダウンロードに失敗します。

結果

スクリーンショット 2023-09-05 15.48.16.png

どうもst_nucleo_f3.cfgの中身を見ると NUCLEO F334R8 用のようで、F303K8用ではないようです。

そこでCubeIDEで、デバッガとしてOpneOCDを選択したとき生成される"プロジェクト名 Debug.cfg"というファイルを持ってきます。CubeIDEのプロジェクトルートにできますので、自分のディレクトにリネームして突っ込んでおくか、Gitで管理するならプロジェクトのルートにコピーしておきます。

スクリーンショット 2023-09-05 16.12.12.png

めでたくブレークポイントで止まっています。

違いは何かというと、openOCDについているものは

/usr/local/Cellar/open-ocd/0.12.0_1/share/openocd/scripts/board/st_nucleo_f3.cfg
# SPDX-License-Identifier: GPL-2.0-or-later

# This is an ST NUCLEO F334R8 board with a single STM32F334R8T6 chip.
# http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1847/PF260004

source [find interface/stlink.cfg]

transport select hla_swd

source [find target/stm32f3x.cfg]

reset_config srst_only

一方CubeIDEが生成しているものは

'プロジェクト名 'Debug.cfg
# This is an NUCLEO-F303K8 board with a single STM32F303K8Tx chip
#
# Generated by STM32CubeIDE
# 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-dap.cfg]

set WORKAREASIZE 0x1000
transport select "dapdirect_swd"
set CHIPNAME STM32F303K8Tx
set BOARDNAME NUCLEO-F303K8

# Enable debug when in low power modes
set ENABLE_LOW_POWER 1

# Stop Watchdog counters when halt
set STOP_WATCHDOG 1

# STlink Debug clock frequency
set CLOCK_FREQ 8000

# Reset configuration
# use hardware reset, connect under reset
# connect_assert_srst needed if low power mode application running (WFI...)
reset_config srst_only srst_nogate connect_assert_srst
set CONNECT_UNDER_RESET 1
set CORE_RESET 0

# ACCESS PORT NUMBER
set AP_NUM 0
# GDB PORT
set GDB_PORT 3333

# BCTM CPU variables
source [find target/stm32f3x.cfg]

と色々設定しています。

stlink-dap.cfgをstlink.cfgとしても動きます。
色々コメントアウトしてみたところ、

set WORKAREASIZE 0x1000

という所が効いているようです。

F303K8用のcfgファイルも用意しておいて頂けると助かるんですが。。。

ということで、うんと簡素化すると

'st_nucleo_f303k8.cfg
# For NUCLEO F303K8

source [find interface/stlink.cfg]
set WORKAREASIZE 0x1000
source [find target/stm32f3x.cfg]

で動いています(WDTはプログラムの中で無効化してます)。
stlink.cfgの中にはST_LinkのUSBのVID, PIDの組が
列挙されていますが、strageあり・なし両方のPIDが書かれているので
どちらでもデバッガとしては問題なく動作します。

他のNucleoボードもこれでいけるのでは。

0
0
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
0
0