Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Template for the Lingua Franca RP2040 target platform
This repo is a template for [Lingua Franca](https://www.lf-lang.org/) projects using the bare metal RP2040 target platform such as found on the Raspberry Pi Pico board and the [Pololu 3pi+ 2040 robot](https://www.pololu.com/docs/0J86). Currently the repo supports MacOS, Linux, and Windows through [WSL](https://learn.microsoft.com/en-us/windows/wsl/install).
To support RP2040-based boards, the repo uses the [Pico SDK](https://github.com/raspberrypi/pico-sdk/tree/master/src) as a dependency which includes a light set of headers, libraries and a build system.
This repo is a template for [Lingua Franca](https://www.lf-lang.org/) projects using the bare metal RP2040 target platform such as found on the Raspberry Pi Pico board and the [Pololu 3pi+ 2040 robot](https://www.pololu.com/docs/0J86). Currently the repo supports MacOS, Linux, and Windows through [WSL](https://learn.microsoft.com/en-us/windows/wsl/install). To support RP2040-based boards, the repo uses the [Pico SDK](https://github.com/raspberrypi/pico-sdk/tree/master/src) as a dependency which includes a light set of headers, libraries and a build system.

## Setup
This template uses nix to manage toolchains and other applications. Install [nix](https://nixos.org/download.html) first for your preferred platform. Make note of the installation type since a **multi-user** install will require sudo permissions and will interact with a system-wide `/nix/store`. After installation, run the following in the shell to enable the experimental nix flakes feature.
Expand All @@ -9,6 +8,8 @@ This template uses nix to manage toolchains and other applications. Install [nix
mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
```
> [!NOTE]
> We are finding that this template is also applicable to RP2350-based boards, such as the Pico 2 and Pico 2 W. In many cases, you can rely on the board configuration (`PICO_BOARD`) to automatically set the platform (`PICO_PLATFORM`). For example, `export PICO_BOARD=pico2` will lead to `PICO_PLATFORM=rp2350`. This can be done in the file `shell.nix`, in the block above `shellHook`, where we have also set `PICO_PLATFORM = "";` to ensure the board header automatically sets it. For more information, see the "Platform and Board Configuration" chapter of the [Raspberry Pi Pico-series C/C++ SDK](https://rptl.io/pico-c-sdk) book.

To launch the lf-pico shell environment, run the following in the root of the lf-pico repository. The launched shell will include the various required toolchains and applications needed for development.

Expand Down
14 changes: 12 additions & 2 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ let
in
pkgs.mkShell {
packages = with pkgs; [
lolcat
picotool
cmake
gcc-arm-embedded
Expand All @@ -20,6 +21,11 @@ pkgs.mkShell {
# lingo
];

# set environment variables
# per "Raspberry Pi Pico-series C/C++ SDK", 7.2 Platform and Board Configuration: "PICO_BOARD=my_board_name in your environment will cause the header my_board_name.h to be included by all other SDK headers in order to provide #defines particular to the board you are using...If PICO_BOARD is specified but not PICO_PLATFORM, PICO_PLATFORM will be set if a value for it is specified in the board header."
#PICO_BOARD = "pico2_w"; # specify if your board is not plain pico, for example: pico_w, pico2, pico2_w, etc
PICO_PLATFORM = ""; # intentionally empty valued, allowing board header to set it

# TODO: integrate dependencies into nix
shellHook = ''
echo "[shell] hook start"
Expand All @@ -28,13 +34,17 @@ pkgs.mkShell {
cd pico-sdk/
git submodule update --init
export PICO_SDK_PATH="$PWD"
echo "[shell] PICO_SDK_PATH: $PICO_SDK_PATH" | lolcat
cd ../
echo "[shell] copy robot header"
echo "[shell] copy robot header (pololu_3pi_2040_robot.h)" | lolcat
cp pololu_3pi_2040_robot.h pico-sdk/src/boards/include/boards/
echo "[shell] PICO_BOARD: $PICO_BOARD" | lolcat
echo "[shell] PICO_PLATFORM: $PICO_PLATFORM" | lolcat
echo "[shell] setup testbed"
cd test/
npm install
echo "[shell] hook end"
cd ../
echo '[shell] To exit the shell, type `exit` or press `Ctrl`+`D`'
echo "[shell] hook end"
'';
}