There is an updated and bugfixed version of this script now added to the OE git repository where all updates from now will be done.
Latest Version
Since the instructions to format an SD card for booting with beagle/zoom2/other omap boards seems to be so complex I decided to write a script that was nice and simple to accomplish the same task.
Here is my tested and working script.
#! /bin/sh
DRIVE=$1
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
echo DISK SIZE - $SIZE bytes
CYLINDERS=`echo $SIZE/255/63/512 | bc`
echo CYLINDERS - $CYLINDERS
{
echo ,9,0x0C,*
echo ,,,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
mkfs.vfat -F 32 -n "boot" ${DRIVE}1
mke2fs -j -L "rootfs" ${DRIVE}2
To run this script you will require to run it as root. On Ubuntu or other linux with sudo setup run the script as
sudo sh mkcard.sh /dev/sdX
replacing sdX with the base device name of your SD card device.
If your running a distribution without sudo setup then become root then run the script as
su -
sh mkcard.sh /dev/sdX
Very nice script — thanks!
Comment by Cliff Brake — September 4, 2009 @ 2:35 pm
Excellent script! Verified that it works on my dev system (ubuntu) and boots my Beagle. Thanks!
Comment by Jeff — September 4, 2009 @ 6:24 pm
> Since the instructions to format an SD card
> for booting with beagle/zoom2/other omap boards
> seems to be so complex
But you could have given the proper credit…
Comment by denix — October 24, 2009 @ 5:41 am
[...] Gregory) has given us a very nice open-source present for the weekend—a script you can use to automatically format SD cards for booting the Beagle Board or any other OMAP [...]
Pingback by Script to auto-format SD cards for booting Beagle Boards « Jeff’s Open Source Resource — October 24, 2009 @ 7:09 am
@denix credit to whom? I developed the script from scratch.
Comment by XorA — October 24, 2009 @ 12:46 pm
> @denix credit to whom? I developed the script from scratch.
I’m not talking about the script, I specifically quoted the relevant part:
> Since the instructions to format an SD card
> for booting with beagle/zoom2/other omap boards
> seems to be so complex
I figured out the technique and came up with the Linux instructions – before that everybody was using Windows formatting tool from HP. See the history of http://wiki.omap.com/index.php/MMC_Boot_Format or ask jkridner, dirk, etc.
I’m usually not that ambitious, and I wouldn’t be so bitchy about the proper credit, if I didn’t see all the praises of how good the script is and complaints of how sucky the instructions are…
Comment by denix — December 9, 2009 @ 9:05 pm
Good script…almost.
Unfortunately, it fails miserably on international – or at least non-english – versions of ubuntu et al.
The call to “fdisk -l” returns a localized string, which doesn’t usually contain “DISK”.
this can easily fixed (i.e. worked around) by adding
LANG=’C’
export LANG
at the top of the script, right after the “DRIVE=$1″ definition.
Works as it should after that.
Thanks
Comment by jay_are — February 1, 2010 @ 5:51 pm
Isnt this fixed by the LC_ALL=C at top of script?
Comment by XorA — February 3, 2010 @ 3:03 pm