mirror of
https://bitbucket.org/gwenhael/cubietruck-slackware.git
synced 2024-12-26 21:58:20 +01:00
REFACTOR ALL THE THINGS!!!!!!!111!!ONE!!
This commit is contained in:
parent
260beb23b4
commit
75c1a37d17
1 changed files with 350 additions and 302 deletions
462
build.sh
462
build.sh
|
@ -13,185 +13,81 @@ CWD=$(pwd)
|
||||||
IMG_NAME=${IMG_NAME:-"SlackwareARM_cubitruck"}
|
IMG_NAME=${IMG_NAME:-"SlackwareARM_cubitruck"}
|
||||||
VERSION=${VERSION:-0.3}
|
VERSION=${VERSION:-0.3}
|
||||||
COMPILE=${COMPILE:-"false"}
|
COMPILE=${COMPILE:-"false"}
|
||||||
|
CREATE_IMAGE=${CREATE_IMAGE:-"true"}
|
||||||
DEST=${DEST:-$CWD/dist}
|
DEST=${DEST:-$CWD/dist}
|
||||||
CUBIETRUCK_DISPLAY=${CUBIETRUCK_DISPLAY:-"HDMI"} # "HDMI" or "VGA"
|
CUBIETRUCK_DISPLAY=${CUBIETRUCK_DISPLAY:-"HDMI"}
|
||||||
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}
|
||||||
TOOLCHAIN_VERSION=${TOOLCHAIN_VERSION:-4.8-2013.10}
|
TOOLCHAIN_VERSION=${TOOLCHAIN_VERSION:-4.8-2013.10}
|
||||||
TOOLCHAIN_URL_RANDOM_NUMBER=${TOOLCHAIN_URL_RANDOM_NUMBER:-155358238}
|
TOOLCHAIN_URL_RANDOM_NUMBER=${TOOLCHAIN_URL_RANDOM_NUMBER:-155358238}
|
||||||
|
|
||||||
PACKAGE_BINARIES=false
|
PACKAGE_BINARIES="false"
|
||||||
|
|
||||||
BINARIES_DIR=$CWD/binaries
|
BINARIES_DIR=$CWD/binaries
|
||||||
|
|
||||||
function cleanall() {
|
# --- Functions ----------------------------------------------------------------
|
||||||
for i in u-boot-sunxi sunxi-tools linux-sunxi; do
|
function prepare_dest() {
|
||||||
( cd $DEST/$i
|
mkdir -p $DEST
|
||||||
make clean CROSS_COMPILE=$CROSS_COMPILE )
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# commandline arguments processing
|
function setup_x_toolchain() {
|
||||||
while [ "x$1" != "x" ]
|
echo ". setting up cross-compiler if needed"
|
||||||
do
|
|
||||||
case "$1" in
|
|
||||||
--clean )
|
|
||||||
shift
|
|
||||||
cleanall
|
|
||||||
exit -1
|
|
||||||
;;
|
|
||||||
-c | --compile )
|
|
||||||
shift
|
|
||||||
COMPILE="true"
|
|
||||||
;;
|
|
||||||
-dc | --dont-compile )
|
|
||||||
shift
|
|
||||||
COMPILE="false"
|
|
||||||
;;
|
|
||||||
-d | --display )
|
|
||||||
shift
|
|
||||||
CUBIETRUCK_DISPLAY=$1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-gz | --compress )
|
|
||||||
shift
|
|
||||||
COMPRESS="true"
|
|
||||||
;;
|
|
||||||
-n | --image-name )
|
|
||||||
shift
|
|
||||||
IMG_NAME=$1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-r | --rootfs-version )
|
|
||||||
shift
|
|
||||||
ROOTFS_VERSION=$1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-s | --image-size )
|
|
||||||
shift
|
|
||||||
IMAGE_SIZE_MB=$1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-o | --output )
|
|
||||||
shift
|
|
||||||
DEST=$1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--package-binaries )
|
|
||||||
shift
|
|
||||||
PACKAGE_BINARIES=true
|
|
||||||
;;
|
|
||||||
-v | --image-version )
|
|
||||||
shift
|
|
||||||
VERSION=$1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-xv | --toolchain-version )
|
|
||||||
shift
|
|
||||||
TOOLCHAIN_VERSION=$1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-xumn | --toolchain-url-magic-number )
|
|
||||||
shift
|
|
||||||
TOOLCHAIN_URL_RANDOM_NUMBER=$1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
-h | --help )
|
|
||||||
echo -e "Usage: run as root: $0 <options>"
|
|
||||||
echo -e "Options:"
|
|
||||||
echo -e "\t--clean"
|
|
||||||
echo -e "\t-c | --compile"
|
|
||||||
echo -e "\t-dc | --dont-compile (default)"
|
|
||||||
echo -e "\t-d | --display [\"HDMI\"|\"VGA\"] (default: $CUBIETRUCK_DISPLAY)"
|
|
||||||
echo -e "\t-gz | --compress (default: $COMPRESS)"
|
|
||||||
echo -e "\t-n | --image-name [\"nom\"] (default: $IMG_NAME)"
|
|
||||||
echo -e "\t-r | --rootfs-version [\"version number\"] (default: $ROOTFS_VERSION)"
|
|
||||||
echo -e "\t-s | --image-size [size in MB] (default: $IMAGE_SIZE_MB)"
|
|
||||||
echo -e "\t-o | --output [/directory/] (default: $DEST)"
|
|
||||||
echo -e "\t--package-binaries"
|
|
||||||
echo -e "\t\tpackage compiled binaries into $BINARIES_DIR-$VERSION.tar.xz"
|
|
||||||
echo -e "\t\t(combine with --compile)"
|
|
||||||
echo -e "\t-v | --image-version [\"version number\"] (default: $VERSION)"
|
|
||||||
echo -e "\t-xv | --toolchain-version [\"version number\"] (default: $TOOLCHAIN_VERSION)"
|
|
||||||
echo -e "\t-xumn | --toolchain-url-magic-number [\"magic number\"] (default: $TOOLCHAIN_URL_RANDOM_NUMBER)"
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# --- Script --------------------------------------------------------------------
|
|
||||||
mkdir -p $DEST
|
|
||||||
|
|
||||||
if [ "$COMPILE" = "true" ]; then
|
|
||||||
mkdir -p $BINARIES_DIR
|
|
||||||
|
|
||||||
echo "--------------------------------------------------------------------------------"
|
|
||||||
echo "Downloading necessary files for building - aka Toolchain"
|
|
||||||
echo "--------------------------------------------------------------------------------"
|
|
||||||
if $(uname -m | grep -q arm); then
|
if $(uname -m | grep -q arm); then
|
||||||
|
echo ". . ARM host detected, no cross-compiler needed"
|
||||||
CROSS_COMPILE=''
|
CROSS_COMPILE=''
|
||||||
else
|
else
|
||||||
#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
|
if [ ! -e $PWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux/ ]; then
|
||||||
[ ! -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
|
if [ ! -e $CWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz ]; then
|
||||||
|
echo ". . downloading cross-compiler"
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
echo ". . installing cross-compiler locally"
|
||||||
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
|
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-
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
echo "--------------------------------------------------------------------------------"
|
function clone_pull_patch_sources() {
|
||||||
echo "Clone / Pull sources and patch"
|
|
||||||
echo "--------------------------------------------------------------------------------"
|
|
||||||
mkdir -p $DEST/image
|
mkdir -p $DEST/image
|
||||||
|
|
||||||
# Boot loader
|
# Boot loader
|
||||||
if [ -d "$DEST/u-boot-sunxi" ]; then
|
if [ -d "$DEST/u-boot-sunxi" ]; then
|
||||||
|
echo ". . updating u-boot-sunxi"
|
||||||
( cd $DEST/u-boot-sunxi;
|
( cd $DEST/u-boot-sunxi;
|
||||||
git pull )
|
git pull )
|
||||||
else
|
else
|
||||||
|
echo ". . cloning u-boot-sunxi"
|
||||||
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
|
echo ". . patching u-boot-sunxi to detect Cubietruck's 2GiB of RAM"
|
||||||
patch -f $DEST/u-boot-sunxi/include/configs/sunxi-common.h < $CWD/patches/u-boot-sunxi/memory.patch || true
|
patch -f $DEST/u-boot-sunxi/include/configs/sunxi-common.h < $CWD/patches/u-boot-sunxi/memory.patch || true
|
||||||
fi
|
fi
|
||||||
echo "------ Compiling boot loader"
|
|
||||||
( cd $DEST/u-boot-sunxi
|
|
||||||
make clean CROSS_COMPILE=$CROSS_COMPILE
|
|
||||||
make -j2 'cubietruck' CROSS_COMPILE=$CROSS_COMPILE
|
|
||||||
make HOSTCC=gcc CROSS_COMPILE='' tools
|
|
||||||
|
|
||||||
mkdir -p $BINARIES_DIR/$(basename $(pwd))
|
|
||||||
mv tools/mkimage $BINARIES_DIR/$(basename $(pwd))
|
|
||||||
)
|
|
||||||
|
|
||||||
# Allwinner tools
|
# Allwinner tools
|
||||||
if [ -d "$DEST/sunxi-tools" ]; then
|
if [ -d "$DEST/sunxi-tools" ]; then
|
||||||
|
echo ". . updating sunxi-tools"
|
||||||
( cd $DEST/sunxi-tools;
|
( cd $DEST/sunxi-tools;
|
||||||
git pull )
|
git pull )
|
||||||
else
|
else
|
||||||
|
echo ". . cloning sunxi-tools"
|
||||||
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
|
||||||
echo "------ Compiling sunxi tools"
|
|
||||||
( cd $DEST/sunxi-tools
|
|
||||||
make clean
|
|
||||||
make fex2bin bin2fex
|
|
||||||
|
|
||||||
mkdir -p $BINARIES_DIR/$(basename $(pwd))
|
|
||||||
mv fexc fex2bin bin2fex $BINARIES_DIR/$(basename $(pwd))
|
|
||||||
)
|
|
||||||
|
|
||||||
# Hardware configurations
|
# Hardware configurations
|
||||||
if [ -d "$DEST/cubie_configs" ]; then
|
if [ -d "$DEST/cubie_configs" ]; then
|
||||||
|
echo ". . updating cubie_configs"
|
||||||
( cd $DEST/cubie_configs;
|
( cd $DEST/cubie_configs;
|
||||||
git pull )
|
git pull )
|
||||||
else
|
else
|
||||||
|
echo ". . cloning sunxi-tools"
|
||||||
git clone https://github.com/cubieboard/cubie_configs $DEST/cubie_configs
|
git clone https://github.com/cubieboard/cubie_configs $DEST/cubie_configs
|
||||||
|
|
||||||
|
echo ". . patching sunxi-tools"
|
||||||
# Applying Patch for high load. Could cause troubles with USB OTG port
|
# Applying Patch for high load. Could cause troubles with USB OTG port
|
||||||
sed -e 's/usb_detect_type = 1/usb_detect_type = 0/g' $DEST/cubie_configs/sysconfig/linux/cubietruck.fex > $DEST/cubie_configs/sysconfig/linux/ct.fex
|
sed -e 's/usb_detect_type = 1/usb_detect_type = 0/g' $DEST/cubie_configs/sysconfig/linux/cubietruck.fex > $DEST/cubie_configs/sysconfig/linux/ct.fex
|
||||||
|
|
||||||
|
@ -199,26 +95,62 @@ if [ "$COMPILE" = "true" ]; then
|
||||||
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
|
||||||
|
|
||||||
|
if [ -d "$DEST/linux-sunxi" ]; then
|
||||||
|
echo ". . updating linux-sunxi"
|
||||||
|
( cd $DEST/linux-sunxi;
|
||||||
|
git pull -f )
|
||||||
|
else
|
||||||
|
echo ". . updating linux-sunxi"
|
||||||
|
git clone https://github.com/linux-sunxi/linux-sunxi $DEST/linux-sunxi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function clean_sources() {
|
||||||
|
echo ". cleaning sources"
|
||||||
|
for i in u-boot-sunxi sunxi-tools linux-sunxi; do
|
||||||
|
echo ". . cleaning $i"
|
||||||
|
( cd $DEST/$i
|
||||||
|
make clean CROSS_COMPILE=$CROSS_COMPILE )
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function compile() {
|
||||||
|
echo ". compiling binaries and installing them into $BINARIES_DIR"
|
||||||
|
mkdir -p $BINARIES_DIR
|
||||||
|
|
||||||
|
( cd $DEST/u-boot-sunxi
|
||||||
|
echo ". . compiling u-boot-sunxi"
|
||||||
|
make -j2 'cubietruck' CROSS_COMPILE=$CROSS_COMPILE
|
||||||
|
make HOSTCC=gcc CROSS_COMPILE='' tools
|
||||||
|
|
||||||
|
echo ". . installing u-boot-sunxi in $BINARIES_DIR"
|
||||||
|
mkdir -p $BINARIES_DIR/$(basename $(pwd))
|
||||||
|
mv tools/mkimage $BINARIES_DIR/$(basename $(pwd))
|
||||||
|
)
|
||||||
|
|
||||||
|
( cd $DEST/sunxi-tools
|
||||||
|
echo ". . compiling sunxi-tools"
|
||||||
|
make fex2bin bin2fex
|
||||||
|
|
||||||
|
echo ". . installing sunxi-tools in $BINARIES_DIR"
|
||||||
|
mkdir -p $BINARIES_DIR/$(basename $(pwd))
|
||||||
|
mv fexc fex2bin bin2fex $BINARIES_DIR/$(basename $(pwd))
|
||||||
|
)
|
||||||
|
|
||||||
|
echo ". . installing cubie_configs in $BINARIES_DIR"
|
||||||
mkdir -p $BINARIES_DIR/cubie_configs
|
mkdir -p $BINARIES_DIR/cubie_configs
|
||||||
$BINARIES_DIR/sunxi-tools/fex2bin $DEST/cubie_configs/sysconfig/linux/ct-vga.fex $BINARIES_DIR/cubie_configs/script-vga.bin
|
$BINARIES_DIR/sunxi-tools/fex2bin $DEST/cubie_configs/sysconfig/linux/ct-vga.fex $BINARIES_DIR/cubie_configs/script-vga.bin
|
||||||
$BINARIES_DIR/sunxi-tools/fex2bin $DEST/cubie_configs/sysconfig/linux/ct-hdmi.fex $BINARIES_DIR/cubie_configs/script-hdmi.bin
|
$BINARIES_DIR/sunxi-tools/fex2bin $DEST/cubie_configs/sysconfig/linux/ct-hdmi.fex $BINARIES_DIR/cubie_configs/script-hdmi.bin
|
||||||
|
|
||||||
if [ -d "$DEST/linux-sunxi" ]; then
|
|
||||||
( cd $DEST/linux-sunxi;
|
|
||||||
git pull -f )
|
|
||||||
else
|
|
||||||
git clone https://github.com/linux-sunxi/linux-sunxi $DEST/linux-sunxi
|
|
||||||
fi
|
|
||||||
echo "------ Compiling kernel"
|
|
||||||
( cd $DEST/linux-sunxi
|
( cd $DEST/linux-sunxi
|
||||||
PATH=$PATH:$BINARIES_DIR/u-boot-sunxi/
|
PATH=$PATH:$BINARIES_DIR/u-boot-sunxi/
|
||||||
|
|
||||||
make clean
|
echo ". . adding ap6210 firmware to kernel"
|
||||||
|
|
||||||
# Adding wlan firmware to kernel source
|
|
||||||
( cd $DEST/linux-sunxi/firmware;
|
( cd $DEST/linux-sunxi/firmware;
|
||||||
unzip -o $CWD/firmwares/ap6210.zip )
|
unzip -o $CWD/firmwares/ap6210.zip )
|
||||||
|
|
||||||
|
echo ". . compiling kernel"
|
||||||
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
|
||||||
|
@ -227,45 +159,31 @@ if [ "$COMPILE" = "true" ]; then
|
||||||
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
|
||||||
|
|
||||||
|
echo ". . installing kernel in $BINARIES_DIR"
|
||||||
mkdir -p $BINARIES_DIR/$(basename $(pwd))
|
mkdir -p $BINARIES_DIR/$(basename $(pwd))
|
||||||
cp $DEST/linux-sunxi/arch/arm/boot/uImage $BINARIES_DIR/$(basename $(pwd))
|
cp $DEST/linux-sunxi/arch/arm/boot/uImage $BINARIES_DIR/$(basename $(pwd))
|
||||||
cp -R $DEST/linux-sunxi/output/lib/modules $BINARIES_DIR/$(basename $(pwd))
|
cp -R $DEST/linux-sunxi/output/lib/modules $BINARIES_DIR/$(basename $(pwd))
|
||||||
cp -R $DEST/linux-sunxi/output/lib/firmware/ $BINARIES_DIR/$(basename $(pwd))
|
cp -R $DEST/linux-sunxi/output/lib/firmware/ $BINARIES_DIR/$(basename $(pwd))
|
||||||
)
|
)
|
||||||
else
|
}
|
||||||
if [ ! -e $BINARIES_DIR ]; then
|
|
||||||
echo "ERROR"
|
|
||||||
echo "Necessary binaries files not present !"
|
|
||||||
echo "Either run $0 --compile or download them from https://bitbucket.org/gwenhael/cubietruck-slackware/downloads"
|
|
||||||
echo "and untar them here."
|
|
||||||
|
|
||||||
exit 99
|
function pack_binaries() {
|
||||||
fi
|
echo ". packaging $BINARIES_DIR into $BINARIES_DIR"
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$PACKAGE_BINARIES" = "true" ]; then
|
|
||||||
tar Jcf $BINARIES_DIR-$VERSION.tar.xz $BINARIES_DIR
|
tar Jcf $BINARIES_DIR-$VERSION.tar.xz $BINARIES_DIR
|
||||||
|
}
|
||||||
|
|
||||||
exit -1
|
function create_and_mount_image() {
|
||||||
fi
|
echo ". creating and mounting image"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "--------------------------------------------------------------------------------"
|
|
||||||
echo "Creating SD Image"
|
|
||||||
echo "--------------------------------------------------------------------------------"
|
|
||||||
mkdir -p $DEST/image
|
mkdir -p $DEST/image
|
||||||
cd $DEST/image
|
cd $DEST/image
|
||||||
|
|
||||||
echo "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"
|
||||||
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
|
||||||
|
@ -278,27 +196,42 @@ 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
|
||||||
|
|
||||||
echo "create filesystem"
|
echo ". . create filesystem"
|
||||||
mkfs.ext4 $LOOP1
|
mkfs.ext4 $LOOP1
|
||||||
|
|
||||||
echo "create mount point and mount image"
|
echo ". . create mount point and mount image"
|
||||||
mkdir -p $DEST/image/sdcard/
|
mkdir -p $DEST/image/sdcard/
|
||||||
mount $LOOP1 $DEST/image/sdcard/
|
mount $LOOP1 $DEST/image/sdcard/
|
||||||
|
}
|
||||||
|
|
||||||
|
function umount_image() {
|
||||||
|
echo ". umount image"
|
||||||
|
umount -d -l $DEST/image/sdcard/
|
||||||
|
losetup -d $LOOP1
|
||||||
|
losetup -d $LOOP0
|
||||||
|
|
||||||
|
echo "cleaning"
|
||||||
|
rm -r $DEST/image/sdcard/
|
||||||
|
}
|
||||||
|
|
||||||
|
function compress_image() {
|
||||||
|
echo ". compress image"
|
||||||
|
xz -z $DEST/image/${IMG_NAME}-${VERSION}_rootfs_SD.raw
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_and_install_minirootfs() {
|
||||||
|
echo ". install minirootds"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "------ Get basic Slackware System"
|
|
||||||
cd $DEST/image/sdcard/
|
cd $DEST/image/sdcard/
|
||||||
[ ! -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
|
if [ ! -e $CWD/slack-$SLACKWARE_VERSION-miniroot_$ROOTFS_VERSION.tar.xz ]; then
|
||||||
|
echo ". . downloading minirootfs"
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
echo ". . extracting minirootfs"
|
||||||
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"
|
function configure_slackwarearm() {
|
||||||
|
echo ". configuring system"
|
||||||
cat > $DEST/image/sdcard/etc/motd <<EOF
|
cat > $DEST/image/sdcard/etc/motd <<EOF
|
||||||
_ _ _ _
|
_ _ _ _
|
||||||
___ _ _ | |__ (_) ___ | |_ _ __ _ _ ___ | | __
|
___ _ _ | |__ (_) ___ | |_ _ __ _ _ ___ | | __
|
||||||
|
@ -309,7 +242,7 @@ cat > $DEST/image/sdcard/etc/motd <<EOF
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "install script to turn off the LED blinking"
|
echo ". . install script to turn off the LED blinking"
|
||||||
cp $CWD/scripts/disable_led.sh $DEST/image/sdcard/bin/disable_led.sh
|
cp $CWD/scripts/disable_led.sh $DEST/image/sdcard/bin/disable_led.sh
|
||||||
chmod +x $DEST/image/sdcard/bin/disable_led.sh
|
chmod +x $DEST/image/sdcard/bin/disable_led.sh
|
||||||
|
|
||||||
|
@ -319,36 +252,21 @@ cat <<EOF >> $DEST/image/sdcard/etc/rc.d/rc.local
|
||||||
# /bin/disable_led.sh
|
# /bin/disable_led.sh
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "scripts for autoresize at first boot from cubian"
|
echo ". . copy script to expand filesystem to the whole card"
|
||||||
cp $CWD/scripts/resize2fs-arch.sh $DEST/image/sdcard/root/resize2fs-root.sh
|
cp $CWD/scripts/resize2fs-arch.sh $DEST/image/sdcard/root/resize2fs-root.sh
|
||||||
chmod +x $DEST/image/sdcard/root/resize2fs-root.sh
|
chmod +x $DEST/image/sdcard/root/resize2fs-root.sh
|
||||||
|
|
||||||
echo "set hostname"
|
echo ". . set hostname"
|
||||||
echo darkstar > $DEST/image/sdcard/etc/HOSTNAME
|
echo darkstar > $DEST/image/sdcard/etc/HOSTNAME
|
||||||
|
|
||||||
echo "setup fstab"
|
echo ". . setup fstab"
|
||||||
### declare root partition in fstab
|
|
||||||
echo '/dev/mmcblk0p1 / ext4 defaults 1 1' >> $DEST/image/sdcard/etc/fstab
|
echo '/dev/mmcblk0p1 / ext4 defaults 1 1' >> $DEST/image/sdcard/etc/fstab
|
||||||
### mount /tmp as tmpfs
|
|
||||||
echo 'tmpfs /tmp tmpfs defaults,nosuid,size=30% 0 0' >> $DEST/image/sdcard/etc/fstab
|
echo 'tmpfs /tmp tmpfs defaults,nosuid,size=30% 0 0' >> $DEST/image/sdcard/etc/fstab
|
||||||
|
}
|
||||||
|
|
||||||
echo "modules to load"
|
function install_kernel_and_boot() {
|
||||||
cat >> $DEST/image/sdcard/etc/rc.d/rc.modules <<EOT
|
echo ". install kernel and setup boot"
|
||||||
#!/bin/sh
|
echo ". . remove the preconfigured boot and setup ours"
|
||||||
|
|
||||||
/sbin/modprobe hci_uart
|
|
||||||
/sbin/modprobe gpio_sunxi
|
|
||||||
/sbin/modprobe bcmdhd
|
|
||||||
/sbin/modprobe ump
|
|
||||||
/sbin/modprobe mali
|
|
||||||
#/sbin/modprobe sunxi_gmac
|
|
||||||
EOT
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "remove the preconfigured boot and setup ours"
|
|
||||||
rm -rf $DEST/image/sdcard/boot/*
|
rm -rf $DEST/image/sdcard/boot/*
|
||||||
|
|
||||||
TARGET=/image/sdcard
|
TARGET=/image/sdcard
|
||||||
|
@ -357,13 +275,14 @@ if [ -x /sbin/makepkg ] && [ -x /sbin/installpkg ]; then
|
||||||
TARGET=/pkg-linux-sunxi
|
TARGET=/pkg-linux-sunxi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo ". . configure u-boot"
|
||||||
cat <<EOF > $DEST$TARGET/boot/uEnv.txt
|
cat <<EOF > $DEST$TARGET/boot/uEnv.txt
|
||||||
root=/dev/mmcblk0p1 ro rootwait
|
root=/dev/mmcblk0p1 ro rootwait
|
||||||
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
|
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
|
EOF
|
||||||
|
|
||||||
echo "setup video output"
|
echo ". . setup video output"
|
||||||
cp $BINARIES_DIR/cubie_configs/script-*.bin $DEST$TARGET/boot/
|
cp $BINARIES_DIR/cubie_configs/script-*.bin $DEST$TARGET/boot/
|
||||||
( cd $DEST$TARGET/boot/
|
( cd $DEST$TARGET/boot/
|
||||||
rm script.bin
|
rm script.bin
|
||||||
|
@ -374,12 +293,26 @@ cp $BINARIES_DIR/cubie_configs/script-*.bin $DEST$TARGET/boot/
|
||||||
;;
|
;;
|
||||||
esac )
|
esac )
|
||||||
|
|
||||||
echo "Installing kernel"
|
echo ". . Installing kernel"
|
||||||
cp $BINARIES_DIR/linux-sunxi/uImage $DEST$TARGET/boot/
|
cp $BINARIES_DIR/linux-sunxi/uImage $DEST$TARGET/boot/
|
||||||
cp -R $BINARIES_DIR/linux-sunxi/modules $DEST$TARGET/lib/
|
cp -R $BINARIES_DIR/linux-sunxi/modules $DEST$TARGET/lib/
|
||||||
cp -R $BINARIES_DIR/linux-sunxi/firmware/ $DEST$TARGET/lib/
|
cp -R $BINARIES_DIR/linux-sunxi/firmware/ $DEST$TARGET/lib/
|
||||||
|
|
||||||
|
echo ". . write rc.modules"
|
||||||
|
mkdir -p $DEST$TARGET/etc/rc.d/
|
||||||
|
cat >> $DEST$TARGET/etc/rc.d/rc.modules <<EOT
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
/sbin/modprobe hci_uart
|
||||||
|
/sbin/modprobe gpio_sunxi
|
||||||
|
/sbin/modprobe bcmdhd
|
||||||
|
/sbin/modprobe ump
|
||||||
|
/sbin/modprobe mali
|
||||||
|
#/sbin/modprobe sunxi_gmac
|
||||||
|
EOT
|
||||||
|
|
||||||
if [ -x /sbin/makepkg ] && [ -x /sbin/installpkg ]; then
|
if [ -x /sbin/makepkg ] && [ -x /sbin/installpkg ]; then
|
||||||
|
echo ". . build slackware package for kernel"
|
||||||
mkdir -p $DEST/pkg-linux-sunxi/install/
|
mkdir -p $DEST/pkg-linux-sunxi/install/
|
||||||
PRGNAM=linux-sunxi
|
PRGNAM=linux-sunxi
|
||||||
cat <<EOF > $DEST/pkg-linux-sunxi/install/slack-desc
|
cat <<EOF > $DEST/pkg-linux-sunxi/install/slack-desc
|
||||||
|
@ -411,20 +344,135 @@ EOF
|
||||||
|
|
||||||
installpkg --root $DEST/image/sdcard/ $DEST/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz
|
installpkg --root $DEST/image/sdcard/ $DEST/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
sync
|
# commandline arguments processing
|
||||||
|
while [ "x$1" != "x" ]
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
--clean )
|
||||||
|
shift
|
||||||
|
clean_sources
|
||||||
|
exit -1
|
||||||
|
;;
|
||||||
|
-c | --compile )
|
||||||
|
shift
|
||||||
|
COMPILE="true"
|
||||||
|
;;
|
||||||
|
-dc | --dont-compile )
|
||||||
|
shift
|
||||||
|
COMPILE="false"
|
||||||
|
;;
|
||||||
|
-d | --display )
|
||||||
|
shift
|
||||||
|
CUBIETRUCK_DISPLAY=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-gz | --compress )
|
||||||
|
shift
|
||||||
|
COMPRESS="true"
|
||||||
|
;;
|
||||||
|
-i | --create-image )
|
||||||
|
shift
|
||||||
|
CREATE_IMAGE="true"
|
||||||
|
;;
|
||||||
|
-ni | --no-image )
|
||||||
|
shift
|
||||||
|
CREATE_IMAGE="false"
|
||||||
|
;;
|
||||||
|
-n | --image-name )
|
||||||
|
shift
|
||||||
|
IMG_NAME=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-r | --rootfs-version )
|
||||||
|
shift
|
||||||
|
ROOTFS_VERSION=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-s | --image-size )
|
||||||
|
shift
|
||||||
|
IMAGE_SIZE_MB=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-o | --output )
|
||||||
|
shift
|
||||||
|
DEST=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--package-binaries )
|
||||||
|
shift
|
||||||
|
PACKAGE_BINARIES="true"
|
||||||
|
;;
|
||||||
|
-v | --image-version )
|
||||||
|
shift
|
||||||
|
VERSION=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-xv | --toolchain-version )
|
||||||
|
shift
|
||||||
|
TOOLCHAIN_VERSION=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-xumn | --toolchain-url-magic-number )
|
||||||
|
shift
|
||||||
|
TOOLCHAIN_URL_RANDOM_NUMBER=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
sleep 3
|
-h | --help )
|
||||||
|
echo -e "Usage: run as root: $0 <options>"
|
||||||
|
echo -e "Options:"
|
||||||
|
echo -e "\t--clean"
|
||||||
|
echo -e "\t-c | --compile"
|
||||||
|
echo -e "\t-dc | --dont-compile (default)"
|
||||||
|
echo -e "\t-i | --create-image (default)"
|
||||||
|
echo -e "\t-ni | --no-image"
|
||||||
|
echo -e "\t-d | --display [\"HDMI\"|\"VGA\"] (default: $CUBIETRUCK_DISPLAY)"
|
||||||
|
echo -e "\t-gz | --compress (default: no)"
|
||||||
|
echo -e "\t-n | --image-name [\"nom\"] (default: $IMG_NAME)"
|
||||||
|
echo -e "\t-r | --rootfs-version [\"version number\"] (default: $ROOTFS_VERSION)"
|
||||||
|
echo -e "\t-s | --image-size [size in MB] (default: $IMAGE_SIZE_MB)"
|
||||||
|
echo -e "\t-o | --output [/directory/] (default: $DEST)"
|
||||||
|
echo -e "\t--package-binaries"
|
||||||
|
echo -e "\t\tpackage compiled binaries into $BINARIES_DIR-$VERSION.tar.xz"
|
||||||
|
echo -e "\t\t(combine with --compile)"
|
||||||
|
echo -e "\t-v | --image-version [\"version number\"] (default: $VERSION)"
|
||||||
|
echo -e "\t-xv | --toolchain-version [\"version number\"] (default: $TOOLCHAIN_VERSION)"
|
||||||
|
echo -e "\t-xumn | --toolchain-url-magic-number [\"magic number\"] (default: $TOOLCHAIN_URL_RANDOM_NUMBER)"
|
||||||
|
|
||||||
echo "umount images"
|
exit 0
|
||||||
umount -d -l $DEST/image/sdcard/
|
;;
|
||||||
losetup -d $LOOP1
|
esac
|
||||||
losetup -d $LOOP0
|
done
|
||||||
|
|
||||||
echo "cleaning"
|
# --- Script --------------------------------------------------------------------
|
||||||
rm -r $DEST/image/sdcard/
|
prepare_dest
|
||||||
|
|
||||||
if [ "$COMPRESS" = "true" ]; then
|
if [ "$COMPILE" = "true" ]; then
|
||||||
echo "compress image"
|
setup_x_toolchain
|
||||||
xz -z $DEST/image/${IMG_NAME}-${VERSION}_rootfs_SD.raw
|
clone_pull_patch_sources
|
||||||
|
clean_sources
|
||||||
|
compile
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[ "$PACKAGE_BINARIES" = "true" ] && pack_binaries && exit -1
|
||||||
|
|
||||||
|
if [ ! -e $BINARIES_DIR ]; then
|
||||||
|
echo "ERROR"
|
||||||
|
echo "Necessary binaries files not present !"
|
||||||
|
echo "Either run $0 --compile or download them from https://bitbucket.org/gwenhael/cubietruck-slackware/downloads"
|
||||||
|
echo "and untar them here."
|
||||||
|
|
||||||
|
exit 99
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$CREATE_IMAGE" = "true" ]; then
|
||||||
|
create_and_mount_image
|
||||||
|
get_and_install_minirootfs
|
||||||
|
configure_slackwarearm
|
||||||
|
install_kernel_and_boot
|
||||||
|
umount_image
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$COMPRESS" = "true" ] && compress_image
|
||||||
|
|
Loading…
Reference in a new issue