rootfsinstall: support for rpi2

This commit is contained in:
Silvan Calarco 2015-03-01 21:15:18 +01:00
parent 609ab12204
commit 74b2fad4e0

View File

@ -25,6 +25,7 @@ function usage() {
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"
echo "-k2 kernel : extract and use specified second kernel file from ROOTFS/boot/ for boot"
echo "-i packages : install packages using package manager in chroot"
echo "-p password : set given password for root user"
echo "-r mode : set given default video mode where applicable (e.g. -r 1920x1080-32@60)"
@ -84,6 +85,13 @@ while [ "$1" ]; do
USEKERNEL=$2
shift
;;
-k2) [ "$2" ] || {
echo "Error: -k2 option requires a kernel file name as argument; aborting."
exit 1
}
USEKERNEL2=$2
shift
;;
-h) [ "$2" ] || {
echo "Error: -h option requires a hostname as argument; aborting."
exit 1
@ -150,9 +158,12 @@ case $TARGETDEVICE in
BOOTFSTYPE=fat32
BOOTFSSIZE=40M
BOOTFSSTART=0
[ "$USEKERNEL" ] || USEKERNEL=zImage-3.6.11-rpi
[ "$USEKERNEL" ] || USEKERNEL="zImage-*-rpi"
[ "$USEKERNEL2" ] || USEKERNEL="zImage-*-rpi2"
KERNELDEST="@BOOT@/kernel.img"
KERNELDEST2="@BOOT@/kernel7.img"
INSTALLPACKAGES="kernel-rpi kernel-rpi-modules raspberrypi-firmware \
kernel-rpi2 kernel-rpi2-modules \
raspberrypi-utils raspi-config $INSTALLPACKAGES"
;;
cubox) ARCH=arm
@ -183,6 +194,7 @@ echo "Target SD card : ${DRIVE}"
[ "$BOOTFSTYPE" ] && echo "Boot fs : $BOOTFSTYPE($BOOTFSSIZE)"
[ "$BOOTFSTYPE" ] && echo "System fs : $SYSTEMFSTYPE"
[ "$USEKERNEL" ] && echo "Kernel : $USEKERNEL -> $KERNELDEST"
[ "$USEKERNEL2" ] && echo "Second kernel : $USEKERNEL2 -> $KERNELDEST2"
echo
[ "$ASSUMEYES" ] || {
@ -323,6 +335,9 @@ if [ "$INSTALLPACKAGES" ]; then
mv $ROOTMP/etc/resolv.conf.rootfsinstall $ROOTMP/etc/resolv.conf
fi
KERNELDEST=`echo $KERNELDEST | sed "s|@BOOT@|$BOOTMP|g"`
KERNELDEST2=`echo $KERNELDEST2 | sed "s|@BOOT@|$BOOTMP|g"`
#
# Prepare boot partition
#
@ -341,38 +356,22 @@ _EOF
:
elif [ "$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
RPI_FIRMWARE_FILES="bootcode.bin fixup_x.dat start_x.elf \
bcm2708-rpi-b-plus.dtb bcm2708-rpi-b-plus.dtb bcm2709-rpi-2-b.dtb"
for f in $RPI_FIRMWARE_FILES; do
if [ -e $ROOTMP/boot/$f ]; then
cp $ROOTMP/boot/$f $BOOTMP/$f
done
IMAGE=`ls $ROOTMP/boot/zImage-*-rpi | head -n 1`
cp $IMAGE $BOOTMP/kernel.img
else
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 "ERROR: firmware file $f for rpi is missing in /boot directory; aborting."
exit 1
fi
# 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
done
if [ -e $ROOTMP/boot/overlays ]; then
cp -a $ROOTMP/boot/overlays $BOOTMP/
fi
# IMAGE=`ls $ROOTMP/boot/$USEKERNEL | head -n 1`
cp $ROOTMP/boot/$USEKERNEL $KERNELDEST
cp $ROOTMP/boot/$USEKERNEL2 $KERNELDEST2
# cmdline.txt : parameters passed to the kernel on boot
echo "\
@ -385,14 +384,18 @@ splash" > $BOOTMP/cmdline.txt
# Create the kernel configuration file
echo "\
start_file=start_x.elf
fixup_file=fixup_x.dat
framebuffer_depth=32
framebuffer_ignore_alpha=1
[rp1]
arm_freq=800
force_turbo=1
gpu_mem=100
disable_overscan=1
start_file=start_x.elf
fixup_file=fixup_x.dat
framebuffer_depth=32
framebuffer_ignore_alpha=1" > $BOOTMP/config.txt
[rp2]
gpu_mem=128
" > $BOOTMP/config.txt
## Enable HDMI mode rather than DVI, if required
#echo "\
@ -405,11 +408,6 @@ framebuffer_ignore_alpha=1" > $BOOTMP/config.txt
# vlls directory: Additional GPU code, e.g. extra codecs.
# Not present in the initial release.
if [ ! "$USEKERNEL" ]; then
# copy kernel modules
mkdir -p $ROOTMP/lib/modules
cp -a $SWHOME/firmware/modules/* $ROOTMP/lib/modules/
fi
[ "$SWHOME" -a "${SWHOME:0:4}" = "/tmp" ] && rm -rf $SWHOME
elif [ "$TARGETDEVICE" = "cubox" ]; then
@ -435,7 +433,6 @@ _EOF
fi
fi
KERNELDEST=`echo $KERNELDEST | sed "s|@BOOT@|$BOOTMP|g"`
if [ "$USEKERNEL" ]; then
if [ -r $ROOTMP/boot/$USEKERNEL ]; then
cp $ROOTMP/boot/$USEKERNEL $KERNELDEST || {