Mark Tyndall July 29, 2011
Creating a Custom Linux Kernel and Root File System for the TI OMAP3530 Processor
Table of Contents
Installing Ubuntu 1
Duel Boot Installation 1
Windows Ubuntu Installer 1
Virtual Machine 2
SD Card Format 2
Creating the Root File System 3
MLO and U-Boot 4
Cross-Compiling Tools 5
Compiling the Kernel 6
Reference Links 8
Useful Links 8
This document details how to setup a cross-compiling environment and sdcard file system on Ubuntu 11.04 Linux for the ARM OMAP3530 processor used on the Texas Instruments Beagleboard.
Installing Ubuntu
For this example, Ubuntu 11.04 (Natty) was the current version available. There are three options available for installing Ubuntu Linux:
-
Duel Boot Installation
-
WUBI – Windows Ubuntu Installer
-
Virtual Machine
Duel Boot Installation
First, you will need to download the DVD ISO image from here[1]. You can burn disk image with the built in ISO burning utility in Windows or use ImgBurn, a free downloadable application available here[2]. If you have a preexisting Windows installation, you will need to repartition your hard drive using Disk Manager from the Windows management console. Once partitioning your hard disk, reboot your computer with the burned DVD in the disk drive. Install Ubuntu to this new partition. Be sure to uncheck the box that says ‘Download updates while installing’ during this installation.
Windows Ubuntu Installer
Alternatively, you can also download an application called WUBI from here[3] and avoid the next step. WUBI will handle the ISO download and Linux installation for you if choose this route. Be sure to uncheck the box that says ‘Download updates while installing’ during this installation. The one drawback to this method is that you must boot into Windows first then use the launcher to boot into Ubuntu.
Virtual Machine
Lastly, you can also use a vmplayer[4] or virtualbox[5]. Install your choice of virtual machine, using the default settings. If you choose to use vmplayer your only choice it to use a Ubuntu virtual appliance found here[6]. If you choose virtualbox create a virtual disk of at least 10 GiB and 512MB of RAM. Use the ISO that you downloaded earlier to install Ubuntu as you would normally.
Further detailed installation tips and methods can be found here[7].
SD Card Format
To be able to boot from an sd card it will need to be partitioned and formatted. Also your sd card should be at least 4GB and MUST be a class 10 type card. You have to options for formatting the sd card, ‘fdisk’ and ‘gparted’. I will be using gparted to format the sd card. If you would like to use fdisk follow the instructions found here[8]. Gparted is not part of base Ubuntu Install so you will need to install it using the following command:
$ sudo apt-get install gparted
Once gparted installs, run the application using the following command. Replace ‘X’ with your drive letter. Most likely will be ‘/dev/sdb’:
$ sudo gparted /dev/sdX
Gparted should automatically show your sd card. Delete any preexisting partitions by right-clicking the drive partition graphic at the top of the program and choosing ‘Delete’ from the menu. Click the green checkmark in the tool bar and click ‘Apply’ from the pop-up dialog box to commit these changes. Once that operation has completed, right click the graphic again and choose ‘New’. In the dialog box next to the option ‘New Size (MiB)’ type 64. From the ‘File System’ drop down box, choose ‘fat32’. In the box next to ‘Label’ type “BOOT” and click ‘Add’. Repeat these steps again for the second partition but for the partition leave it to the default size. For the ‘File System’ choose ‘ext3’ and for the ‘Label’ type “rootfs”. Click ‘Add’ then click the green checkmark and choose ‘Apply’ from the dialog box. Wait for the operation to finish and right-click the “BOOT” partition from the list and choose ‘Manage Flags’, from the pop-up dialog box place a checkmark next to ‘boot’, click ‘Close’ and exit the application. You should now have a properly formatted sd card to boot your processor with.
Creating the Root File System
First, create a directory called ‘TI’. All work should be done from this directory. If you work outside your ‘Home’ directory, there will be issues with permission and might have problems compiling. Create the directory with the following command:
$ mkdir TI
$ cd TI/
$ mkdir rootstock
$ cd rootstock/
From the ‘$HOME/TI/rootstock’ directory, execute the following command:
$ sudo rootstock --fqdn omap --login ubuntu --password temppwd --imagesize 4G --seed linux-image-omap,wget,nano,linux-firmware,wireless-tools,usbutils,xfce4,gdm,xubuntu-gdm-theme,xubuntu-artwork,apt,xemacs21,minicom,gcc,g++,putty,xserver-xorg-video-omap3,alsa-base,build-essential,openssh-server,vlc,firefox,ffmpeg,lame,vorbis-tools,mplayer,xterm,bash,ethtool,samba,apache2,gedit,btrfs-tools,devmem2,i2c-tools,pastebinit,uboot-envtools,uboot-mkimage,usbutils,wpasupplicant,konqueror,midori,lzma,sed,cvs,subversion,git-core,coreutils,unzip,gawk,git,pkg-config, gstreamer0.10-alsa --dist natty --serial ttyO2 --components "main universe multiverse" --kernel-image http://rcn-ee.net/deb/natty/v2.6.39.3-x3/linux-image-2.6.39.3-x3_1.0natty_armel.deb
The can change the argument to the ‘—login’ option to whatever username you desire. The same thing applies to the ‘—password’ option. This will be you username and password for you system. This process will take quite a while to complete.
Once the process is complete you will have a file name ‘armel-rootfs-*.tgz‘, where the ‘*’ is a suffix that is represents the date and time which the file was created. Extract this file to the ‘rootfs’ partition of your sd card with the following command, ‘X’ is your sd card drive letter:
$ mkdir temp
$ sudo mount /dev/sdX2 ./temp
$ sudo tar xfp armel-rootfs-*.tgz -C ./temp
Once the operation is complete unmount ‘./temp’ with the following command:
$ sudo umount ./temp
MLO and U-Boot
The boot partition is where the MLO, U-Boot, uInitrd and uImage (Linux Kernel) are stored. The first file on the partition MUST be the MLO file. Download the MLO file with the following command and copy it to the boot partition of your sd card.
$ wget http://beagleboard.googlecode.com/files/MLO_revc_v3
$ mv MLO_revc_v3 MLO
The second file that should be copied onto the sd card is u-boot.bin. Download the uboot.bin file with the following command and copy it to the boot partition of your sd card.
$ wget http://beagleboard.googlecode.com/files/u-boot-revc4.bin
$ mv u-boot-revc4.bin u-boot.bin
The third that that should be copied on to the sd card is the uInitrd file. From your Kernel sources directory. Execute the following commands to create the uInitrd file and copy it to your sd card boot partition.
$ mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 -n initramfs -d ./initrd.img-* ./uInitrd
Next, you will create the uEnv.txt file. Newer versions of u-boot look for this file instead of boot.src file used in previous versions. Create a new text file named uEnv.txt. Paste the following script into it and save.
bootenv=boot.scr
loaduimage=fatload mmc ${mmcdev} ${loadaddr} ${bootenv}
mmcboot=echo Running boot.scr script from mmc ...; source ${loadaddr}
Now, create a new text file named boot.cmd. Paste the following script into it and save.
setenv dvimode 1280x720MR-16@60
setenv vram 12MB
setenv bootcmd 'fatload mmc 0:1 0x80300000 uImage; fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80300000 0x81600000'
setenv bootargs console=ttyO2,115200n8 console=tty0 root=/dev/mmcblk0p2 rw rootwait rootdelay=2 mem=200M vram=${vram} omapfb.mode=dvi:${dvimode} fixrtc buddy=${buddy} mpurate=${mpurate}
boot
Now, from the same directory where you saved your boot.cmd file. Execute the following command to create the boot.src file that the processor will use to boot Linux.
$ mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Ubuntu" -d ./boot.cmd ./boot.scr
Copy both the boot.cmd and boot.src files to the boot partition of your sd card.
Cross-Compiling Tools
Once the installation of Ubuntu is complete, the next step is to install the GCC for ARM cross compiler tools. Open a terminal and type the following commands to install all the necessary packages you will need to cross compile the Kernel and applications for the ARM architecture.
$ sudo apt-get update
$ sudo apt-get install gitk bzr bzr-grep bzr-gtk linaro-image-tools make picocom u-boot-tools gcc-4.5-arm-linux-gnueabi ccache gcc ctags cscope git-core debhelper build-essential fakeroot kernel-wedge uboot-mkimage
$ sudo update-alternatives --install /usr/bin/arm-linux-gnueabi-gcc arm-linux-gnueabi-gcc /usr/bin/arm-linux-gnueabi-gcc-4.5 80
After you have successfully installed the previous step, test that they are correctly installed by trying to auto complete the arm tools by typing ‘arm’ then pressing the ‘TAB’ key twice. A list should be displayed of available programs that start with ‘arm-linux-gnueabi-‘ prefix, if not retry the ‘sudo update-alternatives’ command above.
Compiling the Kernel
Now that you have the ARM compiler tools installed you are now able to cross compile the Linux Kernel for use on the OMAP3530. The first step in compiling the Kernel is to obtain the sources from kernel.org.
Execute the following command from your “TI” directory, which you created previously, to download the sources and checkout the version that you will be running on the ARM processor and future Kernel dependent software.
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6.git linux-omap
$ cd linux-omap
$ git checkout -b temp v2.6.39
Once the sources have finished downloading and you have checked out the 2.6.39 Kernel execute the following commands to compile the Kernel.
$ export ARCH=arm
$ export CROSS_COMPILE=arm-linux-gnueabi-
$ make distclean
$ wget http://cgit.openembedded.org/cgit.cgi/openembedded/tree/recipes/linux/linux-omap-2.6.39/beagleboard/defconfig
$ mv defconfig .config
$ make menuconfig
After executing ‘menuconfig’ you will see a graphical menu. Use the arrow keys to scroll down to ‘Device Drivers’ and press ‘Enter’ key. In the sub-menu scroll down to ‘Staging Drivers’. If there is not a ‘*’ in the brackets already enable it by pressing the ‘spacebar’. Enter the Staging Driver sub-menu and scroll down to ‘DSP Bridge Driver’ and press ‘M’ key to make it a kernel module. Press ‘ESC’ key until you reach the main menu. Choose ‘Exit’ and you should be prompted to save the changes you just made to the .config file, choose ‘yes’. Continue with the following commands:
$ make prepare
$ make scripts
$ make uImage modules
$ make modules_install INSTALL_MOD_PATH=`pwd`/copy-modules
The compiled uImage file will be located in ‘$HOME/TI/linux-omap/arch/arm/boot’ directory. Copy this file to the root of the boot partition of your sd card. Now copy the contents of the ‘copy-modules’ folder to the rootfs of your sd card.
Insert your new Debian based Linux distribution into the sd card slot of your Beagleboard or other compatible OMAP3530 board and power it on. If you get any errors during boot time it is possible that you did not place files in their correct location. Check your Kernel modules and boot configuration for errors.
Reference Links
[1]: http://www.ubuntu.com/download/ubuntu/download
[2]: http://www.imgburn.com
[3]: http://www.ubuntu.com/download/ubuntu/windows-installer
[4]: http://www.vmware.com/products/player/
[5]: http://www.virtualbox.org/wiki/Downloads
[6]: http://www.vmware.com/appliances/directory/cat/508
[7]: https://help.ubuntu.com/community/Installation
[8]: http://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat
Useful Links
[1]: http://elinux.org/BeagleBoardDebian
[2]: http://elinux.org/Flash_Recovery_Utility
[3]: http://elinux.org/BeagleBoardNAND
[4]: http://elinux.org/BeagleBoard
[5]: http://ossie.wireless.vt.edu/trac/wiki/BeagleBoard_DSPLink
[6]: http://beagledummy.wordpress.com/
[7]: http://elinux.org/BeagleBoardRecovery
[8]: http://code.google.com/p/beagleboard/
[9]: http://www.omappedia.org/wiki/OMAP_Angstrom
[10]: http://www.angstrom-distribution.org/demo/beagleboard/
Share with your friends: |