💪
R2P2を自力でビルドする
経緯
元々0.4.1を使用していてirqを使おうとするとクラッシュしたが、もしかしたらバージョンアップすれば動くのでは?という考えのもと自力でビルドした。
ちなみに作業してから0.5.0のリリースがあることに気づいたのは内緒。
という経緯で無意味な手順かもしれないがせっかくやったので記録として。
環境
M2 MacBookAir(RAM16GB)です。WindowsだとめんどくさそうだったのでMACでやりました。
参考
参考記事:
いざbuild
いざ尋常に。
pico-sdk/R2P2のclone
ソースを取ってきます。
$ cd $HOME/pico
$ git clone https://github.com/raspberrypi/pico-sdk.git
$ git -C pico-sdk checkout 2.2.0
$ git clone https://github.com/raspberrypi/pico-extras.git
$ git -C pico-extras checkout sdk-2.2.0
$ git clone https://github.com/picoruby/R2P2.git
$ git -C R2P2 checkout 0.5.0
$ git -C R2P2 submodule update --init --recursive
$ cd pico-sdk
$ git submodule update --init --recursive
$ cd ../R2P2
$ git submodule update --init --recursive
ライブラリのインストール
rubyは私の環境に入っていたのでスキップ。たぶんなんか適当に入れればいい。古すぎなければ。
以下を参考にGCCをインストール
以下からBinary distributions: から Mac 用のインスーラーをダウンロードする
インストーラーからインストール後、ターミナルで以下を実行
$ sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install
$ cmake --version
cmake version 4.2.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
以下を参考にgcc-arm-none-eabiをインストール
$ brew update
$ brew upgrade
$ brew tap ArmMbed/homebrew-formulae
$ brew install arm-none-eabi-gcc
$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (GCC) 15.2.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gcc-arm-linux-gnueabihfのインストール
MACにはないのでChatGPT曰く代替になるらしいarm-linux-gnueabihf-gccがあるが、gcc-arm-embeddedを入れるのが正解らしい。
$ brew install --cask gcc-arm-embedded
zipはMACにあるのでスキップ
ビルド
shell scriptを作成
$ vi R2P2/run-rake.sh
export PICO_SDK_PATH="/Users/yusama/Documents/picoruby/R2P2_build/pico-sdk"
export PICO_EXTRAS_PATH="/Users/yusama/Documents/picoruby/R2P2_build/pico-extras"
export SKIP_TEST=1
rake picoruby:pico:debug
rake picoruby:pico:debugの部分で対象のボードと入れるものを選べるみたい
今回は無印のpicorubyを選択
実行
$ cd R2P2
$ git submodule update --init --recursive
$ sh run-rake.sh
rake aborted!
Don't know how to build task 'default' (See the list of available tasks with `rake --tasks`)
(See full trace by running task with --trace)
うまくいけばbuildディレクトリにuf2ファイルができている。
Discussion