File uboot-image-highbank-install of Package JeOS
#!/bin/bash
set -x
diskname=$1
flavor=highbank
#==========================================
# install Raspberry Pi firmware in FAT partition
#------------------------------------------
if [ -f "boot/vc/bootcode.bin" ]; then
# Changes made here are lost, so we have to (re)mount it rw
# kiwi already uses loop0 for image, so let's mount p1
mkdir ./mnt
mount /dev/mapper/loop0p1 ./mnt
# Copy content of raspberrypi-firmware package
mv boot/vc/* ./mnt
# TODO: replace kernel image with u-boot image
# to keep kernel only on 2nd partition, in /boot
# Copy kernel image
cp boot/linux.vmx ./mnt/zImage
# kernel cmdline must be written to cmdline.txt
echo $KIWI_KERNEL_OPTIONS > ./mnt/cmdline.txt
# config.txt is used to configure the RPi. See: http://elinux.org/RPiconfig
# Maybe move it to a package?
file=Config.txt
cat > ./mnt/$file <<EOF
# Get more options/information on http://elinux.org/RPiconfig
# Our kernel image is named zImage (not kernel.img)
kernel=zImage
# Use 64 MB for GPU for RPi with 256 MB (Min 16 - Max 192 MB)
gpu_mem_256=64
# Use 128 MB for GPU for RPi with 512 MB (Min 16 - Max 448 MB)
gpu_mem_512=128
# Turbo mode: 0 = enable dynamic freq/voltage - 1 = always max
force_turbo=0
# Start in turbo mode for 30 seconds or until cpufreq sets a frequency
initial_turbo=30
# Max ARM freq (default 700 MHz)
arm_freq=840
# Max core (GPU) freq (default 250 MHz)
core_freq=375
# SDRAM freq (default 400)
sdram_freq=400
# DO NOT overvoltage manually to not void warranty!
over_voltage=0
EOF
umount ./mnt
rmdir ./mnt
fi
#==========================================
# install MLO as raw
#------------------------------------------
if [ -f "boot/MLO" ];then
echo "Installing MLO..."
opt="count=1 seek=1 conv=notrunc"
if ! dd if=boot/MLO of=$diskname bs=128k $opt; then
echo "Couldn't install MLO on $diskname"
exit 1
fi
# /.../
# To avoid any issues when parted leaves x86 boot code
# in the MBR we better clear that part of the image
# ----
dd if=/dev/zero of=$diskname bs=440 count=1 conv=notrunc
fi
#==========================================
# install Origen SPL & u-boot as raw
#------------------------------------------
if [ -f "boot/origen-spl.bin" ];then
echo "Installing SPL..."
if ! dd if=boot/origen-spl.bin of=$diskname seek=1 conv=notrunc; then
echo "Couldn't install SPL on $diskname"
exit 1
fi
if ! dd if=boot/u-boot.bin of=$diskname seek=65 conv=notrunc; then
echo "Couldn't install u-boot on $diskname"
exit 1
fi
fi
#==========================================
# install Arndale SPL & u-boot as raw
#------------------------------------------
if [[ -f "boot/smdk5250-spl.bin" || -f "boot/arndale-spl.bin" ]];then
echo "Installing SPL..."
if ! dd if=boot/arndale-bl1.img of=$diskname seek=1 conv=notrunc; then
echo "Couldn't install BL1 on $diskname"
exit 1
fi
# Get SPL name (depends on u-boot version)
SPL_FILE=$(ls boot/*-spl.bin);
if ! dd if=$SPL_FILE of=$diskname seek=17 conv=notrunc; then
echo "Couldn't install SPL ($SPL_FILE) on $diskname"
exit 1
fi
if ! dd if=boot/u-boot.bin of=$diskname seek=49 conv=notrunc; then
echo "Couldn't install u-boot on $diskname"
exit 1
fi
fi
#==========================================
# install Cubieboard SPL & u-boot as raw
#------------------------------------------
if [ -f "boot/sunxi-spl.bin" ];then
echo "Installing SPL..."
if ! dd if=boot/sunxi-spl.bin of=$diskname bs=1024 seek=8 conv=notrunc; then
echo "Couldn't install SPL on $diskname"
exit 1
fi
if ! dd if=boot/u-boot.bin of=$diskname bs=1024 seek=32 conv=notrunc; then
echo "Couldn't install u-boot on $diskname"
exit 1
fi
fi
#==========================================
# install Chromebook u-boot as boot kernel
#------------------------------------------
if [ -e /usr/bin/vbutil_kernel ]; then
pushd /usr/src/packages/KIWIROOT-oem/
echo "console=tty1 debug verbose" > /tmp/config
vbutil_kernel --pack /tmp/newkern \
--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
--version 1 \
--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
--config=/tmp/config --vmlinuz boot/u-boot.img --arch arm
kpartx -av $diskname
dd if=/tmp/newkern of=/dev/mapper/loop0p1
kpartx -d $diskname
cgpt add -t kernel -i 1 -S 1 -T 5 -P 10 -l U-BOOT $diskname
popd
fi
#==========================================
# install i.MX u-boot as raw
#------------------------------------------
if [ -f "boot/u-boot.imx" ];then
pushd /usr/src/packages/KIWIROOT-oem/
echo "Installing u-boot..."
if ! dd if=boot/u-boot.imx of=$diskname bs=512 seek=2 conv=notrunc; then
echo "Couldn't install u-boot on $diskname"
exit 1
fi
popd
fi