Files
arm-kali/cubietruck.sh

121 lines
3.7 KiB
Bash
Raw Normal View History

2021-09-16 06:42:05 +01:00
#!/usr/bin/env bash
#
2021-09-27 10:51:02 +01:00
# Kali Linux ARM build-script for CubieTruck (CubieBoard3) (32-bit)
# Source: https://gitlab.com/kalilinux/build-scripts/kali-arm
2021-09-16 06:42:05 +01:00
#
# This is a community script - you will need to generate your own image to use
# More information: https://www.kali.org/docs/arm/cubietruck/
#
2021-11-05 20:07:25 +01:00
# Hardware model
hw_model=${hw_model:-"cubietruck"}
# Architecture (arm64, armhf, armel)
2020-07-22 11:42:27 -05:00
architecture=${architecture:-"armhf"}
2021-11-05 20:07:25 +01:00
# Desktop manager (xfce, gnome, i3, kde, lxde, mate, e17 or none)
desktop=${desktop:-"xfce"}
2021-11-05 20:07:25 +01:00
# Load default base_image configs
source ./common.d/base_image.sh
2020-07-22 11:42:27 -05:00
2021-11-05 20:07:25 +01:00
# Network configs
2021-11-06 15:45:57 +01:00
basic_network
2021-11-05 20:07:25 +01:00
add_interface eth0
2021-11-05 20:07:25 +01:00
# Load the ethernet module since it doesn't load automatically at boot
echo "sunxi_gmac" >> ${work_dir}/etc/modules
2020-07-22 11:42:27 -05:00
# Run third stage
2021-11-05 20:07:25 +01:00
include third_stage
2020-07-22 11:42:27 -05:00
# Clean system
2021-11-05 20:07:25 +01:00
include clean_system
# Kernel section. If you want to us ea custom kernel, or configuration, replace
2021-09-16 06:58:38 +01:00
# them in this section
# Get, compile and install kernel
git clone --depth 1 https://github.com/linux-sunxi/u-boot-sunxi
2020-07-22 11:42:27 -05:00
git clone --depth 1 https://github.com/linux-sunxi/linux-sunxi -b stage/sunxi-3.4 ${work_dir}/usr/src/kernel
git clone --depth 1 https://github.com/linux-sunxi/sunxi-tools
git clone --depth 1 https://github.com/linux-sunxi/sunxi-boards
cd "${base_dir}"/sunxi-tools
make fex2bin
./fex2bin "${base_dir}"/sunxi-boards/sys_config/a20/cubietruck.fex ${work_dir}/boot/script.bin
2020-07-22 11:42:27 -05:00
cd ${work_dir}/usr/src/kernel
2015-08-10 22:19:06 -05:00
git rev-parse HEAD > ../kernel-at-commit
patch -p1 --no-backup-if-mismatch < ${repo_dir}/patches/mac80211.patch
touch .scmversion
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
cp ${repo_dir}/kernel-configs/sun7i.config .config
cp ${repo_dir}/kernel-configs/sun7i.config ${work_dir}/usr/src/sun7i.config
make -j $(grep -c processor /proc/cpuinfo) uImage modules
2020-07-22 11:42:27 -05:00
make modules_install INSTALL_MOD_PATH=${work_dir}
cp arch/arm/boot/uImage ${work_dir}/boot
2015-08-10 22:19:06 -05:00
make mrproper
cp ../sun7i.config .config
cd "${base_dir}"
2017-09-20 17:41:33 -05:00
# Fix up the symlink for building external modules
# kernver is used so we don't need to keep track of what the current compiled
# version is
2020-07-22 11:42:27 -05:00
kernver=$(ls ${work_dir}/lib/modules/)
cd ${work_dir}/lib/modules/${kernver}
2017-09-20 17:41:33 -05:00
rm build
rm source
ln -s /usr/src/kernel build
ln -s /usr/src/kernel source
cd "${base_dir}"
2017-09-20 17:41:33 -05:00
# Create boot.txt file
2020-07-22 11:42:27 -05:00
cat << EOF > ${work_dir}/boot/boot.cmd
setenv bootm_boot_mode sec
setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait panic=10 \${extra} rw rootfstype=$fstype net.ifnames=0
fatload mmc 0 0x43000000 script.bin
fatload mmc 0 0x48000000 uImage
bootm 0x48000000
EOF
# Create u-boot boot script image
2020-07-22 11:42:27 -05:00
mkimage -A arm -T script -C none -d ${work_dir}/boot/boot.cmd ${work_dir}/boot/boot.scr
2018-07-06 18:03:37 -05:00
2021-11-05 20:07:25 +01:00
# Calculate the space to create the image and create
make_image
2018-07-06 18:03:37 -05:00
2021-11-05 20:07:25 +01:00
# Create the disk partitions
2021-09-19 13:45:29 +01:00
parted -s "${image_dir}/${image_name}.img" mklabel msdos
parted -s "${image_dir}/${image_name}.img" mkpart primary fat32 1MiB ${bootsize}MiB
parted -s -a minimal "${image_dir}/${image_name}.img" mkpart primary $fstype ${bootsize}MiB 100%
2018-07-06 18:03:37 -05:00
# Set the partition variables
2021-11-05 20:07:25 +01:00
loopdevice=$(losetup --show -fP "${image_dir}/${image_name}.img")
bootp="${loopdevice}p1"
rootp="${loopdevice}p2"
2018-07-06 18:03:37 -05:00
# Create file systems
2021-11-06 14:00:40 +01:00
mkfs_partitions
2021-11-05 20:07:25 +01:00
# Make fstab.
make_fstab
2018-07-06 18:03:37 -05:00
# Create the dirs for the partitions and mount them
2021-11-05 20:07:25 +01:00
status "Create the dirs for the partitions and mount them"
mkdir -p "${base_dir}"/root/
mount "${rootp}" "${base_dir}"/root
mkdir -p "${base_dir}"/root/boot
2021-11-05 20:07:25 +01:00
mount "${bootp}" "${base_dir}"/root/boot
2018-07-06 18:03:37 -05:00
echo "Rsyncing rootfs to image file"
rsync -HPavz -q ${work_dir}/ ${base_dir}/root/
2018-07-06 18:03:37 -05:00
cd "${base_dir}"/u-boot-sunxi/
# Build u-boot
make distclean
make Cubietruck_config
make -j $(grep -c processor /proc/cpuinfo)
2018-07-06 18:03:37 -05:00
dd if=u-boot-sunxi-with-spl.bin of=${loopdevice} bs=1024 seek=8
2021-11-05 20:07:25 +01:00
# Load default finish_image configs
include finish_image