Visual Studio Code Raspberry



Using Visual Studio Code with a Raspberry Pi (Raspbian) We’re back with our LTM (Learning through Making) series of Node.js tutorials and we’re gearing up and getting ready to write some code! We’ve learned how to build a Raspberry Pi from the ground up including Node.js, we’ve created a web server in Node without code, and we’ve. Fans of both Raspberry Pi and Visual Studio Code (aka VS Code) are rejoicing – in February 2021, it was announced that the two tech products will now be integrated! For those who don’t yet know, VS Code is an open-source code editor that was first developed for Windows, Mac, and Linux. The Raspberry Pi Foundation has officially embraced Microsoft's open source Visual Studio Code editor, known for its cross-platform capabilities enhanced by a vast selection of extensions.

Visual Studio Code Raspberry

Raspberry Pi and Visual Studio Code: A great combination :

Raspberry Pis are everywhere. From the tiny new Pico microcontroller to the low-cost desktop PC that’s the Raspberry Pi 400, the ARM-based single board computer is a powerful tool that works as well in education as it does as an IoT device. Pis have been to space, track aircraft around the world, manage home media collections, run development Kubernetes clusters, and much more. If it can be done on a computer, it’ll be done on a Pi.

Microsoft’s Visual Studio Code development environment is another of those ubiquitous tools. Like the Pi, it’s everywhere, and is used for nearly everything a developer wants, from learning to code, to building and running large-scale cloud-native applications. It’s for more than Windows, with macOS and Linux versions, and for Intel and ARM processors, with tools for local and remote development.

With ARM and Linux support, Visual Studio Code is an ideal development tool for the Raspberry Pi, using either its remote development tools to work directly with headless IoT devices, or now running a full installation on a Pi hooked up to a keyboard, monitor and mouse. This makes for a flexible combination for both hobbyist and professional alike.

Visual Studio Code: Now on ARM

Microsoft has recently released a version of Visual Studio Code that runs on both ARMv7 and ARM64 Linux devices. With support for 32- and 64-bit ARM code, you can now run Code on both the 32-bit Raspberry Pi OS (recently renamed from Raspbian, as it’s no longer a direct port of Debian) and its 64-bit beta. As the Raspberry https://www.raspberrypi.org/softwarePi 4 hardware supports ARM64, it’s now more attractive for mainstream Linux distributions, and Ubuntu 20.10 now offers an official Raspberry Pi desktop build, targeted at Pi 4 hardware with more than 4GB of memory.

The Linux ARM versions of Visual Studio Code are available in rpm, deb, and tar formats, so should install on most Raspberry Pi Linux releases. There’s even an Ubuntu Snap release, to simplify installing on 20.10. You get the full Electron-based Code editor, with support for the marketplace. Not all extensions are supported, where they need to access external Intel binaries, but most should work.

Visual Studio Code can be a demanding application; with the Electron platform it’s built on needing significant system resources. In many cases your Pi won’t have the horsepower to run the full Code user interface. You might be able to use the new Raspberry Pi 400, which is, at heart, a 4GB Pi 4 built into a keyboard, but we’d recommend using an 8GB Pi 4, with an SSD drive rather than a SD Card, for speed and storage longevity.

I’ve been using a Pi 4 as a Linux desktop, running the ARM release of Ubuntu 20.10, and installed Code on it, downloading it as a 64-bit deb package from Microsoft’s repository. You need to click through the available versions on the Code site, as the ARM64 release isn’t visible from the main screen. However, it’s a quick download that can then be installed using the familiar apt install syntax, although referencing a local deb file rather than searching the various Ubuntu and Debian repositories.

A modular editor for remote development

Another advantage of Visual Studio Code is its modular nature, which has allowed Microsoft to split it into two parts: a user interface and everything else you need to edit, manage, debug, and test code. This allows a copy of Visual Studio Code running on a PC or a Mac to connect securely to a remote device or into a container, download its core components, and edit code directly on the remote device from your PC. You don’t need virtual machines, and you can develop on ARM and Linux without leaving the familiar Windows environment.

Code

Remote access is best considered if you’re using a Pi as an IoT device, and aren’t using a screen, or where it’s resource-limited. Using the open SSH protocol, Visual Studio Code connects to a device and sets up the appropriate secrets needed for a secure connection. Once connected it will download much of the core Code environment, so you can debug and test code directly on your Pi, using Code extensions to manage your application environment and link to source code management services like GitHub. Connections run over the familiar secure SSH protocol, for editing, for file transfer, and for terminal access to a remote device.

