In this section I'll first show how to prepare a microSD card with Raspbian to boot on your CompuCanvas. Then I'll walk through some of the setup steps that I perform to configure a new system. If you already have your CompuCanvas running you can skip over the initial material here.

Preparing a microSD card with Raspbian

If you want to use a Windows machine or a Mac to prepare your microSD card, refer to this other learn guide about rPi setup. I noticed that guide does not show how to use a Raspberry Pi to do the setup. I often use one rPi system to prepare the microSD card for another, so I'll detail those steps here to complement the other guide. I'll be using a Raspberry Pi with a monitor, keyboard and mouse connected to it. But these steps could be performed with a headless rPi (like a CompuCanvas) as well.

The first thing to do is download a Raspbian image... but even before doing that you should check to make sure you have enough room for downloading and unzipping one of these large files. You can use the df command to figure out how much free space you have. The screenshot below shows how I changed to the Downloads directory and then ran df -h . and that shows I have about 50 Gigabytes free (on a 64GB microSD card), which will be plenty.

As I write this, the Raspbian downloads page has 3 editions of "Buster". Any of them should be ok for running a CompuCanvas. I usually choose the medium sized one: "Raspbian Buster with desktop". It's ok to use the 'desktop' editions even though the CompuCanvas won't have a proper monitor setup.

The download I got is called 2019-09-26-raspbian-buster.zip. The size of this file is about 1.1 Gigabytes, but we need to unzip it (with the unzip command), and that will produce a file with the same name but a .img extension. This 'image' file is about 3.6 Gigabytes.  So I will need almost 5 GB of free space on my system to perform this operation.  As shown in the picture above, I have plenty of space, but you should check this too before downloading and unzipping the image.

If you are working entirely from the command line, you can use the wget command to download the zip file, like this:

wget -O raspbian.zip https://downloads.raspberrypi.org/raspbian_latest

If you are using a browser, you can click the link and it will be downloaded to the /home/pi/Downloads directory.

In the picture below, I've download two of the Raspbian zips and moved them to a directory named rPi that I created to organize them. I have also unzipped one to get the .img file that will be copied to the microSD card.

The next step will be to use a USB to microSD adapter, like the part from Adafruit that was introduced in an earlier section of this guide. We will also need a microSD card.

The pictures here show inserting the microSD card into the adapter.

Next we'll want to plug this into the rPi system where we have the Raspbian image file. When we plug in the adapter, it should become visible as a device with a filename like /dev/sda/dev/sdbor similar.

In the picture below you can see I ran ls /dev/sd* before plugging in the microSD adapter. On the first run there were no files found matching that pattern. Then I plugged in the adapter and ran the same command again. Now I see a sda and sda1 files in /dev. The first one represents the physical device and the second is a logical volume on that device. If we had a second of these adapters plugged in, we would see /dev/sdb and some logical volumes on it matching the pattern /dev/sdb*.

Checking this is important, because the next step is to write the image file to the microSD card. Doing this will erase and overwrite any data on the device we write to, so it's really important to identify the microSD correctly before proceeding. My before-and-after test shown below is a good way of confirming the device name.

Now we can run the dd command to copy the image file to the microSD card. The magic command for this is shown just below. However, note that you will need to fix 2 things before running it. I used raspbian.img as the image file name, but you will need to replace this with the actual image filename from the zip download. Second, I used /dev/sdXYZ as an example device to write to. Replace this with the device we found in the previous step, which is probably /dev/sda, but I always double-check to avoid overwriting the wrong device.

sudo dd bs=64K if=raspbian.img of=/dev/sdXYZ status=progress ; sync

The sync command at the end is really important too! This makes sure that all the data gets written out to the physical disk (instead of being cached on the rPi) so that it will be safe to remove the microSD adapter.

These pictures show how I constructed the dd command and then ran it. The status=progress option gives feedback as the copy is happening, then a summary is printed when it finishes.

There is one more crucial step to perform before unplugging the microSD adapter. As a security measure, remote login (with the ssh command) is disabled by default on new Raspbian images. But remote login will be the primary way of controlling the CompuCanvas, so we need to enable it.

The method for enabling remote logins is to write a file named ssh at the top-level of the "boot" filesystem. But first we may need to mount the boot filesystem so we can write this file to it. When we wrote the Raspbian image file to the microSD card, it should have created 2 logical volumes, a "boot" volume and a "root" filesystem. If you are lucky, they will get auto-mounted under /media/pi but I checked there and was not lucky, so I will need to manually mount the boot filesystem to write the ssh file on it.

The picture below shows how I ran sudo fdisk -l /dev/sda which prints some information about the 2 logical volumes (sda1and sda2) associated with the physical microSD card (/dev/sda). The device with "FAT32" in the type field is the boot volume that we need to mount.

We will need an empty directory to mount the boot filesystem. When things get auto-mounted, they appear under /media/pi. In the picture below, I created a directory /media/pi/microSD to use as the mount point. This will only need to be done once on this machine:

sudo mkdir /media/pi/microSD

Then I ran the following command to mount the volume:

sudo mount /dev/sda1 /media/pi/microSD

After this, as the picture shows, we can ls /media/pi/microSD and see a bunch of files that are used as the Raspberry Pi boots up.

Now I can create the magic ssh file that enables remote logins. This is accomplished with the touch command. which creates a new, empty file:

sudo touch /media/pi/microSD/ssh

The picture below shows the before and after running the command. Notice the ssh file is present the second time we check that directory with ls.

Finally, you should run the sync command one more time to make sure all information is written out to the microSD card, and then unmount the root volume with this command:

sudo umount /dev/sda

This is shown in the next picture

Now you can remove the microSD adapter from this Raspberry Pi and put it into the CompuCanvas!

We can now proceed to the next sub-section of this software odyssey.

Logging into a new CompuCanvas

When you power up the CompuCanvas and it starts to boot up, it will get assigned an IP address on your network. You'll need to find that IP address and use it with the ssh command to login from the second Raspberry Pi. One way to find devices on your local network is with the nmap command. You might need to install it first, like this:

sudo apt update

sudo apt install nmap

Home routers often assign IP addresses where the first 3 digits are 192.168.1 and the final digit is between 1 and 254. So the CompuCanvas could pop up at an address like 192.168.1.33 or any one of about 254 other possibilities. With nmap you can search a range of addresses. You may need to adjust the IP addresses I show for your own network/router configuration. The command below shows how to scan for all devices under 192.168.1:

nmap -sP 192.168.1.1-254

Similar to identifying the microSD card, you'll want to run this command before plugging in the CompuCanvas and get a list of devices currently on your network. Then plugin in the CompuCanvas and wait a few minutes for it to start up and get an IP address assigned. Then run the same nmap command again and look for a new device and note that IP address for the next sub-section.

Suppose that your nmap command shows a new device at address 192.168.1.33 on your network. You can try to login with the ssh command like this:

ssh [email protected]

Sometimes I see several new/unknown devices in the nmap output and I have to guess. If you try to login to the wrong IP address, you will probably see a "connection refused" message.

The pictures here show my initial login to the CompuCanvas. (Note that my subnet is actually 192.168.2 instead of 192.168.1, as reflected in these pictures).

My host rPi doesn't trust this unknown machine, and I have to confirm the connection is ok by typing yes at the prompt.

Then I get a login prompt. In these fresh Raspbian images, there is a pi user account and the default password is raspberry. My ssh command specified the userid (with the [email protected] syntax), so to complete the login I just need to type the default password.

Initial system configuration

The first thing I do when logging into a new Raspbian system is change the pi account password from the default to something else. As shown in these pictures, you can change your password with this command:

sudo passwd pi

Then you need to type the new password twice to confirm the change. Please write down the new password in a safe place.

The next step I take in setting up a new CompuCanvas is to run the raspi-config utility. This command line tool can perform most of the initial configuration you may want for running the CompuCanvas on your network. To start this, type:

sudo raspi-config

The next series of pictures will show some of the features of raspi-config.

Some things to note about these pictures of the raspi-config utility:

  • We could have used raspi-config to change the password, instead of the command line way I showed above. Either way would work.
  • To navigate in raspi-config use the up and down arrow keys to select an action. Use the Enter key to perform the selected action. Use Esc to back out of a sub-menu. Use Tab to navigate between the top section and the actions like <Select> and <Finish> shown on the bottom of the screen.
  • The first thing I do is set the system timezone, which is under "Localization Options".
  • I also delve into the "Network Options" menu to set the system host name.
  • This is a "season to taste" kind of thing. You may have other configuration you want to do for your environment.
  • When exiting raspi-config it will prompt you to reboot. It is advisable to reboot after making the kind of changes I described above (e.g. hostname and timezone). You can go ahead and let raspi-config reboot, or do it from the command line with: sudo reboot.

After the first reboot, there is still a bit more setup to do. I login to the CompuCanvas again with sshand then run these 2 commands:

sudo apt update

sudo apt upgrade

This will upgrade the Raspbian operating system packages to their latest versions. The second command may take a long time, and there may be prompts where you need to type something to make it proceed. The picture below shows the beginning of this process.

It is a good idea to reboot again after this upgrading, but first you could install additional software to run on the CompuCanvas. There are 2 utilities that we will use later in the guide: espeak and screen. You should install those now with the following command:

sudo apt install espeak screen

You could install additional software at this point as well.  After that, reboot again:

sudo reboot 

The final bit of system configuration will be setting up the audio so we can hear sound from the USB speaker. Next, I'll transition back to physical construction topics - specifically lighting up the inside of the canvas.

This guide was first published on Dec 11, 2019. It was last updated on Dec 11, 2019.

This page (Digressions in Code) was last updated on Jan 09, 2020.