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.
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.
setting up the tools in workspace
- You will be greeted with a welcome page that let you customise vs code as per your wish.
-
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.
- At the end of the upgrade process, you will be prompted to make a choice on version, click “install the package maintainer’s version”.
-
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
-
Provide executable permission for the script and run it.
chmod +x pico_setup.sh ./pico_setup.sh
-
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.
-
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.
-
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
-
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.
-
Open any of the folder. Source and header files are always located in src folder.
-
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.
-
To create a new project, copy either of the two project available using the below command.
cp -r led_toggle new_project
-
In git, only the newly created files will appear. You can modify which files to include or neglect by modifying the gitignore file.
-
Navigate to main.c file and try to include any header, autocomplete will work and start suggesting suitable header files.
building and uploading binary file
-
Open the terminal and
cd
into src folder of your required project and run./build.sh
. -
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 ...
-
Now, if everthing is configured properly, output binaries will be available in {project_name}/src/src. Download main.uf2 and main.elf.
-
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.
-
That’s it, we have successfully created a workspace for Pico and flashed it with our first example.
Note
-
Considering remote webusb support is not yet enabled for codespace, it is not possible to debug the Pico from web.
-
Make sure to stop the instance after usage to avoid billing time.