Sunday 8 April 2012

Porting Angstrom to Beagle Board XM revision C by Sayli Ghanekar and Ajinkya Tarkunde

Hello Everyone, We are a group of Engineering students in our final semester and have successfully ported Angstrom and Ubuntu on beagleboard XM revision C. The task took us quite a while as we were completely new to beagle board and linux OS. This blog's sole purpose is to help newbees and and amateur enthusiasts to quickly port embedded OS on BB and get going with your project. You may encounter similar problems which we faced since the information given on the internet is discrete and most of it is for previous revisions of the BB and hence obsolete.
So here we go...

I. Opening the Box :

We assume that you already have your beagleboard with you or at least have ordered it. You will get the following items in the box :
A. 1 Beagleboard in an ESD bag (dont lose the bag! it protects the board form static charges.)
B. 1 MicroSD card.
C. 1 MicroSD card to MMC adapter.
No cables are provided with the BB.




II. Setting up the Hardware environment :


1. The ADAPTER:  5 volts 3 Amps. (2 amps may work but 3 amps is foolproof. Please follow this very strictly). Before buying the Adapter try it with your BB. If there is a red light glowing immediately turn it off and don't buy it. Buy an adapter of another company which gives you a nice GREEN light on your BB. We used a Dlink adapter which works flawlessly.


2.The SCREEN Phenomenon : There are 3 different ways to display the video signals generated by the BB; HDMI to HDMI, HDMI to DVI-D and S-video. I strongly suggest to NOT use S-video since it is still in the experimental phase and gives poor quality video. Also it will not display GUI once you have ported the OS. The best way is to use a screen with an DVI-D input. Buy a GOOD QUALITY HDMI to DVI-D cable. Do not try to cut cost with it since it will give a constant flicker which will burn your brain. In India most LCD screens have VGA input the BB does not give VGA supporting signals. So don't use DVI-D to VGA converter, it will simply not work. DVI-D screen may not be available easily so you may try HDMI-HDMI to a HDMI compatible TV screen.

3. Keyboard and Mouse: Buy a USB keyboard and USB mouse. You can go cheap here. 

4. MicroSD cards Funda : Buy a 4GB+ MicroSD card. It wont hurt to buy extra cards since you are gonna need to format it again and again if you don't follow our exact steps (LOL... Experience speaking), it will increase your speed. The card that is shipped along with the BB has a demo image of angstrom. The card is only 128 MB, so it cannot be used for your project and only used to test if your BB is working or not. Strictly DO NOT format or delete any of the files on this card. You can use any standard card reader to format/write on your memory card.

5. The Minicom logic : We hardly used minicom. There is no need of minicom if you have a DVI-D screen to be frank. But if you still wanna try buy a simple USB to Serial cable since it works best. to know more click here.

6. The Ethernet Cable: This is one of the most important cables. Buy,steal or Beg... quiet easy to get. And very obviously you will need an internet connection. Like the one you are using now.In the initial stages a wired internet connection( using Ethernet cable) is a must since the OS does not have pre-installed drivers of WiFi or usb modems. You can download these drivers later.

III The Software Saga!!!


1. Okay, so now I assume that you have all the above items in one place, electricity and patience of a snail climbing mount Everest. The first thing you ought to do is to test if the BB is in working condition. The test card does exactly that. Put the test card in the card slot, connect the mouse, keyboard, ethernet cable and power supply to the board. Please do not turn on the power supply before everything is plugged, it may damage the board. If you are using HDMI-HDMI or HDMI-DVID cable you will directly get boot logs, while the S-video will give you colored bands and a blank screen. So I suggest again, DO NOT use S-video it may mislead you into believing that the board is faulty! Now the first boot will take a few minutes... so you can relax and see F.R.I.E.N.D.S for a while.

2.You will soon see a GUI on the screen and if everything is proper you might as well surf the net using Midori. Note that this is a test card and the work you do will not be saved due to low memory and kernel limitations.The default login name is "root" and no password just press enter.



BOOTING ANGSTROM 


There are many other ways to boot Angstrom on the board; you may find some more easier steps on the net but I assure you that they wont work unless you tweak them. This method will boot up your board nice and fast. 


Please ensure that you have a working ubuntu 11.10/11.04 on your host machine. Preferably do not use VMware. Use dual boot. I assume that you know how to install ubuntu. If not then go to youtube and learn.


The pre-built binaries available at http://www.angstrom-distribution.org/demo/beagleboard . You will be directed to this place from many other blogs. It is very confusing and NONE of the images work with BBRev C. You need to build your own images. 

