Raspberry Pi 4 Visual Studio Code

Posted on  by 



If you’re not familiar, Visual Studio Code (VS Code) is an open source C development environment from Microsoft. It is available for Windows, macOS and x64 Linux, and now you can run it on Raspberry Pi too.

The tool supports text editing, full web development (with JavaScript, TypeScript and Node.js) and git source code control. It supports extensions too (although not all of them), so you can further expand its capabilities.

Microsoft's own Scott Hanselman pointed this out four years ago in a post titled 'Building Visual Studio Code on a Raspberry Pi 3,' which he followed up a year ago in the article 'How to install Visual Studio Code on a Raspberry Pi 4 in minutes.' In this guide, you'll learn how to install and use Microsoft's Visual Studio Code on the Raspberry Pi. Visual Studio Code, often shortened to VSCode, is an integrated development environment (IDE) that has a bunch of handy features that make writing code more straightforward, such as syntax highlighting, code. “how to get visual studio code on a raspberry pi 4” Code Answer. How to get visual studio code on a raspberry pi 4. Whatever by Troubled Toad on Jul 05 2020 Donate.

SEE ALSO:

Four years ago I wrote how to BUILD (literally compile) Visual Studio Code for a Raspberry Pi ARM machine.Just a few months later in November, community member Jay Rodgers released his labor of love - nightly builds of VS Code for Chromebooks and Raspberry Pi. Visual-studio-code raspberry-pi. Improve this question. Follow asked Feb 7 '19 at 3:16. Hawkeye312 Hawkeye312. 65 2 2 silver badges 9 9 bronze badges.

VS Code is available for Debian Linux on x64, and there are also builds for ARM and ARM64 that can run on Raspberry Pi OS. (If you have a new $4 Raspberry Pi Pico, you’ll be pleased to know the VS Code is installed as part of the setup from the official Getting Started Guide.)

Because it’s part of the Raspberry Pi OS apt packages, it’s very easy to install Visual Studio Code on your Pi. Just launch Terminal and run the following commands:

Once installed, you can run VS Code from the Programming folder in the Pi menu (see the screenshot at the top).

Explaining what’s so good about the ability to install Visual Studio Code on a Raspberry Pi, Microsoft’s Jim Bennett explains that 'There are already some great editors, but nothing of the calibre of VS Code. I can take my $35 computer, plug it into a keyboard and mouse, connect a monitor and a TV and code in a wide range of languages from the same place.'

In this tutorial, we will learn how to Program Raspberry Pi Pico with Visual Studio Code. Visual Studio Code or simply VS Code is a great IDE for software development. We will see how to install VS Code on Raspberry Pi (the host computer) and in a later tutorial we will see the same for a Windows system (including installation of all the other necessary tools).

Introduction

In all the previous Raspberry Pi Pico tutorial, we used Raspberry Pi as the main host computer and used the terminal to program Raspberry Pi Pico in C. This is okay if your application is just to Blink and LED or print some info on the Serial Output.

But if you want to implement a bigger project, using terminal to write and maintain the code becomes tedious (at least for beginners). This is where the like of VS Code and Eclipse IDEs come into play.

The Raspberry Pi Foundation recommends Visual Studio Code IDE to edit and debug the code in Raspberry Pi 4 SBC.

VS Code or Visual Studio Code is a code editing software developed by Microsoft. It is available for all the three major OS platforms: Windows, Linux and Mac. In addition to the basic functionality of code editor, VS Code also has several important features like Debugging, highlighting syntax, support for plugins etc.

First, we will see all the step for installing Visual Studio Code on our Raspberry Pi host computer. Then, we will shift our focus to a Windows System, where we need to download (and install) a whole lot of tools before installing VS Code. So, let’s get started.

Installing Visual Studio Code in Raspberry Pi

IMPORTANT NOTE: Before proceeding with installing VS Code on your Raspberry Pi host computer, I strongly recommend you to complete the previous tutorials on Raspberry Pi Pico. At least the ‘Programming Raspberry Pi Pico with C’ and ‘Program and Debug Raspberry Pi Pico with SWD’ tutorials.

