Tuesday, November 13, 2012

Installing Ubuntu Quantal Quetzal on your BeagleBoard xM - Whoohoo!

Things you will need in this setup:

BeagleBoard xM
5V Power Supply - connected to BB
USB Keyboard (you dont need a mouse right away but will eventually if you install GUI)
4GB or large microSD card
Ethernet cable and connection to network
Serial to USB cable connecting BB to source computer


So here is the lowdown on running the latest version of Ubuntu, Quantal Quetzal, or at least a minimal version, on a BeagleBoard xM.  The starting point is here:

http://elinux.org/BeagleBoardUbuntu#Quantal_12.10_armhf

Now there are some guidelines for what I am about to share that I can only claim success with.  I am working on a Linux system, Mint - which uses Ubuntu under the hood, and Debian by extension.  If you are using another OS or even version of Linux you will have to know enough about your system (or use google) to translate.

First thing to do is grab yourself a microSD card and get it formatted.  On my system I like using the GUI Disk Utility since its a little faster than command line.  So find your card under the "Generic-SD/MMC" heading.  You should see a window something like this:






If the SD card is mounted the first thing you need to do is unmount it - in Disk Utility you just highlight the Volumes bar and click "Unmount Volume" under it.  If the SD has multiple partitions you need to make sure all of them are unmounted.  Once that is done you want to use the "Format Drive" command.  (NOT the "Format Volume")  The default is type is "Master Boot Record" and that is perfect.  So when the format is complete you do not need to remount the volume for this process to work.  You do need to make note of the path to the SD card, in my case is "dev/sdg1"  It should always be sd something but take care to note the proper path, more on that in a minute.





Now the instructions on the webpage will suffice for some but I am going to try and condense it down a bit for everyone.

First start up your favorite Terminal application and change directories to "Downloads"  (If you want to work from another directory, fine but I like keeping downloads in ... Downloads...)

cd Downloads

Now get the archive that contains the operating system with the command

wget http://rcn-ee.net/deb/rootfs/quantal/ubuntu-12.10-r1-minimal-armhf-2012-10-19.tar.xz

It will take a few minutes to download and when it is done we verify the checksum with the command

md5sum ubuntu-12.10-r1-minimal-armhf-2012-10-19.tar.xz

The response should look like this

31be6761a37af98906c5c1e892601e85  ubuntu-12.10-r1-minimal-armhf-2012-10-19.tar.xz

Now we unpack the archive in place

tar xJf ubuntu-12.10-r1-minimal-armhf-2012-10-19.tar.xz

When that is done change directories into the archive folder using this command

cd ubuntu-12.10-r1-minimal-armhf-2012-10-19

Now remember how you were supposed to note the drive assigned to your SD card?  This is really important, and let me tell you why.  You are about to use a script, included in the archive, to format the SD card and copy things over into the proper locations.  If you choose the wrong drive there is a really good chance that you will end up nuking the drive you selected and that could be the one with your operating system on it.  The result will be you will destroy your OS and most likely the data on the drive and the changes will be irreversible - welcome to the command line.  MAKE SURE YOU HAVE THE RIGHT DRIVE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Now a quick check of the web page will show there are a number of options for this next command that will result in builds for a number of boards but here we are working with the BeagleBoard xM, right?  This command also has to be issued with super user (sudo) capabilities so make sure you are a sudo user.

sudo ./setup_sdcard.sh --mmc /dev/sdX --uboot beagle_xm

NOTE - REPLACE "/dev/sdX" with the path to your SC card.  In my case it would be "/dev/sdg1"  Get this wrong and the mayhem will begin.  You will be prompted with something like this

I see...
fdisk -l:
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
Disk /dev/sdb: 128.0 GB, 128035676160 bytes
Disk /dev/sdc: 808.9 GB, 808888614912 bytes
Disk /dev/sdd: 32.0 GB, 32017047552 bytes
Disk /dev/sdg: 16.0 GB, 15970861056 bytes

mount:
/dev/sdb1 on / type ext4 (rw,errors=remount-ro)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)

Are you 100% sure, on selecting [/dev/sdg] (y/n)?


If you have the right drive - well hit "y" and the script will work its magic.  Now in my system I get a couple of popup errors akin to "Cant read - not a folder".  I get two of them, just hit OK and move on.  They do not seem to have a negative effect on the process.

When your SD card is done (the command prompt returns), and it might take 10 minutes or so, eject the card and pop it into your BeagleBoard.

BEFORE applying power, connect your Serial to USB cable up to your system and run the command

ls /dev/tty*

What should appear is a list of all of the tty devices available on your system.  Most likely the one we need will be "/dev/ttyUSB0".  Now we are going to start up the screen application from the command line so use

sudo screen /dev/ttyUSB0 115200

Translation - start up screen to listen to our Serial to USB connection at 115200K Baud, which is the default for most BeagleBoard serial connections.  Since you have not started the BB yet, the terminal window will just clear out and show nothing.  Plug in the power and wait for the magic...

Well you shouldnt have to wait long.  Within a few milliseconds the board should begin the boot process and you will see all the kernel traffic and eventually reach the part where it asks you to login.  For this image the temp username and password are "ubuntu" and "temppwd" - but there is a little problem.  This particular user does not have "sudo" access (or at least mine didnt) so... you now have to live a little dangerously (again but you have made it this far without melting down so what the hell).  Do what everyone says not to - login as "root".  The password is also "root".

Now you need to set up your network, which is not handled automatically.  If you type in the command (which normally requires "sudo" but you are the big Kahuna here so its not needed for any of these commands - just remember to BE CAREFUL)

ifconfig

you will see a list of your network devices.  We are looking for the one "eth0".  If that one is not on the list, make sure your ethernet cable is plugged in.  Now just type into the terminal

dhclient eth0

And this should set up your ethernet connection, assuming your router is setup to issue DHCP.  If not, you are gonna have to find out how things work somewhere other than this blog.

ALMOST DONE!

So now you need to create a user account for yourself so type

adduser [your clever username here]

and you will be prompted to enter a password (twice) and some info (that you can ignore)

Now lets make sure you are a sudo user by adding your new user to the "sudoers" file with the command

visudo

What this actually does is invoke the "vi" text editor on the "sudoers" file.  You have to use the arrow keys to scroll down to the line that looks like this

root   ALL=(ALL:ALL) ALL


and underneath it add

[username]  ALL=(ALL:ALL) ALL

(see the pattern here?)

Now type Control-X - it will ask you if you want to save
Type Shift-Y - you say yes, and it asks about the file name
Dont change file name - Type Enter

You should return to the command prompt.  Now the last command is....

exit

Now login with your new user name and password.  If everything went OK the simple way to check is this... type the command

sudo apt-get update

So this does two things.  If your "sudoers" edit worked, then after entering your password you should not get something like "you do are not a sudoer, this attempt will be reported" or some such.  If your network is setup correctly you should see a whole bunch of calls to network sites that contain the update files for your system.  If you see errors like "could not resolve host" etc then your network is not working, so try that again.

And breathe.... (sorry this is long-winded but I needed to get this all in)  And remember, if you muck it all up, you havent bricked your board.  Just start over, format the SD....  blah, blah...

Next post will be about some tweaks you can make, including installing a desktop, setting up for a camera, wireless networking and getting your monitor looking its best.









No comments:

Post a Comment