… related information
Author: Markus Rathgeb
${HOME}/workspace/oss/pico
https://datasheets.raspberrypi.com/pico/Pico-R3-A4-Pinout.pdf
Create an environment file: ~/bin/env-pico
export PICO_BASEDIR="${HOME}"/workspace/oss/pico
export PICO_SDK_PATH="${PICO_BASEDIR}"/pico-sdk
. ~/bin/env-pico
git clone -b master https://github.com/raspberrypi/pico-sdk.git "${PICO_SDK_PATH}"
cd "${PICO_SDK_PATH}"
git submodule update --init
. ~/bin/env-pico
cd "${PICO_SDK_PATH}"
git pull
git submodule update
. ~/bin/env-pico
git clone -b master https://github.com/raspberrypi/pico-examples.git "${PICO_BASEDIR}"/pico-examples
Ubuntu
apt install \
cmake \
gcc-arm-none-eabi \
libnewlib-arm-none-eabi \
build-essential
Fedora
sudo dnf install \
arm-none-eabi-gcc-cs \
arm-none-eabi-gcc-cs-c++ \
arm-none-eabi-newlib \
arm-none-eabi-binutils-cs \
cmake
https://github.com/raspberrypi/debugprobe/releases
https://github.com/raspberrypi/openocd
Ubuntu
apt install automake autoconf build-essential texinfo libtool libftdi-dev libusb-1.0-0-dev
Fedora
sudo dnf install libtool libusb1-devel
git clone https://github.com/raspberrypi/openocd.git --branch picoprobe --depth=1 --no-single-branch "${PICO_BASEDIR}"/openocd
cd "${PICO_BASEDIR}"/openocd
./bootstrap
CFLAGS="-Wno-error=misleading-indentation -Wno-error=stringop-overflow -Wno-error=calloc-transposed-args"
CXXFLAGS="-Wno-error=misleading-indentation -Wno-error=stringop-overflow -Wno-error=calloc-transposed-args"
./configure \
--enable-picoprobe \
--prefix="${PICO_BASEDIR}"/openocd.install
make -j4
make install
sudo cp -v ${PICO_BASEDIR}/openocd.install/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d
sudo udevadm control --reload
cat <<EOF >"${PICO_BASEDIR}"/openocd.install/share/openocd/scripts/board/debugprobe_picoprobe_rp2040.cfg
source [find interface/picoprobe.cfg]
source [find target/rp2040.cfg]
EOF
cat <<EOF >"${PICO_BASEDIR}"/openocd.install/share/openocd/scripts/board/debugprobe_cmsis-dap_picoprobe_rp2040.cfg
source [find interface/cmsis-dap.cfg]
source [find target/rp2040.cfg]
# For the cmsis-dap part the adapter speed must be provided, othewise you will get "Error: CMSIS-DAP command CMD_DAP_SWJ_CLOCK failed."
# See: https://github.com/raspberrypi/debugprobe/issues/48#issuecomment-1336719133
adapter speed 5000
EOF
Depending on the version of the debugprobe uf2 implementation you have to use picoprobe (2e8a:0004) or cmsis-dap (2e8a:000c).
"${PICO_BASEDIR}"/openocd.install/bin/openocd \
-f interface/picoprobe.cfg \
-f target/rp2040.cfg
-s tcl
For the cmsis-dap part the adapter speed must be provided, othewise you will get “Error: CMSIS-DAP command CMD_DAP_SWJ_CLOCK failed.”
See: https://github.com/raspberrypi/debugprobe/issues/48#issuecomment-1336719133
"${PICO_BASEDIR}"/openocd.install/bin/openocd \
-f interface/cmsis-dap.cfg \
-f target/rp2040.cfg \
-c 'adapter speed 5000' \
-s tcl
"${PICO_BASEDIR}"/openocd.install/bin/openocd \
-f board/debugprobe_cmsis-dap_picoprobe_rp2040.cfg \
-s tcl
Reset
"${PICO_BASEDIR}"/openocd.install/bin/openocd \
-f board/debugprobe_cmsis-dap_picoprobe_rp2040.cfg \
-s tcl \
-c "init; reset; exit"
Upload ELF
"${PICO_BASEDIR}"/openocd.install/bin/openocd \
-f board/debugprobe_cmsis-dap_picoprobe_rp2040.cfg \
-s tcl \
-c "targets rp2040.core0; program $1 preverify verify reset exit"
CLion
Open CMake project and choose Toolchain Pico (and for the moment Unix Makefiles – Ninja currently not installed and so not tested).
Example for a “Run / Debug Configurations”
Use always “Debug” and NOT “Run”.
cmake_minimum_required(VERSION 3.21)
# Pull in SDK (must be before project)
include($ENV{PICO_SDK_PATH}/pico_sdk_init.cmake)
project(buzzer C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
# Seems to be necessary for debugging
set(PICO_DEOPTIMIZED_DEBUG 1)
# Initialize the SDK
pico_sdk_init()
add_compile_options(
-Wall`
-Wno-format # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
-Wno-unused-function # we have some for the docs that aren't called
-Wno-maybe-uninitialized
)
add_executable(buzzer
src/main.cxx
)
target_include_directories(buzzer PRIVATE src)
# pull in common dependencies
target_link_libraries(buzzer pico_stdlib)
# create map/bin/hex file etc.
pico_add_extra_outputs(buzzer)
cd "${PICO_BASEDIR}"
git clone https://github.com/raspberrypi/pico-project-generator.git
cd pico-project-generator
GUI:
cd "${PICO_BASEDIR}"/pico-project-generator
./pico_project.py --gui
Command line:
export PICO_SDK_PATH="/home/pi/pico/pico-sdk"
./pico_project.py --feature spi --feature i2c --project vscode test
${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd
sudo apt-get install libusb-1.0-0-dev
cd "${PICO_BASEDIR}"
git clone -b master https://github.com/raspberrypi/picotool.git
cd picotool
cmake -S . -B build
make -C build
"${PICO_BASEDIR}"/picotool/build/picotool