Computing stuff tied to the physical world

Uploading from Linux

If the “Mac” is not your cup of tea, how about a tasty sip of Linux?

The Linux story has been told many times. If anything can represent the success of open source software, then surely it has to be Linux. It’s free, it’s extensible, and it’s everywhere. Anything with a CPU chip, a modest amount of RAM, and some storage can run Linux.

While some people run Linux as the main operating system on their main computer, this is still a fairly small group. You need to get into chipsets and all the details of the attached peripherals and screens to get things working as consistently as Windows or Mac OSX.

But there are in fact much simpler ways to get started with Linux and use it for software development. A task for which Linux is eminently suited, due to the huge amount of available software and the extreme degree to which it can be customised and automated:

  • set up a virtual machine (VM) running Linux under/next to your main work setup
  • get a low-cost Raspberry Pi, BeagleBone Black, or Odroid embedded board
  • set up a remote server in the cloud running Linux

A remote server is usually not very practical for physical computing projects, which need to connect to the outside environment through USB or direct I/O pin hookups, though Ethernet is definitely a useful option for projects which connect to a LAN or internet. Still, if you just want to get familiar with Linux, setting up a server with say, DigitalCloud is a matter of minutes and will cost you no more than €5 per month (and no minimum).

The choice for a Linux setup need not be restricted to a single one – with low-end Linux boards available for under €25, there’s really little point agonising over what is best. It’s mostly a matter of convenience and long-term stability.

Virtual machines

In terms of convenience, it’s hard to beat the use of a VM: it provides a complete context right next to the setup you’re working with anyway, it’s easy to integrate into your back-up procedures (you do have one, right?), and it’s as fast as what you’re already used to.

All you need is the software to create such a virtualised environment. The big three are VMware, Parallels (on Mac OSX), and VirtualBox. They’re all fairly similar – VBox is free:

Vm logos

The mechanism is always the same: you start up the app (VBox needs registration to add USB support), and you give it a Linux installation CDROM or DVD, or a disk image. From then on, it’s as if you’re running on a separate machine – and in a sense, you are indeed.

There are some important implications:

  • it takes extra disk space, as much as you’d need on a real machine (some 4 .. 20 GB)
  • it needs extra RAM, since the VM is running next to your OS (for Linux, 1 GB is fine)
  • you need to set up a network connection, the VM has to “go through yours” to get out
  • you have to decide and manage which USB devices connect to the VM (exclusively)

If you want to set up a complete graphical user interface under Linux, you can, but it’ll require more RAM and more disk space. The alternative is to set up a minimal VM, very much like you would on a remote server: command-line only, with network access via SSH, the “secure shell”. A basic setup can be done with 2 GB of disk space and 512 KB of RAM.

The benefit of a locally-installed VM is that it becomes part of your work environment. No need to hook up to anything external, no extra hardware (assuming that your setup has enough resources). All while not in any way affecting your own system – Linux lives on the side, it won’t (and cannot) interfere with anything else on your machine, and vice-versa.

A second benefit is that a VM can be suspended – frozen in mid-air, and resumed in exactly the same state later on. No need to shut down, no need to stop processes running on Linux.

One drawback is that you do need a setup with a decent amount of RAM (4 GB at least, probably), and some spare disk space (2 .. 4 GB would be a minimum to have available).

Another drawback is that USB connectivity may be tricky and finicky at times. The VM software is playing nasty tricks at the operating system level to make USB devices available to the Linux VM, and sometimes a restart or unplug shuffle is needed to make it all work.

Dedicated hardware

The other option is to get one of these, or any of their ever-more abundant alternatives:

Emb linuxes

These are all ARM-based boards, from left to right:

All of these have some particular mix of: 1 .. 4 CPU cores, 0.5 .. 2 GB RAM, either 2 .. 4 GB on-board flash or a µSD interface, an Ethernet port, 1 .. 4 USB host ports, a HDMI or similar video interface, and prices ranging from €40 to €80.

For each of these there is either a Debian- or Ubuntu-based distribution (as well as others).

What’s so great about these boards:

  • choice: you pick your mix and options, with corresponding modest price trade-offs
  • availability: some of these boards are selling like, ehm, well, hot pie’s, sort of …
  • interchangeability: at a fairly broad level, all of these boards are very similar
  • documentation: plenty of documentation and forums for these boards, and for Linux
  • truly low-power, usually 3..5 Watt via a 5V adapter, perfect for always-on use
  • simple USB and LAN connectivity, and in some cases tons of freely usable I/O pins

An embedded Linux board does have some issues which you need to be aware of:

  • with an active system running off µSD cards, flash will eventually wear out and fail
  • you have to think carefully how to set things up for backups, especially if always-on
  • when messing with those I/O pins, you can damage and even kill the whole unit
  • each of these boards is different, figuring out all the details can eat up a lot of time
  • sometimes new revisions are released, with pesky little differences to trip you up

One practical strategy, if you’re willing to invest a bit more, is to purchase two identical setups right from the start. Then you can use your laptop to regularly copy the main µSD card to an extra copy, and use the second system as development c.q. staging backup, and as comparison in case you ever suspect any hardware damage.

Compared to a virtual machine, an embedded board will affect how you work:

  • you need to either attach a keyboard + monitor, or connect via SSH (preferable)
  • you now have two systems to deal with: your own laptop and this extra computer
  • this also means you’re probably going to transfer files between them (regularly!)
  • these boards are a lot slower than your laptop, i.e. longer compile & build times

But it’s definitely a very nice low-impact way to get your feet wet in the Linux world. And if you’re planning to set up a home automation server, or some other project requiring a permanent “server”, then chances are that you’re going to need one if these boards anyway.

Choosing a “distribution”

Linux is available in many flavours. Tastes differ. This article will use Ubuntu, which is based on Debian – a solid configuration using “apt” and “aptitude” as package managers.

The nice thing about Ubuntu (at least 14.04 and later), is that it knows about the “lpc21isp” package. Installing it is as easy as typing:

sudo apt-get install lpc21isp

As with Homebrew on Mac, the “lpc21isp” command can then be used on your system.

Here’s how to upload a file to the LPC810, almost exactly the same as on Mac OSX:

  • plug in the (modified) FTDI board, with the breadboard setup described earlier
  • type: lpc21isp -control -bin firmware.bin /dev/ttyUSB* 115200 0

If you get an error, there may be a problem with access permissions. Usually, the way to solve this is to add yourself in the “dialout” permission group, using this command:

sudo usermod -aG dialout <your-linux-username>

Then logout and log back in to make these changes work (or restart Linux).

Keep in mind that with a virtual machine environment, you will have to “attach” the USB device to the VM, preferably in a permanent way, so that later unplugging and re-plugging will still work. Use the following command to look at the end of the system log, to see whether the inserted USB device is indeed being recognised by Linux:

dmesg | tail

Welcome to Linux: there’s a command for just about anything you can imagine, and more. A good one to remember is “apropos ...“, which lists all installed packages related to “…”. It does this by going through the list of installed manual pages. Ah, yes, that’s another useful one to remember – try “apropos nxp” and “man lpc21isp“, for example!

[Back to article index]