Skip to content

Instantly share code, notes, and snippets.

@siberex
Last active August 30, 2024 20:05
Show Gist options
  • Save siberex/28fa949dcc9afd004c942d6a221fa3cc to your computer and use it in GitHub Desktop.
Save siberex/28fa949dcc9afd004c942d6a221fa3cc to your computer and use it in GitHub Desktop.
Pico2 SDK setup for RISC-V
# https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf
# 2.10. Supporting both RP2040 and RP2350 (Page 31)
sudo apt install -y autoconf automake autotools-dev curl python3 python3-pip \
libmpc-dev libmpfr-dev libgmp-dev gawk build-essential \
bison flex texinfo gperf libtool patchutils bc \
zlib1g-dev libexpat1-dev ninja-build git cmake libglib2.0-dev libslirp-dev
sudo mkdir -p /opt/riscv/gcc14-rp2350-no-zcmp
sudo chown -R $(whoami) /opt/riscv/gcc14-rp2350-no-zcmp
mkdir -p $HOME/pico
cd $HOME/pico
git clone https://github.com/riscv/riscv-gnu-toolchain
cd riscv-gnu-toolchain
git clone https://github.com/gcc-mirror/gcc gcc-14 -b releases/gcc-14
./configure --prefix=/opt/riscv/gcc14-rp2350-no-zcmp \
--with-arch=rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb \
--with-abi=ilp32 \
--with-multilib-generator="rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb-ilp32--;rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb-ilp32--" \
--with-gcc-src="$(pwd)/gcc-14"
make -j$(nproc)
# See also:
# https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf
# Appendix C: Manual toolchain setup (Page 32)
# Linux: https://github.com/raspberrypi/pico-setup/blob/master/pico_setup.sh
# Windows: https://github.com/raspberrypi/pico-setup-windows
# Make sample binary
export PICO_COMPILER=pico_arm_gcc
export PICO_SDK_PATH="$HOME/pico/pico-sdk"
export PICO_EXAMPLES_PATH="$HOME/pico/pico-examples"
export PICO_EXTRAS_PATH="$HOME/pico/pico-extras"
export PICO_PLAYGROUND_PATH="$HOME/pico/pico-playground"
cd $HOME/pico/pico-examples/
rm -rf build
mkdir build
cd build
# https://github.com/raspberrypi/pico-sdk/tree/master/src/boards/include/boards
cmake -DCMAKE_BUILD_TYPE=Debug -DPICO_BOARD=pimoroni_tiny2350 ..
cd blink
make -j$(nproc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment