Since there don’t appear to be any clear step-by-step instructions for doing this, I figured I would make a nice instructional post for people that don’t spend their whole day hacking embedded hardware. This assumes you have basic linux knowledge and a BeagleBoard you don’t mind completely gutting out to put on Ubuntu.
Things you need:
- BeagleBoard (Mine is a Rev B7)
- Uboot-mkimage (Ubuntu has this as a package)
- An SD card reader on a machine with ext2/3 support
Step 1: Formatting your card
Because the BeagleBoard firmware (u-boot) can only easily read FAT32, and Ubuntu is much happier with EXT2/3, the first step is to make two partitions on your SD card. I was able to do this using the Disk Utility on my Mac, after installing fuse-ext2, but any partition manager should be able to do this. You want the following setup:
- Partition 1: 50MB – FAT32
- Partition 2: The rest – EXT2/3
The exact setup isn’t that important, the main thing is that the FAT partition is first and large enough to hold the boot kernel.
Step 2: Upgrading the firmware
Since I have no idea what crazy firmware my BeagleBoard came with, the next thing to do was upgrade my board to some known, reasonable version. You will use the FAT partition on your newly formatted SD card for this purpose:
Go to the BeagleBoard downloads page and get the latest versions of the following files:
- u-boot-flash.bin (sometimes named u-boot-f)
(When you download these, these files will have version information stuck on them, like “x-load_revc_v3.bin.ift”. You should rename them to look exactly like the file names above. This is so that in the next step, the commands we use will have the correct filenames.)
Copy the files to the SD card:
All of the above files should be copied to the root of the FAT partition of your SD card. There shouldn’t be anything in that partition other than these 4 files, named exactly as above.
Upgrade the firmware:
Connect to the BeagleBoard over the serial interface, so you can use the console. The Beagleboard serial interface is 115200 baud, 8N1. I like to connect using GNU Screen, so I do the following:
screen -U /dev/ttyUSB0 115200
Now, plug the SD card into the BeagleBoard, and let it start up the boot process. When you see it get to the prompt about autoboot, press a key to interrupt it:
Texas Instruments X-Loader 1.41 Starting OS Bootloader... U-Boot 1.3.3 (Jul 8 2008 - 16:29:02) OMAP3530-GP rev 2, CPU-OPP2 L3-165MHz OMAP3 Beagle Board + LPDDR/NAND DRAM: 128 MB NAND: 256 MiB *** Warning - bad CRC or NAND, using default environment In: serial Out: serial Err: serial Audio Tone on Speakers ... complete Hit any key to stop autoboot: 0 OMAP3 beagleboard.org #
Now, at this point, you have all the things you need to follow the BeagleBoard NAND flashing instructions. There are several versions, but I found the Google code version to be the best for x-loader and u-boot, and the e-linux.org wiki version better for the kernel image (uImage). You will do 3 write sequences, one for x-loader, one for u-boot, and one for uImage.
Step 3: Putting Ubuntu on the SD card
The details of making a custom Ubuntu image can be found on the e-linux.org wiki. However, I just used the demo images linked on the wiki, as I didn’t really need a custom image with a ton of stuff. So first, I downloaded an unzipped the tarball of the Karmic (9.10) demo image. It uses 7Z compression, so you might need to install 7zip if you don’t have it. Included in the tarball are two files, a vmlinuz-* file that will be the kernel image, and a large armel-rootfs-*.tar that will be the root file system.
The installation details are hidden on the wiki, but I will reiterate them for clarity:
- Install the ubuntu package uboot-mkimage.
sudo apt-get install uboot-mkimage
- Use the vmlinuz-* file to make a uImage file.
mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 -n "Linux" -d ./vmlinuz-* ./uImage
- Create a boot script file called ubuntu.cmd with the following lines (note: if you use ext2, change the reference in the second line of this script from ext3 to ext2):
setenv bootcmd 'mmcinit; fatload mmc 0:1 0x80300000 uImage; bootm 0x80300000' setenv bootargs 'console=ttyS2,115200n8 console=tty0 root=/dev/mmcblk0p2 rootwait rootfstype=ext3 ro vram=12M omapfb.mode=dvi:1280x720MR-16@60' boot
- Compile the ubuntu.cmd script into an ubuntu.scr file.
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Ubuntu 9.10" -d ./ubuntu.cmd ./ubuntu.scr
- You should now have two files, uImage and ubuntu.scr. Clear off everything else in the FAT partition of your SD card and copy both of these files there, and rename ubuntu.scr to boot.scr. Your FAT partition should just contain two files: uImage and boot.scr.
- Finally, copy the root filesystem to your EXT partition. You can do this directly from the tar archive:
sudo tar xfp armel-rootfs-[fill this in].tgz -C [SD card EXT mount]
Lastly, there are a couple of quick hacks that need to be done for Karmic (9.10) to work. The e-linux guide is pretty clear about this part, so I’ll just post the relevant link to their wiki section. Basically, you just need to edit a couple of config files on your EXT partition so that the kernel mounts it correctly and doesn’t freak out. Be careful with the paths though, if you forget the ./, you could easily end up editing your own machine’s config files instead!
Now finally, at this point, you can plug the SD card into the BeagleBoard, and you should get to a login prompt. Awesome!