I run ArchLinux ARM on my BBB from the eMMC.  I initialize the eMMC using 
three scripts I execute on another ARM Linux system (a PogoPlug)

Script 1 - executed on my originating system, partitions/formats the micro 
SD card
Script 2 - executed on my originating system, copies the appropriate 
ArchLinux files to the micro SD card.
Script 3 - executed on the BBB after I boot from the micro SD card.

Even if you don't use ArchLinux ARM, these scripts may be helpful for 
creating your own eMMC flasher. Enjoy.

Script 1 (bbb-fdisk-sd.sh):
# bbb-fdisk-sd.sh
# This script partitions SD media for use as a boot device for a BeagleBone
# or BeagleBone black.  The first partition (boot) is sized at 16MB.  If you
# want a larger partition, change the code below (look for +16M).  This 
script
# assumes the device you want to partition is located at /dev/sd?.  Make 
sure
# you verify the correct device name before proceeding.

DEVICELIST=`ls /dev/sd? 2> /dev/null | sed s:/dev/::`
if [ -z "${DEVICELIST}" ]; then
    echo "ERROR: No /dev/sd? devices"
    exit
fi

clear
echo Device Choices: $DEVICELIST
echo
while true
do
    read -p "Enter device name: " DEVICECHOICE
    if echo "$DEVICECHOICE" | grep -q "$DEVICELIST"
    then
    break
else
  echo "ERROR: You entered an invalid device name."
fi
done

echo
while true
do
    read -p "Are you sure you want to use /dev/$DEVICECHOICE (answer yes or 
no)? " ANSWER
    case $ANSWER in
        yes ) break;;
        no ) exit;;
        * ) echo "ERROR: Please answer yes or no.";;
    esac
done

fdisk /dev/$DEVICECHOICE << EOF
o
p
n
p
1

+16M
n
p
2


a
1
t
1
e
p
w
EOF

Script 2 (bbb-make-sd-arch.sh):
# bbb-make-sd-arch.sh
# This script is used to create a new (clean) install of ArchLinux for the 
BeagleBone or
# BeagleBoneBlack on a microSD card.  Verify your media devices before you 
proceed.  This
# script assumes your media device is /dev/sd?.  Ensure you have 
partitioned (fdisk) your
# media before proceeding. You will need two partitions. The first 
partition does not need
# to be large, but needs to be set to bootable and must be type 'e' which 
is FAT 16.
# The second partition is a normal Linux partition, probably ext4. If you 
can't mkfs.vfat,
# download the dosfstools (pacman -Sy dosfstools).

clear
DEVICELIST=`ls /dev/sd? 2> /dev/null | sed s:/dev/::`
if [ -z "${DEVICELIST}" ]; then
echo "ERROR: No /dev/sd? devices"
exit
fi

echo Device Choices: $DEVICELIST
echo
while true
do
read -p "Enter device name: " DEVICECHOICE
if echo "$DEVICECHOICE" | grep -q "$DEVICELIST"
then
break
else
echo "ERROR: You entered an invalid device name."
fi
done

echo
while true
do
read -p "Are you sure you want to use /dev/$DEVICECHOICE (answer yes or 
no)? " ANSWER
case $ANSWER in
yes) break;;
no) exit;;
*) echo "ERROR: Please answer yes or no.";;
esac
done

BOOTLOADER=BeagleBone-bootloader.tar.gz
ARCHLINUX=ArchLinuxARM-am33x-latest.tar.gz
WORKINGDIR=.
BOOTDEV=/dev/$DEVICECHOICE'1'
BOOTTMP=$WORKINGDIR/boot
ROOTDEV=/dev/$DEVICECHOICE'2'
ROOTTMP=$WORKINGDIR/root
BOOTIMAGE=$ROOTTMP/boot/zImage
BBBSCRIPT=/home/public/bbb-make-emmc-arch.sh

mkfs.vfat -F 16 -n "bootloader" $BOOTDEV
sleep 1
mkfs.ext4 -L "rootfs" $ROOTDEV
sleep 1

mkdir $BOOTTMP
mkdir $ROOTTMP
mount $BOOTDEV $BOOTTMP
mount $ROOTDEV $ROOTTMP

