Raspberry Pi and Visual Studio Code: A great combination :
This will install a non-VS branded version of code. The lack of Visual Studio branding is intentional - the code is open source, but the logos are copyright Microsoft. This means that a community build can't use these icons. You can launch this from the menu, Raspberry-Programming-Code - OSS (Headmelted). There is an issue with v1.32. 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. I discovered Visual Studio Code’s remote extension. Visual Studio Code Remote Extension; This allowed me to edit my Raspberry Pi files from within Visual Studio Code. So, I get all the joys of writing code directly on my Raspberry Pi, but with all the bells-and-whistles of Visual Studio Code (VSC). For the most part, setup is pretty. Select the Extensions tab from the sidebar menu, then search for Remote development. Select the Remote Development extension, and select the Install button. Next you can connect to your Raspberry Pi. Launch the VS Code command palette using Ctrl+Shift+P on Linux.
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.
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.
Code for the Pico in Code :
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.
The Raspberry Pi foundation has published a new article to its blog today, providing information on how to code remotely using your Raspberry Pi and the Visual Studio Code application. Earlier this month a Raspberry Pi supported version of the excellent Visual Studio Code software was made available for the Raspberry Pi mini PC by Microsoft.
If you like to run your Raspberry Pi as a ‘headless’ device to control various electronics, the new article provides everything you need to know about coding your Pi mini PC remotely using VS Code. Ashley Whittaker explains more over on the official Raspberry Pi blog.
“Visual Studio Code, or VS Code, is a free, open source, developer’s text editor with a whole swathe of extensions to support you coding in multiple languages, and provide tools to support your development. I practically live day to day in VS Code: whether I’m writing blog posts, documentation or Python code, or programming microcontrollers, it’s my work ‘home’. You can run VS Code on Windows, macOS, and of course on a Raspberry Pi.
One of the extensions that helps here is the Remote SSH extension, part of a pack of remote development extensions. This extension allows you to connect to a remote device over SSH, and run VS Code as if you were running on that remote device. You see the remote file system, the VS Code terminal runs on the remote device, and you access the remote device’s hardware. When you are debugging, the debug session runs on the remote device, but VS Code runs on the host machine.”
For full instructions on how to set up your Raspberry Pi for coding remotely with Visual Studio Code follow the link below.
Source : Raspberry Pi Foundation : VSC
Filed Under: DIY Projects, Top News
Comments are closed.