This is because, I discussed all the necessary tools that you have to install in your Raspberry Pi in order to program Pico with C Programming Language.

All the following steps assume that you have already installed the necessary toolchains as mentioned in the previous tutorials.

First, open the browser in your Raspberry Pi and go to the official VS Code download website. Scroll down to Linux Downloads and download the ARM version of VS Code in .deb package (64-bit or 32-bit depending on your Raspberry Pi OS).

I selected the .deb package for ARM and at the time of writing this tutorial, it downloaded a file called ‘code_1.54.3-1615805722_armhf.deb’.

Open the downloads folder in the Raspberry Pi and double click on the downloaded .deb file to begin the installation of VS Code.

Visual studio code for raspberry pi 4

It will ask for password. Enter your Raspberry Pi’s password. The installation is pretty straight forward and just follow the on-screen instructions.

Studio

Before launching VS Code, you have to install three extension for Visual Studio Code. Use the following commands to install these extensions one after the other.

Start Visual Studio Code

After installing these extensions, you can launch Visual Studio Code using the command ‘code’ in the terminal. But before that, make sure that you set the path for ‘pico-sdk’.

The VS Code IDE will now start and opens its home page.

Open the ‘pico-examples’ folder in VS Code by selecting the ‘Explorer’ option on the left and click on ‘Open Folder’. This will open the file explorer and browse to the ‘/home/pi/pico/pico-examples’ directory and click on OK.

You can see the ‘pico-examples’ directory populated on the left with all the sub-folders. Assuming you have installed the CMake extension for VS Code earlier, the IDE will automatically configure the projects folder. The CMake extension will ask you configure ‘pico-examples’ projects. Click on ‘Yes’.

Vscode Raspberry

If you missed this option, there will be a No Kit Selected option at the bottom Blue coloured Status Bar. Click on that. Then select ‘GCC for arm-none-eabi’ option.

Now, you can build the projects. Again, at the bottom status bar click on ‘Build’ option. Next to this ‘Build’ option, you can select the specific project by clicking on [all] or all the projects will be built. I selected the ‘Blink’ project to demonstrate the working.

In the status bar, there is an option to configure CMake to build for ‘Debug’ or ‘Release’ mode. By default, ‘Debug’ option is selected.

Uploading and Debugging with VS Code

There is a .json file provided by Visual Studio Code called ‘launch.json’, which will help us in uploading the code to Raspberry Pi Pico and also debugging the code. Additionally, there is a ‘settings.json’ file, which will configure CMake extension to work properly.

We have to copy these two files into our ‘pico-examples’ folder. In the ‘pico-examples’ directory, make a new directory called ‘.vscode’.

Now, copy the ‘launch.json’ and ‘settings.json’ files into this directory.

cp ide/vscode/launch-raspberrypi-swd.json .vscode/launch.json

To upload and debug the code, go to Debug Tool bar by pressing “Ctrl+Shift+D”. A ‘Run and Debug’ option will pop-up at the top. Press the green play button to build the code, upload the code to Raspberry Pi Pico and start debugging session.

Additional Debug Control options will appear on the top. Press the Blue play button to start the code (continue option in OpenOCD).

Visual Studio On Raspberry Pi

You can set breakpoints anywhere you want and check if your code is reaching those breakpoints.

Conclusion

A step – by – step tutorial on installing Visual Studio Code in Raspberry Pi and Programming Raspberry Pi Pico with Visual Studio Code or VS Code. You learned how to download and install VS Code in Raspberry Pi OS, install necessary extensions for VS Code, import our examples folder in VS Code environment, configure CMake extension to program and debug the code to Raspberry Pi Pico.

Raspberry Pi 4 Visual Studio Code Free

In a later tutorial, I will show the steps you need to follow to install Visual Studio Code in a Windows System. This is a little bit different as you have install several tools individually instead of running a simple command (like we did in the Raspberry Pi).

Raspberry Pi 4 Visual Studio Code

Related Posts:





Coments are closed