rootfsinstall: new target platform option -cubox
This commit is contained in:
parent
36f4b5abeb
commit
2a9f821f6b
@ -4,10 +4,15 @@
|
|||||||
# Based on rpi-install by: Davide Madrisan
|
# Based on rpi-install by: Davide Madrisan
|
||||||
# Modified by: Silvan Calarco <silvan.calarco@mambasoft.it>
|
# Modified by: Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||||
#
|
#
|
||||||
|
|
||||||
SYSTEMFSTYPE=ext4
|
SYSTEMFSTYPE=ext4
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
echo "Usage: $0 device rootfs-archive [-y] [-rpi] [-fs fstype] [-a archive] [-c command] [-k kernel] [-p password]"
|
echo "Usage: $0 device rootfs-archive [-rpi|-cubox] [-a archive] [-c command] [-fs fstype] [-k kernel] [-p password] [-y]"
|
||||||
|
echo
|
||||||
|
echo "Target platform (optional):"
|
||||||
|
echo "-rpi : make a RaspberryPi SD with boot partition"
|
||||||
|
echo "-cubox : make a Cubox SD with boot partition"
|
||||||
echo
|
echo
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo "-a archive : additional archive to unpack in rootfs root"
|
echo "-a archive : additional archive to unpack in rootfs root"
|
||||||
@ -15,9 +20,8 @@ function usage() {
|
|||||||
echo "-c command : command to run through chroot in rootfs"
|
echo "-c command : command to run through chroot in rootfs"
|
||||||
echo "-fs fstype : filesystem type for system partition (default: ext4)"
|
echo "-fs fstype : filesystem type for system partition (default: ext4)"
|
||||||
echo "-h hostname : set given hostname"
|
echo "-h hostname : set given hostname"
|
||||||
echo "-k kernel : extract/use kernel file from ROOTFS/boot/ for boot"
|
echo "-k kernel : extract and use specified kernel file from ROOTFS/boot/ for boot"
|
||||||
echo "-p password : set given password for root user"
|
echo "-p password : set given password for root user"
|
||||||
echo "-rpi : make a RaspberryPi SD with boot partition"
|
|
||||||
echo "-y : assume yes to all questions (script mode)"
|
echo "-y : assume yes to all questions (script mode)"
|
||||||
echo
|
echo
|
||||||
echo "Example: $0 /dev/sdb /tmp/openmamba-rootfs-light.arm.tar.xz"
|
echo "Example: $0 /dev/sdb /tmp/openmamba-rootfs-light.arm.tar.xz"
|
||||||
@ -32,7 +36,8 @@ function usage() {
|
|||||||
while [ "$1" ]; do
|
while [ "$1" ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-y) ASSUMEYES=1 ;;
|
-y) ASSUMEYES=1 ;;
|
||||||
-rpi) RPIMODE=1 ;;
|
-cubox) TARGETDEVICE=cubox ;;
|
||||||
|
-rpi) TARGETDEVICE=rpi ;;
|
||||||
-fs) [ "$2" ] || {
|
-fs) [ "$2" ] || {
|
||||||
echo "Error: -fs option requires an argument; aborting."
|
echo "Error: -fs option requires an argument; aborting."
|
||||||
exit 1
|
exit 1
|
||||||
@ -111,8 +116,36 @@ else
|
|||||||
PARTITION2=${DRIVE}2
|
PARTITION2=${DRIVE}2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# FIXME: in non rpi mode we only have system partition
|
case $TARGETDEVICE in
|
||||||
[ "$RPIMODE" ] || PARTITION2=$PARTITION1
|
rpi) BOOTFSTYPE=fat32
|
||||||
|
BOOTFSSIZE=40M
|
||||||
|
KERNELDEST="@BOOT@/kernel.img"
|
||||||
|
;;
|
||||||
|
cubox) BOOTFSTYPE=ext3
|
||||||
|
BOOTFSSIZE=20M
|
||||||
|
KERNELDEST="@BOOT@/boot/uImage"
|
||||||
|
;;
|
||||||
|
*) BOOTFSTYPE=
|
||||||
|
if [ "$USEKERNEL" ]; then
|
||||||
|
KERNELDEST="/tmp/$USEKERNEL"
|
||||||
|
else
|
||||||
|
KERNELDEST=
|
||||||
|
fi
|
||||||
|
PARTITION2=$PARTITION1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[ -r "$ROOTFSARCHIVE" ] || {
|
||||||
|
echo "ERROR: unable to read rootfs archive $ROOTFSARCHIVE; aborting."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Rootfs archive : $ROOTFSARCHIVE"
|
||||||
|
echo "Target SD card : ${DRIVE}"
|
||||||
|
[ "$TARGETDEVICE" ] && echo "Target platform: $TARGETDEVICE"
|
||||||
|
[ "$BOOTFSTYPE" ] && echo "Boot fs : $BOOTFSTYPE($BOOTFSSIZE)"
|
||||||
|
[ "$BOOTFSTYPE" ] && echo "System fs : $SYSTEMFSTYPE"
|
||||||
|
[ "$USEKERNEL" ] && echo "Kernel : $USEKERNEL -> $KERNELDEST"
|
||||||
|
echo
|
||||||
|
|
||||||
[ "$ASSUMEYES" ] || {
|
[ "$ASSUMEYES" ] || {
|
||||||
echo -n "All current data in ${DRIVE} will be lost, do you want to proceed [y/N]?"
|
echo -n "All current data in ${DRIVE} will be lost, do you want to proceed [y/N]?"
|
||||||
@ -125,14 +158,14 @@ if [ "$?" != "0" ]; then
|
|||||||
echo "ERROR: parted exited with error $? while creating partition table on ${DRIVE}; aborting."
|
echo "ERROR: parted exited with error $? while creating partition table on ${DRIVE}; aborting."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$RPIMODE" ]; then
|
if [ "$BOOTFSTYPE" ]; then
|
||||||
# FAT partition
|
# FAT partition
|
||||||
sudo parted -s -a cyl -- ${DRIVE} mkpart primary fat32 0 40M
|
sudo parted -s -a cyl -- ${DRIVE} mkpart primary $BOOTFSTYPE 0 $BOOTFSSIZE
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
echo "ERROR: parted exited with error $? while creating boot partition on ${DRIVE}; aborting."
|
echo "ERROR: parted exited with error $? while creating boot partition on ${DRIVE}; aborting."
|
||||||
fi
|
fi
|
||||||
# rootfs partition
|
# rootfs partition
|
||||||
sudo parted -s -a cyl -- ${DRIVE} mkpart primary $SYSTEMFSTYPE 40M -1
|
sudo parted -s -a cyl -- ${DRIVE} mkpart primary $SYSTEMFSTYPE $BOOTFSSIZE -1
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
echo "ERROR: parted exited with error $? while creating system partition on ${DRIVE}; aborting."
|
echo "ERROR: parted exited with error $? while creating system partition on ${DRIVE}; aborting."
|
||||||
fi
|
fi
|
||||||
@ -145,12 +178,18 @@ else
|
|||||||
fi
|
fi
|
||||||
sync
|
sync
|
||||||
|
|
||||||
if [ "$RPIMODE" ]; then
|
if [ "$BOOTFSTYPE" ]; then
|
||||||
echo "Formatting $PARTITION1 (vfat) ..."
|
echo "Formatting $PARTITION1 ($BOOTFSTYPE) ..."
|
||||||
mkfs.vfat -s 1 -F 32 -n "BOOT" $PARTITION1 || {
|
case "$BOOTFSTYPE" in
|
||||||
echo "ERROR: unable to format $PARTITION1; aborting."
|
vfat) mkfs.vfat -s 1 -F 32 -n "BOOT" $PARTITION1 || {
|
||||||
exit 1
|
echo "ERROR: unable to format $PARTITION1; aborting."
|
||||||
}
|
exit 1
|
||||||
|
} ;;
|
||||||
|
ext*) mke2fs -q -t $BOOTFSTYPE -j -L "BOOT" $PARTITION1 || {
|
||||||
|
echo "ERROR: unable to format $PARTITION1; aborting."
|
||||||
|
exit 1
|
||||||
|
} ;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Formatting $PARTITION2 ($SYSTEMFSTYPE)..."
|
echo "Formatting $PARTITION2 ($SYSTEMFSTYPE)..."
|
||||||
@ -173,7 +212,14 @@ mount $PARTITION2 $ROOTMP || {
|
|||||||
}
|
}
|
||||||
trap "[ -e $ROOTMP ] && umount $ROOTMP;[ -e $BOOTMP ] && umount $BOOTMP" 0 HUP INT QUIT ABRT KILL TERM
|
trap "[ -e $ROOTMP ] && umount $ROOTMP;[ -e $BOOTMP ] && umount $BOOTMP" 0 HUP INT QUIT ABRT KILL TERM
|
||||||
|
|
||||||
if [ "$RPIMODE" ]; then
|
if [ "$BOOTFSTYPE" ]; then
|
||||||
|
mount $PARTITION1 $BOOTMP || {
|
||||||
|
echo "ERROR: unable to mount partition $PARTITION1; aborting."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$TARGETDEVICE" = "rpi" ]; then
|
||||||
### SD-Card: install software
|
### SD-Card: install software
|
||||||
|
|
||||||
if [ ! "$USEKERNEL" ]; then
|
if [ ! "$USEKERNEL" ]; then
|
||||||
@ -185,11 +231,6 @@ if [ "$RPIMODE" ]; then
|
|||||||
echo "Fetching firmware boot files from git..."
|
echo "Fetching firmware boot files from git..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mount $PARTITION1 $BOOTMP || {
|
|
||||||
echo "ERROR: unable to mount partition $PARTITION1; aborting."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# bootcode.bin: 2nd stage bootloader, starts with SDRAM disabled
|
# bootcode.bin: 2nd stage bootloader, starts with SDRAM disabled
|
||||||
# loader.bin : 3rd stage bootloader, starts with SDRAM enabled
|
# loader.bin : 3rd stage bootloader, starts with SDRAM enabled
|
||||||
# start.elf : The GPU binary firmware image, provided by the foundation
|
# start.elf : The GPU binary firmware image, provided by the foundation
|
||||||
@ -242,7 +283,22 @@ framebuffer_ignore_alpha=1" > $BOOTMP/config.txt
|
|||||||
fi
|
fi
|
||||||
[ "$SWHOME" -a "${SWHOME:0:4}" = "/tmp" ] && rm -rf $SWHOME
|
[ "$SWHOME" -a "${SWHOME:0:4}" = "/tmp" ] && rm -rf $SWHOME
|
||||||
|
|
||||||
fi # rpimode
|
elif [ "$TARGETDEVICE" = "cubox" ]; then
|
||||||
|
mkdir -p $BOOTMP/boot
|
||||||
|
echo "Creating u-boot boot.scr..."
|
||||||
|
cat > $BOOTMP/boot/boot.txt << _EOF
|
||||||
|
setenv bootargs 'console=ttyS0,115200n8 vmalloc=384M root=/dev/mmcblk0p2 video=dovefb:lcd0:1920x1080-32@60-edid clcd.lcd0_enable=1 clcd.
|
||||||
|
lcd1_enable=0'
|
||||||
|
echo ======== Loading kernel ========
|
||||||
|
ext2load mmc 0:1 0x00200000 /boot/uImage
|
||||||
|
echo ======== Booting kernel ========
|
||||||
|
bootm
|
||||||
|
_EOF
|
||||||
|
mkimage -A arm -O linux -T script -C none -n "u-boot commands" -d $BOOTMP/boot/boot.txt $BOOTMP/boot/boot.scr || {
|
||||||
|
echo "ERROR: mkimage: error creating boot.scr; aborting."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
(
|
(
|
||||||
cd $ROOTMP >/dev/null || {
|
cd $ROOTMP >/dev/null || {
|
||||||
@ -275,23 +331,16 @@ fi # rpimode
|
|||||||
|
|
||||||
[ $? -eq 0 ] || exit $?
|
[ $? -eq 0 ] || exit $?
|
||||||
|
|
||||||
|
KERNELDEST=`echo $KERNELDEST | sed "s|@BOOT@|$BOOTMP|g"`
|
||||||
if [ "$USEKERNEL" ]; then
|
if [ "$USEKERNEL" ]; then
|
||||||
if [ "$RPIMODE" ]; then
|
|
||||||
KERNELDEST=$BOOTMP/kernel.img
|
|
||||||
else
|
|
||||||
KERNELDEST=/tmp/$USEKERNEL
|
|
||||||
fi
|
|
||||||
if [ -r $ROOTMP/boot/$USEKERNEL ]; then
|
if [ -r $ROOTMP/boot/$USEKERNEL ]; then
|
||||||
cp $ROOTMP/boot/$USEKERNEL $KERNELDEST || {
|
cp $ROOTMP/boot/$USEKERNEL $KERNELDEST || {
|
||||||
echo "ERROR: unable to find or copy kernel $USEKERNEL; aborting."
|
echo "ERROR: unable to find or copy kernel $USEKERNEL; aborting."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
if [ -e /tmp/$USEKERNEL ]; then
|
echo "Kernel image available as $KERNELDEST"
|
||||||
echo "Extracted kernel is available as $KERNELDEST"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "ERROR: can't find kernel file $ROOTMP/boot/$USERKERNEL; aborting."
|
echo "WARNING: can't find kernel file $ROOTMP/boot/$USERKERNEL"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -324,7 +373,7 @@ if [ "$CHROOTCOMMAND" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
sync
|
sync
|
||||||
if [ "$RPIMODE" ]; then
|
if [ "$BOOTFSTYPE" ]; then
|
||||||
umount $PARTITION1
|
umount $PARTITION1
|
||||||
rmdir $BOOTMP
|
rmdir $BOOTMP
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user