2
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?

Zephyrを理解するためにわかったことをまとめる忘備録

2
Last updated at Posted at 2026-02-18

DeviceTreeについて

ビルド時にZephyerが参照する設定ファイルで.dtsの中に入ってる。

build/zephyr/zephyr.dts

Cのコードから、DT_〇〇でマクロから参照させる

スクリーンショット 2026-02-18 14.30.27.png

他にもDT_NODE_HAS_STATUS_OKAY,DT_NODELABEL(uart20)などがある。

マクロ 用途
DT_ALIAS(sw0) aliasからノード取得
DT_NODELABEL(uart20) ラベル名からノード取得
DT_NODE_HAS_STATUS_OKAY(node) statusがokayか確認
GPIO_DT_SPEC_GET(node, gpios) GPIOの仕様取得
DEVICE_DT_GET(node) デバイス構造体取得
DT_PROP(node, プロパティ名) 任意のプロパティ値取得

nrf54l15に書き込むときに使用するRepo

下記で必要なmoduleがinstallされる

west init -m .

この時、pythonが3.9使うとBuildに失敗するので

python3.12 -m venv .venv

Buildに必要なmoduleをinstall

pip install -r zephyr/scripts/requirements.txt

Start Build

下記をしたいのだが

west build -b xiao_nrf54l15/nrf54l15/cpuapp nrf54l15-connectkit/samples/blinky

Errorとなり、Buildができない。理由は、xiao_nrf54l15/nrf54l15/cpuappの対応するBoardが存在しないから。

どうやらXIAOのnrf54l15を動かしたい場合は、このRepository単体では動かないことがわかった。

CMake Error at /Users/matsudomasato/Documents/board-write/zephyr/cmake/modules/boards.cmake:226 (message):
  Invalid BOARD; see above.
Call Stack (most recent call first):
  cmake/modules/sysbuild_default.cmake:15 (include)
  /Users/matsudomasato/Documents/board-write/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:75 (include)
  /Users/matsudomasato/Documents/board-write/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  /Users/matsudomasato/Documents/board-write/zephyr/share/sysbuild-package/cmake/SysbuildConfig.cmake:8 (include)
  template/CMakeLists.txt:10 (find_package)


-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: /opt/homebrew/bin/cmake -DWEST_PYTHON=/Users/matsudomasato/Documents/board-write/.venv/bin/python3.11 -B/Users/matsudomasato/Documents/board-write/build -GNinja -DBOARD=xiao_nrf54l15/nrf54l15/cpuapp -S/Users/matsudomasato/Documents/board-write/zephyr/share/sysbuild -DAPP_DIR:PATH=/Users/matsudomasato/Documents/board-write/nrf54l15-connectkit/samples/blinky

cleneしてきた、repo:nrf54l15-connectkitのwest.yamlにSeeedのRepoを追加して、west update

# Copyright (c) 2016-2025 Makerdiary <https://makerdiary.com>
# SPDX-License-Identifier: Apache-2.0

manifest:
  self:
    path: nrf54l15-connectkit

  remotes:
    - name: makerdiary
      url-base: https://github.com/makerdiary
    - name: zephyrproject-rtos
      url-base: https://github.com/zephyrproject-rtos
    - name: nrfconnect
      url-base: https://github.com/nrfconnect
    - name: seeed #✅ 追加する
      url-base: https://github.com/Seeed-Studio

  group-filter:
    - +bsec

  projects:
    - name: nrf
      remote: nrfconnect
      repo-path: sdk-nrf
      revision: v3.1.0
      import: true
    - name: seeedboards #✅ 追加する
      remote: seeed
      repo-path: platform-seeedboards
      path: seeedboards
      revision: main

✅外部からBoardを設定する

west build -p always -b xiao_nrf54l15/nrf54l15/cpuapp nrf54l15-connectkit/samples/blinky -- -DBOARD_ROOT=/Users/matsudomasato/Documents/board-write/seeedboards/zephyr

そうすると.hexが生成される。

[6/245] Generating include/generated/zephyr/version.h
-- Zephyr version: 4.1.99 (/Users/matsudomasato/Documents/board-write/zephyr), build: ncs-v3.1.0
[245/245] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       36184 B      1428 KB      2.47%
             RAM:        6608 B       188 KB      3.43%
        IDT_LIST:          0 GB        32 KB      0.00%
Generating files from /Users/matsudomasato/Documents/board-write/build/blinky/zephyr/zephyr.elf for board: xiao_nrf54l15
[10/10] Generating ../merged.hex

チップに書き込み

west flash

ちなみにBuild時に一回ずつbuild/を消さないとErrorになる。

ERROR: Build directory "/Users/matsudomasato/Documents/board-write/build" is for application "/Users/matsudomasato/Documents/board-write/nrf54l15-connectkit/samples/blinky", but source directory "/Users/matsudomasato/Documents/board-write/nrf54l15-connectkit/samples/button" was specified; please clean it, use --pristine, or use --build-dir to set another build directory
FATAL ERROR: refusing to proceed without --force due to above error

nrf54l15の通信で行われるBLEのセキュリティについて

暗号化するトリガーを下記で行う。セキュリティレベルが存在する。
ZephyerのSampleでは、SECRUTY_L2で行われてることがわかった。

bt_conn_set_security(conn, BT_SECURITY_L2)

実際にセキュリティレベルは4段階存在してることがわかった。

/** Security level. */
typedef enum __packed {
	/** Level 0: Only for BR/EDR special cases, like SDP */
	BT_SECURITY_L0,
	/** Level 1: No encryption and no authentication. */
	BT_SECURITY_L1,
	/** Level 2: Encryption and no authentication (no MITM). */
	BT_SECURITY_L2,
	/** Level 3: Encryption and authentication (MITM). */
	BT_SECURITY_L3,
	/** Level 4: Authenticated Secure Connections and 128-bit key. */
	BT_SECURITY_L4,
	/** Bit to force new pairing procedure, bit-wise OR with requested
	 *  security level.
	 */
	BT_SECURITY_FORCE_PAIR = BIT(7),
} bt_security_t;

実際に、各Layerごとは、下記になってるらしい

L0: BR/EDR(Classic Bluetooth)専用の特殊ケース。
L1: 暗号化なし・認証なし。事実上セキュリティなし
L2: 暗号化あり・認証なし(MITM保護なし)。Just Worksペアリング
L3: 暗号化あり・認証あり(MITM保護あり)。Passkey入力やNumeric Comparison等
L4: L3 + Secure Connections(ECDH P-256)+ 128bit鍵。最強

MITM保護

Man-In-The-Middle(中間者)保護を表す

デバイスA ←――――――→ デバイスBの通信の途中で、中継と改ざんをできないようにする

L2は

・ペアリング時にユーザー確認しない
・暗号化はされるけど、相手が本物かは検証しない
・攻撃者が間に入っても気付けない。

L3は

・Passkey Entry: 6桁の数字を入力させる

暗号化自体は、AES-CCM(128bit)を利用する

ZephyerでBuildしたあと

zephyerの設定を確認できる

west build -t menuconfig

スクリーンショット 2026-02-25 1.46.45.png

prj.confにて下記と記述するとURATで、screenで表示される。

CONFIG_LOG=y

Matterのデータモデルについて

Node(デバイス1台)
└── Endpoint(機能単位)
    └── Cluster(機能の実装)
        ├── Attributes(状態・値)
        ├── Commands(操作)
        └── Events(通知)
2
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
2
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?