scripts/ti-old-omap: Use EvalExAuto / prepare card-kernel-write

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
This commit is contained in:
Andreas Müller
2018-10-02 23:26:43 +02:00
parent 84344f5aec
commit 8bf79ed118
3 changed files with 43 additions and 89 deletions

View File

@@ -16,99 +16,44 @@ DEFAULT_FIND_KERNEL="-name ${DEFAULT_KERNEL_IMAGE_TYPE}-abiversion-* -type l"
RootCardWriteCallback() {
tmpdir=`mktemp -d`
# bootloaders and environment
echo "Writing bootloaders and environment to boot partition"
mount ${DevicePath}1 $tmpdir || exit 1
rm -rf $tmpdir/*
# mount boot partition
EvalExAuto "mount ${DevicePath}1 $tmpdir" "\nMount boot partition ${DevicePath}1 to $tmpdir..."
# clean boot partition
EvalExAuto "rm -rf $tmpdir/*" "\nCleanup boot patition..."
# MLO
if [ -e ${DeployFileDir}/MLO ] ; then
cp ${DeployFileDir}/MLO $tmpdir/MLO
EvalExAuto "cp ${DeployFileDir}/MLO $tmpdir/MLO" "\nCopy MLO (u-boot SPL) boot loader..."
fi
cp ${DeployFileDir}/u-boot.img $tmpdir/u-boot.img
# u-boot
EvalExAuto "cp ${DeployFileDir}/u-boot.img $tmpdir/u-boot.img" "\nCopy u-boot loader..."
# uEnv.txt
if [ -e ${DeployFileDir}/uEnv.txt ] ; then
cp ${DeployFileDir}/uEnv.txt $tmpdir
EvalExAuto "cp ${DeployFileDir}/uEnv.txt $tmpdir" "\nCopy uEnv.txt..."
fi
sleep 1
umount ${DevicePath}1 || exit 1
# unmount boot partition
EvalExAuto "sleep 1 && umount ${DevicePath}1" "\nUnmount boot partition..."
# rootfs
time(
mount ${DevicePath}2 $tmpdir || exit 1
rm -rf $tmpdir/*
# mount rootfs
EvalExAuto "mount ${DevicePath}2 $tmpdir" "\nMount rootfs ${DevicePath}2 to $tmpdir..."
# clean rootfs
EvalExAuto "rm -rf $tmpdir/*" "\nCleanup rootfs..."
olddir=`pwd`
cd $tmpdir
tar xvjf $DeployedFile
cd ..
umount ${DevicePath}2 || exit 1
EvalExAuto "tar xvjf $DeployedFile" "\nExtract rootfs..."
cd "$olddir"
# unmount rootfs
EvalExAuto "sleep 1 && umount ${DevicePath}2" "\nUnmount rootfs..."
)
rm -rf $tmpdir
}
# callback for card-kernel-write
RootCardKernelWriteCallback() {
# TODO
tmpdir=`mktemp -d`
# initial kernel / devicetrees
mount ${DevicePath}1 $tmpdir || exit 1
echo "Write initial kernel and devicetrees to boot partition..."
# kernel (REVISIT for aarch64)
cp -f $DeployedFile $tmpdir/kernel7.img
# devicetrees
rm -f $tmpdir/*.dtb
for dtb in `find ${DeployFileDir} -name "bcm27*.dtb"`; do
cp -f $dtb $tmpdir/
done
echo "${style_green}Write done.${style_normal}"
# devicetree overlays
echo "Write devicetree-overlays to boot partition..."
rm -f $tmpdir/overlays/*.dtbo
for dtbo in `find ${DeployFileDir} -name "*.dtbo"`; do
bname=`basename $dtbo`
if ! echo "${bname}" | grep -q 'Image-'; then
cp -f ${dtbo} $tmpdir/overlays/
fi
done
echo "${style_green}Write done.${style_normal}"
# TODO bootfiles?
echo "Unmount boot partition..."
sleep 1
umount ${DevicePath}1 || exit 1
echo "${style_green}Unmount done.${style_normal}"
# rootfs/boot
mount ${DevicePath}2 $tmpdir || exit 1
echo "Write kernel to rootfs..."
rm -f $tmpdir/boot/${KernelImageType}*
KernelFileName=`basename $DeployedFile`
cp $DeployedFile $tmpdir/boot/
ln -sf $KernelFileName $tmpdir/boot/$KernelImageType
echo "${style_green}Write done.${style_normal}"
# rootfs/lib/modules
echo "Write modules to rootfs..."
kernel_abi_ver=`echo $KernelFileName | sed 's:'${KernelImageType}'-::g'`
rm -rf $tmpdir/lib/modules/$kernel_abi_ver
for modules in `find ${DeployFileDir} -name "modules-${Machine}.tgz"`; do
tar xvzf ${modules} -C $tmpdir/
done
echo "${style_green}Write done.${style_normal}"
# run depmod (stolen from dempodwrapper)
sys_map=`realpath ${OeTmpDir}/pkgdata/${Machine}/kernel-depmod/System.map-$kernel_abi_ver`
echo "Run depmod on modules..."
depmod -a -b $tmpdir -F "$sys_map" "$kernel_abi_ver"
echo "${style_green}Run done.${style_normal}"
# cleanup
echo "Unmount rootfs partition..."
umount ${DevicePath}2 || exit 1
echo "${style_green}Unmount done.${style_normal}"
rm -rf $tmpdir
ErrorOut "Card kernel write for old TI is not yet implemented"
}
CheckPrerequisite "time"
CheckPrerequisite "gunzip"
CheckPrerequisite "dd"

View File

@@ -0,0 +1,14 @@
#! /bin/bash
# ti-old-omap-card-kernel-write.sh
# (c) Copyright 2018 Andreas Müller <schnitzeltony@gmail.com>
# Licensed under terms of GPLv2
#
# This script writes image to sdcard and aligns rootfs partition to max size.
# Includes
. `dirname $0`/include/common-helpers.inc
. `dirname $0`/include/card-helpers.inc
. `dirname $0`/include/machine-ti-old-omap.inc
StartCardKernelWrite

View File

@@ -12,33 +12,28 @@
. `dirname $0`/../tools.inc
# overrride default
# overrride default SelectInOut - we have nothing to deploy here
SelectInOut() {
# DevicePath for target card
SelectCardDevice
RootParams="$DevicePath"
}
# implement here - not im machine-ti-old-omap.inc
RootCardWriteCallback() {
# kill u-boot environment
dd if=/dev/zero of=$DevicePath bs=1024 count=1024
EvalExAuto "dd if=/dev/zero of=$DevicePath bs=1024 count=1024" "\nKill u-boot environment..."
# Create the FAT partition of 64MB and make it bootable
parted -s $DevicePath mklabel msdos
parted -s $DevicePath mkpart primary fat32 63s 64MB
parted -s $DevicePath toggle 1 boot
EvalExAuto "parted -s $DevicePath mklabel msdos && parted -s $DevicePath mkpart primary fat32 63s 64MB && parted -s $DevicePath toggle 1 boot" "\nCreate boot partition..."
# Create the rootfs partition until end of device
parted -s $DevicePath -- mkpart primary ext4 64MB -0
EvalExAuto "parted -s $DevicePath -- mkpart primary ext4 64MB -0" "\nCreate rootfs partition..."
# write partitions
mkfs.vfat -F 32 -n "boot" -I ${DevicePath}1
mke2fs -F -j -t ext4 -L "rootfs" ${DevicePath}2
# create filesystems
EvalExAuto "mkfs.vfat -F 32 -n "boot" -I ${DevicePath}1" "\nCreate boot filesystem..."
EvalExAuto "mke2fs -F -j -t ext4 -L "rootfs" ${DevicePath}2" "\nCreate rootfs filesystem..."
}
CheckPrerequisite "parted"
CheckPrerequisite "dd"
CheckPrerequisite "mkfs.vfat"