1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

XIAO nRF52840でBLEパケットキャプチャする

1
Last updated at Posted at 2026-03-29

概要

これを使って、BLEパケットキャプチャをする。

を参考にさせていただいた。

ホストPCはUbuntu24.04を使用する。

インストール

以前の記事では、nordicのスニファのhexバイナリを直接取得するとなっているが、
現在はnordicが公開を止めているので取れない。

代わりに、
https://www.nordicsemi.jp/tools/nrf-util/
のコマンドを使って必要なファイルを取得する。

  1. nrf-utilのインストール
    上記のNordicのサイトから、nrfutilの実行ファイルをダウンロードする。
    実行権をつけて、パスの通ったところに置く。
  2. ble-snifferコマンドのインストール
$nrfutil install ble-sniffer

で、~/.nrfutil以下にコマンドがインストールされる。

$nrfutil list
Command      Version  Description
ble-sniffer  0.18.0   Bluetooth Low Energy (Bluetooth LE) sniffer for Nordic Semiconductor devices.

Found 1 installed command(s)

となれば、成功。

  1. ファイルをコピーする
$ cp ~/.nrfuti/share/nrfutil-ble-sniffer/firmwar/esniffer_nrf52840dongle_nrf52840_4.1.1.zip ~/work
$ cd ~/work
$ unzip firmwaresniffer_nrf52840dongle_nrf52840_4.1.1.zip

として、dongle用のファイルをコピーして解凍する
zipのあるディレクトリには、別のボードのhexがあるので、ドングル以外のdkボードの場合はそちらを使う。

  1. ufs2ツールの取得
$ git clone https://github.com/microsoft/uf2.git
$ cd uf2/utils
  1. ufs2に変換
$ python3 uf2conv.py ~/work/sniffer_nrf52840dongle_nrf52840_4.1.1.bin -c -f 0xADA52840 --base 0x1000

Converted to uf2, output size: 139264, start address: 0x1000
Wrote 139264 bytes to flash.uf2

でflash.uf2ができる

  1. ボードに書き込み
    PCにボードを接続して、リセットボタンを2回押す。
    USBメモリとして認識されたら、flash.uf2をドラッグ・アンド・ドロップでコピーする
    うまくいくと、
$ lsusb
Bus 003 Device 010: ID 1915:522a Nordic Semiconductor ASA nRF Sniffer for Bluetooth LE

$ ls /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0  3月 29 21:00 /dev/ttyACM0

で動く。

Wiresharkのインストール

から最新のStableを取得する。
ubuntuの場合は、

$ sudo add-apt-repository ppa:wireshark-dev/stable
$ sudo apt update
$ sudo apt install wireshark

でOK

excapの設定

以下を実行する

$ mkdir -p ${HOME}/.local/lib/wireshark/extcap
$ nrfutil ble-sniffer bootstrap

これで、.local/lib/wireshark/extcapにWireshak用のexcapのファイルができる。

-rwxr-xr-x 1  631000  3月 29 19:30 nrfutil-ble-sniffer-hci-shim
-rwxr-xr-x 1  630984  3月 29 19:30 nrfutil-ble-sniffer-shim
-rw-rw-r-- 1      56  3月 29 19:30 nrfutil-ble-sniffer-shim-config.json

PCとボードをつないだ状態で、

$ wireshark -D
24. /dev/ttyACM0-4.6 (nRF Sniffer for Bluetooth LE)

が出たら、認識された。
このとき、ボードのUSRのLEDが赤から青になる。

Wireshakでパケットキャプチャ

起動後に、/dev/ttyACMでつながっている
「nRF Sniffer for Bluetooth LE」
を選ぶと、以下の通り、BLEのパケットキャプチャが行えた。

image.png

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?