Hello,
I use a home made tool since the beginnig and during my test it goes
more and more powerful and usefull. through making and using it I've
understood the build process, may it be the same for you. There is
nothing really new in it, it centralize and does everything in one
command (prior settings needed of course) ...
finally i'll name it lbcc.
Lbcc
a script that does build your target machine (ex : VIA config)
and build your rom with log and so on. Heavily refactored
and strenghen to be more portable and robust. Form it
you can control the whole process of making a LinuxBIOS
booting a payload.
It does :
- config LinuxBios
- Log ALL activity
- Calculate build time
- Display rom bindings
- Choose payload
- Configure payload
- Make payload
- Make the rom
- Flash the rom
- Make coffee .. err .. no still not :)
To come :
- Itegrate videobios
some advices :
It needs to be copied into the freebios2/target and it need lb_flash,
think of making symbolic link to it and after to the lbcc generated logs
like buildtaget.log and make.log, etc..
It'll *NEED* some of *YOUR* path fix into its head. If it bugs, think
of this, anyway, find in script bug's exact place. Since this logs
everything think of having a look to theses and often you'll get your
answer (that's the aim of this facility :)
If you are lost into it or troubled with a bug I can reply/explain to
detailed requested.
disclaim:
Actually, this is a comfort and maybe it *couldn't be usefull to
everyone*, ask yourself if some necessary adapt time is worth this ease.
A last number : It is 400 lines of bash script code
any comments, ideas, etc.. reply onto this thread.
Good lxbiosing.
mathieu.
#!/bin/bash
#
#
# Do script: script that does !
#
# NOTES:
# *The payload making process must be the same
# for both roms (BTW, payload lines must be
# the same for normal & fallbac)
# *The payload fetch also assert first payload is
# normal second is fallback
#
# path and way in
VERSION="24/05/04|09:50:26 MD"
FLASHER="/home/root/projet/utils/"
LOG_BUILDTARGET="buildtarget.log"
LOG_BUILDTARGETTEE="buildtarget.log"
LOG_MAKE="make.log"
LOG_MAKETEE="make.log"
#
# Init var. (no edit in here)
#
DATE="date +%F-%T"
NO_LOG=0;T=0;Y=0;BIND_DEBUG=0
TDIR="";BDIR="";NPDIR="";FPDIR="";NPPDIR="";FPPDIR="";NPPT="";FPPT="";
che="";x="";LLL="";DAT="";Z=0;i=0;N="";HARG="";YARG="$*";ERR_DUMP="`tty`"
#
#
# functions & procedures
#
pause () {
[ -z "$1" ] && echo "error in pause() " && exit 1
( [ "$2" -lt 3 ] && i=3 ) || i=$2
echo "PROCEED TO $1 IN $i SECONDS..."
while [ $i -ne 0 ];do
echo -n $i...
sleep 1
T=$?
i=`expr $i - 1`
if [ $T -eq 130 ] ; then
echo "Terminated on user\'s request"
exit 130
fi
done
echo ""
}
log_prepare() {
if [ $NO_LOG -ne 1 ]; then
echo 'Prepare logging facility'
# Log handling and .old'ing previous log
if [ -f "$LOG_BUILDTARGET" ]; then
if [ -f "$LOG_BUILDTARGET.old" ]; then
mv -i "$LOG_BUILDTARGET.old" "$BUILDTARGET.`$DATE`.old";T=$?
else
mv -i "$LOG_BUILDTARGET" "$LOG_BUILDTARGET.old"; T=$?
fi
fi
echo "DO Log v. $VERSION started on `$DATE`" >>"$LOG_BUILDTARGETTEE"
echo "------------------------------------------------------------" >>"$LOG_BUILDTARGETTEE"
echo "Build Directory found as $TDIR/$BDIR" >>"$LOG_BUILDTARGETTEE"
echo "Normal Payload Directory found as $NPPDIR (type : $NPPT)" >>"$LOG_BUILDTARGETTEE"
echo "Fallback Payload Directory found as $FPPDIR (type : $FPPT)">>"$LOG_BUILDTARGETTEE"
echo "------------------------------------------------------------">>"$LOG_BUILDTARGETTEE"
else
echo "No logging..."
fi
}
config_build () {
echo "Editing $TDIR/Config.lb ..."; sleep 1
vim $TDIR/Config.lb
pause "BUILD TARGET" 3
time ./buildtarget $TDIR/Config.lb 2>$ERR_DUMP | tee "$LOG_BUILDTARGETTEE" ||\
(echo "Errors occured.. exiting.";exit 1)
if [ $NO_LOG -ne 1 ]; then
Y=`cat $LOG_BUILDTARGETTEE | grep -i -n -e "warn" | wc -l`
echo "$Y buildtarget warnings" | tee -a "$LOG_BUILDTARGETTEE"
fi
}
rom_binding() {
cd $TDIR/$BDIR
echo "----------------------------------------"
echo "Normal rom sizing value :"
cd normal
cat Makefile.settings | grep -i -e"FALLBACK_SIZE:" -e"ROM_SIZE:" \
-e"ROM_IMAGE_SIZE:" -e"ROM_SECTION_SIZE:" -e "CONFIG_ROM_STREAM_START:"\
-e"PAYLOAD_SIZE:" -e "ROMBASE:" -e"XIP_ROM_BASE:" | tee -a "$LOG_BUILDTARGETTEE"
cd ..
echo "----------------------------------------"
echo "fallback rom sizing value :"
cd fallback
cat Makefile.settings | grep -i -e"FALLBACK_SIZE:" -e"ROM_SIZE:" \
-e"ROM_IMAGE_SIZE:" -e"ROM_SECTION_SIZE:" -e "CONFIG_ROM_STREAM_START:"\
-e"PAYLOAD_SIZE:" -e "ROMBASE:" -e"XIP_ROM_BASE:" | tee -a "$LOG_BUILDTARGETTEE"
cd ..
echo "----------------------------------------"
cd $TOP
}
rom_making() {
cd $TDIR/$BDIR
export LLL=$LANG;export LANG="C";
if [ -f "$LOG_MAKE" ]; then
DAT="`date "+%F %H-%M-%S"`"
mv "$LOG_MAKE" "make $DAT.log"
fi
echo "Cleaning old build..."
make clean 2>$ERR_DUMP
if [ $BIND_DEBUG -eq 1 ]; then
echo "NORMAL BINDINGS" | tee -a "$LOG_MAKETEE"
sleep 1
cd normal
make echo | tee -a "$LOG_MAKETEE" | less
cd ..
echo "FALLBACK BINDINGS" | tee -a "$LOG_MAKETEE"
sleep 1
cd fallback
make echo | tee -a "$LOG_MAKETEE" | less
cd ..
fi
time make 2>$ERR_DUMP | tee -a "$LOG_MAKETEE"
export LANG=$LLL
if [ $NO_LOG -ne 1 ]; then
Z=`cat "$LOG_MAKETEE" | grep -i -n -e "warning" -e "averti" -e "no such" -e "not found" | wc -l `
Z=`expr $Z + 0 `
echo "$Z warnings, avertissements,no such file, not found" | tee -a "$LOG_MAKETEE"
N=`cat "$LOG_MAKETEE" | grep -i -n -e "warn" -e"avert" -e"No such" -e "undefined" |\
grep -e"not used" -e"unused" -e"#warning " -v | wc -l`
echo "-------------------------------------------------" | tee -a "$LOG_MAKETEE"
echo "$N only of theses seems to be relevant :" | tee -a "$LOG_MAKETEE"
cat "$LOG_MAKETEE" | grep -i -n -e "warn" -e"avert" -e"No such" | grep -e"not used"\
-e"unused" -e"#warning " -v | tee -a "$LOG_MAKETEE"
fi
cd $TOP
}
rom_flashing() {
che="`pwd`/$TDIR/$BDIR"
che="`echo $che | tr -s "/"`"
echo "Starting flashing rom : $che/linuxbios.rom..."
echo "Place target bios rom onboard. "
echo " !!! WARNING WARNING !!! ALL IN CHIP DATA WILL BE ERASED !"
echo -n "Continue (y/n) ? "
read rep
if [ "x$rep" != "xy" ]; then
echo "Aborting now !"
echo "No flash done, chip data unchanged ."
else
cd $FLASHER
echo "Erasing chip... Stand by for 40 seconds approx..."
time ./flash_rom -wv /dev/zero; B=$?
[ $B -eq 0 ] || (echo "Error while erasing chip, exiting" && exit 1)
echo "Programming chip... Stand by for 40 seconds approx..."
time ./flash_rom -wv "$che/linuxbios.rom";B=$?
[ $B -eq 0 ] || (echo "Error while programming chip, exiting" && exit 2)
echo -n "All right."
cd $TOP
fi
}
# This is the normal procedure
#
normal_process() {
echo "Normal process stated..."
log_prepare
config_build
# Stage 2 : Editing and making payload
case "$payload_type" in
"filo")
T=`cat $TDIR/Config.lb|grep "CONFIG_FS_STREAM=" | tail -1 |\
cut -f2 -d"="`
Y=`cat $TDIR/Config.lb|grep "CONFIG_ROM_STREAM=" | tail -1 |\
cut -f2 -d"="`
if [ $T -ne 1 ] && [ $Y -ne 1 ]; then
echo " Stop : Filo payload impossible"
echo " Stop : no filo CONFIG strings found in $TDIR/Config.lb"
echo " Stop : example CONFIG_FS_STREAM=1 and/or CONFIG_ROM_STREAM=1"
echo " Early quit"
cd $TOP
exit 5
fi
;;
"null"|'/dev/null'|"none"|"void")
echo " NO PAYLOAD"
sleep 3
;;
esac
# Stage 3 : Rom bindings (mostly here for debug)
pause "ROM BINDING" 10
rom_binding
# Stage 4 : Rom making
pause "*ROM MAKING*" 10
rom_making
# Stage 5 : Rom flashing
pause "!! ROM FLASHING !!" 10
rom_flashing
echo "done."
}
# This is the flash_only procedure
#
flash_only_process() {
echo "Flash_only process stated..."
# Stage 1 : Rom flashing
rom_flashing
echo "done."
}
#
# This is the make_only procedure
#
make_only_process() {
echo "Make_only process stated..."
log_prepare
# Stage 1 : must be hand made.
# Stage 2: Rom bindings (mostly here for debug)
rom_binding
# Stage 3 : Rom making
pause "*ROM MAKING*" 10
rom_making
echo "done."
}
usage() {
echo "usage: $0 target_config.lb_dir action [options]"
echo "actions : -all,-a | --make-only,-m | --flash-only,-f | --payload-only,-p"
echo -e "\t --all,-a\t\t Edit all config files and make them all and flash"
echo -e "\t --make-only,-m\t\t Make ROM only"
echo -e "\t --flash-only,-f\t Flash a linuxbios ROM"
echo -e "\t --payload-only,-p\t Make payload only"
echo "[options], --no-log,-n --bind-debug,-b --err-dump,-e"
echo "v.$VERSION Mathieu Deschamps for Mangrove-systems"
}
#
# Arg validates ?
#
#
if [ -z "$1" ]; then
usage
exit 0
fi
if [ ! -d $1 -o ! -f $1/Config.lb ]; then
echo "$1 is no a target directory"
echo "I can't find any $1/Config.lb"
echo -e "\n\n"
usage
exit 1
fi
TDIR="$1"
TOP="`pwd`"
# find BUILD directory in config.lb (target field)
BDIR=`cat $TDIR/Config.lb|grep "target " |tail -1 |\
cut -f1-2 -d" "|grep "target"|cut -f2 -d" " `
# find PAYLOAD directory in config.lb (payload field)
# remplaceer par
# gets the normal payload answer is for example "payload /dev/null"
#cat via/epia/Config.lb|grep "payload "| cut -f1 -d"#"| tr -s "\n" | grep payload | tr -d "\n" | cut -f2 | cut -f2
# gets the fallback payload
#cat via/epia/Config.lb|grep "payload "| cut -f1 -d"#"| tr -s "\n" | grep payload | tr -d "\n" | cut -f3 | cut -f2
NPPDIR=`cat $TDIR/Config.lb|grep "payload "| cut -f1 -d"#"| tr -s "\n" | grep payload | tr -d "\n" | cut -f2 | cut -f2 -d" "`
FPPDIR=`cat $TDIR/Config.lb|grep "payload "| cut -f1 -d"#"| tr -s "\n" | grep payload | tr -d "\n" | cut -f3 | cut -f2 -d" "`
# get from thoses dirnames
NPDIR=`dirname $NPPDIR`
FPDIR=`dirname $FPPDIR`
# Get payload types
NPPT="`cat via/epia/Config.lb|grep "##payload_type"| tr "\n" ":"| cut -f1 -d":"| cut -f2 -d"="`"
FPPT="`cat via/epia/Config.lb|grep "##payload_type"| tr "\n" ":"| cut -f2 -d":"| cut -f2 -d"="`"
echo "Build Directory found as $TDIR/$BDIR"
echo "Normal Payload Directory found as $NPPDIR (type : $NPPT)"
echo "Fallback Payload Directory found as $FPPDIR (type : $FPPT)"
pause "INIT PROCESS " 5
if [ -z $BDIR ]; then
echo "Fatal : Couldn't find target field in $TDIR/Config.lb"
exit 4
fi
if [ -z $NPDIR ]; then
echo "Fatal : Couldn't find normal payload field in $TDIR/Config.lb"
exit 3
fi
if [ -z $FPDIR ]; then
echo "Fatal : Couldn't find fallback payload field in $TDIR/Config.lb"
exit 3
fi
if [ "x$NPPT" = "x" ] || [ "x$FPPT" = "x" ]; then
echo "Fatal : Couldn't retrieve the 2 payload_type string in $TDIR/Config.lb"
echo "(e.g ##payload_type=null)"
fi
payload_type=$NPPT
# Get the options to do something
i=0
for x in $YARG; do
if [ $i -ge 2 ]; then
case "$x" in
--no-log|-n)
LOG_MAKETEE="/dev/null"
LOG_BUILDTARGETTEE="/dev/null"
NO_LOG=1
;;
--bind-debug|-b)
BIND_DEBUG=1
;;
--err-dump|-e)
echo "Special compilation error dumping to what tty ?"
echo "example : /dev/pts/1"
echo -n "so ? "
read gh
T=`ls $gh >/dev/null;echo $?`
if [ $T -eq 0 ]; then
ERR_DUMP="$gh"
echo Dumpng ALL error to $ERR_DUMP...
else
echo "Impossible to do that... dump as normal (on this term)"
ERR_DUMP="`tty`"
fi
;;
*)
echo "Warning : unknown parameter $x..."
;;
esac
fi
i=` expr $i + 1`
done
if [ $NO_LOG -ne 1 ]; then
echo "Build target log : `pwd`/$TDIR/"$LOG_MAKE""
echo "Rom making log : `pwd`/$TDIR/$BDIR/"$LOG_MAKE""
if [ $NPPDIR != "/dev/null" ] || [ $FPPDIR != "/dev/null" ]; then
echo "Payload making log : `pwd`/$NPDIR/"$LOG_MAKE""
else
echo "Payload making log : <none>"
fi
fi
# Fetch the action command
HARG="$2"
case "$HARG" in
--all|-a)
normal_process
;;
--make-only|-m)
make_only_process
echo "Rom making log : `pwd`/$TDIR/$BDIR/"$LOG_MAKE""
;;
--flash-only|-f)
flash_only_process
;;
--payload-only|-p)
echo "Nothing for now"
echo "To get filo to be the payload just put CONFIG_FS_STREAM=1 \\
and/or CONFIG_ROM_STREAM=1 in Config.lbi"
echo This option is intended to build external payload solution
echo "Payload making log : `pwd`/$NPDIR/"$LOG_MAKE""
;;
*)
echo "Fatal : No action specified"
exit 5
;;
esac