![](pics/HSA-Banner.png) # Raspberry Pi Pico - Template for C ## Table of Content 1. [**Introduction**](#1.-Introduction) 2. [**Required Software and Library**](#2.-Required_Software) * [*Windows*](#Windows) * [*Mac-OS*](#Mac-OS) * [*Linux*](#Linux) 3. [**Required Visual Studio Code Plugins**](#3.-Required_Visual_Studio_Code_Plugins) 4. [**Recommended Visual Studio Code Plugins**](#4.-Recommended_Visual_Studio_Code_Plugins) 5. [**Optional Visual Studio Code Themes**](#5.-Optional_Visual_Studio_Code_Themes)
## 1. Introduction This repository can be used as a template for a new Raspberry Pi Pico C-Project. > **Note:** Once you have downloaded/cloned this repository, open it in Visual Studio Code. Note, to follow the guideline of folder structure and all necessary programs and plugins for Visual Studio Code. Open cmake in Visual Studio Code and build the "blink" project. Copy the "blink.uf2" file from the `build` folder to the Raspberry Pi Pico by following the instructions according to the description in [Core](/core).
## 2. Required Software and Library (Windows/Mac-OS/Linux) Regardless which operating system is used for compilation, the Pico-SDK is always needed. The Raspberry Pi version of OpenOCD is optional and only required, if the Pico should be debugged and the system integrated version of OpenOCD does not support Picoprobe as a debugger. Picoprobe is also optional and only required, if a second Pico should be used as a debugger. | Name | Description | Link | |:----:|-------------|------| | ***Raspberry Pi Pico-SDK***
| The Raspberry Pi Pico SDK (henceforth the SDK) provides the headers, libraries and build system necessary to write programs for the RP2040-based devices such as the Raspberry Pi Pico in C, C++ or assembly language. | [https://github.com/raspberrypi/pico-sdk](https://github.com/raspberrypi/pico-sdk) | | ***Raspberry Pi OpenOCD***
(optional)
| OpenOCD provides on-chip programming and debugging support with a layered architecture of JTAG interface and TAP support. | [https://github.com/raspberrypi/openocd](https://github.com/raspberrypi/openocd) | | ***Raspberry Pi Debugprobe***
(optional)
| Debugprobe allows a Pico / RP2040 to be used as USB -> SWD and UART bridge. This means it can be used as a debugger and serial console for another Pico. | [https://github.com/raspberrypi/debugprobe](https://github.com/raspberrypi/debugprobe) | This repository refers to the Pico-SDK, which must be in search path. The Pico-SDK must be at the same folder level as this repository. If debugging is needed, also the OpenOCD folder must be at the same level. ```bash Project Folder | ├──Pico-SDK | ├──OpenOCD (optional) | └── ```
### Windows For windows is an installer available, which provide all the necessary tools to compile C-Code for the Raspberry Pi Pico. | Name | Description | Link | |:----:|-------------|------| | ***Pico Setup Windows***
| This project aims to create an easy-to-use installer to get started on Windows (using the C/C++ SDK) with Raspberry Pi Pico and other RP2040-based boards. It is inspired by, and is roughly equivalent to, the pico-setup project for Linux systems. | [https://github.com/raspberrypi/pico-setup-windows](https://github.com/raspberrypi/pico-setup-windows) | This intstaller includes the following software: * [Arm GNU Toolchain](https://developer.arm.com/downloads/-/gnu-rm) * [CMake](https://cmake.org/download/) * [Ninja](https://github.com/ninja-build/ninja) * [Python](https://www.python.org/downloads/windows/) * [Git for Windows](https://git-scm.com/download/win) * [Visual Studio Code](https://code.visualstudio.com/) * [OpenOCD](https://github.com/openocd-org/openocd/)
### Mac-OS On Mac-OS the following software is needed to compile C-Code for the Raspberry Pi Pico. | Name | Description | Link | |:----:|-------------|------| | ***Visual Studio Code***
| Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages and runtimes (such as C++, C#, Java, Python, PHP, Go, .NET). | [https://code.visualstudio.com/](https://code.visualstudio.com/) | | ***Git***
| Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. | [https://git-scm.com/](https://git-scm.com/) | | ***Homebrew Formulae (CMake)***
| CMake is an extensible, open-source system that manages the build process in an operating system and in a compiler-independent manner. Unlike many cross-platform systems, CMake is designed to be used in conjunction with the native build environment. | [https://formulae.brew.sh/formula/cmake](https://formulae.brew.sh/formula/cmake) | | ***Homebrew Formulae (Arm-None-EABI-GCC)***
| The GNU Arm Embedded Toolchain is a ready-to-use, open-source suite of tools for C, C++ and assembly programming. The GNU Arm Embedded Toolchain targets the 32-bit Arm Cortex-A, Arm Cortex-M, and Arm Cortex-R processor families. The GNU Arm Embedded Toolchain includes the GNU Compiler (GCC) and is available free of charge directly from Arm for embedded software development on Windows, Linux, and Mac OS X operating systems. | [https://formulae.brew.sh/formula/arm-none-eabi-gcc#default](https://formulae.brew.sh/formula/arm-none-eabi-gcc#default) | The Installation for Toolchain and CMake depends on Homebrew, if you don’t have Homebrew installed you should go ahead and install it. ```bash $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" ``` Then install the Toolchain and CMake. ```bash $ brew install cmake $ brew tap ArmMbed/homebrew-formulae $ brew install arm-none-eabi-gcc ```
### Linux On Linux the following software is needed to compile C-Code for the Raspberry Pi Pico. | Name | Description | Link | |:----:|-------------|------| | ***Visual Studio Code***
| Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages and runtimes (such as C++, C#, Java, Python, PHP, Go, .NET). | [https://code.visualstudio.com/](https://code.visualstudio.com/) | | ***Git***
| Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. | *Part of Linux Distribution* | | ***CMake***
| CMake is an extensible, open-source system that manages the build process in an operating system and in a compiler-independent manner. Unlike many cross-platform systems, CMake is designed to be used in conjunction with the native build environment. | *Part of Linux Distribution* | | ***Arm-None-EABI***
| The GNU Arm Embedded Toolchain is a ready-to-use, open-source suite of tools for C, C++ and assembly programming. The GNU Arm Embedded Toolchain targets the 32-bit Arm Cortex-A, Arm Cortex-M, and Arm Cortex-R processor families. The GNU Arm Embedded Toolchain includes the GNU Compiler (GCC) and is available free of charge directly from Arm for embedded software development on Windows, Linux, and Mac OS X operating systems. | *Part of Linux Distribution* | Git, CMake and Toolchain are normally part of the Linux Distribution and can be installed with the package manager. #### Arch Linux ```bash pacman -S git cmake arm-none-eabi-gcc arm-none-eabi-gdb arm-none-eabi-newlib arm-none-eabi-binutils ``` #### Debian/Ubuntu based Linux ```bash sudo apt update sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib build-essential ``` #### Raspbian (Raspberry Pi) If you are developing for Raspberry Pi Pico on the Raspberry Pi 4B, or the Raspberry Pi 400, most of the installation steps can be skipped by running the setup script. > **Note:** This setup script requires approximately 2.5GB of disk space on your SD card, so make sure you have enough free space before running it. You can check how much free disk space you have with the `df -h` command. ```bash wget https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh chmod +x pico_setup.sh ./pico_setup.sh ```
## 3. Required Visual Studio Code Plugins | Name | Description | Link | |:----:|-------------|------| | ***C/C++***
| The C/C++ extension adds language support for C/C++ to Visual Studio Code, including editing (IntelliSense) and debugging features. | [https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) | | ***CMake***
| This extension provides support for CMake in Visual Studio Code. | [https://marketplace.visualstudio.com/items?itemName=twxs.cmake](https://marketplace.visualstudio.com/items?itemName=twxs.cmake) | | ***CMake Tools***
| CMake Tools CMake Tools provides the native developer a full-featured, convenient, and powerful workflow for CMake-based projects in Visual Studio Code. | [https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) |