Gatsby Logo

Beaglebone Black - Getting Started Pt.2

2019-12-22

As you recall from pt. 1 of this series, we installed an OS on the Beaglebone that has no GUI. To develop on this BBB, you could SSH in, write your code in the terminal, compile, and run - but you would miss out on all the great features of modern editors such as VSCode.

With a little configuration we can setup a local VSCode instance to point to the remote BBB. We will be able to browse files/folders and create new ones, edit code with syntax highlighting, and more. It's like you're developing locally, but you're editing, compiling, and running remote code.

Setup

Today I will be working with a Macbook Pro w/ macOS Mojave.

To check the kernel and OS on the Beaglebone you can cat /etc/os-release and cat /proc/version. You can see that we have Debian 9 and Kernel 4.14.

alt text

Hosts File

The hosts file is used to map IP addresses to friendly names. With it we can map the Beaglebone IP to a name we can remember and one that is easier to type.

So, I sudo nano /etc/hosts and add an entry to map my beaglebone IP to the hostname bbb.

alt text

Recall in the prior post we were able to ssh the IP of the BBB. Now, we are able to ssh bbb -l debian also. A bit easier to type, but also I don't have to try to remember the IP of so many different systems.

alt text

Code Editor

In case you haven't heard, VSCode is Microsoft's open source, no-cost, cross platform, extensible code editor. We will leverage that extensibility to connect to the remote BBB.

Install VSCode from: https://code.visualstudio.com/

Install the Remote Development Extension too.

alt text

With these installed you can setup the connection to the BBB. In VSCode, open the Command Palette with CMD + SHIFT + P . At the prompt, start typing the word remote-ssh to filter the options. Soon you should see Remote-SSH: Add New SSH Host.... Select this option, and continue the prompts.

alt text

Next, you will need to enter the command you want for connecting to your BBB. Note here I am using the hosts file entry for our bbb.

alt text

To open the remote connection to the host we just created, once again open the Command Palette and filter by beginning to type remote. Select the option for Remote-SSH: Connect to Host....

alt text

Select the bbb host we just created. This will connect to the remote host and open a new instance of VSCode. You will be asked for the SSH login password.

alt text

Now I can open a test app folder I created for this tutorial. It is located on the remote BBB at ~/code/test.

alt text

Opening VSCode's integrated terminal with CTRL + ~ I can now build and launch the app remotely on the BBB.

alt text

Summary

In this tutorial we added the Beaglebone to our hosts file, and configured VSCode to connect to the remote BBB. The purpose has been to make a nicer environment where we can develop code.

For further reading you might consider cross-compiling for the BBB or setting up ssh keys for authentication in lieu of passwords.