Commit ded97060 authored by Joanne Hugé's avatar Joanne Hugé

Add image and kernel utils scripts

Add make-bootable-sd, configure-board, copy-full-img, install-to-board, make-bootable-sd and update-vm-scripts
parent 02ddb222
...@@ -6,3 +6,17 @@ clockres/build/clockres ...@@ -6,3 +6,17 @@ clockres/build/clockres
clockres/build/clockres_arm clockres/build/clockres_arm
packet-exchange/build/server packet-exchange/build/server
packet-exchange/build/client packet-exchange/build/client
img-kernel-utils/full-img-debian
img-kernel-utils/full-img-olimex
img-kernel-utils/full-img-custom
img-kernel-utils/custom-kernels
img-kernel-utils/config
img-kernel-utils/debian-netboot
img-kernel-utils/boot-ressources/rootfs.tar.bz2
img-kernel-utils/boot-ressources/rootfs
img-kernel-utils/boot-ressources/u-boot-sunxi-with-spl.bin
scripts/packet-histogram_stop-options*
setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait panic=10 isolcpus=1 nohz_full=1 rcu_nocb=1
load mmc 0:1 0x43000000 ${fdtfile} || load mmc 0:1 0x43000000 boot/${fdtfile}
load mmc 0:1 0x42000000 uImage || load mmc 0:1 0x42000000 boot/uImage
bootm 0x42000000 - 0x43000000
#!/bin/bash
usage() {
echo "Usage: $0 [-h] [-p PARTITION_NUMBER] (emerald | onyx | slate) DEVICE"
exit 1;
}
partition_number=2
while getopts "h" opt; do
case "${opt}" in
h )
usage
;;
p )
partition_number=${OPTARG}
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "$2" ]; then
usage
fi
board_name=$1
device=$2
cfg_dir=../config
if [ $board_name != "emerald" ] && [ $board_name != "onyx" ] && [ $board_name != "slate" ]; then
usage
fi
rm -rf mnt_sd;
mkdir -p mnt_sd;
mount ${device}${partition_number} mnt_sd;
cp -r $cfg_dir/common/* mnt_sd;
cp -r $cfg_dir/$board_name/* mnt_sd;
umount ${device}${partition_number};
rm -rf mnt_sd;
#!/bin/bash
usage() {
echo 'Usage: $0 [-h] -c | -d ("5.6" | "4.19") | -o IMG DEVICE';
exit 1;
}
while getopts "hcd:o:" opt; do
case "${opt}" in
h )
usage
;;
c )
copy_custom=1
;;
d )
copy_debian=1
version=${OPTARG}
;;
o )
copy_olimex=1
img=${OPTARG}
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "$1" ]; then
usage
fi
device=$1
if [ -n "$copy_custom" ]; then
img="../full-img-custom/custom.img"
elif [ -n "$copy_debian" ]; then
if [ $version != "4.19" ] && [ $version != "5.6" ]; then
usage
fi
img="../full-img-debian/"
if [ $version == "4.19" ]; then
img+=debian_rt_4_19_buster.img
else
img+=debian_rt_5_6_bullseye-testing.img
fi
fi
dd if=$img of=$device bs=64k status=progress;
sync
#!/bin/bash
usage() {
echo "Usage: $0 [-h] [-dkm -i ARCHIVE_PATH] DEVICE"
exit 1;
}
while getopts "hdkmi:" opt; do
case "${opt}" in
h )
usage
;;
d )
install_dtb=1
;;
k )
install_kernel=1
;;
m )
install_modules=1
;;
i )
archive=${OPTARG}
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "$1" ]; then
usage
fi
device=$1
archive_name="$(basename -- $archive_path)"
echo "Uncompressing ${archive}...";
rm -rf kernel_output;
mkdir -p kernel_output;
echo "tar -xvf ${archive} -C kernel_output";
tar -xvf $archive -C kernel_output;
cd kernel_output;
rm -rf mnt_sd;
mkdir -p mnt_sd;
mount ${device}2 mnt_sd;
if [ -n "${install_modules}" ]; then
rm -rf mnt_sd/lib/modules;
mv modules mnt_sd/lib/;
fi
umount mnt_sd;
if [ -n "${install_kernel}" ] || [ -n "${install_dtb}" ]; then
mount ${device}1 mnt_sd;
if [ -n "${install_kernel}" ]; then
mv uImage mnt_sd/;
fi
if [ -n "${install_dtb}" ]; then
mv sun7i-a20-olinuxino-lime2.dtb mnt_sd/;
fi
umount mnt_sd;
fi
rm -rf mnt_sd;
cd ..;
rm -rf kernel_output;
#!/bin/bash
usage() {
echo "Usage: $0 [-hdkm] [-i ARCHIVE_PATH] [BOARD_NAME]"
exit 1;
}
board_name="emerald"
archive_path="$HOME/output.tar.gz"
while getopts "hdkmi:" opt; do
case "${opt}" in
h )
usage
;;
d )
install_dtb=1
;;
k )
install_kernel=1
;;
m )
install_modules=1
;;
i )
archive_path=$(readlink -m ${OPTARG})
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
if [ -n "$1" ]; then
board_name=$1
fi
archive_name="$(basename -- $archive_path)"
echo "Copying to ${board_name}...";
scp $archive_path $board_name:;
heredoc="$(cat << ENDBOARDSSH
echo "Uncompressing ${archive_name}...";
rm -rf kernel_output;
mkdir -p kernel_output;
echo "tar -xvf ${archive_name} -C kernel_output";
tar -xvf $archive_name -C kernel_output;
cd kernel_output;
if [ -n "${install_modules}" ]; then
sudo rm -rf /lib/modules;
sudo mv modules /lib/;
fi
if [ -n "${install_kernel}" ]; then
sudo mv uImage /boot/;
fi
if [ -n "${install_dtb}" ]; then
sudo mv sun7i-a20-olinuxino-lime2.dtb /boot/
fi
cd ..;
sudo rm -rf kernel_output;
sudo reboot;
ENDBOARDSSH
)"
echo "ssh on $board_name"
ssh -t $board_name "$heredoc"
echo "Installation done, rebooting...";
sleep 4;
until ssh $board_name uname -r;
do
sleep 1;
done
echo "Successful installation"
#!/bin/bash
usage() {
echo "Usage: $0 [-h] [-p | -r] DEVICE"
exit 1;
}
while getopts "hpr" opt; do
case "${opt}" in
h )
usage
;;
p )
only_partition=1
;;
r )
only_rootfs=1
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "$1" ]; then
usage
fi
device=$1
boot_ressources=../boot-ressources
# Partition and u-boot setup
if [ -z "$only_rootfs" ]; then
# Clear the partitions
dd if=/dev/zero of=${device} bs=1M count=1;
sync;
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${device}
o # clear the in memory partition table
n # new partition
# default - primary partition
# default - partition number 1
# default - start at beginning of disk
+16M # 16 MB parttion
n # new partition
# default - primary partition
# default - partion number 2
# default, start immediately after preceding partition
# default, extend partition to end of disk
w # write the partition table
q # and we're done
EOF
mkfs.vfat ${device}1;
mkfs.ext4 ${device}2;
dd if=$boot_ressources/u-boot-sunxi-with-spl.bin of=$device bs=1024 seek=8;
sync;
rm -rf mnt_sd;
mkdir -p mnt_sd;
mount ${device}1 mnt_sd;
cp $boot_ressources/boot.cmd mnt_sd;
mkimage -C none -A arm -T script -d mnt_sd/boot.cmd mnt_sd/boot.scr;
umount ${device}1;
rm -d mnt_sd;
fi
if [ -z "$only_partition" ]; then
rm -rf mnt_sd;
mkdir -p mnt_sd;
mount ${device}2 mnt_sd;
tar -C mnt_sd/ -xjpf $boot_ressources/rootfs.tar.bz2
umount ${device}2;
rm -d mnt_sd;
fi
#!/bin/bash
scp vm-scripts/compile-kernel nexedi-vm:
scp vm-scripts/install-to-board nexedi-vm:
#!/bin/bash
usage() {
echo "Usage: $0 [-hdkms] [-l LINUX_PATH] [-o OUTPUT_STR] (-u CONFIG_PATH | -c CONFIG_PATH | -n OLD_CONFIG_PATH NEW_CONFIG_PATH)"
exit 1;
}
linux_path=$HOME/linux
output_str=""
while getopts "hdkmsu:c:nl:o:" opt; do
case "${opt}" in
h )
usage
;;
s )
copy_to_sepia=1
;;
d )
compile_dtb=1
install_opts+="-d "
;;
k )
compile_kernel=1
install_opts+="-k "
;;
m )
compile_modules=1
install_opts+="-m "
;;
n )
new_config=1
config_set=1
;;
c )
use_config=1
config_path=$(readlink -m ${OPTARG})
config_set=1
;;
u )
update_config=1
config_path=$(readlink -m ${OPTARG})
config_set=1
;;
l )
linux_path=$(readlink -m ${OPTARG})
;;
o )
output_str="_${OPTARG}"
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "${config_set}" ]; then
usage;
fi
# Setup
linux_path=$(readlink -m $linux_path)
if [ -n "${new_config}" ]; then
if [ "$#" -ne 2 ]; then
usage
fi
old_config_path=$(readlink -m $1)
new_config_path=$(readlink -m $2)
fi
export ARCH=arm;export CROSS_COMPILE=arm-linux-gnueabihf-;
cd $linux_path;
# Kernel configuration
if [ -n "${new_config}" ]; then
make mrproper;
cp $old_config_path $linux_path/.config;
make olddefconfig;
make menuconfig;
cp $linux_path/.config $new_config_path
elif [ -n "${update_config}" ]; then
make mrproper;
cp $config_path ${config_path}_old;
cp $config_path $linux_path/.config;
make olddefconfig;
make menuconfig;
cp $linux_path/.config $config_path
else
make mrproper;
cp $config_path $linux_path/.config;
make olddefconfig;
fi
# Compilation
if [ -n "${compile_kernel}" ]; then
echo "Compiling kernel...";
make -j20 LOADADDR=0x48000000 uImage;
echo "Kernel compilation done";
fi
if [ -n "${compile_modules}" ]; then
echo "Compiling modules...";
make -j20 modules;
rm -rf output
make -j20 INSTALL_MOD_PATH=output modules modules_install;
echo "Modules compilation done";
fi
if [ -n "${compile_dtb}" ]; then
echo "Compiling dtb...";
make sun7i-a20-olinuxino-lime2.dtb;
echo "dtb compilation done";
fi
# Compression
kernel_version=$(git branch | sed -n -e 's/^\* (HEAD detached at \(.*\))/\1/p')
output_name=${kernel_version}_kernel${output_str}
echo "Creating output folder";
mkdir -p ../$output_name;
if [ -n "${compile_modules}" ]; then
echo "Adding modules to output folder...";
cp -r $linux_path/output/lib/modules ../$output_name/;
echo "Done";
fi
if [ -n "${compile_kernel}" ]; then
echo "Adding kernel to output folder...";
cp $linux_path/arch/arm/boot/uImage ../$output_name/;
echo "Done";
fi
if [ -n "${compile_dtb}" ]; then
echo "Adding dtb to output folder...";
cp $linux_path/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dtb ../$output_name/;
echo "Done";
fi
echo "Compressing archive...";
cd ../$output_name;
tar cf - * | pigz -9 -p 20 > ../$output_name.tar.gz;
cd ..;
echo "Removing output folder...";
rm -rf $output_name;
echo "Archive saved to $output_name.tar.gz"
if [ -n "$copy_to_sepia" ]; then
echo "Copying to sepia...";
scp $output_name.tar.gz sepia:/home/vlaya/Documents/tsn-internship/img-kernel-utils/scripts/kernels/;
fi
#!/bin/bash
usage() {
echo "Usage: $0 [-h] [-dkm -i ARCHIVE] BOARD_NAME"
exit 1;
}
while getopts "hdkmi:" opt; do
case "${opt}" in
h )
usage
;;
d )
install_dtb=1
;;
k )
install_kernel=1
;;
m )
install_modules=1
;;
i )
archive_path=$(readlink -m ${OPTARG})
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "$1" ]; then
usage
fi
board_name=$1
archive_name="$(basename -- $archive_path)"
echo "Copying to ${board_name}...";
scp $archive_path $board_name:;
heredoc="$(cat << ENDBOARDSSH
echo "Uncompressing ${archive_name}...";
rm -rf kernel_output;
mkdir -p kernel_output;
echo "tar -xvf ${archive_name} -C kernel_output";
tar -xvf $archive_name -C kernel_output;
cd kernel_output;
if [ -n "${install_modules}" ]; then
sudo rm -rf /lib/modules;
sudo mv modules /lib/;
fi
if [ -n "${install_kernel}" ]; then
sudo mv uImage /boot/;
fi
if [ -n "${install_dtb}" ]; then
sudo mv sun7i-a20-olinuxino-lime2.dtb /boot/
fi
cd ..;
sudo rm -rf kernel_output;
sudo reboot;
ENDBOARDSSH
)"
echo "ssh on $board_name"
ssh -t $board_name "$heredoc"
echo "Installation done, rebooting...";
sleep 4;
until ssh $board_name uname -r;
do
sleep 1;
done
echo "Successful installation"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment