Last active
November 22, 2016 02:31
-
-
Save ur0n2/9770b9639780aed61ab5576774988e05 to your computer and use it in GitHub Desktop.
mkmmc-android.sh for beagle_xm_MMC(4GB)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#editor: LeeJunHwan | |
EXPECTED_ARGS=1 | |
if [ $# == $EXPECTED_ARGS ] | |
then | |
echo "Assuming Default Locations for Prebuilt Images" | |
$0 $1 Boot_Images/MLO Boot_Images/u-boot.bin Boot_Images/uImage Boot_Images/boot.scr Filesystem/rootfs* Media_Clips START_HERE | |
exit | |
fi | |
if [[ -z $1 || -z $2 || -z $3 || -z $4 ]] | |
then | |
echo "mkmmc-android Usage:" | |
echo " mkmmc-android <device> <MLO> <u-boot.bin> <uImage> <boot.scr> <rootfs tar.bz2 > <Optional Media_Clips> <Optional START_HERE folder>" | |
echo " Example: mkmmc-android /dev/sdc MLO u-boot.bin uImage boot.scr rootfs.tar.bz2 Media_Clips START_HERE" | |
exit | |
fi | |
if ! [[ -e $2 ]] | |
then | |
echo "Incorrect MLO location!" | |
exit | |
fi | |
if ! [[ -e $3 ]] | |
then | |
echo "Incorrect u-boot.bin location!" | |
exit | |
fi | |
if ! [[ -e $4 ]] | |
then | |
echo "Incorrect uImage location!" | |
exit | |
fi | |
if ! [[ -e $5 ]] | |
then | |
echo "Incorrect boot.scr location!" | |
exit | |
fi | |
if ! [[ -e $6 ]] | |
then | |
echo "Incorrect rootfs location!" | |
exit | |
fi | |
echo "All data on "$1" now will be destroyed! Continue? [y/n]" | |
read ans | |
if ! [ $ans == 'y' ] | |
then | |
exit | |
fi | |
echo "[Unmounting all existing partitions on the device ]" | |
umount $1* | |
echo "[Partitioning $1...]" | |
DRIVE=$1 | |
echo $1 | |
#read asd | |
dd if =/dev/zero of=$1 bs=1024 count=1024 | |
echo "umount:"$1 | |
echo | |
echo "dd complete" | |
echo "fdisk start" | |
fdisk $1 <<@ | |
o | |
d | |
p | |
n | |
p | |
1 | |
2800000 | |
t | |
c | |
a | |
n | |
p | |
2 | |
4800000 | |
n | |
p | |
3 | |
p | |
w | |
@ | |
echo "fdisk end" | |
echo "[Making filesystems...]" | |
mkfs.vfat -F 32 -n boot "$1"1 << @ | |
y | |
@ | |
mkfs.ext3 -L rootfs "$1"2<< @ | |
y | |
@ | |
mkfs.vfat -F 32 -n data "$1"3<< @ | |
y | |
@ | |
echo "[Copying files...]" | |
mount "$1"1 /mnt | |
cp $2 /mnt/MLO | |
cp $3 /mnt/u-boot.bin | |
cp $4 /mnt/uImage | |
cp $5 /mnt/boot.scr | |
if [ "$8" ] | |
then | |
echo "[Copying START_HERE floder to boot partition]" | |
cp -r $8 /mnt/START_HERE | |
fi | |
umount "$1"1 | |
mount "$1"2 /mnt | |
tar jxvf $6 -C /mnt &> /dev/null | |
chmod 755 /mnt | |
umount "$1"2 | |
if [ "$7" ] | |
then | |
echo "[Copying all clips to data partition]" | |
mount "$1"3 /mnt | |
cp -r $7/* /mnt/ | |
umount "$1"3 | |
fi | |
echo "[Done]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment