てきとうなさいと べぇたばん

Raspberry Pi PicoでNuttXを使ってみる

TOP > てきとうにこらむ > ゲーム作りとプログラミング日記 > Raspberry Pi PicoでNuttXを使ってみる

NuttXを起動したところ

環境

  • MacBook Air(macOS 13.4(22F66))
  • Raspberry Pi Pico
  • Raspberry Pi Pico Debug Probe

セットアップ

macOS側でHomebrewをインストールするのが大前提

brew install x86_64-elf-gcc  # Used by simulator
brew install u-boot-tools  # Some platform integrate with u-boot

Kconfigをインストールする

git clone https://bitbucket.org/nuttx/tools.git
cd tools/kconfig-frontends
# on MacOS do the following:
patch < ../kconfig-macos.diff -p 1
./configure --enable-mconf --disable-shared --enable-static --disable-gconf --disable-qconf --disable-nconf
make
make install

Armのツールチェインをインストールする

HOST_PLATFORM=x86_64-linux   # use "mac" for macOS.
curl -L -O https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-${HOST_PLATFORM}.tar.bz2
tar xf gcc-arm-none-eabi-9-2019-q4-major-${HOST_PLATFORM}.tar.bz2

NuttXをダウンロード

mkdir nuttxspace
cd nuttxspace
curl -L https://www.apache.org/dyn/closer.lua/nuttx/12.0.0/apache-nuttx-12.0.0.tar.gz?action=download -o nuttx.tar.gz
curl -L https://www.apache.org/dyn/closer.lua/nuttx/12.0.0/apache-nuttx-apps-12.0.0.tar.gz?action=download -o apps.tar.gz
tar zxf nuttx.tar.gz
tar zxf apps.tar.gz

コンパイル

NuttXのビルド…の前にPico SDKをダウンロードして使えるようにする

$ npm install --global xpm@latest
$ xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest --verbose
$ export PATH="$HOME/Library/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/12.2.1-1.2.1/.content/bin/:$PATH"  # ~/.bash_profileに記述する
$ mkdir src/
$ cd src
$ git clone https://github.com/raspberrypi/pico-sdk.git
$ export PICO_SDK_PATH=$HOME/src/pico-sdk # ~/.bash_profileに記述する

ビルドする内容を調べる、今回はraspberrypi-pico:nsh

cd nuttx
./tools/configure.sh -L | less
./tools/configure.sh -m raspberrypi-pico:nsh
make menuconfig
make

nuttx.uf2が出来上がるので、それをPico側にコピーする、何らかのシリアル通信で通信する (Pico Debug Probeが必要)

$ minicom -b 112500 /dev/cu.usbmodem11402

Welcome to minicom 2.8

OPTIONS:
Compiled on Oct 24 2022, 11:16:41.
Port /dev/cu.usbmodem11402, 16:26:34

Press Meta-Z for help on special keys


nsh> ls
/:
 dev/
 proc/
nsh> uname
NuttX
nsh> uname -a
NuttX 12.0.0 ccf0b5af0d Jun 17 2023 16:41:27 arm raspberrypi-pico

これで動いた!

2023/06/18 2:38