A built-in terminal allows you to step outside your editing environment, to test code, to check your logs, or monitor system performance. It’s a useful way of checking code running on a Pi from a remote PC, as well as evaluating commands for use in shell scripts. The terminal can help debug setting up the remote service components on your Pi, using the Output view.

Setting up SSH on a Raspberry Pi

If you’re using Ubuntu on Raspberry Pi, you first need to set up an openssh server to use Visual Studio Code’s remote access tooling. That’s easy enough: just use the built-in package management tools to install the appropriate packages, and then use the Windows command line to ssh to your Pi to set up the appropriate keys. If you see the Raspberry Pi bash prompt, you’re ready to go.

One of my Pis runs as a headless aircraft tracker, with no monitor or keyboard. Here I have used the built-in Raspberry Pi OS (previously known as Raspbian) SSH support. This is easy enough to enable: simply add a blank file called ‘ssh’ to the boot partition of your Raspberry Pi SD card or SSD from your PC before you put the card into the device. It’ll then boot up ready to use SSH. You won’t be able to do this from a booted Pi — it needs to be done from another machine.

Alternatively you can use the Raspberry Pi configuration tool to enable SSH support. Choose Interface Options and enable SSH here. However, you do need to be logged into a Pi to do this, so it won’t work for a headless appliance. In this case, you can quickly plug your Pi into a screen and keyboard to set up SSH before installing the device where you plan on using it.

Visual Studio Code Raspberry

Code for the Pico in Code :

Visual Studio Code Raspberry Pi Ubuntu

The Raspberry Pi Foundation’s latest device, the Raspberry Pi Pico microcontroller, is based on its own RP2040 silicon. It’s programmable in MicroPython and C/C++, with Visual Studio Code the preferred development environment for C/C++ applications. It works well with the command-line debugging tools from the RP2040 SDK, using a Raspberry Pi 4 as a development host. Code written and compiled in Code can be debugged on the Pico over a wired connection to your host Pi.

The combination of Raspberry Pi and Visual Studio Code is a powerful one. As Pis have become more capable, they’re now an alternative to desktop PCs in educational environments and a good-quality free code editor turns them into an effective development environment for teaching programming and for building your own IoT applications. Remote development tools mean you can stay in your chosen platform, whether it’s Windows, macOS, or Linux. And if you prefer, you can simply plug a Pi into a keyboard and screen and start coding.

A new version of Visual Studio Code has arrived just in time for Chocolate Egg Day featuring 'official support for Raspberry Pi OS', which might come as a surprise to those who have spent the last month or so complaining about it.

📢 The March @code update is here! Check out what's new:
📓 Notebooks improvements
🍎 Updated macOS Big Sur icons
📝 Default tab decorations for editor status
🍓 Official Raspberry Pi support
... & more!
Release notes: https://t.co/Y4xjFMssbv
Download: https://t.co/1CSkQpMbwdpic.twitter.com/HtlE086XUw

— Visual Studio Code (@code) March 31, 2021

In this case 'official' appears to mean that Microsoft has added some Pi-specific instructions on how to get the code wrangler up and running on the diminutive computer under Raspberry Pi OS (formerly known as Raspbian). In this case a simple sudo apt install code should do the trick after the usual sudo apt update.

The code, in 32-bit and 64-bit variants, had already turned up in the Raspberry Pi OS APT repository a few weeks ago and generated a fair bit of controversy as some users worried about open source and transparency as Microsoft-signed keys turned up.

Others were just happy to see the arrival of Visual Studio Code, although it can be a bit of a beast on the memory front (we're not sure we'd want to use it on a Pi without plenty of RAM).

As for the new version of VS Code itself (1.55), accessibility is the name of the game with initial screen reader support for multiple cursors. The number of lines that can be announced by screen reader has also been bumped from 100 to 1,000 (and plans are afoot to remove the limit entirely).

Raspberry Pi Foundation boss waves off listing rumours, says biz discussions may have been 'over-interpreted'

READ MORE

Visual Studio Code Raspberry Pi Remote

Other changes include support for defined profiles in the terminal, handy for firing up a non-default shell. The WebGL renderer is now the default (having first turned up in experimental form towards the end of 2019), and Start Debugging and Stop on Entry for the JavaScript debugger has made a welcome return.

Visual Studio Code Raspberry Pi Zero W

Mac users obsessing over cosmetics will be delighted to see icons better suited to Apple's Big Sur OS update.

Finally, some extra APIs have been added to allow extensions to check if a user had used the CLI flag --disable-telemetry to disable telemetry. Additional properties have been added to the env object of the extension API and onDidChangeTelemetryEnabled now fires any time isTelemetryEnabled. ®

Get ourTech Resources