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 "-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 "-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 "-h hostname : set given hostname"
|
||||
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."
|
||||
exit 1
|
||||
}
|
||||
CHROOTCOMMAND=$2
|
||||
CHROOTCOMMANDS[${#CHROOTCOMMANDS[*]}]="$2"
|
||||
shift
|
||||
;;
|
||||
-cp) [ "$2" ] || {
|
||||
@ -229,31 +229,70 @@ if [ "$BOOTFSTYPE" ]; then
|
||||
}
|
||||
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
|
||||
SWHOME=`mktemp -d`
|
||||
echo "Cloning firmware repository from git..."
|
||||
cd $SWHOME
|
||||
git clone git://github.com/raspberrypi/firmware.git --depth=1
|
||||
else
|
||||
echo "Fetching firmware boot files from git..."
|
||||
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
|
||||
)
|
||||
|
||||
# bootcode.bin: 2nd stage bootloader, starts with SDRAM disabled
|
||||
# loader.bin : 3rd stage bootloader, starts with SDRAM enabled
|
||||
# start.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
|
||||
[ $? -eq 0 ] || exit $?
|
||||
|
||||
if [ "$TARGETDEVICE" = "rpi" ]; then
|
||||
# fetch and install firmware files if missing
|
||||
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
|
||||
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
|
||||
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."
|
||||
}
|
||||
echo "Fetching firmware boot files from git..."
|
||||
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
|
||||
echo "\
|
||||
@ -298,8 +337,7 @@ 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:$VIDEO_MODE-edid clcd.lcd0_enable=1 clcd.
|
||||
lcd1_enable=0'
|
||||
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'
|
||||
echo ======== Loading kernel ========
|
||||
ext2load mmc 0:1 0x00200000 /boot/uImage
|
||||
echo ======== Booting kernel ========
|
||||
@ -311,37 +349,6 @@ _EOF
|
||||
}
|
||||
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"`
|
||||
if [ "$USEKERNEL" ]; then
|
||||
if [ -r $ROOTMP/boot/$USEKERNEL ]; then
|
||||
@ -378,12 +385,12 @@ if [ "$PRECHROOTCOMMAND" ]; then
|
||||
}
|
||||
fi
|
||||
|
||||
if [ "$CHROOTCOMMAND" ]; then
|
||||
chroot $ROOTMP $CHROOTCOMMAND || {
|
||||
echo "ERROR: error running chroot command; aborting."
|
||||
for c in `seq 1 ${#CHROOTCOMMANDS[*]}`; do
|
||||
chroot $ROOTMP ${CHROOTCOMMANDS[c-1]} || {
|
||||
echo "ERROR: error running chroot command '${CHROOTCOMMANDS[c-1]}'; aborting."
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
done
|
||||
|
||||
sync
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user