Raspberry Pico

From bibbleWiki
Revision as of 04:41, 20 August 2022 by Iwiseman (talk | contribs) (Important)
Jump to navigation Jump to search

Introduction

Install the micro ros agent

sudo snap install micro-ros-agent
sudo snap set micro-ros-agent daemon=true
sudo systemctl restart snapd

Set up Environment Variables

Here are ones I use. I believe the build system rely on PICO_SDK_PATH and PICO_TOOLCHAIN_PATH

# Set up base directory
export PICO_ROOT=/home/$USER/dev/pico
export PICO_SDK_PATH=$PICO_ROOT/pico-sdk
export PICO_TOOLCHAIN_PATH=$PICO_ROOT/gcc-arm-none-eabi-10-2020-q4-major/bin

Get the compiler

This is how I got started.
Unzip and get the latest compiler from https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads

I then extract it to $PICO_ROOT

Clone the SDK

Get the SDK

cd $PICO_ROOT
git clone --recurse-submodules https://github.com/raspberrypi/pico-sdk.git
git clone https://github.com/micro-ROS/micro_ros_raspberrypi_pico_sdk.git

Make the sample

It using CMake so we goto the source make a build directory and make. This should produce a file pico_micro_ros_example.uf2

cd $PICO_ROOT
cd micro_ros_raspberrypi_pico_sdk

mkdir build
cd build
cmake ..
make

Copy to device

So plug in the PICO holding down the boot button

cp pico_micro_ros_example.uf2 /media/$USER/RPI-RP2

Next

We can now look and see if the snap:pico slot is present with

snap interface serial-port

This did not work the first time and the slots: section was missing. I ended up rebooting the PICO, copying the file.

name:    serial-port
summary: allows accessing a specific serial port
plugs:
  - micro-ros-agent
slots:
  - snapd:pico (allows accessing a specific serial port)

New PICO Stuff

Spent lots of time doing lots of other stuff, ESP, learning React etc. Come back to PICO and this is note on this second view

Important

For a PICO to show up, you need to hold the BOOTSEL prior to plugging in the device. Release when powered and you should see

Bus 003 Device 004: ID 2e8a:0003 Raspberry Pi RP2 Boot

When you copy .uf2 software to the device /media/$USER/RPI-RP2/ the device will reboot and may or may not show up depending in what the software is. E.g.

cp ./blink.uf2 /media/$USER/RPI-RP2/

# Disconnects but runs the software on the PICO
sudo dmesg

[80798.165244] FAT-fs (sdf1): unable to read boot sector to mark fs as dirty

Building MicroPython From Source

Revisiting build of this using the guild. Couple of glitches, repo was incorrect but this worked for me.

mkdir pico
cd pico
git clone  https://github.com/micropython/micropython
cd micropython/
cd lib/pico-sdk
git submodule update --init
sudo apt install cmake gcc-arm-none-eabi build-essential
cd ../..
make -C mpy-cross
cd ports/rp2
make

Building picotool From Source

sudo apt install build-essential pkg-config libusb-1.0-0-dev
export PICO_SDK_PATH=/home/iwiseman/dev/projects/pico/pico/micropython/lib/pico-sdk

git clone https://github.com/raspberrypi/picotool
cd picotool
mkdir build
cd build
cmake ..
make
# optional
sudo cp /home/$USER/dev/projects/pico/pico/picotool/build/picotool /usr/bin/picotool