cyb4_linux/mkrescue

92 lines
2.3 KiB
Bash

#!/bin/bash
# Qisda, Howard Hsu,2009/12/16
# Move the actual make kernel steps to RescueFS/src/dlfw/mkzImage
# 1) Only do below two steps here:
# 3.Cat kernel with pre-made rescue file system.
# 4.Pad the zeros to 4-byte boundar
# 2) change first command line parameter to "project name"
#
# Qisda,Howard Hsu,2009/11/18
# The script is used to create rescue.bin under ./arch/arm/boot/
# Steps:
# 1. Take rescue config and make its kernel
# 2. Pad the zeros to kernel up to 1586688 bytes
# 3. Cat kernel with pre-made rescue file system.
# 4. Pad the zeros to 4-byte boundary,
# the resulted is rescue.bin under ./arch/arm/boot/
#
# arguments: "skip" : do not remake the kernel, directly do rescue.bin packing
#
# Qisda,Howard Hsu,2009/11/20
# restore the original .config to avoid affect the original kernel build .config
# input
# this file should be executable
# output: rescue.bin
rescueBin=./arch/arm/boot/rescue.bin
# input: two files
# 1-FS
rescueFs=../RescueFS/img/urootfs.img
let projectbuild=0
# 2-Kernel, decide
supportProjs=( qd060b00_movi bq060b00 sh060b00 qd090b00 as090b00 st060b00 )
if [ $# ne 1 ]; then
echo "usage: $0 (600 | 900 | project_name)"
exit 1;
else
currProj=$1
for name in ${supportProjs[@]}
do
echo "check for $name proj"
if [ $currProj == $name ]; then
echo "$currProj is supported"
if [ -f "../RescueFS/img/uzImage_$currProj" ]; then
rescueKernel="../RescueFS/img/uzImage_$currProj"
else
if [[ $currProj =~ 060 ]]; then
rescueKernel=../RescueFS/img/uzImage600
else
rescueKernel=../RescueFS/img/uzImage900
fi
fi
projectbuild=1
break
fi
done
if [ "$currProj" == "skip" ]; then
echo "temp workaround for skip option"
rescueKernel=../RescueFS/img/uzImage600
projectbuild=1
fi
fi
if [ "$projectbuild" -ne "1" ]; then
echo "Invalid proj name: $currProj"
echo "supported projs: ${supportProjs[@]}"
fi
# intermediate
if [ ! -f "$rescueFs" ]; then
echo "$rescueFs does not exist!!!"
exit 1;
fi
if [ ! -f "$rescueKernel" ]; then
echo "$rescueKernel does not exist!!!"
exit 1;
fi
echo "cat kernel($rescueKernel) and Fs into rescue.bin"
cat $rescueKernel $rescueFs > $rescueBin
size=$(stat -c%s "$rescueBin")
let padzero=4-size%4
if [ padzero != 0 ]; then
echo "step4: need $padzero to 4-byte align"
dd if=/dev/zero of=./zero.bin bs=$padzero count=1
cat ./zero.bin >> $rescueBin
rm ./zero.bin
fi