Skip to main content

STM32 build tool for non-CubeIDE editors

Project description

kst

STM32CubeIDE プロジェクトを VS Code などの外部エディタでビルド・書き込みするための CLI ツールです。

.ioc ファイルと CubeIDE の内蔵ツールチェーンだけに依存するため、CubeIDE ユーザーのワークフローを一切変えずに、エディタを選ばない開発環境を実現します。

前提条件

  • Windows
  • STM32CubeIDE がインストール済み(C:\ST\STM32CubeIDE_*
  • Python 3.11 以上

インストール

1. パッケージをインストールする

pip install --user kikaiken-kst

2. Scripts ディレクトリを PATH に追加する

pip install --userkst.exe を以下のディレクトリに配置します。

C:\Users\<ユーザー名>\AppData\Roaming\Python\Python3xx\Scripts

このディレクトリが PATH に含まれていない場合、以下の手順で追加してください。

PowerShell で自動追加(一度だけ実行):

$scriptsPath = "$env:APPDATA\Python\$(python -c 'import sys; print(f\"Python{sys.version_info.major}{sys.version_info.minor}\")')\Scripts"
[Environment]::SetEnvironmentVariable("PATH", "$([Environment]::GetEnvironmentVariable('PATH','User'));$scriptsPath", "User")

設定後、ターミナルを再起動すると kst コマンドが使えるようになります。

アップデート

pip install --user --upgrade kikaiken-kst

使い方

1. 初期化(初回・CubeMX 再生成後)

kst init <プロジェクトディレクトリ>
  • .clangd を生成(VS Code + clangd の IntelliSense 設定)
  • compile_commands.json を生成(clangd が IntelliSense に使用)
  • kst.toml を生成(ビルド設定ファイル)
  • .gitignore に kst の生成物を追加

2. ビルド

kst build <プロジェクトディレクトリ>
  • .ioc を解析して MCU フラグを取得
  • プロジェクトを走査してソース・インクルードを収集
  • Makefile.kstcompile_commands.json を生成
  • CubeIDE 内蔵の gcc / make でビルド

3. 書き込み

kst flash <プロジェクトディレクトリ>

ビルドを行ってから、CubeIDE 内蔵の STM32CubeProgrammer を使って ST-LINK 経由で書き込みます。
接続モードは CubeIDE のデフォルト(Under Reset + Hardware Reset)に合わせています。

ビルド済みの ELF をそのまま書き込む場合は --no-build を指定します。

kst flash --no-build <プロジェクトディレクトリ>

4. クリーン

kst clean <プロジェクトディレクトリ>

kst_build/ ディレクトリを削除します。


プロジェクトディレクトリの指定を省略するとカレントディレクトリが使われます。

cd path/to/project
kst build

kst.toml

kst init で生成されるプロジェクト設定ファイルです。git で管理してチームで共有します。

[build]
# printf / scanf での浮動小数点数の出力・入力を有効にする
# newlib-nano のデフォルトでは無効のため約 +20 KB 増加する
float_io = true

[scan]
# コンパイル対象から除外するファイル(プロジェクトルートからの相対パス)
# 同じディレクトリに排他的な実装が複数ある場合に使用する
exclude_files = []

仕組み

役割 CubeIDE kst
MCU フラグ取得 .cproject .ioc を解析
ソース収集 GUI で手動登録 フォルダをスキャンして自動収集
ビルド CDT make 同じ CubeIDE 内蔵 gcc / make
書き込み ST-LINK GDB Server 同じ CubeIDE 内蔵 STM32CubeProgrammer
IntelliSense CDT Indexer clangd + compile_commands.json

git 管理について

ファイル git 管理 説明
kst.toml ✅ する プロジェクト共通のビルド設定
kst_build/ ❌ しない ビルド成果物
Makefile.kst ❌ しない kst build で毎回生成
.clangd ❌ しない 環境依存(CubeIDE のインストールパスを含む)
compile_commands.json ❌ しない 環境依存

CubeIDE ユーザーへの影響

ありません。 .ioc の Toolchain/IDE 設定は STM32CubeIDE のままです。
CubeIDE ユーザーは従来通り CubeIDE でビルド・書き込みできます。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kikaiken_kst-0.7.0.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kikaiken_kst-0.7.0-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file kikaiken_kst-0.7.0.tar.gz.

File metadata

  • Download URL: kikaiken_kst-0.7.0.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for kikaiken_kst-0.7.0.tar.gz
Algorithm Hash digest
SHA256 a3daf85d88d41cadd3c465c454ba5345b72b12ea74d292847ea697a54792fd49
MD5 6998b29445bd2aac6f16993b0c1d0fb6
BLAKE2b-256 902f0b96206a94db2378cb1a814c8968c848fe45320ba18a48c73e94529ee5a3

See more details on using hashes here.

File details

Details for the file kikaiken_kst-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: kikaiken_kst-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for kikaiken_kst-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d59143714069c8cceee10dd1a32c78d286c835d4c06f1c7c240ffadca90a2bd2
MD5 f2f1d7b9ecadbd445619bd01a3f46a71
BLAKE2b-256 7e2c78267f56e78dd7ef97bc731ab9d5594f24205df8ca5b76c9aedf33b26b15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page