wget http://archlinuxarm.org/os/omap/$BOOTLOADER -O $WORKINGDIR/$BOOTLOADER
sleep 1
wget http://archlinuxarm.org/os/$ARCHLINUX -O $WORKINGDIR/$ARCHLINUX
sleep 1

if which pv &> /dev/null
 then
  pv $WORKINGDIR/$BOOTLOADER | tar xzf - -C $BOOTTMP
  pv $WORKINGDIR/$ARCHLINUX | tar xzf - -C $ROOTTMP
 else
  tar xvf $WORKINGDIR/$BOOTLOADER -C $BOOTTMP
  tar xvf $WORKINGDIR/$ARCHLINUX -C $ROOTTMP
fi

echo "Copying Boot Image"
cp $BOOTIMAGE $BOOTTMP

echo "Copying" $BBBSCRIPT "script to /"
cp $BBBSCRIPT /

echo "Synching"
sync

umount $BOOTTMP
umount $ROOTTMP
rmdir $BOOTTMP
rmdir $ROOTTMP

clear
echo "Upload Complete"
echo
while true
do
read -p "Delete downloaded files (answer yes or no)? " ANSWER
case $ANSWER in
yes )
rm $WORKINGDIR/$BOOTLOADER
rm $WORKINGDIR/$ARCHLINUX
exit
;;
no ) exit;;
* ) echo "ERROR: Please answer yes or no.";;
esac
done

Script 3 (bbb-make-emmc-arch.sh):
# bbb-make-emmc-arch.sh
# This script is used to create a new (clean) install of ArchLinux ARM to 
the BeagleBone Black's
# onboard eMMC storage.  This script assumes you have booted the BeagleBone 
Black using a microSD
# card with the appropriate ArchLinux ARM files and now want to install 
ArchLinux in the onboard
# eMMC storage.

BOOTLOADER=BeagleBone-bootloader.tar.gz
ARCHLINUX=ArchLinuxARM-am33x-latest.tar.gz
WORKINGDIR=/tmp
BOOTDEV=/dev/mmcblk1p1
BOOTTMP=$WORKINGDIR/boot
ROOTDEV=/dev/mmcblk1p2
ROOTTMP=$WORKINGDIR/root
BOOTIMAGE=$ROOTTMP/boot/zImage

clear
while true
do
echo "You need the mkfs.vfat format and wget commands."
echo "Use pacman -Sy wget AND pacman -Sy dosfstools (for vfat format)."
echo 
read -p "Are these two commands installed (answer yes or no)? " ANSWER
case $ANSWER in
yes) break;;
no) exit;;
*) echo "ERROR: Please answer yes or no.";;
esac
done

mkfs.vfat -F 16 -n "bootloader" $BOOTDEV
sleep 1
mkfs.ext4 -L "rootfs" $ROOTDEV
sleep 1

mkdir $BOOTTMP
mkdir $ROOTTMP
mount $BOOTDEV $BOOTTMP
mount $ROOTDEV $ROOTTMP

wget http://archlinuxarm.org/os/omap/$BOOTLOADER -O $WORKINGDIR/$BOOTLOADER
sleep 1
wget http://archlinuxarm.org/os/$ARCHLINUX -O $WORKINGDIR/$ARCHLINUX
sleep 1

if which pv &> /dev/null
 then
  pv $WORKINGDIR/$BOOTLOADER | tar xzf - -C $BOOTTMP
  pv $WORKINGDIR/$ARCHLINUX | tar xzf - -C $ROOTTMP
 else
  tar xvf $WORKINGDIR/$BOOTLOADER -C $BOOTTMP
  tar xvf $WORKINGDIR/$ARCHLINUX -C $ROOTTMP
fi

echo "Copying Boot Image"
cp $BOOTIMAGE $BOOTTMP

echo "Synching"
sync

umount $BOOTTMP
umount $ROOTTMP
rmdir $BOOTTMP
rmdir $ROOTTMP

clear
while true
do
read -p "Delete downloaded files (answer yes or no)? " ANSWER
case $ANSWER in
yes)
rm $WORKINGDIR/$BOOTLOADER
rm $WORKINGDIR/$ARCHLINUX
exit
;;
no) exit;;
*) echo "ERROR: Please answer yes or no.";;
esac
done


-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to