2013-12-29 12:01:02 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-02-26 14:46:08 +01:00
|
|
|
set -e
|
|
|
|
|
2014-02-28 08:03:56 +01:00
|
|
|
# Requires root ..
|
|
|
|
if [ "$UID" -ne 0 ]; then
|
|
|
|
echo "Please run as root"
|
2014-08-20 15:25:24 +02:00
|
|
|
exit 1
|
2014-02-28 08:03:56 +01:00
|
|
|
fi
|
|
|
|
|
2014-02-28 12:21:10 +01:00
|
|
|
CWD=$(pwd)
|
|
|
|
|
2014-01-02 11:33:32 +01:00
|
|
|
# --- Configuration -------------------------------------------------------------
|
2014-02-26 14:07:17 +01:00
|
|
|
IMG_NAME=${IMG_NAME:-"SlackwareARM_cubitruck"}
|
2014-08-20 15:33:55 +02:00
|
|
|
VERSION=${VERSION:-0.4}
|
2014-03-01 18:57:47 +01:00
|
|
|
COMPILE_BINARIES=${COMPILE_BINARIES:-"false"}
|
|
|
|
DOWNLOAD_BINARIES=${DOWNLOAD_BINARIES:-"true"}
|
2014-03-01 17:53:25 +01:00
|
|
|
CREATE_IMAGE=${CREATE_IMAGE:-"true"}
|
2014-02-28 17:12:11 +01:00
|
|
|
DEST=${DEST:-$CWD/dist}
|
2014-03-01 17:53:25 +01:00
|
|
|
CUBIETRUCK_DISPLAY=${CUBIETRUCK_DISPLAY:-"HDMI"}
|
2014-02-26 14:07:17 +01:00
|
|
|
IMAGE_SIZE_MB=${IMAGE_SIZE_MB:-2000}
|
2014-08-20 15:33:55 +02:00
|
|
|
SLACKWARE_VERSION=${SLACKWARE_VERSION:-current}
|
2015-02-20 11:18:06 +01:00
|
|
|
ROOTFS_VERSION=${ROOTFS_VERSION:-06Jan15}
|
2014-02-26 14:46:08 +01:00
|
|
|
TOOLCHAIN_VERSION=${TOOLCHAIN_VERSION:-4.8-2013.10}
|
|
|
|
TOOLCHAIN_URL_RANDOM_NUMBER=${TOOLCHAIN_URL_RANDOM_NUMBER:-155358238}
|
2014-02-26 14:07:17 +01:00
|
|
|
|
2014-08-21 10:03:52 +02:00
|
|
|
REPO_UBOOT=${REPO_UBOOT:-https://github.com/cubieboard/u-boot-sunxi}
|
|
|
|
REPO_SUNXI_TOOLS=${REPO_SUNXI_TOOLS:-https://github.com/linux-sunxi/sunxi-tools.git}
|
|
|
|
REPO_CONFIGS=${REPO_CONFIGS:-https://github.com/cubieboard/cubie_configs}
|
|
|
|
REPO_LINUX=${REPO_LINUX:-https://github.com/linux-sunxi/linux-sunxi}
|
|
|
|
# REPO_LINUX=${REPO_LINUX:-https://github.com/cubieboard2/linux-sunxi}
|
|
|
|
# REPO_LINUX=${REPO_LINUX:-https://github.com/cubieboard/linux-sunxi}
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
PACKAGE_BINARIES="false"
|
2014-02-28 12:12:50 +01:00
|
|
|
|
|
|
|
BINARIES_DIR=$CWD/binaries
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
# --- Functions ----------------------------------------------------------------
|
|
|
|
function prepare_dest() {
|
|
|
|
mkdir -p $DEST
|
2014-03-01 16:41:47 +01:00
|
|
|
}
|
|
|
|
|
2014-03-01 18:57:47 +01:00
|
|
|
function download_and_install_binaries() {
|
|
|
|
echo ". install binaries"
|
2014-08-20 15:25:56 +02:00
|
|
|
mkdir -p $DEST/image/sdcard/
|
2014-03-01 18:57:47 +01:00
|
|
|
cd $DEST/image/sdcard/
|
2014-08-20 16:57:33 +02:00
|
|
|
if [ ! -e $CWD/binaries-$VERSION.tar.xz ]; then
|
2014-03-01 18:57:47 +01:00
|
|
|
echo ". . downloading binaries"
|
|
|
|
wget -c https://bitbucket.org/gwenhael/cubietruck-slackware/downloads/binaries-$VERSION.tar.xz \
|
|
|
|
-O $CWD/binaries-$VERSION.tar.xz
|
|
|
|
fi
|
|
|
|
echo ". . extracting binaries"
|
|
|
|
tar xf $CWD/binaries-$VERSION.tar.xz
|
|
|
|
}
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
function setup_x_toolchain() {
|
|
|
|
echo ". setting up cross-compiler if needed"
|
2014-02-28 08:03:56 +01:00
|
|
|
if $(uname -m | grep -q arm); then
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . ARM host detected, no cross-compiler needed"
|
2014-02-28 08:03:56 +01:00
|
|
|
CROSS_COMPILE=''
|
|
|
|
else
|
|
|
|
#Read this for further information if you run into problems with gcc compiler
|
|
|
|
#http://linux-sunxi.org/Toolchain
|
|
|
|
if [ ! -e $PWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux/ ]; then
|
2014-03-01 17:53:25 +01:00
|
|
|
if [ ! -e $CWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz ]; then
|
|
|
|
echo ". . downloading cross-compiler"
|
2014-03-01 18:57:47 +01:00
|
|
|
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
|
2014-03-01 17:53:25 +01:00
|
|
|
fi
|
|
|
|
echo ". . installing cross-compiler locally"
|
2014-02-28 08:03:56 +01:00
|
|
|
tar xf $CWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz
|
|
|
|
fi
|
2014-02-26 12:06:35 +01:00
|
|
|
|
2014-02-28 08:03:56 +01:00
|
|
|
CROSS_COMPILE=$PWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux/bin/arm-linux-gnueabihf-
|
|
|
|
fi
|
2014-03-01 17:53:25 +01:00
|
|
|
}
|
2014-02-28 08:03:56 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
function clone_pull_patch_sources() {
|
2014-02-28 17:12:11 +01:00
|
|
|
mkdir -p $DEST/image
|
2014-02-17 08:53:07 +01:00
|
|
|
|
2014-02-27 23:11:40 +01:00
|
|
|
# Boot loader
|
|
|
|
if [ -d "$DEST/u-boot-sunxi" ]; then
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . updating u-boot-sunxi"
|
2014-02-27 23:11:40 +01:00
|
|
|
( cd $DEST/u-boot-sunxi;
|
|
|
|
git pull )
|
|
|
|
else
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . cloning u-boot-sunxi"
|
2014-08-21 10:03:52 +02:00
|
|
|
git clone $REPO_UBOOT $DEST/u-boot-sunxi
|
2014-02-27 23:11:40 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Allwinner tools
|
|
|
|
if [ -d "$DEST/sunxi-tools" ]; then
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . updating sunxi-tools"
|
2014-02-27 23:11:40 +01:00
|
|
|
( cd $DEST/sunxi-tools;
|
|
|
|
git pull )
|
|
|
|
else
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . cloning sunxi-tools"
|
2014-08-21 10:03:52 +02:00
|
|
|
git clone $REPO_SUNXI_TOOLS $DEST/sunxi-tools
|
2014-02-27 23:11:40 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Hardware configurations
|
|
|
|
if [ -d "$DEST/cubie_configs" ]; then
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . updating cubie_configs"
|
2014-02-27 23:11:40 +01:00
|
|
|
( cd $DEST/cubie_configs;
|
|
|
|
git pull )
|
|
|
|
else
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . cloning sunxi-tools"
|
2014-08-21 10:03:52 +02:00
|
|
|
git clone $REPO_CONFIGS $DEST/cubie_configs
|
2014-02-27 23:11:40 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . patching sunxi-tools"
|
2014-02-27 23:11:40 +01:00
|
|
|
# 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
|
|
|
|
|
|
|
|
# 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 = 4/g' $DEST/cubie_configs/sysconfig/linux/ct.fex > $DEST/cubie_configs/sysconfig/linux/ct-vga.fex
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "$DEST/linux-sunxi" ]; then
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . updating linux-sunxi"
|
2014-02-27 23:11:40 +01:00
|
|
|
( cd $DEST/linux-sunxi;
|
|
|
|
git pull -f )
|
|
|
|
else
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . updating linux-sunxi"
|
2014-08-21 10:03:52 +02:00
|
|
|
git clone $REPO_LINUX $DEST/linux-sunxi
|
2014-02-27 23:11:40 +01:00
|
|
|
fi
|
2014-03-01 17:53:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2015-02-20 10:44:55 +01:00
|
|
|
cp $CWD/config/kernel.config $DEST/u-boot-sunxi/include/linux/config.h
|
2014-03-01 17:53:25 +01:00
|
|
|
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
|
|
|
|
$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
|
|
|
|
|
2014-02-28 10:10:59 +01:00
|
|
|
( cd $DEST/linux-sunxi
|
2014-02-28 11:12:33 +01:00
|
|
|
PATH=$PATH:$BINARIES_DIR/u-boot-sunxi/
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . adding ap6210 firmware to kernel"
|
2014-02-28 10:10:59 +01:00
|
|
|
( cd $DEST/linux-sunxi/firmware;
|
2014-02-28 11:58:39 +01:00
|
|
|
unzip -o $CWD/firmwares/ap6210.zip )
|
2014-02-26 12:06:35 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . compiling kernel"
|
2014-02-28 10:10:59 +01:00
|
|
|
make -j2 ARCH=arm CROSS_COMPILE=$CROSS_COMPILE sun7i_defconfig
|
2014-02-26 12:06:35 +01:00
|
|
|
|
2014-02-28 10:10:59 +01:00
|
|
|
# get proven 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 INSTALL_MOD_PATH=output modules_install
|
2014-02-28 11:12:33 +01:00
|
|
|
make -j2 ARCH=arm CROSS_COMPILE=$CROSS_COMPILE INSTALL_HDR_PATH=output headers_install
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . installing kernel in $BINARIES_DIR"
|
2014-02-28 11:12:33 +01:00
|
|
|
mkdir -p $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/firmware/ $BINARIES_DIR/$(basename $(pwd))
|
|
|
|
)
|
2014-03-01 17:53:25 +01:00
|
|
|
}
|
2014-02-26 12:06:35 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
function pack_binaries() {
|
|
|
|
echo ". packaging $BINARIES_DIR into $BINARIES_DIR"
|
2014-02-28 12:21:10 +01:00
|
|
|
tar Jcf $BINARIES_DIR-$VERSION.tar.xz $BINARIES_DIR
|
2014-03-01 17:53:25 +01:00
|
|
|
}
|
2014-02-28 12:25:36 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
function create_and_mount_image() {
|
|
|
|
echo ". creating and mounting image"
|
|
|
|
mkdir -p $DEST/image
|
|
|
|
cd $DEST/image
|
2013-12-29 12:01:02 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
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
|
2014-02-26 12:06:35 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
LOOP0=$(losetup -f)
|
|
|
|
losetup $LOOP0 ${IMG_NAME}-${VERSION}_rootfs_SD.raw
|
2014-02-26 12:06:35 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . Partitionning and mounting filesystem"
|
|
|
|
dd if=$DEST/u-boot-sunxi/u-boot-sunxi-with-spl.bin of=$LOOP0 bs=1024 seek=8
|
2013-12-29 12:01:02 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
# create one partition starting at 2048 which is default
|
|
|
|
(echo n; echo p; echo 1; echo; echo; echo w) | fdisk $LOOP0 >> /dev/null || true
|
2014-02-27 23:11:40 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
# just to make sure
|
|
|
|
partprobe $LOOP0
|
2014-02-27 23:11:40 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
LOOP1=$(losetup -f)
|
|
|
|
# 2048 (start) x 512 (block size) = where to mount partition
|
|
|
|
losetup -o 1048576 $LOOP1 $LOOP0
|
2014-02-27 23:11:40 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . create filesystem"
|
|
|
|
mkfs.ext4 $LOOP1
|
2014-02-27 23:11:40 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . create mount point and mount image"
|
|
|
|
mkdir -p $DEST/image/sdcard/
|
|
|
|
mount $LOOP1 $DEST/image/sdcard/
|
|
|
|
}
|
2014-02-27 23:11:40 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
function umount_image() {
|
|
|
|
echo ". umount image"
|
|
|
|
umount -d -l $DEST/image/sdcard/
|
|
|
|
losetup -d $LOOP1
|
|
|
|
losetup -d $LOOP0
|
2014-02-27 23:11:40 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo "cleaning"
|
|
|
|
rm -r $DEST/image/sdcard/
|
|
|
|
}
|
2014-02-27 23:11:40 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
function compress_image() {
|
|
|
|
echo ". compress image"
|
|
|
|
xz -z $DEST/image/${IMG_NAME}-${VERSION}_rootfs_SD.raw
|
|
|
|
}
|
2014-02-27 23:11:40 +01:00
|
|
|
|
2014-03-01 18:57:47 +01:00
|
|
|
function download_and_install_minirootfs() {
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". install minirootds"
|
|
|
|
cd $DEST/image/sdcard/
|
|
|
|
if [ ! -e $CWD/slack-$SLACKWARE_VERSION-miniroot_$ROOTFS_VERSION.tar.xz ]; then
|
|
|
|
echo ". . downloading minirootfs"
|
2014-03-01 18:57:47 +01:00
|
|
|
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
|
2014-03-01 17:53:25 +01:00
|
|
|
fi
|
|
|
|
echo ". . extracting minirootfs"
|
|
|
|
tar xf $CWD/slack-$SLACKWARE_VERSION-miniroot_$ROOTFS_VERSION.tar.xz
|
|
|
|
}
|
2014-01-02 11:33:32 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
function configure_slackwarearm() {
|
|
|
|
echo ". configuring system"
|
|
|
|
cat > $DEST/image/sdcard/etc/motd <<EOF
|
2014-02-24 19:44:00 +01:00
|
|
|
_ _ _ _
|
2014-01-10 15:08:31 +01:00
|
|
|
___ _ _ | |__ (_) ___ | |_ _ __ _ _ ___ | | __
|
|
|
|
/ __|| | | || '_ \ | | / _ \| __|| '__|| | | | / __|| |/ /
|
2014-02-24 19:44:00 +01:00
|
|
|
| (__ | |_| || |_) || || __/| |_ | | | |_| || (__ | <
|
2014-01-10 15:08:31 +01:00
|
|
|
\___| \__,_||_.__/ |_| \___| \__||_| \__,_| \___||_|\_\
|
2014-02-24 19:44:00 +01:00
|
|
|
Slackware
|
2014-01-10 15:08:31 +01:00
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . install script to turn off the LED blinking"
|
|
|
|
cp $CWD/scripts/disable_led.sh $DEST/image/sdcard/bin/disable_led.sh
|
|
|
|
chmod +x $DEST/image/sdcard/bin/disable_led.sh
|
2014-01-01 19:34:06 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
cat <<EOF >> $DEST/image/sdcard/etc/rc.d/rc.local
|
2014-02-27 22:35:25 +01:00
|
|
|
|
|
|
|
# Uncomment the following line to turn off the leds after booting
|
|
|
|
# /bin/disable_led.sh
|
|
|
|
EOF
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . copy script to expand filesystem to the whole card"
|
|
|
|
cp $CWD/scripts/resize2fs-arch.sh $DEST/image/sdcard/root/resize2fs-root.sh
|
|
|
|
chmod +x $DEST/image/sdcard/root/resize2fs-root.sh
|
2013-12-29 12:01:02 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . set hostname"
|
|
|
|
echo darkstar > $DEST/image/sdcard/etc/HOSTNAME
|
2014-01-29 19:33:14 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . setup fstab"
|
|
|
|
echo '/dev/mmcblk0p1 / ext4 defaults 1 1' >> $DEST/image/sdcard/etc/fstab
|
|
|
|
echo 'tmpfs /tmp tmpfs defaults,nosuid,size=30% 0 0' >> $DEST/image/sdcard/etc/fstab
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_kernel_and_boot() {
|
|
|
|
echo ". install kernel and setup boot"
|
|
|
|
echo ". . remove the preconfigured boot and setup ours"
|
|
|
|
rm -rf $DEST/image/sdcard/boot/*
|
|
|
|
|
|
|
|
TARGET=/image/sdcard
|
|
|
|
if [ -x /sbin/makepkg ] && [ -x /sbin/installpkg ]; then
|
|
|
|
mkdir -p $DEST/pkg-linux-sunxi/{boot,lib}/
|
|
|
|
TARGET=/pkg-linux-sunxi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ". . configure u-boot"
|
|
|
|
cat <<EOF > $DEST$TARGET/boot/uEnv.txt
|
|
|
|
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
|
|
|
|
panic=10 rootfstype=ext4 rootflags=discard
|
|
|
|
EOF
|
2014-02-15 15:22:33 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo ". . setup video output"
|
|
|
|
cp $BINARIES_DIR/cubie_configs/script-*.bin $DEST$TARGET/boot/
|
|
|
|
( cd $DEST$TARGET/boot/
|
2014-08-20 17:00:46 +02:00
|
|
|
[ -e script.bin ] && rm script.bin
|
2014-03-01 17:53:25 +01:00
|
|
|
case $CUBIETRUCK_DISPLAY in
|
|
|
|
VGA) ln script-vga.bin script.bin
|
|
|
|
;;
|
|
|
|
HDMI) ln script-hdmi.bin script.bin
|
|
|
|
;;
|
|
|
|
esac )
|
|
|
|
|
|
|
|
echo ". . Installing kernel"
|
|
|
|
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/firmware/ $DEST$TARGET/lib/
|
|
|
|
|
|
|
|
echo ". . write rc.modules"
|
|
|
|
mkdir -p $DEST$TARGET/etc/rc.d/
|
|
|
|
cat >> $DEST$TARGET/etc/rc.d/rc.modules <<EOT
|
2014-02-26 12:06:35 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2014-02-24 19:44:00 +01:00
|
|
|
/sbin/modprobe hci_uart
|
|
|
|
/sbin/modprobe gpio_sunxi
|
|
|
|
/sbin/modprobe bcmdhd
|
|
|
|
/sbin/modprobe ump
|
|
|
|
/sbin/modprobe mali
|
|
|
|
#/sbin/modprobe sunxi_gmac
|
2014-01-25 11:03:52 +01:00
|
|
|
EOT
|
2014-03-02 17:45:06 +01:00
|
|
|
chmod +x $DEST$TARGET/etc/rc.d/rc.modules
|
2013-12-29 12:01:02 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
if [ -x /sbin/makepkg ] && [ -x /sbin/installpkg ]; then
|
|
|
|
echo ". . build slackware package for kernel"
|
|
|
|
mkdir -p $DEST/pkg-linux-sunxi/install/
|
|
|
|
PRGNAM=linux-sunxi
|
|
|
|
cat <<EOF > $DEST/pkg-linux-sunxi/install/slack-desc
|
2014-03-01 09:00:50 +01:00
|
|
|
$PRGNAM: $PRGNAM (Linux sunxi kernel)
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM: Linux is a clone of the operating system Unix, written from scratch by
|
|
|
|
$PRGNAM: Linus Torvalds with assistance from a loosely-knit team of hackers
|
|
|
|
$PRGNAM: across the Net. It aims towards POSIX and Single UNIX Specification
|
|
|
|
$PRGNAM: compliance.
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM: It has all the features you would expect in a modern fully-fledged Unix
|
|
|
|
$PRGNAM:
|
2014-08-21 10:03:52 +02:00
|
|
|
$PRGNAM: $REPO_LINUX
|
2014-03-01 09:00:50 +01:00
|
|
|
$PRGNAM:
|
|
|
|
EOF
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
VERSION=$(cat $DEST/linux-sunxi/Makefile | grep "^VERSION" | sed "s|^VERSION = \(.*\)$|\1|g")
|
|
|
|
VERSION=$VERSION.$(cat $DEST/linux-sunxi/Makefile | grep "^PATCHLEVEL" | sed "s|^PATCHLEVEL = \(.*\)$|\1|g")
|
|
|
|
VERSION=$VERSION.$(cat $DEST/linux-sunxi/Makefile | grep "^SUBLEVEL" | sed "s|^SUBLEVEL = \(.*\)$|\1|g")
|
|
|
|
# VERSION=$VERSION.$(cat $DEST/linux-sunxi/Makefile | grep "^EXTRAVERSION" | sed "s|^EXTRAVERSION = \(.*\)$|\1|g")
|
|
|
|
ARCH=arm
|
|
|
|
BUILD=1
|
|
|
|
TAG=cyco
|
2014-03-01 09:00:50 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
( cd $DEST/pkg-linux-sunxi
|
2014-03-01 09:00:50 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
makepkg -l y -c n $DEST/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz
|
|
|
|
)
|
2014-03-01 09:00:50 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
installpkg --root $DEST/image/sdcard/ $DEST/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz
|
|
|
|
fi
|
|
|
|
}
|
2013-12-29 12:01:02 +01:00
|
|
|
|
2014-03-01 18:57:47 +01:00
|
|
|
function clean_image() {
|
|
|
|
rm $DEST/image/*
|
|
|
|
}
|
|
|
|
|
|
|
|
function clean_binaries() {
|
|
|
|
rm -r $DEST/binaries/*
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
# commandline arguments processing
|
|
|
|
while [ "x$1" != "x" ]
|
|
|
|
do
|
|
|
|
case "$1" in
|
2014-03-01 18:57:47 +01:00
|
|
|
-b | --binaries )
|
|
|
|
shift
|
|
|
|
DOWNLOAD_BINARIES="true"
|
|
|
|
COMPILE_BINARIES="false"
|
|
|
|
;;
|
2014-03-01 17:53:25 +01:00
|
|
|
--clean )
|
|
|
|
shift
|
|
|
|
clean_sources
|
2014-03-01 18:57:47 +01:00
|
|
|
clean_binaries
|
|
|
|
clean_image
|
2014-03-01 17:53:25 +01:00
|
|
|
exit -1
|
|
|
|
;;
|
|
|
|
-c | --compile )
|
|
|
|
shift
|
2014-03-01 18:57:47 +01:00
|
|
|
COMPILE_BINARIES="true"
|
|
|
|
DOWNLOAD_BINARIES="false"
|
2014-03-01 17:53:25 +01:00
|
|
|
;;
|
|
|
|
-dc | --dont-compile )
|
|
|
|
shift
|
2014-03-01 18:57:47 +01:00
|
|
|
COMPILE_BINARIES="false"
|
2014-03-01 17:53:25 +01:00
|
|
|
;;
|
|
|
|
-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
|
|
|
|
;;
|
|
|
|
|
|
|
|
-h | --help )
|
|
|
|
echo -e "Usage: run as root: $0 <options>"
|
|
|
|
echo -e "Options:"
|
|
|
|
echo -e "\t--clean"
|
2014-03-01 18:57:47 +01:00
|
|
|
echo -e "\t\tclean sources, remove binaries and image"
|
|
|
|
|
|
|
|
echo -e "\t-b | --binaries"
|
|
|
|
echo -e "\t\tdownload and use pre-built binaries"
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo -e "\t-c | --compile"
|
2014-03-01 18:57:47 +01:00
|
|
|
echo -e "\t\tbuild binaries locally"
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo -e "\t-dc | --dont-compile (default)"
|
2014-03-01 18:57:47 +01:00
|
|
|
echo -e "\t\tskip compilation"
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo -e "\t-i | --create-image (default)"
|
2014-03-01 18:57:47 +01:00
|
|
|
echo -e "\t\tgenerate image"
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo -e "\t-ni | --no-image"
|
2014-03-01 18:57:47 +01:00
|
|
|
echo -e "\t\tskip image generation"
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo -e "\t-d | --display [\"HDMI\"|\"VGA\"] (default: $CUBIETRUCK_DISPLAY)"
|
2014-03-01 18:57:47 +01:00
|
|
|
echo -e "\t\tconfiguration image video output"
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo -e "\t-gz | --compress (default: no)"
|
2014-03-01 18:57:47 +01:00
|
|
|
echo -e "\t\tcompress image (takes time)"
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo -e "\t-n | --image-name [\"nom\"] (default: $IMG_NAME)"
|
2014-03-01 18:57:47 +01:00
|
|
|
echo -e "\t\tname the image"
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo -e "\t-r | --rootfs-version [\"version number\"] (default: $ROOTFS_VERSION)"
|
2014-03-01 18:57:47 +01:00
|
|
|
echo -e "\t\tversion of the minirootfs"
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo -e "\t-s | --image-size [size in MB] (default: $IMAGE_SIZE_MB)"
|
2014-03-01 18:57:47 +01:00
|
|
|
echo -e "\t\tsize of the image (see resizefs script in image)"
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo -e "\t-o | --output [/directory/] (default: $DEST)"
|
2014-03-01 18:57:47 +01:00
|
|
|
echo -e "\t\tdirectory where the image will be generated"
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo -e "\t--package-binaries"
|
|
|
|
echo -e "\t\tpackage compiled binaries into $BINARIES_DIR-$VERSION.tar.xz"
|
|
|
|
echo -e "\t\t(combine with --compile)"
|
2014-03-01 18:57:47 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
echo -e "\t-v | --image-version [\"version number\"] (default: $VERSION)"
|
2014-03-01 18:57:47 +01:00
|
|
|
echo -e "\t\tversion the image"
|
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
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)"
|
2014-03-01 18:57:47 +01:00
|
|
|
echo -e "\t\tversion of the cross-compiler"
|
2014-03-01 17:53:25 +01:00
|
|
|
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2014-02-27 23:11:40 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
# --- Script --------------------------------------------------------------------
|
|
|
|
prepare_dest
|
2014-02-27 23:11:40 +01:00
|
|
|
|
2014-03-01 18:57:47 +01:00
|
|
|
if [ "$COMPILE_BINARIES" = "true" ]; then
|
2014-03-01 17:53:25 +01:00
|
|
|
setup_x_toolchain
|
|
|
|
clone_pull_patch_sources
|
|
|
|
clean_sources
|
|
|
|
compile
|
2014-03-01 18:57:47 +01:00
|
|
|
else
|
2014-08-20 15:26:11 +02:00
|
|
|
if [ "$DOWNLOAD_BINARIES" = "true" ]; then
|
2014-03-01 18:57:47 +01:00
|
|
|
download_and_install_binaries
|
|
|
|
fi
|
2014-03-01 17:53:25 +01:00
|
|
|
fi
|
2014-02-26 12:06:35 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
[ "$PACKAGE_BINARIES" = "true" ] && pack_binaries && exit -1
|
2014-02-27 23:16:25 +01:00
|
|
|
|
2014-03-01 17:53:25 +01:00
|
|
|
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
|
2014-03-01 18:57:47 +01:00
|
|
|
download_and_install_minirootfs
|
2014-03-01 17:53:25 +01:00
|
|
|
configure_slackwarearm
|
|
|
|
install_kernel_and_boot
|
|
|
|
umount_image
|
2014-02-28 08:42:21 +01:00
|
|
|
fi
|
2014-03-01 17:53:25 +01:00
|
|
|
|
|
|
|
[ "$COMPRESS" = "true" ] && compress_image
|