Modified to build a Slackware ARM image

Signed-off-by: Gwenhael Le Moine <gwenhael.le.moine@gmail.com>
This commit is contained in:
Gwenhael Le Moine 2014-02-24 19:44:00 +01:00
parent d1bb6d133c
commit d2afeab395

107
build.sh
View file

@ -2,12 +2,12 @@
# --- Configuration -------------------------------------------------------------
#change to your needs
VERSION="ArchLinux_0.1"
DEST_LANG="de_DE"
DEST_LANGUAGE="de"
VERSION="SlackwareARM_0.1"
DEST_LANG="en_US"
DEST_LANGUAGE="us"
COMPILE="true"
mkdir ~/cubie
DEST=~/cubie
mkdir ~/cubieslack
DEST=~/cubieslack
DISPLAY=3 # "3:hdmi; 4:vga"
# --- End -----------------------------------------------------------------------
SRC=$(pwd)
@ -36,7 +36,7 @@ rsn_pairwise=CCMP
auth_algs=1
macaddr_acl=0
fi
echo "Building Cubietruck-Arch in $DEST from $SRC"
echo "Building Cubietruck-Slackware in $DEST from $SRC"
sleep 3
#--------------------------------------------------------------------------------
# Downloading necessary files for building - aka Toolchain
@ -58,6 +58,8 @@ then
cd $DEST/u-boot-sunxi ; git pull; cd $SRC
else
git clone https://github.com/cubieboard/u-boot-sunxi $DEST/u-boot-sunxi # Boot loader
# Applying Patch for 2gb memory
patch -f $DEST/u-boot-sunxi/include/configs/sunxi-common.h < $SRC/patch/memory.patch || true
fi
if [ -d "$DEST/sunxi-tools" ]
then
@ -70,30 +72,26 @@ then
cd $DEST/cubie_configs; git pull; cd $SRC
else
git clone https://github.com/cubieboard/cubie_configs $DEST/cubie_configs # Hardware configurations
# 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
cd $DEST/linux-sunxi; git pull -f; cd $SRC
else
git clone https://github.com/patrickhwood/linux-sunxi $DEST/linux-sunxi # Patwood's kernel 3.4.75+
fi
# Applying Patch for 2gb memory
patch -f $DEST/u-boot-sunxi/include/configs/sunxi-common.h < $SRC/patch/memory.patch || true
# 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
###PATCH kernel CONFIG_HZ, Arm dfault is hardcoded 100hz (10ms latency!). For mulitimedia and desktop a higher frequency is recomended.
#test -f $SRC/patch/250HZ.patch && patch -f $DEST/linux-sunxi/arch/arm/Kconfig < $SRC/patch/250HZ.patch
test -f $SRC/patch/300HZ.patch && patch -f $DEST/linux-sunxi/arch/arm/Kconfig < $SRC/patch/300HZ.patch
test -f $SRC/patch/300HZ.patch && patch -f $DEST/linux-sunxi/arch/arm/Kconfig < $SRC/patch/300HZ.patch
#test -f $SRC/patch/1000HZ.patch && patch -f $DEST/linux-sunxi/arch/arm/Kconfig < $SRC/patch/1000HZ.patch
fi
# Copying Kernel config
@ -115,14 +113,14 @@ cp fex2bin bin2fex /usr/local/bin/
fex2bin $DEST/cubie_configs/sysconfig/linux/ct-vga.fex $DEST/output/script-vga.bin
fex2bin $DEST/cubie_configs/sysconfig/linux/ct-hdmi.fex $DEST/output/script-hdmi.bin
if ["$COMPILE" = "true"]; then
if [ "$COMPILE" = "true" ]; then
# kernel image
echo "------ Compiling kernel"
cd $DEST/linux-sunxi
make clean
# Adding wlan firmware to kernel source
cd $DEST/linux-sunxi/firmware;
cd $DEST/linux-sunxi/firmware;
unzip -o $SRC/bin/ap6210.zip
cd $DEST/linux-sunxi
@ -139,9 +137,9 @@ fi
echo "------ Creating SD Images"
cd $DEST/output
# create 2Gb image and mount image to next free loop device
dd if=/dev/zero of=arch_rootfs.raw bs=1M count=2000
dd if=/dev/zero of=slackware_rootfs.raw bs=1M count=2000
LOOP0=$(losetup -f)
losetup $LOOP0 arch_rootfs.raw
losetup $LOOP0 slackware_rootfs.raw
echo "------ Partitionning and mounting filesystem"
# make image bootable
@ -154,30 +152,27 @@ partprobe $LOOP0
LOOP1=$(losetup -f)
# 2048 (start) x 512 (block size) = where to mount partition
losetup -o 1048576 $LOOP1 $LOOP0
losetup -o 1048576 $LOOP1 $LOOP0
# create filesystem
mkfs.ext4 $LOOP1
# create mount point and mount image
# create mount point and mount image
mkdir -p $DEST/output/sdcard/
mount $LOOP1 $DEST/output/sdcard/
echo "------ Get basic Arch System"
#wget -q -P $DEST/output/sdcard/ -O - http://archlinuxarm.org/os/ArchLinuxARM-sun7i-latest.tar.gz | tar -xzf -
echo "------ Get basic Slackware System"
cd $DEST/output/sdcard/
wget -q http://archlinuxarm.org/os/ArchLinuxARM-sun7i-latest.tar.gz
tar xzf ArchLinuxARM-sun7i-latest.tar.gz
wget -q ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-devtools/minirootfs/roots/slack-14.1-miniroot_04Nov13.tar.xz
tar xf slack-14.1-miniroot_04Nov13.tar.xz
sync
rm ArchLinuxARM-sun7i-latest.tar.gz
# we need this donno why???
#cp /usr/bin/qemu-arm-static $DEST/output/sdcard/usr/bin/
rm slack-14.1-miniroot_04Nov13.tar.xz
cat > $DEST/output/sdcard/etc/motd <<EOF
_ _ _ _
_ _ _ _
___ _ _ | |__ (_) ___ | |_ _ __ _ _ ___ | | __
/ __|| | | || '_ \ | | / _ \| __|| '__|| | | | / __|| |/ /
| (__ | |_| || |_) || || __/| |_ | | | |_| || (__ | <
| (__ | |_| || |_) || || __/| |_ | | | |_| || (__ | <
\___| \__,_||_.__/ |_| \___| \__||_| \__,_| \___||_|\_\
Slackware
EOF
@ -190,9 +185,9 @@ chmod +x $DEST/output/sdcard/bin/disable_led.sh
echo disable_led.sh > $DEST/output/sdcard/etc/rc.conf
# scripts for autoresize at first boot from cubian
cp $SRC/scripts/cubian-resize2fs $DEST/output/sdcard/cubian-resize2fs
cp $SRC/scripts/resize2fs-arch.sh $DEST/output/sdcard/resize2fs-arch.sh
# make it executable
chmod +x $DEST/output/sdcard/cubian-resize2fs
chmod +x $DEST/output/sdcard/resize2fs-arch.sh
# and startable on boot just execute it once not on every boot!!!
#echo cubian-resize2fs > $DEST/output/sdcard/etc/rc.conf
@ -202,20 +197,18 @@ cp $SRC/bin/nand1-boot-cubietruck-arch.tgz $DEST/output/sdcard/root
# install and configure locales for Germany
echo LANG='$DEST_LANG'.UTF-8 > $DEST/output/sdcard/etc/default.conf
echo KEYMAP=de-latin1-nodeadkeys > $DEST/output/sdcard/etc/vconsole.conf
echo KEYMAP=us > $DEST/output/sdcard/etc/vconsole.conf
#use this command when System runs
# sudo timedatectl set-timezone Zone/SubZone
# when setup preferred gui like openbox then use loadkeys de
# i recommend you to change this urgently + add a proper user for the System!!!
# default passwort for user "root" is "root"
# default passwort for user "root" is "root"
#echo 1234;echo 1234; | passwd root
# set hostname
echo cubie > $DEST/output/sdcard/etc/hostname
# set hostname
echo darkstar > $DEST/output/sdcard/etc/hostname
# not update the firmware!!
sed -i 's/#IgnorePkg =/IgnorePkg = linux-sun7i/g' $DEST/output/sdcard/etc/pacman.conf
### mount /tmp as tmpfs
@ -234,13 +227,13 @@ echo "timeout 5" >> /etc/dhcpcd.conf
# load modules you may load them per sysctl
cat > $DEST/output/sdcard/etc/modules-load.d/cubieModules.conf <<EOT
hci_uart
gpio_sunxi
bcmdhd
ump
mali
#sunxi_gmac
cat >> $DEST/output/sdcard/etc/rc.d/rc.local <<EOT
/sbin/modprobe hci_uart
/sbin/modprobe gpio_sunxi
/sbin/modprobe bcmdhd
/sbin/modprobe ump
/sbin/modprobe mali
#/sbin/modprobe sunxi_gmac
EOT
@ -259,7 +252,7 @@ EOT
#auto wlan0
#allow-hotplug wlan0
#iface wlan0 inet dhcp
# wpa-ssid SSID
# wpa-ssid SSID
# wpa-psk xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# to generate proper encrypted key: wpa_passphrase yourSSID yourpassword
@ -314,8 +307,8 @@ cp -R $DEST/linux-sunxi/output/lib/firmware/ $DEST/output/sdcard/lib/
#sed -e 's/%DAEMONNAME_TAG%/usbsrvd/g' $DEST/usb-redirector-linux-arm-eabi/files/rc.usbsrvd1 > $DEST/usb-redirector-linux-arm-eabi/files/rc.usbsrvd
#chmod +x $DEST/usb-redirector-linux-arm-eabi/files/rc.usbsrvd
# copy to root
#cp $DEST/usb-redirector-linux-arm-eabi/files/usb* $DEST/output/sdcard/usr/local/bin/
#cp $DEST/usb-redirector-linux-arm-eabi/files/modules/src/tusbd/tusbd.ko $DEST/output/sdcard/usr/local/bin/
#cp $DEST/usb-redirector-linux-arm-eabi/files/usb* $DEST/output/sdcard/usr/local/bin/
#cp $DEST/usb-redirector-linux-arm-eabi/files/modules/src/tusbd/tusbd.ko $DEST/output/sdcard/usr/local/bin/
#cp $DEST/usb-redirector-linux-arm-eabi/files/rc.usbsrvd $DEST/output/sdcard/etc/modules-load.d/
# started by default
@ -327,13 +320,13 @@ cp $SRC/config/hostapd.conf $DEST/output/sdcard/etc/
# sunxi-tools
cd $DEST/sunxi-tools
make clean && make -j2 'fex2bin' CC=arm-linux-gnueabihf-gcc && make -j2 'bin2fex' CC=arm-linux-gnueabihf-gcc && make -j2 'nand-part' CC=arm-linux-gnueabihf-gcc
cp fex2bin $DEST/output/sdcard/usr/bin/
cp fex2bin $DEST/output/sdcard/usr/bin/
cp bin2fex $DEST/output/sdcard/usr/bin/
cp nand-part $DEST/output/sdcard/usr/bin/
# umount images
umount $DEST/output/sdcard/
# umount images
umount $DEST/output/sdcard/
losetup -d $LOOP1
losetup -d $LOOP0
# compress image
# compress image
gzip $DEST/output/*.raw