{"id":16102327,"url":"https://github.com/chlodalejandro/pico-c-template","last_synced_at":"2025-04-06T01:11:44.651Z","repository":{"id":206896279,"uuid":"717937687","full_name":"ChlodAlejandro/pico-c-template","owner":"ChlodAlejandro","description":"Template project for Raspberry Pi Pico C/C++ projects using CMake, CLion, and the Pico SDK.","archived":false,"fork":false,"pushed_at":"2023-11-13T03:11:21.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-12T06:59:41.930Z","etag":null,"topics":["clion","cmake","pico","pico-h","pico-hw","pico-w","raspberry-pi","rp2040"],"latest_commit_sha":null,"homepage":"","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChlodAlejandro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-13T02:18:30.000Z","updated_at":"2024-07-15T15:54:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"1a7b471c-03ce-4246-b339-9feeb81c51af","html_url":"https://github.com/ChlodAlejandro/pico-c-template","commit_stats":null,"previous_names":["chlodalejandro/pico-c-template"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChlodAlejandro%2Fpico-c-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChlodAlejandro%2Fpico-c-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChlodAlejandro%2Fpico-c-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChlodAlejandro%2Fpico-c-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChlodAlejandro","download_url":"https://codeload.github.com/ChlodAlejandro/pico-c-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419872,"owners_count":20936013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clion","cmake","pico","pico-h","pico-hw","pico-w","raspberry-pi","rp2040"],"created_at":"2024-10-09T18:53:32.621Z","updated_at":"2025-04-06T01:11:44.635Z","avatar_url":"https://github.com/ChlodAlejandro.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Raspberry Pi Pico C/C++ base project\r\n\r\nThis is a template for a Raspberry Pi Pico C/C++ project. It uses\r\nthe [Raspberry Pi Pico SDK](https://www.raspberrypi.com/documentation/pico-sdk)\r\nand [CMake](https://cmake.org/) to build the project. This project is\r\nconfigured to run on CLion on Windows; for a Visual Studio Code version,\r\nsee the `Pico - Visual Studio Code` shortcut bundled with the SDK instead.\r\n\r\n## Getting started\r\n\r\n### Prerequisites\r\n\u003e [!IMPORTANT]\r\n\u003e If possible, install the Pico SDK in a location that does not contain any spaces.\r\n\u003e This means **not** installing it in \"C:/Program Files/\". You will be unable to\r\n\u003e debug with OpenOCD in CLion if this is not the case. By default, this template\r\n\u003e will also look at \"C:/PicoSDK\". If you installed your SDK in a different location,\r\n\u003e set `PICO_INSTALL_PATH` as an environment variable or a CMake variable.\r\n\u003e \r\n\u003e In addition, you also need to place **your project** in a location that does\r\n\u003e not contain any spaces. If your user directory contains spaces (e.g.\r\n\u003e \"C:/Users/John Smith/\"), move your project to a different folder on your drive.\r\n\r\n* [Pico SDK](https://github.com/raspberrypi/pico-setup-windows/releases/latest/)\r\n* [CLion](https://www.jetbrains.com/clion/)\r\n* [CMake](https://cmake.org/download/)\r\n  * For a quick installation on Windows 11, run `winget install Kitware.CMake` in cmd/PowerShell.\r\n\r\n### Project structure\r\nThe CLion CMake configuration is stored and shared inside the project files.\r\nThe default project is named pico_base_main, and refers to the project in the\r\n`includes/` directory. The CMakeLists.txt file in this directory is used to\r\nbuild the project. **Libraries need to be explicitly linked here.**\r\n\r\nWhen the template has been cloned/copied, open the folder with CLion. Load the\r\ntop-level `CMakeLists.txt` file at the root of this template by right-clicking\r\nthe file and selecting \"Load CMake Project\". You can also click on the \"Load\r\nCMake Project\" in the blue banner that appears.\r\n\r\n### CMake\r\nCMake will automatically detect an installation of the Pico SDK on first load.\r\nIf you have multiple versions of the SDK installed, the latest one will be\r\nused. If you want to use a specific version, set the `PICO_INSTALL_PATH`\r\nenvironment variable in the CMake settings of the IDE (or in \r\n`.idea/cmake.xml`).\r\n\r\n**The compiler toolchain set in CLion will always be  overridden by the\r\narm-none-eabi-gcc toolchain bundled with the SDK.** To avoid this, set the\r\n`PICO_SET_TOOLCHAIN` environment variable to `0`.\r\n\r\nCLion will automatically load the project when the template has been opened\r\nand trusted. If you want to load the project manually, run `cmake .` in the\r\ncurrent folder.\r\n\r\n\u003e [!NOTE]\r\n\u003e To set CMake variables, go to `File \u003e Settings \u003e Build, Execution, Deployment \u003e CMake`.\r\n\u003e At the bottom, there is an \"Environment\" field. You may add the variables here,\r\n\u003e separated by semicolons, or click on the \"$\" icon on the right side for a graphical\r\n\u003e interface.\r\n\r\n### Building\r\nTo build the project, run Build (Ctrl + F9) with the \"pico_base_main\" \r\nconfiguration. CMake will build the executable and generate build files.\r\nOutput files, such as the .elf/.uf2 files, will be located in `build/includes`.\r\nYou can then flash this onto your Pico as you would normally.\r\n\r\n**Building for Pico W?** Set the `PICO_BOARD` environment variable to `pico_w`\r\nor add the following line to the top-level or project-level `CMakeLists.txt`:\r\n```cmake\r\nset(PICO_BOARD pico_w)\r\n```\r\n\r\n### Running with PicoProbe\r\n\u003e [!NOTE]\r\n\u003e Debugging (but not running) requires that the project and the SDK be located in\r\n\u003e a folder without spaces due to a CLion bug. This is being tracked at\r\n\u003e [CPP-28608](https://youtrack.jetbrains.com/issue/CPP-28608). While this bug\r\n\u003e remains unfixed, you will need to move your project and SDK (reinstalling,\r\n\u003e if required) to a path without spaces.\r\n\r\nCLion has built-in OpenOCD support, which can be used to run or debug firmware\r\nrunning on the Pico through PicoProbe. For more info on PicoProbe, see the\r\n[Pico Getting Started Guide, Appendix A: Using PicoProbe](https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf)\r\nOpenOCD is bundled with the Pico SDK, so you can skip to the \"PicoProbe Wiring\"\r\nsection.\r\n\r\n\u003e [!IMPORTANT]\r\n\u003e Due to oddities in the packaging of OpenOCD in the Raspberry Pi Pico SDK,\r\n\u003e a symlink needs to be created in the SDK folder. Before doing the following\r\n\u003e step, run the following command in an elevated (administrator) Command\r\n\u003e Prompt in the SDK folder:\r\n\u003e ```cmd\r\n\u003e mklink /J openocd\\bin openocd\r\n\u003e ```\r\n\r\nPoint CLion to the proper OpenOCD executable in the IDE settings. Go to\r\n`File \u003e Settings \u003e Build, Execution, Deployment \u003e Embedded Development`,\r\nand set the \"OpenOCD Location\" to the \"openocd.exe\" file found in the\r\n`openocd/bin` folder of the Pico SDK.\r\n\r\nA custom board configuration must be used for OpenOCD. This is the `pico-debug.cfg`\r\nfile at the root of this template. To use this, go to the \"Run through PicoProbe\"\r\nconfiguration, and update the \"Board config file\" to point to that configuration\r\nfile.\r\n\r\nAfter this, you can now use the \"Run through PicoProbe (OpenOCD)\" configuration\r\nto run the firmware on the Pico. Running normally will flash the firmware and\r\nreset the Pico; debugging will flash the firmware and enter a GDB debug\r\nsession on the Pico. You can then set breakpoints, step debug, and do as you\r\nwould a normal C project.\r\n\r\n## License\r\n```\r\nCopyright 2023 Chlod Alejandro\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining\r\na copy of this software and associated documentation files (the “Software”),\r\nto deal in the Software without restriction, including without limitation\r\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\r\nand/or sell copies of the Software, and to permit persons to whom\r\nthe Software is furnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included\r\nin all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS\r\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r\nTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\r\nDEALINGS IN THE SOFTWARE.\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchlodalejandro%2Fpico-c-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchlodalejandro%2Fpico-c-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchlodalejandro%2Fpico-c-template/lists"}