This post is mainly for self-documenting, feel free to follow my footsteps at your own risk. These steps will probably also work on the Beagleboard.
Back up the original image
The Beaglebone comes with the Linux Ångström distribution. So I backed up the original image, in case something failed. Even if I were to stick with the Ångström distro, it's a good idea to back up the original image.
I removed the microSD that shipped with the Beaglebone, and inserted it into my PC SD slot. Then I checked in which partition it got mounted, using the following command.
df -l
/dev/sda is my PC harddrive, and /dev/sdb is the Beaglebone SD card.
After identifying where the SD was mounted, I used the following command to backup the SD.
dd if=/dev/<sdx> | gzip > /path/to/image.gz
In case I needed to restore the image, I'll have to use the following command:
gzip -dc /path/to/image.gz | dd of=/dev/<sdx>
Installing Ubuntu
I followed the instructions from elinux. These are the summarized steps:
- Download the minimal Ubuntu 12.10 image
cd ~/Desktop
wget http://rcn-ee.net/deb/rootfs/quantal/ubuntu-12.10-r2-minimal-armhf-2012-11-29.tar.xz
wget http://rcn-ee.net/deb/rootfs/quantal/ubuntu-12.10-r2-minimal-armhf-2012-11-29.tar.xz
- Verify the integrity of the image
md5sum ubuntu-12.10-r2-minimal-armhf-2012-11-29.tar.xz
Which should match the following output
b0ee1964a3f8196f4f1a501d1d2ac83a ubuntu-12.10-r2-minimal-armhf-2012-11-29.tar.xz
- Untar the package
tar xJf ubuntu-12.10-r2-minimal-armhf-2012-11-29.tar.xz
cd ubuntu-12.10-r2-minimal-armhf-2012-11-29
cd ubuntu-12.10-r2-minimal-armhf-2012-11-29
- Flash the image into your SD
sudo ./setup_sdcard.sh --mmc /dev/<sdx> --uboot bone
Finished flashing the Ubuntu image into the SD card.
For the record (Older releases):
Release 1: http://rcn-ee.net/deb/rootfs/quantal/ubuntu-12.10-r1-minimal-armhf-2012-10-19.tar.xz
MD5: 31be6761a37af98906c5c1e892601e85
Connecting to your Beaglebone
After flashing the Ubuntu image, I removed the SD from my PC and plugged it back into the Beaglebone. I decided to make the first connection using the tty over USB.
After connecting the Beaglebone to my PC using a USB cable, I had to figure out the exact name of the ttyUSBx with the following command.
dmesg | grep ttyUSB
From documentation, ttyUSB0 -> JTAG, ttyUSB1 -> UART (terminal)
I used GNU screen to stablish the connection:
sudo apt-get install screen
screen /dev/<ttyUSBx> 115200
screen /dev/<ttyUSBx> 115200
After the connection was established. I saw no output so I pressed the reset button on the Beaglebone.
Voilà
The default login information is below.
- login: ubuntu
- password: temppwd
Things to do after installing Ubuntu
OK, I logged in! ... Now what?
Change your password
First thing first, I changed the default password to something stronger
# On the Beaglebone
passwd
passwd
Connect the Beaglebone to the internet
I plugged an Ethernet cable into the Beaglebone, and checked if the connection was OK.
# On the Beaglebone
ping www.google.com
I let ping run for a while and then I finished it with Ctrl+C.ping www.google.com
Notice the "0% packet lost", that's a Win.
OK I lied, it didn't work the first time, I got 100% packet lost, but resetting the Beaglebone solved the problem.
Autocompletion
Next, I enabled bash completion - a.k.a. the tab autocompletion:
# On the Beaglebone
sudo apt-get update && sudo apt-get install bash-completion
sudo apt-get update && sudo apt-get install bash-completion
Change the hostname
The terminal prompt says "ubuntu@arm". This means the Beaglebone hostname is "arm". I changed that with the following commands.
# On the Beaglebone
cat /etc/hosts
I got the following output.cat /etc/hosts
# On the Beaglebone
127.0.0.1 localhost
127.0.1.1 arm
So I changed the second line with:127.0.0.1 localhost
127.0.1.1 arm
# On the Beaglebone
sudo nano /etc/hosts
# changed the second line from arm to <new-hostname>
Next, I did:sudo nano /etc/hosts
# changed the second line from arm to <new-hostname>
# On the Beaglebone
cat /etc/hostname
And got:cat /etc/hostname
# On the Beaglebone
arm
I changed that with:arm
# On the Beaglebone
sudo nano /etc/hostname
# changed the hostname from arm to <new-hostname>
Finally I rebooted the Beaglebone to apply the changes.sudo nano /etc/hostname
# changed the hostname from arm to <new-hostname>
# On the Beaglebone
sudo reboot
sudo reboot
Change your login name
Now the terminal prompt says "ubuntu@beaglebone", the login is "ubuntu". I also changed that.
I had to enable the root account:
# On the Beaglebone
sudo passwd root
# Entered a temporary password
Pressed "Ctrl + D" to logout and I logged as root: sudo passwd root
# Entered a temporary password
Logging as root.
I changed the old username with:
# On the Beaglebone
usermod -l <new-username> ubuntu
I also added a comment to my new user:usermod -l <new-username> ubuntu
# On the Beaglebone
usermod -c "<full-name-or-comment>" <new-username>
Next, I moved to my new home:usermod -c "<full-name-or-comment>" <new-username>
# On the Beaglebone
usermod -md /home/<new-username> <new-username>
Finally, I also renamed the "ubuntu" group to match my new username:usermod -md /home/<new-username> <new-username>
# On the Beaglebone
groupmod -n <new-username> ubuntu
I logged out (Ctrl + D) and logged with my new username:groupmod -n <new-username> ubuntu
Logged with my new username.
Finally I locked the root account:
# On the Beaglebone
sudo passwd -l root
sudo passwd -l root
Set up a zeroconf hostname
A zeroconf hostname, simplifies SSHing with a local machine by assigning it a hostname on the LAN. This way I don't need to know the IP (which can change over time) to start a SSH session.
#On the Beaglebone
sudo apt-get install avahi-daemon
Now I can connect to the BeagleBone via ssh using the following command:sudo apt-get install avahi-daemon
# On the PC
ssh <beagle-username>@<beagle-hostname>.local
ssh <beagle-username>@<beagle-hostname>.local
SSHing the Beaglebone
I finished the screen session, using Ctrl+A and then K. I rebooted the Beaglebone, this way the avahi daemon got launched on the next boot.
ssh jorge@beaglebone.local instead of ssh jorge@192.168.1.x
SSH login without password
Everytime I SSH'ed the Beaglebone I needed to input the Beaglebone login and password. The next commands got rid of that.
# On the PC
ssh-keygen # Don't enter a passphrase
ssh-copy-id <beagle-username>@<beagle-hostname>.local
ssh-keygen # Don't enter a passphrase
ssh-copy-id <beagle-username>@<beagle-hostname>.local
SSH without login
Install GNU screen
I quickly found out that I needed multiple SSH sessions to open multiple terminals on the Beaglebone. Searching for a workaround I found GNU Screen.
With GNU screen I can create multiple "screens", with one terminal inside each of them. All this can be done with keyboard commands.
#On the Beaglebone
sudo apt-get install screen
To start screen I needed to use the following command on every login.sudo apt-get install screen
#On the Beaglebone
screen -S 1
This was annoying, so I automated the task:screen -S 1
# On the PC
gedit ~/.bashrc
I appended the following text:gedit ~/.bashrc
Now with a single command, I can SSH login into the Beaglebone and enter in a running "screen" or create a new "screen", if it doesn't exists.
#On the PC
sshbeaglebone
sshbeaglebone
SSH session with the Beaglebone splitted in 3 using screen.
Other important software
I also installed additional software:
#On the Beaglebone
sudo apt-get install man-db # Manuals
sudo apt-get install vim # Text editor
sudo apt-get install octave # Numerical package
sudo apt-get install build-essential # make, gcc, et al.
sudo apt-get install man-db # Manuals
sudo apt-get install vim # Text editor
sudo apt-get install octave # Numerical package
sudo apt-get install build-essential # make, gcc, et al.
What's next?
- Convert Vim into an IDE.
- Using an USB WiFi dongle to connect to wireless networks at boot.
Figure out how to access (with C or ...Python?) the Beaglebone hardware registers. Sorry, no time for this one, you might want to check PyBBIO. Good Luck!
Acknowledgements
- The BeagleBoard community for producing the Beaglebone.
- The Embedded Linux community for their tutorial on how to install Ubuntu on the Beagles.
- Brandon Mintern for his great post about SSH and Screen.