From 8ca5fd464d9ca8192102a0f248f860a70d95ea42 Mon Sep 17 00:00:00 2001 From: hackbard Date: Wed, 8 Jul 2015 23:38:35 +0200 Subject: [PATCH] improved uboot and kernel build a bit --- build.config | 25 ++++++---- build.sh | 129 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 116 insertions(+), 38 deletions(-) diff --git a/build.config b/build.config index 615037f..335eba8 100644 --- a/build.config +++ b/build.config @@ -38,24 +38,29 @@ GETTY=ttyO0 # add your packages here ADDPKGS="vim git make gcc lua5.2 golang build-essential kmod" -ADDPKGS="$ADDPKGS net-tools iputils-ping wget openssh-server rsync" +ADDPKGS="$ADDPKGS net-tools iputils-ping iproute2 wget openssh-server rsync" # beagle -ADDPKGS="$ADDPKGS wireless-tools wpasupplicant hostapd" +#ADDPKGS="$ADDPKGS wireless-tools wpasupplicant hostapd" # nellboard -#ADDPKGS="$ADDPKGS python dnsmasq" +ADDPKGS="$ADDPKGS python dnsmasq" # # kernel # # beagleboard +# # use/copy debian linux-image package! +# # nellboard KERVER="2.6.33" KERPATCH="linux-2.6.33_lpc313x-v1.01.patch" KERCONF="ea313x_defconfig" -KERHOOK="sed 's/# CONFIG_DEVTMPFS.*/CONFIG_DEVTMPFS=y/' -i ./arch/arm/configs/ea313x_defconfig;" -KERHOOK="sed 's/# CONFIG_EXT4_FS.*/CONFIG_EXT4_FS=y/' -i ./arch/arm/configs/ea313x_defconfig;" -KERHOOK="$KERHOOK cp ../files/lpc313x/ea313x.c arch/arm/mach-lpc313x/;" +KERHOOK=" + sed 's/# CONFIG_DEVTMPFS.*/CONFIG_DEVTMPFS=y/' -i \ + ./arch/arm/configs/ea313x_defconfig; + sed 's/# CONFIG_EXT4_FS.*/CONFIG_EXT4_FS=y/' -i \ + ./arch/arm/configs/ea313x_defconfig; \ + cp ../files/lpc313x/ea313x.c arch/arm/mach-lpc313x/;" # # u-boot patch and target @@ -64,9 +69,9 @@ UBSRC="git://git.denx.de/u-boot.git" # beagleboard #UBSRC="" #UBPATCH="" -UBCONF=omap3_beagle_config +#UBCONF=omap3_beagle_config # nellboard -#UBVER="v2009.11" -#UBPATCH="u-boot-2009.11_lpc313x-v1.01.patch" -#UBCONF="EA3131_config" +UBVER="v2009.11" +UBPATCH="u-boot-2009.11_lpc313x-v1.01.patch" +UBCONF="EA3131_config" diff --git a/build.sh b/build.sh index 770d170..703a604 100755 --- a/build.sh +++ b/build.sh @@ -5,7 +5,7 @@ function check_prereq() { # read config - [ -f ./config.build ] && . ./config.build + [ -f ./build.config ] && . ./build.config # check tc="gcc-`echo $MAKEOPT | sed 's/.*\ CROSS_COMPILE=\(.*\)-.*/\1/'`" deps=0 @@ -34,7 +34,7 @@ function umount_if_mounted() { function build_all { # read config - [ -f ./config.build ] && . ./config.build + [ -f ./build.config ] && . ./build.config # build stage 1 if [ -f .build_stage1 ]; then echo "stage one already done, skipping ..." @@ -69,7 +69,7 @@ function build_all { fi # copy myself cp -v ./build.sh ./rootfs.mnt - cp -v ./config.build ./rootfs.mnt + cp -v ./build.config ./rootfs.mnt if [ ! -f .build_stage2 ]; then # prepare/run second stage modprobe binfmt_misc @@ -90,13 +90,13 @@ function build_all { touch .build_stage2 # cleanup rm -v ./rootfs.mnt/build.sh - rm -v ./rootfs.mnt/config.build + rm -v ./rootfs.mnt/build.config fi } function build_in_chroot { # read config - [ -f ./config.build ] && . ./config.build + [ -f ./build.config ] && . ./build.config # build second stage echo "building debian image, second stage ..." [ -f /debootstrap/debootstrap ] && \ @@ -141,38 +141,111 @@ function build_in_chroot { # function build_uboot() { - [ -f ./config.build ] && . ./config.build - git clone $UBSRC + echo "building u-boot ..." + echo " argv: $@" + nopatch=0 + noget=0 + update=0 + nocheckout=0 + noclean=0 + no2all=0 + while [ "$1" ]; do + case "$1" in + -nopatch) nopatch=1; shift;; + -noget) noget=1; shift;; + -update) update=1; shift;; + -nocheckout) nocheckout=1; shift;; + -noclean) noclean=1; shift;; + -no2all) no2all=1; shift;; + *) shift;; + esac + done + if [ "$no2all" = "1" ]; then + nopatch=1 + noget=1 + nocheckout=1 + noclean=1 + fi + [ -f ./build.config ] && . ./build.config + if [ "$noget" = "0" ]; then + rm -rf u-boot + git clone $UBSRC + fi + if [ "$update" = "1" ]; then + cd u-boot + git pull + cd .. + fi cd u-boot - if [ ! -z "$UBVER" ]; then - git checkout $UBVER + if [ "$nocheckout" = "0" ]; then + if [ ! -z "$UBVER" ]; then + git checkout $UBVER + fi + fi + if [ "$nopatch" = "0" ]; then + if [ ! -z "$UBPATCH" ]; then + for patch in $UBPATCH; do + patch -Nfp1 < ../patches/$patch + done + fi fi - if [ ! -z "$UBPATCH" ]; then - patch -Nfp1 < ../patches/$UBPATCH + if [ "$noclean" = "0" ]; then + make $MAKEOPT distclean fi - make $MAKEOPT distclean make $MAKEOPT $UBCONF make $MAKEOPT cd .. } function build_kernel() { - [ -f ./config.build ] && . ./config.build + nopatch=0 + noget=0 + nohook=0 + noclean=0 + no2all=0 + while [ "$1" ]; do + case "$1" in + -nopatch) nopatch=1; shift;; + -noget) noget=1; shift;; + -nohook) nohook=1; shift;; + -noclean) noclean=1; shift;; + -no2all) no2all=1; shift;; + *) shift;; + esac + done + if [ "$no2all" = "1" ]; then + nopatch=1 + noget=1 + nohook=1 + noclean=1 + fi + [ -f ./build.config ] && . ./build.config KV=`echo $KERVER | awk -F. '{ if($1=="3") print "3.x" else print$1 "." $2 }'` - KERSRC="https://www.kernel.org/pub/linux/kernel/" - KERSRC="$KERSRC/v$KV/linux-${KERVER}.tar.bz2" - wget $KERSRC - tar xfj linux-${KERVER}.tar.bz2 + if [ "$noget" = "0" ]; then + rm -rf linux-${KERVER}* + KERSRC="https://www.kernel.org/pub/linux/kernel/" + KERSRC="$KERSRC/v$KV/linux-${KERVER}.tar.bz2" + wget $KERSRC + tar xfj linux-${KERVER}.tar.bz2 + fi cd linux-$KERVER - if [ ! -z "$KERPATCH" ]; then - patch -Nfp1 < ../patches/$PATCH + if [ "$nopatch" = "0" ]; then + if [ ! -z "$KERPATCH" ]; then + for patch in $KERPATCH; do + patch -Nfp1 < ../patches/$patch + done + fi + fi + if [ "$noclean" = "0" ]; then + make $MAKEOPT mrproper fi - make $MAKEOPT mrproper - if [ ! -z "$KERHOOK" ]; then - $KERHOOK + if [ "$nohook" = "0" ]; then + if [ ! -z "$KERHOOK" ]; then + $KERHOOK + fi fi if [ ! -z "$KERCONF" ]; then make $MAKEOPT $KERCONF @@ -192,24 +265,24 @@ function build_sdcard() { # # configuration -if [ ! -f ./config.build ]; then +if [ ! -f ./build.config ]; then echo "no configuration found, aborting ..." else - . ./config.build + . ./build.config fi # debootstrap if [ -z $1 ]; then check_prereq - build_all > ./build.log 2>&1 + build_all | tee ./build.log 2>&1 elif [ "$1" = "chroot" ]; then - build_in_chroot > ./build_in_chroot.log 2>&1 + build_in_chroot | tee ./build_in_chroot.log 2>&1 elif [ "$1" = "uboot" ]; then check_prereq - build_uboot > ./build_uboot.log 2>&1 + build_uboot $@ | tee ./build_uboot.log 2>&1 elif [ "$1" = "kernel" ]; then check_prereq - build_kernel > ./build_kernel.log 2>&1 + build_kernel $@ | tee ./build_kernel.log 2>&1 else echo "unknown option: '$1'" fi -- 2.39.2