Files
arm-kali/cubieboard2.sh

125 lines
3.6 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 CubieBoard2 (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/cubieboard2/
#
2021-11-06 20:31:54 +01:00
# Hardware model
hw_model=${hw_model:-"cubieboard2"}
2022-08-22 20:24:28 +03:00
2021-11-06 20:31:54 +01:00
# Architecture (arm64, armhf, armel)
2020-07-22 11:26:34 -05:00
architecture=${architecture:-"armhf"}
2022-08-22 20:24:28 +03:00
2021-11-06 20:31:54 +01:00
# Desktop manager (xfce, gnome, i3, kde, lxde, mate, e17 or none)
desktop=${desktop:-"xfce"}
2013-10-29 16:45:51 +02:00
2021-11-06 20:31:54 +01:00
# Load default base_image configs
source ./common.d/base_image.sh
2021-11-06 20:31:54 +01:00
# Network configs
basic_network
add_interface eth0
2013-10-29 16:45:51 +02:00
2020-07-22 11:26:34 -05:00
# Run third stage
2021-11-06 20:31:54 +01:00
include third_stage
2013-10-29 16:45:51 +02:00
2020-07-22 11:26:34 -05:00
# Clean system
2021-11-06 20:31:54 +01:00
include clean_system
2021-11-06 20:31:54 +01:00
# Calculate the space to create the image and create
make_image
2022-08-22 20:24:28 +03:00
2021-09-16 06:58:38 +01:00
# Load the ethernet module since it doesn't load automatically at boot
2022-08-22 20:24:28 +03:00
echo "sunxi_emac" >>${work_dir}/etc/modules
2013-10-29 16:45:51 +02:00
# 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
2013-10-29 16:45:51 +02:00
# Get, compile and install kernel
cd ${base_dir}
2013-10-29 16:45:51 +02:00
git clone --depth 1 https://github.com/linux-sunxi/u-boot-sunxi
2020-07-22 11:26:34 -05:00
git clone --depth 1 https://github.com/linux-sunxi/linux-sunxi -b stage/sunxi-3.4 ${work_dir}/usr/src/kernel
2013-10-29 16:45:51 +02:00
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
2013-10-29 16:45:51 +02:00
make fex2bin
./fex2bin "${base_dir}"/sunxi-boards/sys_config/a20/cubieboard2.fex ${work_dir}/boot/script.bin
2013-10-29 16:45:51 +02:00
2020-07-22 11:26:34 -05:00
cd ${work_dir}/usr/src/kernel
2022-08-22 20:24:28 +03:00
git rev-parse HEAD >${work_dir}/usr/src/kernel-at-commit
patch -p1 --no-backup-if-mismatch <${repo_dir}/patches/mac80211.patch
2013-10-29 16:45:51 +02:00
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
2013-10-29 16:45:51 +02:00
make -j $(grep -c processor /proc/cpuinfo) uImage modules
2020-07-22 11:26:34 -05:00
make modules_install INSTALL_MOD_PATH=${work_dir}
cp arch/arm/boot/uImage ${work_dir}/boot
2015-08-10 22:18:56 -05:00
make mrproper
cp ../sun7i.config .config
cd "${base_dir}"
2013-10-29 16:45:51 +02:00
2017-09-20 17:40:59 -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:26:34 -05:00
kernver=$(ls ${work_dir}/lib/modules/)
cd ${work_dir}/lib/modules/${kernver}
2017-09-20 17:40:59 -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:40:59 -05:00
2013-10-29 16:45:51 +02:00
# Create boot.txt file
2022-08-22 20:24:28 +03:00
cat <<EOF >${work_dir}/boot/boot.cmd
setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait panic=10 ${extra} rw rootfstype=$fstype net.ifnames=0
2013-10-29 16:45:51 +02:00
fatload mmc 0 0x43000000 script.bin
fatload mmc 0 0x48000000 uImage
bootm 0x48000000
EOF
# Create u-boot boot script image
2020-07-22 11:26:34 -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
# Create the disk and partition it
echo "Creating image file ${image_name}.img"
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-07 10:55:31 +01:00
make_loop
2022-08-22 20:24:28 +03:00
2018-07-06 18:03:37 -05:00
# Create file systems
2021-11-06 20:31:54 +01:00
mkfs_partitions
2022-08-22 20:24:28 +03:00
2021-11-06 20:31:54 +01:00
# Make fstab.
make_fstab
2018-07-06 18:03:37 -05:00
# 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
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/
2022-08-22 20:24:28 +03:00
2013-10-29 16:45:51 +02:00
# Build u-boot
make distclean
make Cubieboard2_config
2020-07-22 20:09:10 +00:00
make -j $(nproc)
2013-10-29 16:45:51 +02:00
2018-07-06 18:03:37 -05:00
dd if=u-boot-sunxi-with-spl.bin of=${loopdevice} bs=1024 seek=8
2013-10-29 16:45:51 +02:00
cd "${base_dir}"
2013-10-29 16:45:51 +02:00
2021-11-06 20:31:54 +01:00
# Load default finish_image configs
include finish_image