Marco Attia's Script Turns a Raspberry Pi Into a Plug-and-Play USB Gadget with Web VNC, VS Code

Just connect a USB cable and enjoy the Raspberry Pi OS desktop, and a web version of Microsoft's VS Code, right in your browser.

Gareth Halfacree
7 months ago β€’ Productivity

Marco Attia has released a customized operating system image builder which turns a Raspberry Pi single-board computer (SBC) into a plug-and-play USB gadget β€” putting a full graphical desktop and a version of Microsoft's Visual Studio Code (VS Code) right into the browser.

"After at least a month of work on this. I was able to get a custom image builder that creates a [Raspberry Pi OS] Desktop image with a web VNC client (NoVNC) that I simplified to maximize the screen estate as well as a web version of Visual Studio Code," Attia explains. "It will be the basis for all the work and projects I run on the Pi."

The idea is simple: Attia's script produces a customized version of Raspberry Pi OS "Bullseye," using the Raspberry Pi's USB controller in gadget mode to turn it into a peripheral for any USB-capable host machine. When connected to said host machine via the Raspberry Pi's USB Type-C port β€” or micro-USB, on the Raspberry Pi Zero family β€” it creates a network between the two, and fires up a desktop accessible using the host's browser.

In addition to the desktop, which provides access to any software installed on the Raspberry Pi, the image also hosts a version of Microsoft's Visual Studio Code integrated development environment (IDE) which can be accessed as a web page β€” avoiding any performance issues that can come from using a VNC server to interact with streaming snapshots of the graphical desktop.

"I should give credit where it is due, I base this work on too many resources, including the obscure and old parts of the internet, to count on my hand, but all of this was possible thanks to Ben Hardill's work on the source repository," Attia writes, referring to Hardill's script for producing USB gadget operating system images. "But I gotta say I am pretty proud of how it turned out in the end!"

Attia's script is available, along with instructions on its use, on GitHub under the permissive Apache 2.0 license; it is, however, only compatible with Raspberry Pi OS "Bullseye," and not the recently-released Raspberry Pi OS "Bookworm" version which made the jump from X11 to Wayland.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles