GithubHelp home page GithubHelp logo

rp2's Introduction

Raspberry Pi Pico (RP2) Development

These scripts configure a GNU/Linux or macOS system for Raspberry Pi Pico development, producing:

  • Raspberry Pi Pico C/C++ SDK
  • Raspberry Pi Pico Python SDK (MicroPython RP2 port)
  • OpenOCD
  • Picoprobe
  • Picotool

Caveats:

  • On Fedora, a multi-architecture GNU debugger (gdb) is not available.
  • On Apple silicon, gdb requires Rosetta 2.

In following figure, the Raspberry Pi Pico on the left acts as a debug probe/serial console for the Pico under development on the right. The Pico debug probe is connected via USB to a desktop/build system from which these scripts are run.

Raspberry Pi Pico Debug Probe
Pico configured as debug probe (Image credit: Raspberry Pi)

NB: If the Pico under development is a USB host then, instead of wiring VSYS to VSYS (Pico pin 39), wire VBUS to VBUS (Pico pin 40) so that development USB can provide 5V.

For further information, please refer to:

Prerequisites

Until a release version of these scripts is distributed, the following utilities are needed to generate the configure script:

  • GNU autotools (i.e., autoconf, automake, libtool)
  • GNU make
  • GNU bash version 5+

On Debian/Ubuntu, run:

sudo apt install -y autoconf automake libtool make

on Fedora, run:

sudo dnf install -y autoconf automake libtool make

macOS Prerequisites

In addition to Xcode, to be able to install the requisite software, the build script assumes that MacPorts is already installed. It's possible to use Homebrew instead, but the build script would need to be updated accordingly.

sudo port install bash bash-completion autoconf automake libtool gmake
export PATH=/usr/local/bin:$PATH

Installation from Source

In a terminal, run:

git clone https://github.com/revolution-robotics/rp2.git
cd rp2
./autogen.sh
./configure
make PICO_BOARD=pico PICO_BASEDIR=${PWD}/build

To build for Pico W, replace PICO_BOARD=pico above with PICO_BOARD=pico_w.

Follow the instructions for updating the shell initialization scripts printed at the end of make command. Finally, run:

sudo make install

Install Picoprobe

To install Picoprobe, the debug probe Pico (i.e., in the diagram above, the left Pico) first needs to be mounted on the build system as a USB Mass Storage device as follows:

With the Pico connected via USB cable to the build system, press and hold the Pico BOOTSEL button on the debug probe, then momentarily short the debug probe pins 30 (RUN) and 28 (GND). A moment later, release BOOTSEL. Shorting the RUN pin to ground causes the Pico to reset and, with BOOTSEL pressed, boot into USB Mass Storage mode.

If all went well, the Pico should be mounted on a folder of the build system, i.e., on

  • Ubuntu as: /media/${USER}/RPI-RP2
  • Fedora as: /run/media/${USER}/RPI-RP2
  • macOS as: /Volumes/RPI-RP2

Picoprobe can now be installed to the Pico by copying the file picoprobe.uf2 to Pico's mount point, i.e., on

  • Ubuntu, run:
cp ${PICO_BASEDIR}/picoprobe/build/picoprobe.uf2 \
    /run/media/${USER}/RPI-RP2
  • Fedora, run:
cp ${PICO_BASEDIR}/picoprobe/build/picoprobe.uf2 \
    /run/media/${USER}/RPI-RP2
  • macOS, run:
cp ${PICO_BASEDIR}/picoprobe/build/picoprobe.uf2 \
    /Volumes/RPI-RP2

That's it!

Flash MicroPython

After installing Picoprobe, OpenOCD can be used for flashing applications to the development system. For instance, to flash MicroPython, run:

make -C "$PICO_BUILD_PATH" flash \
    PICO_IMAGE="${PICO_BASEDIR}/micropython/ports/rp2/build-PICO/firmware.elf"

Then open the REPL with:

ttypico

Debug Pico

To illustrate, debugging, start by flashing the blink application to the Pico:

make -C "$PICO_BUILD_PATH" flash \
    PICO_IMAGE="${PICO_BASEDIR}/pico-examples/build/blink.elf"

Verify that the development Pico's LED is blinking, then start the debug server:

make -C "$PICO_BUILD_PATH" debug

In another terminal, open the blink ELF image in GNU debugger:

gdb-multiarch "${PICO_BASEDIR}/pico-examples/build/blink/blink.elf"

At the GNU debugger prompt, (gdb), connect to the OpenOCD debug server:

target remote localhost:3333

Set a breakpoint, restart the blink application and list or step through it:

break main
monitor reset init
continue
list
step

After entering a command, hit the Enter key to repeat it. Use quit to exit the GNU debugger and CTRL+C to terminate the debug server.

rp2's People

Contributors

slewsys avatar

Watchers

 avatar Aaron Moore avatar Kostas Georgiou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.