Saturday, August 02, 2008

How to make a bootable MMC card on Linux for BeagleBoard (using gparted)

H/w I have:
a) Beagle board rev A5
b) a 512Meg Micro SD card with adapter
c) USB2Serial convertor (my laptop docking station has a PCI UART, but I hardly ever use docking stations)
d) card reader
Objective use the UI tools in Linux as much as possible to boot mmc card on beagleboard.

Step 1:
getting to know the usb sd/mmc card reader device:
plugin the reader and run dmesg
E.g.:
[50306.414076] sd 6:0:0:0: [sdb] 254208 512-byte hardware sectors (130 MB)
[50306.419071] sd 6:0:0:0: [sdb] Write Protect is off
[50306.419080] sd 6:0:0:0: [sdb] Mode Sense: 03 00 00 00
[50306.419084] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[50306.431052] sd 6:0:0:0: [sdb] 254208 512-byte hardware sectors (130 MB)
[50306.436051] sd 6:0:0:0: [sdb] Write Protect is off
[50306.436059] sd 6:0:0:0: [sdb] Mode Sense: 03 00 00 00
[50306.436063] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[50306.436071] sdb:
[50306.442153] sd 6:0:0:0: [sdb] Attached SCSI removable disk
[50306.442235] sd 6:0:0:0: Attached scsi generic sg1 type 0
See here for more instructions on using fdisk
-> here are my own instructions (Ubuntu 8.04)
Step 2: Formating the mmc card
a) Stop HAL from autodetecting drives..
sudo /etc/init.d/hal stop
b) Run gparted
sudo gparted /dev/sdb
c) Delete all partitions present

































d) create the minimum FAT32 partition (primary partition)











e) create the rest of the disk for ext3fs (primary partition)











f) apply the changes
g) Set the FAT32 partition as bootable:
select manage flags for the FAT32 partition

select bootable option:


apply and quit from gparted.
h) restart the hal
sudo /etc/init.d/hal start
sudo /etc/init.d/hal restart


(At this point, you can replug your mmc card without it being auto detected ;)...
Step 3:Copy the images
a) run mount command to see the partitions:
mount

/dev/sdb2 on /media/disk-1 type ext3 (rw,nosuid,nodev,uhelper=hal)
/dev/sdb1 on /media/disk-2 type vfat (rw,nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,flush)

b) mount the partitions and copy the following to FAT32 partition:
MLO, uImage, u-boot.bin (See here and here for more versions)
c) unmount the filesystem on the PC. put the card in the board
d) boot up and you should see x-loader followed by u-boot coming up.

Boot args: for Linux to boot out of mmc card and continue using the filesystem in mmc partition 2,
setenv bootargs "console=ttyS2,115200n8 noinitrd root=/dev/mmcblk0p1 rootfstype=ext2 rw rootdelay=1 nohz=off"
setenv bootcmd 'mmcinit; fatload mmc 0 0x80300000 uImage;bootm 0x80300000'
saveenv


NOTE: I dont trust the bootargs completely.. any one with proper values.. please comment in.. there are two variants here:
a) partition number mmcblk0p1 or the equal based on udev etc..
b) partition type - ext2/ext3 etc..

3 comments:

mno.pwq said...

Thanks for your articles, Nishanth - I have always found them useful. Good stuff!-shrikumar

Anonymous said...

I really want to read this blog post. But all the blogger.com sidebars are covering up critical info, making this page useless.

Gopal Amlekar said...

Hi Nishanth,
You have done a great work. I am trying to unbrick my beagleboard using your method.
I can not find the script file that you have put link to. It directs to the google group homepage only.
Can you please upload it somewhere or if possible send me on gopal_amlekar@yahoo.com?
Thanks a lot!