element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog Using Github Codespace as a c/c++ development environment for Raspberry Pico (w)
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
GPIO Pinout
Raspberry Pi Wishlist
Comparison Chart
Quiz
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: balajivan1995
  • Date Created: 18 Jan 2024 3:20 PM Date Created
  • Views 2515 views
  • Likes 7 likes
  • Comments 5 comments
Related
Recommended
  • coding
  • raspberry
  • c
  • pico
  • programming
  • raspberry-pi-projects
  • vscode

Using Github Codespace as a c/c++ development environment for Raspberry Pico (w)

balajivan1995
balajivan1995
18 Jan 2024

If you are stuck with a crappy laptop or cursed with windows OS with misconfigured c/c++ setup, use this repo as a template and create a workspace. All the files will be copied into your new workspace. From there follow the setup instruction to install required tools. I have previously tried this setup for installing Nordic Semiconductor's SDKs. After seeing shabaz 's post I decided to try with Pico board and share the results.

Creating codespace

There are two ways to create workspace.

1.using the template option available on top right corner of this repo. Click the dropdown and select open in a codespace.

image

2.On the right side, click the code and then codespace option. You will be presented with an option to create a workspace using Github dev container. For details regarding usage, refer here.

image

setting up the tools in workspace

  1. You will be greeted with a welcome page that let you customise vs code as per your wish.
image
  1. Once you are satisfied with how it looks, select the terminal option and run the below commands to keep your system up to date.

    sudo apt update && sudo apt upgrade -y

    The dev container is preinstalled with dot net, python, node js and conda. If you prefer your environment without unnecessary bloat, you can uninstall them before updating the system.

  1. At the end of the upgrade process, you will be prompted to make a choice on version, click “install the package maintainer’s version”.
image
  1. Once the system update is over, install the toolchain by running the below commands. The first command will download the script to download and install the required toolchains, SDK and placing them in default location.

    wget https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh
  2. Provide executable permission for the script and run it.

    chmod +x pico_setup.sh
    ./pico_setup.sh
  3. By the time the git submodules are being cloned, you will be prompted by code to install suggested extensions. Install the c/c++ extension pack and cmake tools extension.

  4. The process ends with “E: Unable to locate package code”, that’s it all our tools are installed and ready to use now. Your explorer will look like this.

    image
  5. Enter the below command to add PICO_SDK_PATH to system environment variables to ensure absolute path is referred everywhere.

    export PICO_SDK_PATH=/workspaces/pico_space/pico/pico-sdk

structure of the workspace

  1. The workspace was created with a thought of having multiple projects with in a single repo. Examples for single file project and multiple file projects are available as template.

  2. Open any of the folder. Source and header files are always located in src folder.

  3. Since this is not a single project per repo, there is no single build configuration, the build.sh inside each project will compile and build the output binary.

  4. To create a new project, copy either of the two project available using the below command.

    cp -r led_toggle new_project
    image
  5. In git, only the newly created files will appear. You can modify which files to include or neglect by modifying the gitignore file.

image
  1. Navigate to main.c file and try to include any header, autocomplete will work and start suggesting suitable header files.

    image

building and uploading binary file

  1. Open the terminal and cd into src folder of your required project and run ./build.sh.

  2. To build binaries for pico wireless, edit the build.sh file and modify the below line and follow the instructions in the official sdk guide.

    cmake -DPICO_BOARD=pico_w ...
  3. Now, if everthing is configured properly, output binaries will be available in {project_name}/src/src. Download main.uf2 and main.elf.

    image
  4. Press the bootsel button on Pico and plug it in your system. It will open up file explorer. Drag and drop your uf2 file to Pico’s drive.

  5. That’s it, we have successfully created a workspace for Pico and flashed it with our first example.

Note

  1. Considering remote webusb support is not yet enabled for codespace, it is not possible to debug the Pico from web.

  2. Make sure to stop the instance after usage to avoid billing time.

  • Sign in to reply
  • balajivan1995
    balajivan1995 over 1 year ago in reply to Fred27

    Debugging does not work. That is why I have specifically mentioned about downloading both uf2 file and elf file. You can use the elf file for debugging locally with openocd + gdb setup. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Fred27
    Fred27 over 1 year ago

    A very nice write-up, thanks. I've always had a bad experience with hosted development environments - but it's normally been a performance issue. (Compiling 5GB of Unreal Engine C++ source on a VM is not a good idea, no matter what the company trying to sell that to your boss says.) However, for something small like Pico development I can see that it might work.

    Debugging though... I suspect that might be something else entirely!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz over 1 year ago

    Great work documenting this! I've not used GitHub Codespace, but have used a couple of other cloud IDEs in the past, and they can be super convenient.

    Very well written explanation!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balajivan1995
    balajivan1995 over 1 year ago

    Oh by the way, it needs not to be GitHub codespace, any cloud based IDE that works on VScode can be used.

    Ex : vscode online (nearly same as GitHub codespace), Redhat sandbox IDE, Google IDX (if you have access), replit, etc..

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balajivan1995
    balajivan1995 over 1 year ago

    From now on, I am going to create a MD file for every blog I want to post on this site and convert it into html file, then copy paste the content in source code section. Compared to my previous attempts with copy/pasting Microsoft word content and adding images one after another, this is way easier.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube