When it comes down to linux distributions, debian is my favourite. I believe it is one of the oldest out there and it has proven its worth. It is also said that debian is rocksolid. I really like that you can start with a minimal setup and add what you need instead of remove what you don’t need.
How to get debian on the beaglebone? Normally you would make a bootdisc and continue over netinstall. The beaglebone doesn’t come with a CD drive, but it does have the microSD slot, which you can use to insert a bootable disk. Unfortunately there is a bug somewhere (I don’t know if it is a hardware issue, a software issue with the installer or whatever), which prevents you from using the ethernet with a netinstall. I was warned about this, but I was stubborn and tried anyway… and failed. So no clean netinstall…
Demo image
Luckily there are more people who wanted debian on their beaglebone and among those people are also some better skilled linux people. I followed the instructions under the “Demo image” on this website to get it working. In the final step on preparing the microSD card I had to make a small change to get it working:
sudo ./setup_sccard.sh --mmc /dev/sdX --uboot bone
instead of bone/bone_dtb. Or perhaps I misunderstood and I should have put in bone_dtb, but I’m not going to change it now anymore.
Previously I mentioned that what I liked debian is that you can add what you need. We now arrived to the adding part. The image already came with a bit of a setup (no need to install apache or sudo), but I did want to add a couple of things.
Update and upgrade
With the image ready, the ethernet connection works again. Login with the root account The first thing we want to do is set the system clock and see if there are some debian upgrades waiting for us:
ntpdate pool.ntp.org
apt-get update
apt-get upgrade
The first line sets the date and time. I’m not sure if this is more of a convenience of if it is really necesarry. It doens’t hurt anyway to get the right date and time settings. The apt-get update command does not update your system. It updates the list with resources, packages, applications and so on. The third command (apt-get upgrade) checks this list of resources and if there are any new upgrades available, it’ll install them.
Add user
The demo image comes already with two users: root and debian. It is good practice not to log in with root for ‘normal’ things: you use your own account for that. Since my name is not debian, I make a new account:
useradd rob
passwd rob
mkdir /home/rob
chown rob:rob /home/rob
adduser rob sudo
The ‘useradd’ command does what is says: add an user named ‘rob’. With the second line you add a password to rob. The third command is an abbriviation for ‘make directory’ with the directory name of ‘rob’ and it should be placed in ‘/home’. The ‘home’ directory is the place where all the users home directories go. Because we run this command as root, root gets set as owner of the directory. Since it is the home directory of rob, we need to transfer the ownership to that user by using ‘chown’ (change owner). There are two sets of arguments to this command. The first is ‘rob:rob’. The first ‘rob’ is the user and after the colon is the ‘group’. There is no need to worry much more about users and groups at this time (you can really fill up entire blogs about users, groups and permissions). The second argument for ‘chown’ is the directory path (or file) from which the ownership needs to be transferred. The last command adds the user rob to the sudo group. This allows the user rob to run a command as root. You’ll find this very userful as you want to control the GPIO on the beaglebone (which only works running it as root).
More installs
There are a couple more programs you’ll want to install:
apt-get install apache2
apt-get install ssh
apt-get install vim
apt-get install locate
apt-get install postgresql-9.1 postgresql-client postgresql-contrib
apt-get install postgis postgresql-9.1-postgis
apt-get install zip
apt-get install gcc
apt-get install build-essential
I believe apache already came installed on the demo image, so probably apt-get doesn’t do much with the first command. At some point you’ll find ‘ssh’ (secure shell) to be very useful to communicate with other computers. My favourite terminal text editor program is ‘vim’. It has a very steep learning curve, but it’s great once you learned it. With ‘locate’ you’ll have a nice tool to quickly search files and folders on your hard drive. After you installed it, run ‘updatedb’ to start the indexing. Afterwards you can find files and directories with ‘locate’ (e.g.: ‘locate www’ will show you all the files connected to ‘www’). Some people prefer mysql, but I rather work with ‘postgresql’. It is a database engine and I use it a lot at work, especially in combination with ‘postgis’. If you have never heard of SQL then it’s probably best to skip this and install it once you actually need it. I’m going to write another post on how to set up postgresql en postgis. You’ll need to install ‘zip’ to deal with zipfiles. It gives you the commandos to ‘zip’ and ‘unzip’ files. The last two commands are necessary to compile source code (once you run into ‘make’ and ‘make install’).
Firewall
You’ll probably want to setup a firewall as well. I’m totally not the expert here. I followed this blog to set it up: https://kura.io/2010/02/11/howto-iptables-on-debian-ubuntu/ The demo-image that I used already had iptables installed. I only added port 5432 for postgresql.
Desktop environment
So far we’ve been doing terminal stuff. Now comes the desktop environment that most people are familiar with. With linux there is a lot of choice (and there is a lot of fighting over which one is the best) in desktop environments. For the beaglebone I choose a lightweight window manager: lxde.
apt-get install task-lxde-desktop
With this command you’ll install the lxde desktop. Run this command and wait for a bit… well… actually quite a bit.
Once the install finishes, it is probably best to reboot:
reboot
The system goes down and when it comes back up: it’ll start a login screen where you log in to the graphical interface. You’ll see that with the install also the debiant version of ‘firefox’ was installed and that you now have ‘libreoffice’. Libreoffice is an office package to assist you with writing, spreadsheets, presentations etc.
Good to go?
Almost. I have changed the wallpaper to something nicer than the standard one. To change the wallpaper for the login screen, you’ll have to change this file:
/etc/lightdm/lightdm-gtk-greater.conf
There is a line somewhere that says: background=...
. Fill in the file name of the image that you wnat to use as wallpaper and you’re set.
When you’re logged into the desktop environment and want to return to a terminal, you normally use a terminal emulator. In lxde that is: ‘Lxterminal’. You can change the settings of the appearance of the terminal, but in my case these changes weren’t saved after I quit the terminal. To make it save your changes, you’ll have to change the user rights of the configuration file:
chmod 777 ~/.config/lxterminal/lxterminal.conf
Now it saves your changes. Remember that the terminal emulator starts in a ‘shell’, not in a ‘bash shell’. To start a bash shell, type bash
into the terminal. In another blogpost I will explain on how to use bash and how to set preferences for bash.
As a finishing touch, I also changed the hostname to BBB. You have to change two files:
/etc/hostname
/etc/hosts
In the hostname file, there is just one line with the hostname. I’ve changed this to BBB. The second file contains two lines, from which you’ll have to edit the last one. Replace the current hostname with the hostname you like. My file now looks like this:
127.0.0.1 localhost
127.0.1.1 BBB
GPIO
On of the reasons to get a beaglebone is to use the GPIO to control electronics. Adafruit made a really nice python library for it. Get it from http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black. Follow the instructions for Ubuntu. At the last item in the tutorial I ran into a small problem, but that was easily fixed by running:
sudo easy_install -U distribute
and then redo the last step (sudo pip install Adafruit_BBIO
).
The Adafruit library unfortunately doesn’t support the user LEDS on the beaglebone. So I wrote a python library myself. You can find it here: https://github.com/borrob/beaglebone_userled/. I’ll write a blogpost about this later as well.