How To Install Turbo C++ On Windows 10
Reading Fourth dimension: 6 minutes
This tutorial covers setting upward a pretty painless Raspberry Pi Pico C / C++ SDK evolution workflow on Windows using the Windows Subsystem for Linux (WSL) and Visual Studio Code (VS Code) with IntelliSense code completion!
With the Raspberry Pi Pico microcontroller being so new the current C / C++ SDK development process on Windows is a flake cumbersome. This tutorial should hopefully give you some ideas on how to go about programming the Raspberry Pi Pico the easy style with WSL and VS Code.
Note: This is non a beginner tutorial and assumes some minimal development experience.
The Raspberry Pi Pico is an heady new microcontroller lath launched on January 21, 2021. It'due south based on the RP2040 microcontroller (past the Raspberry Pi Foundation) sporting a dual-cadre ARM Cortex-M0+ running at 133 MHz. The nearly exciting feature is the Programmable I/O, or PIO, that has 8 independent processors (simple state machines). This is huge for robotics where there's a need to ingest real-fourth dimension sensor data in the background while performing other tasks. Keep an eye out for my tutorial on reading multiple DC motor quadrature encoders at the aforementioned fourth dimension without messing with lots of timers and interrupts using the PIO!
Prerequisites
- Enable Windows Subsystem for Linux and install the latest Ubuntu epitome (twenty); follow the "Manual Installation" steps. WSL is a congenital-in feature of Windows 10 and brings almost of the power of developing on a Linux motorcar natively into Windows! Exist sure to install Windows Final for an even better experience (instructions towards the end of the link above).
- Install Visual Studio Code and install the following extensions: Remote – WSL, C/C++, and CMake Tools. Y'all can search for these extensions by proper name directly in VS Code.
Configure WSL
Setup Script
If you are in a bit of a rush I've created a setup script that will perform all the WSL configuration tasks for you. Just open WSL, run the following commands, and then skip to setting up Visual Studio Lawmaking!
cd ~ git clone https://github.com/74ls04/pico-wsl-setup.git cd pico-wsl-setup ./pico_wsl_setup.sh
This script will install the SDK in ~/pico
and also installs a few Pico extras from the Raspberry Pi Pico repos.
Install Dependencies
Note: I'm using Ubuntu 18 for this demo but if you're starting from scratch employ 20 to avoid bug with CMake compatibility.
First, open upward the WSL Ubuntu terminal and become to the abode directory.
And then install the required build dependencies
sudo apt update sudo apt install git cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential
That's all at that place is for dependencies!
Install the Raspberry Pi Pico C / C++ SDK
While still in the domicile directory create a directory called pico
and go into the pico
directory
After that clone the SDK and examples git repositories.
git clone -b main https://github.com/raspberrypi/pico-sdk.git cd pico-sdk git submodule update --init cd .. git clone -b chief https://github.com/raspberrypi/pico-examples.git
The git submodule
command basically pulls in a separate Raspberry Pi repository from https://github.com/raspberrypi/tinyusb.git
and downloads those files.
Here is what all the commands look like later execution.
Configure and Build with Visual Studio Lawmaking
Now we're going to configure VS Code and build the post-obit "blink" example.
#include "pico/stdlib.h" int principal() { const uint LED_PIN = 25; gpio_init(LED_PIN); gpio_set_dir(LED_PIN, GPIO_OUT); while (truthful) { gpio_put(LED_PIN, 1); sleep_ms(250); gpio_put(LED_PIN, 0); sleep_ms(250); } }
So far you should have the following directories:
~/pico ~/pico/pico-sdk ~/pico/pico-examples
Move into the pico-examples
directory
Now here is where the integration of VS Code and WSL actually shines. Open VS Code into this directory
This command will launch VS Code and automatically link it to the WSL instance. Yous should see a green connection label in the lesser left. This procedure also creates a subconscious .vscode sub-directory that will hold the VS Code configuration for this workspace.
If this is your outset time using VS Code with WSL follow these quick instructions to make sure the iii extensions mentioned at the superlative are also installed in WSL. At this point you may run into a notification request if you would similar to configure the project — click on "Non at present" as nosotros need to prepare up a few things first.
Configure CMake Extension
Click the gear icon in the bottom left and select Settings
.
Expand the Extensions tree, select CMake Tools configuration, and then click Add Item
under "Cmake: Build Environment" to add the SDK path as shown below. If you followed the directory structure in this tutorial your PICO_SDK_PATH
volition be /home/$USER/pico/pico-sdk
where $USER is your WSL username . In this case my tutorial username is "main."
Configure IntelliSense (Code Completions)
Open up the Command Palette, Ctrl+Shift+P
, and kickoff typing "C/C++" then select C/C++: Edit Configurations (JSON).
This will create the following file:
/home/$USER/pico/pico-examples/.vscode/c_cpp_properties.json
Change the file to lucifer the following settings. Keep in heed that these settings are purely for code-completion and have null to do with the actual compiling.
{ "configurations": [ { "name": "Linux", "includePath": [ "${workspaceFolder}/**", "/home/$USER/projects/pico/pico-sdk/**", "/usr/lib/gcc/arm-none-eabi/**" ], "defines": [], "compilerPath": "arm-none-eabi-gcc", "cStandard": "c11", "cppStandard": "c++17", "intelliSenseMode": "gcc-arm", "configurationProvider": "ms-vscode.cmake-tools" } ], "version": 4 }
Replace $USER with your WSL username under "includePath"!
Shut VS Lawmaking and relaunch it again from the terminal with
This time when CMake asks whether you'd like to configure the project select "Yes" and look for information technology to finish configuring.
Configure Compiler and Build
Tell VS Code which compiler to use by clicking the "No Kit Selected" text at the lesser
And then selecting GCC for arm-none-eabi...
If using Ubuntu 20 your compiler version volition be different since I'm using 18.
Open up up the "blink.c" example file using the explorer bill of fare on the left, CTRL+SHIFT+E
. You should meet no errors highlighted in the file and code hints should be working besides.
Tell CMake which project to build past clicking on [all]
at the bottom
Then curlicue until yous see "glimmer."
Y'all should now come across [blink]
instead of [all]
. Click on "Build" to build the project!
VS Code will automatically create a build directory and spit out the project binaries into that directory.
Keep in heed this congenital the debug configuration, yous can modify information technology to release past clicking on CMake: [Debug]: Ready
at the lesser.
Upload to Raspberry Pi Pico
Uploading the binary to the Pico is merely a matter of dragging the .uf2
file into the folder that opens when you plug in the Pico while belongings down the BOOTSEL
button.
The file to transfer is:
/abode/main/pico/pico-examples/build/blink/glimmer.uf2
To open the directory y'all can either right clock on the directory name in VS Lawmaking and then click "Reveal in Explorer" or simply type
in the WSL concluding to open that directory in Windows Explorer. That'south 1 of the most useful WSL commands!
Plug in the Raspberry Pi Pico while property down the BOOTSEL
button and and so drag over the .uf2
file to the Pico folder.
It will automatically disconnect afterward transferring and immediately start running the program!
It's also pretty piece of cake to configure VS Lawmaking to automatically motion the file later building but for the sake of keeping this short I'll save that for some other fourth dimension.
More to come!
This should hopefully give you an idea of how the current development process is for the Raspberry Pi Pico. My goal is to create another robotics-focused Pico tutorial in the coming months starting from scratch and using the PIO — maybe in conjunction with a Raspberry Pi!
Experience free to enquire whatsoever questions or offer suggestions in the comments!
Updated: 2/eleven/2021
Source: https://paulbupejr.com/raspberry-pi-pico-windows-development/
Posted by: oharacompay.blogspot.com
0 Response to "How To Install Turbo C++ On Windows 10"
Post a Comment