10 Commits

Author SHA1 Message Date
Leszek
44f236e9cd Arm build (#14) 2025-07-26 17:28:49 +02:00
Marco
002d69b364 Bump-up SDK version and add test for PICO2W (#12)
* Bump-up SDK

Update
Pico SDK 2.1.1
Pico Tool 2.1.1
RTOS Kernel 11.2.0

* add the pico2_w to the testscript

Add the pico2_w for both architecture.

* add pico2_w_riscv test case

---------

Co-authored-by: Marco <maggo1404@users.noreply.github.com>
2025-05-07 21:12:16 +02:00
lukstep
be7e625e2b Upgrade pico-sdk and picotool to 2.1.0 version 2024-12-09 18:49:41 +01:00
Chris Routh
f6fd10e14b Minor build warning fix
Minor case change fixes warning message

"WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 7)"
2024-11-03 22:36:26 +01:00
lukstep
8c283d7619 Raspberry Pi Pico 2 support 2024-08-27 23:11:16 +02:00
lukstep
0a2bba1365 Debugging instruction 2024-07-05 16:53:56 +02:00
lukstep
b7da9deed4 Dev container tutorial 2024-06-06 19:50:20 +02:00
lukstep
7269f053f6 Test freertos_test_project build 2024-04-04 22:29:17 +02:00
lukstep
4457cf9404 Add FreeRTOS to container image and demo project 2024-04-04 22:29:17 +02:00
lukstep
3d8b06e9b7 Specify the C and C++ compiler path 2023-07-23 12:57:49 +02:00
10 changed files with 551 additions and 112 deletions

View File

@@ -19,8 +19,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build SDK
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
context: .
load: true
@@ -28,7 +32,7 @@ jobs:
- name: Test SDK
run: bash ./test_sdk.sh ${{ env.TEST_TAG }}
- name: Log into Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
@@ -39,9 +43,10 @@ jobs:
images: lukstep/raspberry-pi-pico-sdk
- name: Push SDK image
if: github.event_name == 'release' && github.event.action == 'published'
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64

View File

@@ -1,32 +1,53 @@
FROM alpine:3.17.0
FROM ubuntu:24.10 AS gcc_build
# Install toolchain
RUN apk update && \
apk upgrade && \
apk add git \
# Build GCC RISC-V
COPY ./install_gcc.sh /home/install_gcc.sh
RUN bash /home/install_gcc.sh
FROM ubuntu:24.10 AS sdk_setup
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get install --no-install-recommends -y \
git \
ca-certificates \
python3 \
py3-pip \
cmake \
build-base \
libusb-dev \
bsd-compat-headers \
newlib-arm-none-eabi \
gcc-arm-none-eabi
tar \
build-essential \
gcc-arm-none-eabi \
libnewlib-arm-none-eabi \
libstdc++-arm-none-eabi-newlib \
cmake && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Raspberry Pi Pico SDK
ARG SDK_PATH=/usr/share/pico_sdk
RUN git clone --depth 1 --branch 1.5.1 https://github.com/raspberrypi/pico-sdk $SDK_PATH && \
ARG SDK_PATH=/usr/local/picosdk
RUN git clone --depth 1 --branch 2.1.1 https://github.com/raspberrypi/pico-sdk $SDK_PATH && \
cd $SDK_PATH && \
git submodule update --init
ENV PICO_SDK_PATH=$SDK_PATH
# FreeRTOS
ARG FREERTOS_PATH=/usr/local/freertos
RUN git clone --depth 1 --branch V11.2.0 https://github.com/FreeRTOS/FreeRTOS-Kernel $FREERTOS_PATH && \
cd $FREERTOS_PATH && \
git submodule update --init --recursive
ENV FREERTOS_KERNEL_PATH=$FREERTOS_PATH
# Picotool installation
RUN git clone --depth 1 --branch 1.1.2 https://github.com/raspberrypi/picotool.git /home/picotool && \
RUN git clone --depth 1 --branch 2.1.1 https://github.com/raspberrypi/picotool.git /home/picotool && \
cd /home/picotool && \
mkdir build && \
cd build && \
cmake .. && \
make && \
cp /home/picotool/build/picotool /bin/picotool && \
make -j$(nproc) && \
cmake --install . && \
rm -rf /home/picotool
# Install GCC RISC-V
COPY --from=gcc_build /opt/riscv/gcc14-rp2350-no-zcmp /opt/riscv/gcc14-rp2350-no-zcmp
ENV PATH="$PATH:/opt/riscv/gcc14-rp2350-no-zcmp/bin"

193
README.md
View File

@@ -2,140 +2,155 @@
# Raspberry Pi Pico Docker SDK
Lightweight Raspberry Pi Pico C++ SDK container.
A SDK environment for Raspberry Pi Pico 1 and 2 in a Docker container.
## Pull container from Docker Hub and run
## Pulling the Image from Docker Hub and Running
The latest version of the image is stored on [Docker Hub](https://hub.docker.com/repository/docker/lukstep/raspberry-pi-pico-sdk/general)
and can be used for container runs.
Commands below show how to run a container, using an image from Docker Hub
```
The latest image is available on [Docker Hub](https://hub.docker.com/repository/docker/lukstep/raspberry-pi-pico-sdk/general)
and can be used to run a container.
The following commands show how to run the container using the Docker Hub image:
```bash
docker run -d -it --name pico-sdk --mount type=bind,source=${PWD},target=/home/dev lukstep/raspberry-pi-pico-sdk:latest
docker exec -it pico-sdk /bin/sh
```
The directory from which the `docker run` command was called will be mounted to /home/dev in the container.
So after attaching to the SDK container you can build your project following the steps:
The directory from which the `docker run` command was executed will be mounted in the container at `/home/dev`.
After attaching to the SDK container, you can build your project by executing the following steps:
```
```bash
cd /home/dev
mkdir build
cd build
cmake .. && make -j4
```
## Build image and run container:
## Building the Image and Running the Container
To build your own SDK image, You need to clone this repository and run the following commands:
To build your own SDK image, clone this repository and run the following commands:
```
```bash
cd raspberry-pi-pico-docker-sdk
docker build . --tag pico-sdk
docker run -d -it --name pico-sdk --mount type=bind,source=${PWD},target=/home/dev pico-sdk
docker exec -it pico-sdk /bin/sh
```
## Visual Studio Code as Rassberry Pi PICO projects IDE
## Visual Studio Code as IDE for Raspberry Pi Pico Projects
You can use the SDK container with Visual Studio Code as Raspberry Pi Pico projects IDE.
You can use the SDK container with Visual Studio Code to create an IDE for Raspberry Pi Pico projects.
There are two solutions prepared: a new one using the Visual Studio Dev Containers extension and an old one with manual configuration.
### Attaching VSCode to SDK Docker container
### [Visual Studio Code Dev Container](https://code.visualstudio.com/docs/devcontainers/containers)
Follow the instruction below to set up VSCode:
#### Prerequisites
1. Install [Visual Studio Code](https://code.visualstudio.com) and next [Remote Development](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) extensions.
To use the dev container, you need to have VSCode, Docker, and the VSCode extensions installed.
Follow [this](https://code.visualstudio.com/docs/devcontainers/tutorial#_prerequisites) guide for setup.
![image-1](https://user-images.githubusercontent.com/20487002/201380432-da387680-f6b0-4542-8c02-6a3eec8e103d.png)
#### Using the Dev Container for Pico IDE
2. Open the terminal and go to the projects you want to open in VSCode.
- Clone [pico-template-project](https://github.com/lukstep/pico-template-project) repository.
- Open `pico-template-project` folder in Visual Studio Code.
- In VSCode, click the button in the bottom left corner of VSCode and select: Reopen in Container...
![image-1](https://github.com/lukstep/raspberry-pi-pico-docker-sdk/assets/20487002/f1f06bca-cb0b-4c2d-bf4c-611ef004e70a)
- Build the project.
- Enjoy coding you Pico project with Intellisense.
![image-1](https://github.com/lukstep/raspberry-pi-pico-docker-sdk/assets/20487002/ed367c06-aa9f-440a-9ca2-ddfbd7bdd266)
3. Pull SDK image from Docker HUB and run SDK container via the following command. The container must be running while you attach to it via VSCode.
## Pico Memory Flashing and Debugging via Pico Probe and OpenOCD
```
docker run -d -it --name pico-sdk --mount type=bind,source=${PWD},target=/home/dev lukstep/raspberry-pi-pico-sdk:latest
> [!WARNING]
> OpenOCD not support RP2350 (Pico 2). Currently this part is only valid for RP2040 boards (Pico 1).
docker exec -it pico-sdk /bin/sh
To work efficiently on the project, we need the ability to upload firmware to the microcontroller, debug, and communicate through the serial port. The Raspberry Pi Pico board itself allows for software uploads, but this process is not very convenient or efficient for larger projects. The Pico Probe extends the capabilities of the Raspberry Pi Pico board to include fast firmware uploads to the microcontroller's memory, debugging via Serial Wire Debug (SWD), and it also serves as a USB UART converter.
The Debug Probe is compatible with the CMSIS-DAP interface, allowing OpenOCD to be used as the debugger server. By using OpenOCD, it becomes possible to communicate between development containers and the Debug Probe via TCP. On Linux, the Docker container can communicate directly through COM ports. However, on Mac and Windows, this is not possible because Docker runs in a dedicated virtual machine that does not have access to COM ports. Therefore, a solution with the OpenOCD server on the host machine was chosen.
The diagram below shows the environment topology:
1. Pico Probe is connected to the Raspberry Pi Pico board:
- SWD (Serial Wire Debug) interface for debugging.
- UART (Universal Asynchronous Receiver/Transmitter) interface for serial communication.
2. The Pico Probe is connected to the PC via USB.
3. OpenOCD (Open On-Chip Debugger) runs on the PC and communicates with the Pico Probe.
4. The development container (devContainer) connects to OpenOCD via TCP.
![image-1](https://github.com/lukstep/raspberry-pi-pico-docker-sdk/assets/20487002/27bbb17d-5de4-4e41-9481-17a9e249e7b3)
### Instal required tools
To install OpenOCD on Linux, run the following command in a terminal:
```bash
sudo apt install openocd
```
4. When the container is launched, go to VSCode, click the green button in the lower left corner of VSCode and select options: Attach to Running Container...
To install OpenOCD on macOS, run the following command:
![image-2](https://user-images.githubusercontent.com/20487002/201471437-b12dc225-28ab-4ebd-b694-fc7058d34e2e.png)
5. Select the SDK container.
![image-4](https://user-images.githubusercontent.com/20487002/201383009-54a3fc62-1206-4105-83d0-d956448434dd.png)
6. Then a new VSCode window will open. At the bottom window, you can see that it is attached to the SDK container.
![image-5](https://user-images.githubusercontent.com/20487002/201383452-10573842-de2a-46c3-9ebf-f6fd5f06c687.png)
7. Now, there is needed to open project files. Your project is mounted to `/home/dev` in the container. Go to EXPLORE tab in VSCode and click Open Folder. In opened window write `/home/dev` and click the OK button.
![image-6](https://user-images.githubusercontent.com/20487002/201386202-dd0934b2-5fae-4a2d-8875-f2cb40b1dc59.png)
8. Now You can explore, develop and build your Raspberry Pi Pico project via Visual Studio Code!
![image-7](https://user-images.githubusercontent.com/20487002/201389505-d1346622-a8e1-4d0b-842c-57e5b54f9183.png)
### Pico SDK aware Intellisense
For an IntelliSense that will be aware of Raspberry Pi Pico SDK dependencies, we will use [Clangd](https://clangd.llvm.org). Clangd is a C/C++ language server provided by the LLVM project. To Setup Clang as Intellisense engine follow instruction below:
1. To begin with, you need to install the server itself (Clangd is not installed by default in the SDK container image), to do this in the terminal call the command:
```
apk add clang-extra-tools
```bash
brew install openocd
```
2. Next is needed to install the Visual Studio Code [Clangd extension](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd).
To install OpenOCD on Windows, follow these steps:
![image-1](https://user-images.githubusercontent.com/20487002/201468256-be7741a2-9092-406a-8be1-d4d9640a85e7.png)
- Go to the page https://github.com/xpack-dev-tools/openocd-xpack/releases.
1. To set-up The Clangd extension, in the project root directory, create folder .vcode with file settings.json. To settings.json past configuration from the snippet below:
- Download the Windows build of OpenOCD. For example, you might download a file named xpack-openocd-0.12.0-2-win32-x64.zip.
```json
{
"C_Cpp.intelliSenseEngine": "Disabled",
"clangd.path": "/usr/bin/clangd",
"clangd.checkUpdates": false,
"clangd.restartAfterCrash": true,
"clangd.detectExtensionConflicts": true,
"clangd.arguments": ["-log=verbose",
"-pretty",
"--background-index",
"--query-driver=/usr/bin/arm-none-eabi-gcc",
"--compile-commands-dir=/home/dev/build"]
}
- Unzip the downloaded file to extract its contents.
### How to Use: Step-by-Step Instructions
1. Connect the Pico Probe to the Pico Board via SWD (1) and connect the Pico board UART to the UART-USB converter on the Pico Probe (2).
![image-1](https://github.com/lukstep/raspberry-pi-pico-docker-sdk/assets/20487002/92974093-0699-4299-b88c-b15633cee616)
2. Connect the Pico Probe and Pico Board to your PC
3. Start the OpenOCD
On Linux and Mac, open a new terminal and run the following command:
```bash
sudo openocd -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c 'bindto 0.0.0.0' -c 'adapter speed 5000' -c 'init'
```
![image-2](https://user-images.githubusercontent.com/20487002/201468479-7de7e598-3aac-4fe4-a240-d7404200a0a6.png)
On Windows, open PowerShell, navigate to the folder containing OpenOCD, and run `openocd.exe`:
4. For clangd to work, it needs a `compile_commands.json` file. This file contains the compilation and dependency information of each file in the project. To create it you need to add to the CMake command, `-DCMAKE_EXPORT_COMPILE_COMMANDS=1`. So You need to build your project with the command:
```
mkdir build
cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
make
```bash
cd .\Desktop\xpack-openocd-0.12.0-2\
.\bin\openocd.exe -f interface\cmsis-dap.cfg -f target\rp2040.cfg -c 'bindto 0.0.0.0' -c 'adapter speed 5000' -c 'init'
```
5. Now IntelliSense should work!. Now you should see a prompt when you start typing. If you hover your cursor over a function from the SDK you should see its documentation, You can go to the function definition by pressing F12.
4. Open the project in the Dev Container.
![image-3](https://user-images.githubusercontent.com/20487002/201469349-b8a9721f-4169-4bf6-a8d6-d459f8f97180.png)
5. Make a debug build. Go to the CMake extension tab (1), click "Select Variant" (2), and choose "Debug" build (3). Start the build (4). If the build completes successfully, you can proceed to flashing the memory and debugging.
![image-4](https://user-images.githubusercontent.com/20487002/201468782-50fc6abb-1f82-49d5-8b93-631dd30f1f58.png)
![image-1](https://github.com/lukstep/raspberry-pi-pico-docker-sdk/assets/20487002/262fb68b-8ef5-4ec2-a05e-8fd09597915d)
![image-5](https://user-images.githubusercontent.com/20487002/201468813-2ef7b04f-ede6-46cb-84e2-a40db595811d.png)
6. To start a debug session, first add a breakpoint in the main function. Next, go to the debugger extension tab (1), and click "Play" (2). The debug session starts by flashing the Pico's memory and restarting the microcontroller. After the reset, the flashed firmware starts and the program should stop at the breakpoint.
![image-1](https://github.com/lukstep/raspberry-pi-pico-docker-sdk/assets/20487002/598f6508-0b9a-44dc-b1f9-3a9eb391f0c3)
It is possible to flash the Pico's memory without starting a debugger session. To do that, run the preprogrammed tasks.
- Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac) to open the Command Palette.
- Type Run Task into the Command Palette and press Enter.
- Select task `Flash`.
## Manual configuration of VSCode as Pico IDE (old)
Refer [here](docs/vscode_manual_setup.md) for step-by-step instruction
## References
[Raspberry Pi Debug Probe](https://www.raspberrypi.com/documentation/microcontrollers/debug-probe.html)
[Raspberry Pi Pico C/C++ SDK](https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf)
[OpenOCD project page](https://openocd.org)

View File

@@ -0,0 +1,94 @@
# Manual configuration of VSCode as Pico IDE
## Prerequisites
You need to Visual Studio Code and Docker installed.
## Attaching VSCode to SDK Docker container
Follow the instruction below to set up VSCode:
- Install [Visual Studio Code](https://code.visualstudio.com) and next [Remote Development](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) extensions.
![image-1](https://user-images.githubusercontent.com/20487002/201380432-da387680-f6b0-4542-8c02-6a3eec8e103d.png)
- Open the terminal and go to the projects you want to open in VSCode.
- Pull SDK image from Docker HUB and run SDK container via the following command. The container must be running while you attach to it via VSCode.
```
docker run -d -it --name pico-sdk --mount type=bind,source=${PWD},target=/home/dev lukstep/raspberry-pi-pico-sdk:latest
docker exec -it pico-sdk /bin/sh
```
- When the container is launched, go to VSCode, click the green button in the lower left corner of VSCode and select options: Attach to Running Container...
![image-2](https://user-images.githubusercontent.com/20487002/201471437-b12dc225-28ab-4ebd-b694-fc7058d34e2e.png)
- Select the SDK container.
![image-4](https://user-images.githubusercontent.com/20487002/201383009-54a3fc62-1206-4105-83d0-d956448434dd.png)
- Then a new VSCode window will open. At the bottom window, you can see that it is attached to the SDK container.
![image-5](https://user-images.githubusercontent.com/20487002/201383452-10573842-de2a-46c3-9ebf-f6fd5f06c687.png)
- Now, there is needed to open project files. Your project is mounted to `/home/dev` in the container. Go to EXPLORE tab in VSCode and click Open Folder. In opened window write `/home/dev` and click the OK button.
![image-6](https://user-images.githubusercontent.com/20487002/201386202-dd0934b2-5fae-4a2d-8875-f2cb40b1dc59.png)
- Now You can explore, develop and build your Raspberry Pi Pico project via Visual Studio Code!
![image-7](https://user-images.githubusercontent.com/20487002/201389505-d1346622-a8e1-4d0b-842c-57e5b54f9183.png)
## Pico SDK aware Intellisense
For an IntelliSense that will be aware of Raspberry Pi Pico SDK dependencies, we will use [Clangd](https://clangd.llvm.org). Clangd is a C/C++ language server provided by the LLVM project. To Setup Clang as Intellisense engine follow instruction below:
- To begin with, you need to install the server itself (Clangd is not installed by default in the SDK container image), to do this in the terminal call the command:
```
apk add clang-extra-tools
```
- Next is needed to install the Visual Studio Code [Clangd extension](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd).
![image-1](https://user-images.githubusercontent.com/20487002/201468256-be7741a2-9092-406a-8be1-d4d9640a85e7.png)
- To set-up The Clangd extension, in the project root directory, create folder .vcode with file settings.json. To settings.json past configuration from the snippet below:
```json
{
"C_Cpp.intelliSenseEngine": "Disabled",
"clangd.path": "/usr/bin/clangd",
"clangd.checkUpdates": false,
"clangd.restartAfterCrash": true,
"clangd.detectExtensionConflicts": true,
"clangd.arguments": ["-log=verbose",
"-pretty",
"--background-index",
"--query-driver=/usr/bin/arm-none-eabi-gcc",
"--compile-commands-dir=/home/dev/build"]
}
```
![image-2](https://user-images.githubusercontent.com/20487002/201468479-7de7e598-3aac-4fe4-a240-d7404200a0a6.png)
- For clangd to work, it needs a `compile_commands.json` file. This file contains the compilation and dependency information of each file in the project. To create it you need to add to the CMake command, `-DCMAKE_EXPORT_COMPILE_COMMANDS=1`. So You need to build your project with the command:
```
mkdir build
cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
make
```
- Now IntelliSense should work!. Now you should see a prompt when you start typing. If you hover your cursor over a function from the SDK you should see its documentation, You can go to the function definition by pressing F12.
![image-3](https://user-images.githubusercontent.com/20487002/201469349-b8a9721f-4169-4bf6-a8d6-d459f8f97180.png)
![image-4](https://user-images.githubusercontent.com/20487002/201468782-50fc6abb-1f82-49d5-8b93-631dd30f1f58.png)
![image-5](https://user-images.githubusercontent.com/20487002/201468813-2ef7b04f-ede6-46cb-84e2-a40db595811d.png)

View File

@@ -0,0 +1,31 @@
cmake_minimum_required(VERSION 3.13)
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)
include($ENV{FREERTOS_KERNEL_PATH}/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake)
set(CMAKE_C_COMPILER /usr/bin/arm-none-eabi-gcc CACHE PATH "" FORCE)
set(CMAKE_CXX_COMPILER /usr/bin/arm-none-eabi-g++ CACHE PATH "" FORCE)
project(freertos_demo C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
pico_sdk_init()
add_library(FreeRTOS-Config INTERFACE)
target_include_directories(FreeRTOS-Config INTERFACE ${CMAKE_SOURCE_DIR}/config)
add_executable(freertos_demo main.cpp)
target_include_directories(freertos_demo PRIVATE ${CMAKE_CURRENT_LIST_DIR})
target_link_libraries(freertos_demo
pico_stdlib
FreeRTOS-Config
FreeRTOS-Kernel
FreeRTOS-Kernel-Heap4)
pico_enable_stdio_usb(freertos_demo 1)
pico_enable_stdio_uart(freertos_demo 1)
pico_add_extra_outputs(freertos_demo)

View File

@@ -0,0 +1,136 @@
/*
* FreeRTOS V202107.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* http://www.FreeRTOS.org
* http://aws.amazon.com/freertos
*
* 1 tab == 4 spaces!
*/
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
* Application specific definitions.
*
* These definitions should be adjusted for your particular hardware and
* application requirements.
*
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
*
* See http://www.freertos.org/a00110.html
*----------------------------------------------------------*/
/* Scheduler Related */
#define configUSE_PREEMPTION 1
#define configUSE_TICKLESS_IDLE 0
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 1
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
#define configMAX_PRIORITIES 32
#define configMINIMAL_STACK_SIZE ( configSTACK_DEPTH_TYPE ) 256
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
/* Synchronization Related */
#define configUSE_MUTEXES 1
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_APPLICATION_TASK_TAG 0
#define configUSE_COUNTING_SEMAPHORES 1
#define configQUEUE_REGISTRY_SIZE 8
#define configUSE_QUEUE_SETS 1
#define configUSE_TIME_SLICING 1
#define configUSE_NEWLIB_REENTRANT 0
#define configENABLE_BACKWARD_COMPATIBILITY 1
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5
/* System */
#define configSTACK_DEPTH_TYPE uint32_t
#define configMESSAGE_BUFFER_LENGTH_TYPE size_t
/* Memory allocation related definitions. */
#define configSUPPORT_STATIC_ALLOCATION 0
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configTOTAL_HEAP_SIZE (128*1024)
#define configAPPLICATION_ALLOCATED_HEAP 0
/* Hook function related definitions. */
#define configCHECK_FOR_STACK_OVERFLOW 2
#define configUSE_MALLOC_FAILED_HOOK 1
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
/* Run time and task stats gathering related definitions. */
#define configGENERATE_RUN_TIME_STATS 0
#define configUSE_TRACE_FACILITY 1
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
/* Co-routine related definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES 1
/* Software timer related definitions. */
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
#define configTIMER_QUEUE_LENGTH 10
#define configTIMER_TASK_STACK_DEPTH 1024
/* Interrupt nesting behaviour configuration. */
/*
#define configKERNEL_INTERRUPT_PRIORITY [dependent of processor]
#define configMAX_SYSCALL_INTERRUPT_PRIORITY [dependent on processor and application]
#define configMAX_API_CALL_INTERRUPT_PRIORITY [dependent on processor and application]
*/
/* SMP port only */
#define configNUM_CORES 2
#define configTICK_CORE 0
#define configRUN_MULTIPLE_PRIORITIES 1
#define configSUPPORT_PICO_SYNC_INTEROP 1
#define configSUPPORT_PICO_TIME_INTEROP 1
#include <assert.h>
/* Define to trap errors during development. */
#define configASSERT(x) assert(x)
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_xTaskGetCurrentTaskHandle 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1
#define INCLUDE_xTaskGetIdleTaskHandle 1
#define INCLUDE_eTaskGetState 1
#define INCLUDE_xTimerPendFunctionCall 1
#define INCLUDE_xTaskAbortDelay 1
#define INCLUDE_xTaskGetHandle 1
#define INCLUDE_xTaskResumeFromISR 1
#define INCLUDE_xQueueGetMutexHolder 1
/* A header file that defines trace macro can be included here. */
#endif /* FREERTOS_CONFIG_H */

View File

@@ -0,0 +1,41 @@
#include "FreeRTOS.h"
#include "task.h"
#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/gpio.h"
#ifdef __cplusplus
extern "C" {
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
void vApplicationTickHook( void );
void vApplicationMallocFailedHook( void );
}
#endif
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ) {}
void vApplicationTickHook( void ) {}
void vApplicationMallocFailedHook( void ) {}
constexpr int LED_PIN = 25;
void vBlink(void* unused_arg) {
stdio_init_all();
for (;;) {
gpio_put(LED_PIN, 1);
vTaskDelay(250);
gpio_put(LED_PIN, 0);
puts("Hello FreeRTOS\n");
vTaskDelay(250);
}
}
int main() {
gpio_init(LED_PIN);
gpio_set_dir(LED_PIN, GPIO_OUT);
xTaskCreate(vBlink, "Blink", 128, NULL, 1, NULL);
vTaskStartScheduler();
}

51
install_gcc.sh Normal file
View File

@@ -0,0 +1,51 @@
#!/bin/bash
RET_VALUE=$?
RED='\033[0;31m'
NC='\033[0m' # No Color
apt-get update -y && \
apt-get upgrade -y && \
apt-get install -y autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev
if [ $RET_VALUE != 0 ]; then
echo "${RED}Instalation failed!${NC}"
exit 1
fi
mkdir -p /opt/riscv/gcc14-rp2350-no-zcmp
chown -R "$(whoami)" /opt/riscv/gcc14-rp2350-no-zcmp
git clone --depth 1 https://github.com/riscv/riscv-gnu-toolchain /home/riscv-gnu-toolchain
if [ $RET_VALUE != 0 ]; then
echo "${RED}Cloning RISC-V repo failed!${NC}"
exit 1
fi
cd /home/riscv-gnu-toolchain || exit
git clone --depth 1 https://github.com/gcc-mirror/gcc gcc-14 -b releases/gcc-14
if [ $RET_VALUE != 0 ]; then
echo "${RED}Cloning GCC repo failed!${NC}"
exit 1
fi
./configure --prefix=/opt/riscv/gcc14-rp2350-no-zcmp \
--with-arch=rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb --with-abi=ilp32 \
--with-multilib-generator="rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb-ilp32--;rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb-ilp32--" \
--with-gcc-src=`pwd`/gcc-14
if [ $RET_VALUE != 0 ]; then
echo "${RED}Configure failed!${NC}"
exit 1
fi
make -j$(nproc)
cd /home || exit
rm -rf /home/riscv-gnu-toolchain

View File

@@ -1,7 +1,6 @@
cmake_minimum_required(VERSION 3.13)
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)
include($ENV{PICO_SDK_PATH}/pico_sdk_init.cmake)
project(sample C CXX ASM)
set(CMAKE_C_STANDARD 11)

52
test_sdk.sh Normal file → Executable file
View File

@@ -1,9 +1,55 @@
#! /usr/bin/env bash
RED="\e[31m"
GREEN="\e[32m"
NC="\e[0m"
STATUS=0
if [[ -z $1 ]]; then
echo "Please provide an SDK image you want to test"
fi
docker run -d -it --name pico-sdk --mount type=bind,source=${PWD}/test_poject,target=/home/dev $1
docker exec pico-sdk /bin/sh -c "cd /home/dev && mkdir build && cd build && cmake .. && make -j4"
docker exec pico-sdk /bin/sh -c "picotool"
declare -a boards=("pico" "pico_w" "pico2" "pico2_riscv" "pico2_w" "pico2_w_riscv")
docker run -d -it --name pico-sdk --mount type=bind,source="${PWD}"/test_poject,target=/home/dev "$1"
for board in "${boards[@]}"
do
echo "---- $board build test ----"
docker exec pico-sdk /bin/bash -c "rm -rf /home/dev/build"
if [[ $board = pico2_riscv ]] ; then
docker exec -i pico-sdk /bin/bash -c "cd /home/dev && mkdir build && cd build && cmake .. -DPICO_BOARD=pico2 -DPICO_PLATFORM=rp2350-riscv && make -j4"
elif [[ $board = pico2_w_riscv ]] ; then
docker exec -i pico-sdk /bin/bash -c "cd /home/dev && mkdir build && cd build && cmake .. -DPICO_BOARD=pico2_w -DPICO_PLATFORM=rp2350-riscv && make -j4"
else
docker exec -i pico-sdk /bin/bash -c "cd /home/dev && mkdir build && cd build && cmake .. -DPICO_BOARD=${board} && make -j4"
fi
if [ $? != 0 ]; then
echo -e "${RED}----- Test failed -----${NC}"
STATUS=1
break
fi
echo "${GREEN}----- Test passed -----${NC}"
done
docker container kill pico-sdk
docker container rm pico-sdk
exit ${STATUS}
# for board in "${boards[@]}"
# do
# echo "FreeRTOS $board build test"
# docker run -d -it --name pico-sdk --mount type=bind,source=${PWD}/freertos_test_project,target=/home/dev $1
# if [[ $board -eq "pico2_riscv" ]] ; then
# docker exec pico-sdk /bin/bash -c "cd /home/dev && mkdir build && cd build && cmake .. -DPICO_BOARD=pico2 -DPICO_PLATFORM=rp2350-riscv && make -j4"
# else
# docker exec pico-sdk /bin/bash -c "cd /home/dev && mkdir build && cd build && cmake .. -DPICO_BOARD=${board} && make -j4 && cd .. && rm -rf build"
# fi
# docker exec pico-sdk /bin/bash -c "rm -rf /home/dev/build"
# docker container kill pico-sdk
# docker container rm pico-sdk
# rm -rf ./test_poject/build/
# done