Skip to content

Switch to Ninja and add README #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Switch to Ninja and add README #53

wants to merge 2 commits into from

Conversation

will-v-pi
Copy link
Contributor

Install Ninja and switch the pico-examples build over to that, so you get automatic multithreading without -j giving simpler command line instructions, and a shorter build output.

Add a README which:

  • Explains the purpose of the script & how to run it
  • Mentions VS Code extension as the way to go if you want a GUI
  • Includes some quick Getting Started bits for command line compilation
  • Adds basic command line setup instructions for other OSes that can't use the script (including mentioning that Linux with apt should work with the script)

will-v-pi added 2 commits June 4, 2025 17:58
Also build for W picos as well
Adds some simple command line instructions, along with basic setup instructions for other OSes that can't use this script
@will-v-pi will-v-pi requested a review from lurch June 6, 2025 14:13

> If you're not using one of the default boards (pico, pico_w, pico2, or pico2_w), you'll need to create a new build directory for your board - you can do this with:
> ```
> cmake -S . -B build_$board -GNinja -DPICO_BOARD=$board -DCMAKE_BUILD_TYPE=Debug

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like people might just copy/paste this which won't work

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might just be explicit about replacing $board, and ppl who get shells will get that it is a var too


> If you're not using one of the default boards (pico, pico_w, pico2, or pico2_w), you'll need to create a new build directory for your board - you can do this with:
> ```
> cmake -S . -B build_$board -GNinja -DPICO_BOARD=$board -DCMAKE_BUILD_TYPE=Debug

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might just be explicit about replacing $board, and ppl who get shells will get that it is a var too


Put your board in bootsel mode and use `picotool` to load the blink example:
```bash
picotool load build/blink/blink.uf2 -x

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to like -vx and above

@@ -0,0 +1,182 @@
# Pico Command Line Setup

This script gives you an easy way to setup your Raspberry Pi to be able to build and run programs on your Pico from the command line. Compatibility with any systems not running Raspberry Pi OS or Raspberry Pi OS Lite is not guaranteed or maintained.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever the group noun is in the datasheet (Pico-series microcontroller)

```
You should now have a blinking Pico! For more info on the `picotool` command which is used to load and query binaries on the device, see its [README](https://github.com/raspberrypi/picotool?tab=readme-ov-file#readme)

## Input/Output

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console Input/Output perhaps

> cmake -S . -B build_$board -GNinja -DPICO_BOARD=$board -DCMAKE_BUILD_TYPE=Debug
> ```

To build & run the blink example, first attach a Pico in bootsel mode, and run the following commands:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly split between build/run and a little sentence on what each does


## Input/Output

To view console output, you can either connect the UART output to a [Debug Probe](https://www.raspberrypi.com/documentation/microcontrollers/debug-probe.html#getting-started) (or similar) and use stdio_uart (see the hello_serial example), or you can use stdio_usb (see the hello_usb example).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stdio_uart etc.

cmake --build build
```

Put your board in bootsel mode and use `picotool` to load the blink example:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe bootsel is always BOOTSEL

```bash
picotool load build/blink/blink.uf2 -x
```
You should now have a blinking board

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arguably the board doesn't blink ;-)


For more details on debugging with GDB, see the [GDB docs](https://sourceware.org/gdb/current/onlinedocs/gdb.html/)

## Multiple Terminals

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really something we should include? won't most people just open multiple terminal instances?


If you have `apt`, then running the [pico_setup.sh](./pico_setup.sh) script should hopefully work for you, and you won't need to do any manual setup.

If it doesn't work, or you don't have `apt`, then you can manually install the `GIT_DEPS` and `SDK_DEPS` from the script. Then follow the [manual setup instructions](#setup-sdk--picotool).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should list the dependencies (and also add a note about newlib for certain distros - see that a lot on the forums)

Note that i think the new openocd will download its own dependencies so that might be a help, but yeah i don't much care about telling people how to build that - it has instructions

cd pico/pico-examples
```

Depending on the board you're using (eg pico2), replace `build_pico` with the relevant build directory (eg `build_pico2`) in the following commands.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this advice to create a board-specific build directory - IIRC we've never done that elsewhere in any of our other documentation?
(also, I suspect the vast majority of people will only have a single board and/or single type of board?)

> cmake -S . -B build_$board -GNinja -DPICO_BOARD=$board -DCMAKE_BUILD_TYPE=Debug
> ```

To build & run the blink example, first attach a Pico in bootsel mode, and run the following commands:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC we generally write BOOTSEL in uppercase rather than lowercase?

@lurch
Copy link
Contributor

lurch commented Jun 7, 2025

This expanded documentation is great; but in order to avoid duplication of effort, I wonder if it might be better to add it to https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf instead and then have this README.md point people to that? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants