rootfsinstall: support for multiple chroot commands and rpi: use internal firmware files instead of downloading if present
This commit is contained in:
parent
b3c56bc969
commit
b7329e8bc8
@ -17,7 +17,7 @@ function usage() {
|
|||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo "-a archive : additional archive to unpack in rootfs root"
|
echo "-a archive : additional archive to unpack in rootfs root"
|
||||||
echo "-cp command : command to run before chroot. Use @ROOT@ as reference to rootfs path"
|
echo "-cp command : command to run before chroot. Use @ROOT@ as reference to rootfs path"
|
||||||
echo "-c command : command to run through chroot in rootfs"
|
echo "-c command : command to run through chroot in rootfs (maybe specified multiple times)"
|
||||||
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 and use specified kernel file from ROOTFS/boot/ for boot"
|
echo "-k kernel : extract and use specified kernel file from ROOTFS/boot/ for boot"
|
||||||
@ -61,7 +61,7 @@ while [ "$1" ]; do
|
|||||||
echo "Error: -c option requires a command string as argument; aborting."
|
echo "Error: -c option requires a command string as argument; aborting."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
CHROOTCOMMAND=$2
|
CHROOTCOMMANDS[${#CHROOTCOMMANDS[*]}]="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-cp) [ "$2" ] || {
|
-cp) [ "$2" ] || {
|
||||||
@ -229,31 +229,70 @@ if [ "$BOOTFSTYPE" ]; then
|
|||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$TARGETDEVICE" = "rpi" ]; then
|
(
|
||||||
### SD-Card: install software
|
cd $ROOTMP >/dev/null || {
|
||||||
|
echo "ERROR: unable to access system partition mount point; aborting."
|
||||||
|
umount $PARTITION2
|
||||||
|
rmdir $ROOTMP
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
if [ ! "$USEKERNEL" ]; then
|
echo "Uncompressing $ROOTFSARCHIVE..."
|
||||||
SWHOME=`mktemp -d`
|
echo -n "This can take a while, please wait..."
|
||||||
echo "Cloning firmware repository from git..."
|
tar xf $ROOTFSARCHIVE || {
|
||||||
cd $SWHOME
|
echo
|
||||||
git clone git://github.com/raspberrypi/firmware.git --depth=1
|
echo "ERROR: unable to uncompress rootfs archive; aborting."
|
||||||
else
|
exit 1
|
||||||
echo "Fetching firmware boot files from git..."
|
}
|
||||||
|
echo "DONE"
|
||||||
|
|
||||||
|
if [ "$ADDITIONALARCHIVE" ]; then
|
||||||
|
echo "Uncompressing $ADDITIONALARCHIVE..."
|
||||||
|
echo -n "This can take a while, please wait..."
|
||||||
|
tar xf $ADDITIONALARCHIVE || {
|
||||||
|
echo
|
||||||
|
echo "ERROR: unable to uncompress additional archive; aborting."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
echo "DONE"
|
||||||
fi
|
fi
|
||||||
|
)
|
||||||
|
|
||||||
# bootcode.bin: 2nd stage bootloader, starts with SDRAM disabled
|
[ $? -eq 0 ] || exit $?
|
||||||
# loader.bin : 3rd stage bootloader, starts with SDRAM enabled
|
|
||||||
# start.elf : The GPU binary firmware image, provided by the foundation
|
if [ "$TARGETDEVICE" = "rpi" ]; then
|
||||||
# kernel.img : The OS kernel to load on the ARM processor.
|
# fetch and install firmware files if missing
|
||||||
for f in bootcode.bin fixup_x.dat kernel.img start_x.elf LICENCE.broadcom; do
|
if [ -e $ROOTMP/boot/bootcode.bin -a -e $ROOTMP/boot/fixup_x.dat -a -e $ROOTMP/boot/start_x.elf ]; then
|
||||||
|
for f in bootcode.bin fixup_x.dat start_x.elf; do
|
||||||
|
cp $ROOTMP/boot/$f $BOOTMP/$f
|
||||||
|
done
|
||||||
|
cp $ROOTMP/boot/zImage*-rpi $BOOTMP/kernel.img
|
||||||
|
else
|
||||||
if [ ! "$USEKERNEL" ]; then
|
if [ ! "$USEKERNEL" ]; then
|
||||||
cp $SWHOME/firmware/boot/$f $BOOTMP/
|
SWHOME=`mktemp -d`
|
||||||
|
echo "Cloning firmware repository from git..."
|
||||||
|
cd $SWHOME
|
||||||
|
git clone git://github.com/raspberrypi/firmware.git --depth=1
|
||||||
else
|
else
|
||||||
curl -s -L -k https://github.com/raspberrypi/firmware/raw/master/boot/$f -o $BOOTMP/$f || {
|
echo "Fetching firmware boot files from git..."
|
||||||
echo "ERROR: could not fetch $f from raspberrypi git; aborting."
|
|
||||||
}
|
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
# bootcode.bin: 2nd stage bootloader, starts with SDRAM disabled
|
||||||
|
# loader.bin : 3rd stage bootloader, starts with SDRAM enabled
|
||||||
|
# start_x.elf : The GPU binary firmware image, provided by the foundation
|
||||||
|
# kernel.img : The OS kernel to load on the ARM processor.
|
||||||
|
for f in bootcode.bin fixup_x.dat kernel.img start_x.elf LICENCE.broadcom; do
|
||||||
|
if [ ! "$USEKERNEL" ]; then
|
||||||
|
cp $SWHOME/firmware/boot/$f $BOOTMP/
|
||||||
|
else
|
||||||
|
if [ "$f" != "kernel.img" ]; then
|
||||||
|
curl -s -L -k https://github.com/raspberrypi/firmware/raw/master/boot/$f -o $BOOTMP/$f || {
|
||||||
|
echo "ERROR: could not fetch $f from raspberrypi git; aborting."
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# cmdline.txt : parameters passed to the kernel on boot
|
# cmdline.txt : parameters passed to the kernel on boot
|
||||||
echo "\
|
echo "\
|
||||||
@ -298,8 +337,7 @@ elif [ "$TARGETDEVICE" = "cubox" ]; then
|
|||||||
mkdir -p $BOOTMP/boot
|
mkdir -p $BOOTMP/boot
|
||||||
echo "Creating u-boot boot.scr..."
|
echo "Creating u-boot boot.scr..."
|
||||||
cat > $BOOTMP/boot/boot.txt << _EOF
|
cat > $BOOTMP/boot/boot.txt << _EOF
|
||||||
setenv bootargs 'console=ttyS0,115200n8 vmalloc=384M root=/dev/mmcblk0p2 video=dovefb:lcd0:$VIDEO_MODE-edid clcd.lcd0_enable=1 clcd.
|
setenv bootargs 'console=ttyS0,115200n8 vmalloc=384M root=/dev/mmcblk0p2 video=dovefb:lcd0:$VIDEO_MODE-edid clcd.lcd0_enable=1 clcd.lcd1_enable=0 rootwait'
|
||||||
lcd1_enable=0'
|
|
||||||
echo ======== Loading kernel ========
|
echo ======== Loading kernel ========
|
||||||
ext2load mmc 0:1 0x00200000 /boot/uImage
|
ext2load mmc 0:1 0x00200000 /boot/uImage
|
||||||
echo ======== Booting kernel ========
|
echo ======== Booting kernel ========
|
||||||
@ -311,37 +349,6 @@ _EOF
|
|||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(
|
|
||||||
cd $ROOTMP >/dev/null || {
|
|
||||||
echo "ERROR: unable to access system partition mount point; aborting."
|
|
||||||
umount $PARTITION2
|
|
||||||
rmdir $ROOTMP
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Uncompressing $ROOTFSARCHIVE..."
|
|
||||||
echo -n "This can take a while, please wait..."
|
|
||||||
tar xf $ROOTFSARCHIVE || {
|
|
||||||
echo
|
|
||||||
echo "ERROR: unable to uncompress rootfs archive; aborting."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
echo "DONE"
|
|
||||||
|
|
||||||
if [ "$ADDITIONALARCHIVE" ]; then
|
|
||||||
echo "Uncompressing $ADDITIONALARCHIVE..."
|
|
||||||
echo -n "This can take a while, please wait..."
|
|
||||||
tar xf $ADDITIONALARCHIVE || {
|
|
||||||
echo
|
|
||||||
echo "ERROR: unable to uncompress additional archive; aborting."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
echo "DONE"
|
|
||||||
fi
|
|
||||||
)
|
|
||||||
|
|
||||||
[ $? -eq 0 ] || exit $?
|
|
||||||
|
|
||||||
KERNELDEST=`echo $KERNELDEST | sed "s|@BOOT@|$BOOTMP|g"`
|
KERNELDEST=`echo $KERNELDEST | sed "s|@BOOT@|$BOOTMP|g"`
|
||||||
if [ "$USEKERNEL" ]; then
|
if [ "$USEKERNEL" ]; then
|
||||||
if [ -r $ROOTMP/boot/$USEKERNEL ]; then
|
if [ -r $ROOTMP/boot/$USEKERNEL ]; then
|
||||||
@ -378,12 +385,12 @@ if [ "$PRECHROOTCOMMAND" ]; then
|
|||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$CHROOTCOMMAND" ]; then
|
for c in `seq 1 ${#CHROOTCOMMANDS[*]}`; do
|
||||||
chroot $ROOTMP $CHROOTCOMMAND || {
|
chroot $ROOTMP ${CHROOTCOMMANDS[c-1]} || {
|
||||||
echo "ERROR: error running chroot command; aborting."
|
echo "ERROR: error running chroot command '${CHROOTCOMMANDS[c-1]}'; aborting."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
fi
|
done
|
||||||
|
|
||||||
sync
|
sync
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user