File uboot-image-highbank-setup of Package JeOS
#!/bin/bash
set -x
flavor=highbank
target=firstboot
kerneladdr=
ramdiskaddr=
case $target in
firstboot)
conf=boot/boot.script
binconf=boot/boot.scr
kernel=boot/linux.vmx
initrd=boot/initrd.uboot
# the kernel command line is already prepopulated
bootargs=
;;
boot)
hookName=$1 # name of hook script calling this code
mountPrefix=$2 # mount path of the image
destsPrefix=$3 # base dir for the config files
unum=$4 # boot partition ID
rdev=$5 # root partition
ufix=$6 # title postfix
swap=$7 # optional swap partition
conf=$destsPrefix/boot/boot.script
binconf=$destsPrefix/boot/boot.script
#======================================
# make sure conf dir exists
#--------------------------------------
mkdir -p $destsPrefix/boot
#======================================
# check for device by ID
#--------------------------------------
local diskByID=`getDiskID $rdev`
local swapByID=`getDiskID $swap swap`
#======================================
# check for system image .profile
#--------------------------------------
if [ -f $mountPrefix/image/.profile ];then
importFile < $mountPrefix/image/.profile
fi
#======================================
# check for kernel options
#--------------------------------------
if [ ! -z "$kiwi_cmdline" ];then
KIWI_KERNEL_OPTIONS="$KIWI_KERNEL_OPTIONS $kiwi_cmdline"
fi
# /.../
# On other systems which supports a boot menu we add
# the linux kernel and initrd with its file names
# like this:
#
# kernel=`echo $i | cut -f1 -d:`
# initrd=`echo $i | cut -f2 -d:`
#
# But on arm systems there can only be one kernel because
# uboot doesn't support a menu. Thus perl-bootloader also
# doesn't support updating the uboot configuration and
# that's the reason why we use the links created by
# mkinitrd to point to the kernel and initrd in order
# to support kernel updates
# ----
kernel=uImage
initrd=initrd
# gather kernel command line
bootargs="root=$diskByID loader=$loader"
if [ "$imageDiskDevice" ];then
bootargs="$bootargs disk=$(getDiskID $imageDiskDevice)"
fi
if [ "$swap" ];then
bootargs="$bootargs resume=$swapByID"
fi
if [ "$haveLVM" = "yes" ];then
bootargs="$bootargs VGROUP=$VGROUP"
fi
bootargs="$bootargs $KIWI_INITRD_PARAMS"
bootargs="$bootargs $KIWI_KERNEL_OPTIONS"
# start with a fresh config
true > $conf
;;
*)
echo "Unknown target $target" >&2
exit 1
;;
esac
bootdevs=mmc
units="0"
bootparts='${unit}:1'
boottype=bootz
setdev='mmc dev ${unit}'
sizeprefix=0x
case $flavor in
beagle)
# TODO: update u-boot to be able to use DT for beagle and check if nothing is missing
kerneladdr=0x80200000
ramdiskaddr=0x81000000
# fdtaddr=0x80F80000
# should_use_fdt=1
# should_load_fdt=1
# fdtfile=call_findfdt
;;
beaglebone)
kerneladdr=0x80200000
ramdiskaddr=0x81000000
fdtaddr=0x80F80000
should_use_fdt=1
should_load_fdt=1
fdtfile=call_findfdt
;;
panda)
should_use_fdt=1
should_load_fdt=1
kerneladdr=0x80000000
ramdiskaddr=0x82000000
fdtaddr=0x80F80000
fdtfile=call_findfdt
;;
highbank|midway)
bootdevs=scsi
should_use_fdt=1
setdev=1
# Highbank's u-boot already prepends 0x to the file size
sizeprefix=
# And calls the variable $fdt_addr rather than $fdtaddr
use_fdt_addr=1
;;
cubox)
boottype=bootm
kerneladdr=0x2000000
ramdiskaddr=0x5000000
;;
melea1000|cubieboard)
boottype=bootm
kerneladdr=0x48000000
ramdiskaddr=0x43100000
should_load_fdt=1
fdtfile=$flavor.bin
fdtaddr=0x43000000
;;
loco)
kerneladdr=0x70800000
ramdiskaddr=0x7e000000
fdtaddr=0x7d800000
should_use_fdt=1
should_load_fdt=1
units="0 1"
fdtfile=dtb/imx53-qsb.dtb
;;
arndale)
kerneladdr=0x40007000
ramdiskaddr=0x44000000
fdtaddr=0x42000000
boottype=bootm
units="0 1" # 0: is internal memory or USB stick - 1: is SD card
should_use_fdt=1
should_load_fdt=1
fdtfile=dtb/exynos5250-arndale.dtb
;;
chromebook)
kerneladdr=0x40007000
ramdiskaddr=0x44000000
fdtaddr=0x42000000
boottype=bootm
bootdevs="mmc usb"
units="0 1" # 0: is internal memory or USB stick - 1: is SD card
bootparts='${unit}:2'
should_use_fdt=1
should_load_fdt=1
fdtfile=dtb/exynos5250-snow.dtb
;;
sabrelite)
kerneladdr=0x10008000
ramdiskaddr=0x14000000
fdtaddr=0x12000000
bootdevs="mmc usb"
units="0 1" # 0: is SD3 (bottom) slot - 1: is uSD4 (top) slot
should_use_fdt=1
should_load_fdt=1
fdtfile=dtb/imx6q-sabrelite.dtb
;;
esac
# override zImage file names
if [ $boottype = bootz -a $target = boot ]; then
kernel=zImage
fi
initrd_high=0xffffffff
fdt_high=0xffffffff
# copy bash variables into boot script
for variable in kernel initrd fdtfile flavor target bootargs bootdevs bootparts \
initrd_high fdt_high boottype kerneladdr ramdiskaddr should_use_fdt \
should_load_fdt fdtaddr setdev units sizeprefix use_fdt_addr; do
value=$(eval "echo $(echo \$$variable)")
# only set variables that contain data, leave the others alone
if [ "$value" ]; then
echo "setenv $variable '$value'" >> $conf
fi
done
cat >> $conf <<-"EOF"
printenv kerneladdr || setenv kerneladdr ${kernel_addr_r}
printenv ramdiskaddr|| setenv ramdiskaddr ${ramdisk_addr_r}
setenv load_kernel 'ext2load ${bootdev} ${bootpart} ${kerneladdr} ${kernel}'
setenv load_initrd 'ext2load ${bootdev} ${bootpart} ${ramdiskaddr} ${initrd}; setenv rd_filesize ${sizeprefix}${filesize}'
if itest 1${should_load_fdt} == 11; then
if test 0${fdtfile} = 0call_findfdt; then
run findfdt
setenv fdtfile dtb/${fdtfile}
fi
setenv loadfdt 'ext2load ${bootdev} ${bootpart} ${fdtaddr} ${fdtfile}'
else
setenv loadfdt ''
fi
if itest 1${use_fdt_addr} == 11; then
# Calxeda systems use $fdt_addr rather than $fdtaddr
setenv fdtaddr $fdt_addr
fi
if itest 1${should_use_fdt} == 11; then
setenv boot_kernel '${boottype} ${kerneladdr} ${ramdiskaddr}:${rd_filesize} ${fdtaddr}'
else
setenv boot_kernel '${boottype} ${kerneladdr} ${ramdiskaddr}:${rd_filesize}'
fi
setenv doit 'if run load_kernel; then; run load_initrd; run loadfdt; run boot_kernel; fi'
setenv bootcmd 'for bootdev in ${bootdevs}; do for unit in ${units}; do setenv bootpart; for bootpart in ${bootparts}; do setenv fix_bootpart "setenv bootpart $bootpart"; run fix_bootpart; run setdev; run doit; done; done; done'
boot
EOF
#==========================================
# Create machine readable uboot format
# (only during image creation)
#------------------------------------------
if [ -x /usr/bin/mkimage -a "$target" = firstboot ];then
mkopts="-A arm -O linux -a 0 -e 0 -T script -C none";
if ! mkimage $mkopts -n 'Boot-Script' -d $conf $binconf;then
echo "Failed to create uboot script image"
exit 1
fi
fi
#==========================================
# install Cubieboard script.bin
#------------------------------------------
if [ "$flavor" = "cubieboard" ]; then
echo "installing Cubieboard bin"
install -m 0644 /usr/share/sunxi-boards/a10/cubieboard.bin boot/cubieboard.bin
fi
set +x