LoginSignup
2
0

More than 3 years have passed since last update.

micro:bit runtime開発環境をつくる

Posted at

環境

  • Windows10

概要

Windows10上にC++を使ってmicro:bitの実行ライブラリ micro:bit runtime を直接利用するプログラムの開発環境を構築する。

手順

micro:bit runtimeインストール方法は Offline Development - micro:bit runtime に従う。

Mbed のビルドシステム yotta と、EPROM 用ファイルをつくるための SRecord を入れることになる。

Pythonを入れる

yottaはPython2.7.9以降を要求している。
未確認だがPython3.7でも問題は無いようだ。
インストーラーで入れてCコンパイラも入れたが、Cコンパイラの必要性は不明。

参照: Python 2.7のインストール - python.jp

CMake を入れる

インストーラーで導入。

Download | CMake

Ninja を入れる

yottaで利用しているビルドシステム。
Zipファイルを適当なディレクトリに解凍して、パスを通す。

Ninja, a small build system with a focus on speed

arm-none-eabi-gcc を入れる

マイコンのコードをクロスコンパイルするための道具一式。
yottaのドキュメントでは 4.9 を使っていると書いてある。未検証だがそれ以降でも可能かもしれない。
GNU Arm Embedded Toolchain in Launchpad
GNU Toolchain | GNU-RM Downloads – Arm Developer

yotta を入れる

Windows10 Python2.7の環境で、2019年10月8日の最新リリース yotta v0.19.0 は error:'Version' object has no attribute 'truncate' が出て動かなかった。
以下の修正コミットを指定して入れたら動いた。

`yotta target` fails with `error: 'RegistryThingVersion' object has no attribute 'truncate'` · Issue #856 · ARMmbed/yotta

pip install git+git://github.com/ARMmbed/yotta.git@047cff288c3f7fe520c391fc61805ea3c8dafebc

SRecord を入れる

SRecord の Windows 版をダウンロードする。
SRecord - Browse /srecord-win32 at SourceForge.net
Zipファイルを適当なディレクトリに解凍して、パスを通す。

使い方

Offline Development - micro:bit runtime を参照。

プロジェクトをダウンロードする

git clone https://github.com/lancaster-university/microbit-samples
cd microbit-samples

yottaのターゲットを設定する

yt target bbc-microbit-classic-gcc

プロジェクトをビルドする

yt build

micro:bitへ書き込む

cp ./build/bbc-microbit-classic-gcc/source/microbit-samples-combined.hex /Volumes/"MICROBIT"

資料

micro:bit runtime

micro:bit runtimeの公式ドキュメントであり、アーキテクチャやAPIの説明が書いてある。

BBC micro:bit C++ Getting Started

micro:bit rumtimeを使った開発の手順やスレッドやイベント、メモリなどを解説している。

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