1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Zephyr GDB Debugging (FRDM-MCXN947)

1
Last updated at Posted at 2026-05-05

概要

FRDM-MCXN947における、GDBデバッグ方法の備忘録

ボード

こちらを使う
https://docs.zephyrproject.org/latest/boards/nxp/frdm_mcxn947/doc/index.html

ZephyrRTOS version

-- Zephyr version: 4.4.99 (/home/tqm/zephyrproject/zephyr), build: v4.4.0-539-g1105af8d04c2

LinkServerのセットアップ

をダウンロードして、以下の要領でインストールする。

$ chmod +x LinkServer_*.x86_64.deb.bin
$ ./LinkServer_*.x86_64.deb.bin --noexec --keep
$ cd installer
$ sudo install.sh

ビルド

適当なサンプルをビルドする

$ west build -b frdm_mcxn947/mcxn947/cpu0 samples/synchronization

Flash

MCULinkの方のUSBポートに接続し、ログを確認すると、
firmware versionが古い旨のエラーメッセージが出ていたので、firmwareをまず書き換える。
1 .ボード上の、J21 (ISP jumper)にジャンパーを取り付ける
2 .firmware書き換えを実行

$ /usr/local/LinkServer_26.3.123/MCU-LINK_installer/scripts/program_CMSIS

3 .J21のジャンパーを外す

動作確認

ボードが認識されていることを確認

$ /usr/local/LinkServer_26.3.123/LinkServer probes
  #  Description                                    Serial         Device    Board         Capabilities
---  ---------------------------------------------  -------------  --------  ------------  ----------------
  1  MCU-LINK FRDM-MCXN947 (r0E7) CMSIS-DAP V3.172  HGNWCXTMTFTGM  MCXN947   FRDM-MCXN947  DEBUG, VCOM, SIO

問題なければ、書き込む

$ west flash

デバイスに接続して起動ログを確認しておく。

*** Booting Zephyr OS build v4.4.0-539-g1105af8d04c2 ***
thread_a: Hello World from cpu 0 on frdm_mcxn947!
thread_b: Hello World from cpu 0 on frdm_mcxn947!
thread_a: Hello World from cpu 0 on frdm_mcxn947!

Debuggerの起動

LinkServerから、probesサブコマンドで確認した Device:Board を指定してGDBサーバを起動する。

$ /usr/local/LinkServer_26.3.123/LinkServer gdbserver MCXN947:FRDM-MCXN947

そして、GDBクライアントを起動

$ ~/zephyr-sdk-1.0.0/gnu/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb

ターゲットに接続し、elfの読み込み、リセット、実行などの操作ができることを確認する

(gdb) target remote localhost:3333
(gdb) file file ~/zephyrproject/zephyr/build/zephyr/zephyr.elf
(gdb) monitor reset halt
Failed to reset to initial execution state - Ec(06). No image address available for soft reset.

resetができない。。。
なぜかベクタのアドレスに飛んでくれないので、リセットベクタとSPを読み出して手動で設定する

(gdb) p /x *(unsigned int *)0x10000004
$1 = 0x10001a2d
(gdb) set $pc = 0x10001a2d
(gdb) p /x *(unsigned int *)0x10000000
$2 = 0x30001b20
(gdb) set $sp = 0x30001b20
(gdb) c
Continuing.

リセット相当の動きをした。(色々触ってるとreset halt が効くときもあったので謎)

*** Booting Zephyr OS build v4.4.0-539-g1105af8d04c2 ***
thread_a: Hello World from cpu 0 on frdm_mcxn947!
thread_b: Hello World from cpu 0 on frdm_mcxn947!
thread_a: Hello World from cpu 0 on frdm_mcxn947!

感想

オンチップデバッガは便利

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?