truly enforce COMPILE + various optimization and cleanup

This commit is contained in:
Gwenhael Le Moine 2014-02-27 23:11:40 +01:00
parent 7ed9cd2b99
commit 0e846d6423

182
build.sh
View file

@ -8,7 +8,7 @@ IMG_NAME=${IMG_NAME:-"SlackwareARM_cubitruck"}
VERSION=${VERSION:-0.2} VERSION=${VERSION:-0.2}
COMPILE=${COMPILE:-"true"} COMPILE=${COMPILE:-"true"}
DEST=${DEST:-~/cubieslack} DEST=${DEST:-~/cubieslack}
DISPLAY=${DISPLAY:-"HDMI"} # "HDMI" or "VGA" CUBIETRUCK_DISPLAY=${CUBIETRUCK_DISPLAY:-"HDMI"} # "HDMI" or "VGA"
IMAGE_SIZE_MB=${IMAGE_SIZE_MB:-2000} IMAGE_SIZE_MB=${IMAGE_SIZE_MB:-2000}
SLACKWARE_VERSION=${SLACKWARE_VERSION:-14.1} SLACKWARE_VERSION=${SLACKWARE_VERSION:-14.1}
ROOTFS_VERSION=${ROOTFS_VERSION:-04Nov13} ROOTFS_VERSION=${ROOTFS_VERSION:-04Nov13}
@ -26,51 +26,49 @@ if [ "$UID" -ne 0 ]; then
fi fi
echo "Building Cubietruck-Slackware in $DEST from $CWD" echo "Building Cubietruck-Slackware in $DEST from $CWD"
sleep 3
#-------------------------------------------------------------------------------- echo "--------------------------------------------------------------------------------"
# Downloading necessary files for building - aka Toolchain echo "Downloading necessary files for building - aka Toolchain"
#-------------------------------------------------------------------------------- echo "--------------------------------------------------------------------------------"
echo "------ Downloading cross-compiler"
#Read this for further information if you run into problems with gcc compiler #Read this for further information if you run into problems with gcc compiler
#http://linux-sunxi.org/Toolchain #http://linux-sunxi.org/Toolchain
if [ ! -e $PWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux/ ]; then
wget -c https://launchpadlibrarian.net/$TOOLCHAIN_URL_RANDOM_NUMBER/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz -O $CWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz [ ! -e $CWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz ] && wget -c https://launchpadlibrarian.net/$TOOLCHAIN_URL_RANDOM_NUMBER/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz -O $CWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz
tar xf $CWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz tar xf $CWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz
fi
CROSS_COMPILE=$PWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux/bin/arm-linux-gnueabihf- CROSS_COMPILE=$PWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux/bin/arm-linux-gnueabihf-
#-------------------------------------------------------------------------------- echo "--------------------------------------------------------------------------------"
# Preparing output / destination files echo "Clone / Pull sources and patch"
#-------------------------------------------------------------------------------- echo "--------------------------------------------------------------------------------"
echo "------ Clone / Pull sources and patch"
mkdir -p $DEST/output mkdir -p $DEST/output
cp output/uEnv.txt $DEST/output
# Boot loader if [ "$COMPILE" = "true" ]; then
if [ -d "$DEST/u-boot-sunxi" ]; then # Boot loader
if [ -d "$DEST/u-boot-sunxi" ]; then
( cd $DEST/u-boot-sunxi; ( cd $DEST/u-boot-sunxi;
git pull ) git pull )
else else
git clone https://github.com/cubieboard/u-boot-sunxi $DEST/u-boot-sunxi git clone https://github.com/cubieboard/u-boot-sunxi $DEST/u-boot-sunxi
# Applying Patch for 2gb memory # Applying Patch for 2gb memory
patch -f $DEST/u-boot-sunxi/include/configs/sunxi-common.h < $CWD/patch/memory.patch || true patch -f $DEST/u-boot-sunxi/include/configs/sunxi-common.h < $CWD/patch/memory.patch || true
fi fi
# Allwinner tools # Allwinner tools
if [ -d "$DEST/sunxi-tools" ]; then if [ -d "$DEST/sunxi-tools" ]; then
( cd $DEST/sunxi-tools; ( cd $DEST/sunxi-tools;
git pull ) git pull )
else else
git clone https://github.com/linux-sunxi/sunxi-tools.git $DEST/sunxi-tools git clone https://github.com/linux-sunxi/sunxi-tools.git $DEST/sunxi-tools
fi fi
# Hardware configurations # Hardware configurations
if [ -d "$DEST/cubie_configs" ]; then if [ -d "$DEST/cubie_configs" ]; then
( cd $DEST/cubie_configs; ( cd $DEST/cubie_configs;
git pull ) git pull )
else else
git clone https://github.com/cubieboard/cubie_configs $DEST/cubie_configs git clone https://github.com/cubieboard/cubie_configs $DEST/cubie_configs
# Applying Patch for high load. Could cause troubles with USB OTG port # Applying Patch for high load. Could cause troubles with USB OTG port
@ -79,46 +77,36 @@ else
# Prepare fex files for VGA & HDMI # Prepare fex files for VGA & HDMI
sed -e 's/screen0_output_type.*/screen0_output_type = 3/g' $DEST/cubie_configs/sysconfig/linux/ct.fex > $DEST/cubie_configs/sysconfig/linux/ct-hdmi.fex sed -e 's/screen0_output_type.*/screen0_output_type = 3/g' $DEST/cubie_configs/sysconfig/linux/ct.fex > $DEST/cubie_configs/sysconfig/linux/ct-hdmi.fex
sed -e 's/screen0_output_type.*/screen0_output_type = 4/g' $DEST/cubie_configs/sysconfig/linux/ct.fex > $DEST/cubie_configs/sysconfig/linux/ct-vga.fex sed -e 's/screen0_output_type.*/screen0_output_type = 4/g' $DEST/cubie_configs/sysconfig/linux/ct.fex > $DEST/cubie_configs/sysconfig/linux/ct-vga.fex
fi fi
# Patwood's kernel 3.4.75+ # Patwood's kernel 3.4.75+
if [ -d "$DEST/linux-sunxi" ]; then if [ -d "$DEST/linux-sunxi" ]; then
( cd $DEST/linux-sunxi; ( cd $DEST/linux-sunxi;
git pull -f ) git pull -f )
else else
git clone https://github.com/patrickhwood/linux-sunxi $DEST/linux-sunxi git clone https://github.com/patrickhwood/linux-sunxi $DEST/linux-sunxi
fi
fi fi
#-------------------------------------------------------------------------------- echo "--------------------------------------------------------------------------------"
# Compiling everything echo "Compiling everything"
#-------------------------------------------------------------------------------- echo "--------------------------------------------------------------------------------"
echo "------ Compiling kernel boot loaderb"
# Copying Kernel config
cp $CWD/config/kernel.config $DEST/linux-sunxi/
echo "------ Compiling boot loader"
cd $DEST/u-boot-sunxi
make clean
make -j2 'cubietruck' CROSS_COMPILE=$CROSS_COMPILE
make HOSTCC=gcc CROSS_COMPILE='' tools
PATH=$PATH:$DEST/u-boot-sunxi/tools/
echo "------ Compiling sunxi tools"
cd $DEST/sunxi-tools
make clean fex2bin bin2fex
mkdir -p $CWD/bin/
cp fex2bin bin2fex $CWD/bin/
# hardware configuration
$CWD/bin/fex2bin $DEST/cubie_configs/sysconfig/linux/ct-vga.fex $DEST/output/script-vga.bin
$CWD/bin/fex2bin $DEST/cubie_configs/sysconfig/linux/ct-hdmi.fex $DEST/output/script-hdmi.bin
echo "------ Compiling kernel"
if [ "$COMPILE" = "true" ]; then if [ "$COMPILE" = "true" ]; then
# kernel image echo "------ Compiling boot loader"
cd $DEST/u-boot-sunxi
make clean
make -j2 'cubietruck' CROSS_COMPILE=$CROSS_COMPILE
make HOSTCC=gcc CROSS_COMPILE='' tools
echo "------ Compiling sunxi tools"
cd $DEST/sunxi-tools
make clean
make fex2bin bin2fex
PATH=$PATH:$DEST/u-boot-sunxi/tools/
echo "------ Compiling kernel" echo "------ Compiling kernel"
cd $DEST/linux-sunxi cd $DEST/linux-sunxi
make clean make clean
@ -130,26 +118,29 @@ if [ "$COMPILE" = "true" ]; then
make -j2 ARCH=arm CROSS_COMPILE=$CROSS_COMPILE sun7i_defconfig make -j2 ARCH=arm CROSS_COMPILE=$CROSS_COMPILE sun7i_defconfig
# get proven config # get proven config
cp $DEST/linux-sunxi/kernel.config $DEST/linux-sunxi/.config cp $CWD/config/kernel.config $DEST/linux-sunxi/.config
make -j2 ARCH=arm CROSS_COMPILE=$CROSS_COMPILE uImage modules make -j2 ARCH=arm CROSS_COMPILE=$CROSS_COMPILE uImage modules
make -j2 ARCH=arm CROSS_COMPILE=$CROSS_COMPILE INSTALL_MOD_PATH=output modules_install make -j2 ARCH=arm CROSS_COMPILE=$CROSS_COMPILE INSTALL_MOD_PATH=output modules_install
make -j2 ARCH=arm CROSS_COMPILE=$CROSS_COMPILE INSTALL_HDR_PATH=output headers_install make -j2 ARCH=arm CROSS_COMPILE=$CROSS_COMPILE INSTALL_HDR_PATH=output headers_install
fi fi
#--------------------------------------------------------------------------------
# Creating SD Images
#--------------------------------------------------------------------------------
echo "------ Creating SD Images"
echo "--------------------------------------------------------------------------------"
echo "Creating SD Image"
echo "--------------------------------------------------------------------------------"
cd $DEST/output cd $DEST/output
# create image and mount image to next free loop device echo "create image and mount image to next free loop device"
dd if=/dev/zero of=${IMG_NAME}-${VERSION}_rootfs_SD.raw bs=1M count=$IMAGE_SIZE_MB dd if=/dev/zero of=${IMG_NAME}-${VERSION}_rootfs_SD.raw bs=1M count=$IMAGE_SIZE_MB
LOOP0=$(losetup -f) LOOP0=$(losetup -f)
losetup $LOOP0 ${IMG_NAME}-${VERSION}_rootfs_SD.raw losetup $LOOP0 ${IMG_NAME}-${VERSION}_rootfs_SD.raw
echo "------ Partitionning and mounting filesystem" echo "------ Partitionning and mounting filesystem"
# make image bootable
dd if=$DEST/u-boot-sunxi/u-boot-sunxi-with-spl.bin of=$LOOP0 bs=1024 seek=8 dd if=$DEST/u-boot-sunxi/u-boot-sunxi-with-spl.bin of=$LOOP0 bs=1024 seek=8
# create one partition starting at 2048 which is default # create one partition starting at 2048 which is default
@ -162,18 +153,27 @@ LOOP1=$(losetup -f)
# 2048 (start) x 512 (block size) = where to mount partition # 2048 (start) x 512 (block size) = where to mount partition
losetup -o 1048576 $LOOP1 $LOOP0 losetup -o 1048576 $LOOP1 $LOOP0
# create filesystem echo "create filesystem"
mkfs.ext4 $LOOP1 mkfs.ext4 $LOOP1
# create mount point and mount image echo "create mount point and mount image"
mkdir -p $DEST/output/sdcard/ mkdir -p $DEST/output/sdcard/
mount $LOOP1 $DEST/output/sdcard/ mount $LOOP1 $DEST/output/sdcard/
echo "------ Get basic Slackware System" echo "------ Get basic Slackware System"
cd $DEST/output/sdcard/ cd $DEST/output/sdcard/
wget -c ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-devtools/minirootfs/roots/slack-$SLACKWARE_VERSION-miniroot_$ROOTFS_VERSION.tar.xz -O $CWD/slack-$SLACKWARE_VERSION-miniroot_$ROOTFS_VERSION.tar.xz [ ! -e $CWD/slack-$SLACKWARE_VERSION-miniroot_$ROOTFS_VERSION.tar.xz ] && wget -c ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-devtools/minirootfs/roots/slack-$SLACKWARE_VERSION-miniroot_$ROOTFS_VERSION.tar.xz -O $CWD/slack-$SLACKWARE_VERSION-miniroot_$ROOTFS_VERSION.tar.xz
tar xf $CWD/slack-$SLACKWARE_VERSION-miniroot_$ROOTFS_VERSION.tar.xz tar xf $CWD/slack-$SLACKWARE_VERSION-miniroot_$ROOTFS_VERSION.tar.xz
echo "Configuring Slackware"
cat > $DEST/output/sdcard/etc/motd <<EOF cat > $DEST/output/sdcard/etc/motd <<EOF
_ _ _ _ _ _ _ _
___ _ _ | |__ (_) ___ | |_ _ __ _ _ ___ | | __ ___ _ _ | |__ (_) ___ | |_ _ __ _ _ ___ | | __
@ -184,10 +184,8 @@ cat > $DEST/output/sdcard/etc/motd <<EOF
EOF EOF
# script to turn off the LED blinking echo "install script to turn off the LED blinking"
cp $CWD/scripts/disable_led.sh $DEST/output/sdcard/bin/disable_led.sh cp $CWD/scripts/disable_led.sh $DEST/output/sdcard/bin/disable_led.sh
# make it executable
chmod +x $DEST/output/sdcard/bin/disable_led.sh chmod +x $DEST/output/sdcard/bin/disable_led.sh
cat <<EOF >> $DEST/output/sdcard/etc/rc.d/rc.local cat <<EOF >> $DEST/output/sdcard/etc/rc.d/rc.local
@ -196,21 +194,20 @@ cat <<EOF >> $DEST/output/sdcard/etc/rc.d/rc.local
# /bin/disable_led.sh # /bin/disable_led.sh
EOF EOF
# scripts for autoresize at first boot from cubian echo "scripts for autoresize at first boot from cubian"
cp $CWD/scripts/resize2fs-arch.sh $DEST/output/sdcard/root/resize2fs-root.sh cp $CWD/scripts/resize2fs-arch.sh $DEST/output/sdcard/root/resize2fs-root.sh
# make it executable
chmod +x $DEST/output/sdcard/root/resize2fs-root.sh chmod +x $DEST/output/sdcard/root/resize2fs-root.sh
# set hostname echo "set hostname"
echo darkstar > $DEST/output/sdcard/etc/HOSTNAME echo darkstar > $DEST/output/sdcard/etc/HOSTNAME
# setup fstab echo "setup fstab"
### declare root partition in fstab ### declare root partition in fstab
echo '/dev/mmcblk0p1 / ext4 defaults 1 1' >> $DEST/output/sdcard/etc/fstab echo '/dev/mmcblk0p1 / ext4 defaults 1 1' >> $DEST/output/sdcard/etc/fstab
### mount /tmp as tmpfs ### mount /tmp as tmpfs
echo 'tmpfs /tmp tmpfs defaults,nosuid,size=30% 0 0' >> $DEST/output/sdcard/etc/fstab echo 'tmpfs /tmp tmpfs defaults,nosuid,size=30% 0 0' >> $DEST/output/sdcard/etc/fstab
# modules to load echo "modules to load"
cat >> $DEST/output/sdcard/etc/rc.d/rc.modules <<EOT cat >> $DEST/output/sdcard/etc/rc.d/rc.modules <<EOT
#!/bin/sh #!/bin/sh
@ -222,31 +219,44 @@ cat >> $DEST/output/sdcard/etc/rc.d/rc.modules <<EOT
#/sbin/modprobe sunxi_gmac #/sbin/modprobe sunxi_gmac
EOT EOT
#remove the preconfigured boot from the image and use the one we want
echo "remove the preconfigured boot and setup ours"
rm -rf $DEST/output/sdcard/boot/ rm -rf $DEST/output/sdcard/boot/
mkdir -p $DEST/output/sdcard/boot/ mkdir -p $DEST/output/sdcard/boot/
cp $DEST/output/uEnv.txt $DEST/output/sdcard/boot/ cat <<EOF > $DEST/output/sdcard/boot/uEnv.txt
cp $DEST/linux-sunxi/arch/arm/boot/uImage $DEST/output/sdcard/boot/ root=/dev/mmcblk0p1 ro
extraargs=console=tty0,115200 sunxi_no_mali_mem_reserve sunxi_g2d_mem_reserve=0 sunxi_ve_mem_reserve=0 hdmi.audio=EDID:0 disp.screen0_output_mode=EDID:1280x720p50 rootwait panic=10 rootfstype=ext4 rootflags=discard
panic=10 rootfstype=ext4 rootflags=discard
EOF
# copy proper bin file echo "setup video output"
case $DISPLAY in echo $CUBIETRUCK_DISPLAY
"VGA") # VGA case $CUBIETRUCK_DISPLAY in
cp $DEST/output/script-vga.bin $DEST/output/sdcard/boot/script.bin VGA) # VGA
$DEST/sunxi-tools/fex2bin $DEST/cubie_configs/sysconfig/linux/ct-vga.fex$DEST/output/sdcard/boot/script.bin
;; ;;
"HDMI") # HDMI HDMI) # HDMI
cp $DEST/output/script-hdmi.bin $DEST/output/sdcard/boot/script.bin $DEST/sunxi-tools/fex2bin $DEST/cubie_configs/sysconfig/linux/ct-hdmi.fex $DEST/output/sdcard/boot/script.bin
;; ;;
*) exit 1 *) exit 1
esac esac
echo "Installing kernel"
cp $DEST/linux-sunxi/arch/arm/boot/uImage $DEST/output/sdcard/boot/
cp -R $DEST/linux-sunxi/output/lib/modules $DEST/output/sdcard/lib/ cp -R $DEST/linux-sunxi/output/lib/modules $DEST/output/sdcard/lib/
cp -R $DEST/linux-sunxi/output/lib/firmware/ $DEST/output/sdcard/lib/ cp -R $DEST/linux-sunxi/output/lib/firmware/ $DEST/output/sdcard/lib/
# umount images sync
sleep 3
echo "umount images"
umount $DEST/output/sdcard/ umount $DEST/output/sdcard/
losetup -d $LOOP1 losetup -d $LOOP1
losetup -d $LOOP0 losetup -d $LOOP0
sync
# compress image echo "compress image"
gzip $DEST/output/*.raw gzip $DEST/output/*.raw