Building your own image using Narcissus:

Step 1 : Go to this website. 


Step 2 : Machine->Beagleboard, Name-> your choice, Complexity->Adnanced,  
User Environment->console only (don't go for X11 as suggested by many others)  
Leave everything else as it is by default, Directly go to Platform Specific Packages and select 
" Beagleboard Validation GNOME image " .
Step 3 : Click Build me!

Again this will take a while to process. Do not press refresh or back while the image is being created for you. It can take anywhere between 20 Mins to 1 Hour depending on your net speed. 

This will give you a very basic filesystem with minimal packages. You can download and install the packages directly from the net after Angstrom boots up on BB. For Example if you wish to download packages related to GCC or G++ then all you need to do is type:  opkg list gcc* . Then download the listed packages using : opkg install <filename>. 


After the built is complete you will get a file with .tar.gz extension. It will be around 250MB in size. Download this file. Then do the following :


Step 1 : Formatting the SD card ( Use Ubuntu )
A. Download the script mkcard.txt from the site http://www.angstrom-distribution.org/demo/beagleboard . That's it. Do not download anything else from here.

B.Insert blank card in your card reader and plug it to your machine. 
Start the Ubuntu terminal (ctrl+alt+t) . Type the following commands...
->>sudo df -h
or ->> sudo fdisk -l . This will show where your SD card is mounted. sda will be the main hard disk of your computer so the sdcard will be either 'sdb' or 'sdc' . I will refer it as sdX from here onward. 

C. Once you know where your card is mounted we can proceed to actually formatting the card. First you will have to unmount the card using :
->>sudo umount /dev/sdX   if the card is not partitioned already it will not mount. But still I suggest you give this command and check what happens. Now the next command is :
Go to the directory where mkcard.txt is saved. For eg ->> cd Desktop .
Now, ->> chmod +x mkcard.txt   (makes mkcard.txt executable)
->> sudo ./mkcard.txt /dev/sdX    ( Formats the entire card and partitions it to sdX1(boot) and sdX2(Angstrom). 
->>sync

D. The boot partition will have the boot files and boot arguments. The angstrom partition will have your filesystem.

Step 2: Writing image to your SD card

A. Untar the downloaded file into you Angstrom partition by the following commands:
->>sudo tar -xvz -C /media/Angstrom -f [your-download-file]
->>sync

B. In the Angstrom partition there will be a folder named 'boot', this will contain the boot files names MLO, u-boot.bin, uImage. Copy them to your boot partiton strictly in the following order using these commands: (Please check the spaces while entering the commands)
->>cd
->>cd /media/Angstrom
->>cd boot
->>sudo cp MLO  /media/boot
->>sudo cp u-boot.bin  /media/boot
->>sudo cp uImage  /media/boot

C. BB revC uses a file named uEnv.txt which is very important since it contains the boot arguments. This also specifies the video mode which you are using and sets the resolution and other such parameters.Hence to modify these parameters you need to make changes in this file. Copy the following text into a text editor and name it uEnv.txt 

dvimode="hd720 omapfb.vram=0:8M,1:4M,2:4M"
vram=16M
optargs="consoleblank=0"
console="tty0 console=ttyO2,115200n8"


If the booting process gets stuck at a point try changing ttyO2,115200n8 to ttyS2,115200n8 in the console parameters.But O2 should work in the latest kernels.

copy this file to the boot partition by using, remember to go to the directory in which it is saved :

->> sudo cp uEnv.txt  /media/boot

D. Safely eject your card using following commands:
->> cd
->>sudo umount  /dev/sdX1
->>sudo umount  /dev/sdX2

Step 3: Your are done with your SD card preparation. Now pray to all the Gods you believe in and insert the card into your board. Connect keyboard, mouse and Ethernet cable. Apply power to the board. The boot process may take 20-30 min to boot up for the first time. Soon you will see the cool green desktop wallpaper of Angstrom Linux and you can get going :-) . 

P.S. : A terminal is very important part of linux OS. In case a GNOME-terminal is not present on your OS. Then press ctrl+alt+F1 and then download the same using command ->>opkg install gnome-terminal. To go back to GUI from the terminal press ctrl+alt+F2 or ctrl+alt+F8.

We have tried to compile all the useful information from various sites, forums, groups etc. Hope it helps you :D
Blog Posted by
1. Sayli Ghanekar
2. Ajinkya Tarkunde
If you face any problems please leave a comment or email me at beaglexmc@gmail.com