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

Initial commit

parent bd2cb5fd
custom-kernels
boot-ressources/rootfs.tar.bz2
boot-ressources/u-boot-sunxi-with-spl.bin
setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait panic=10 isolcpus=1 rcu_nocbs=1 irqaffinity=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 [-hgdkm] [-l LINUX_PATH] [-o OUTPUT_STR | -O OUTPUT_NAME] (-p | -u CONFIG_PATH | -c CONFIG_PATH | -n OLD_CONFIG_PATH NEW_CONFIG_PATH)"
exit 1;
}
linux_path=$HOME/linux
output_str=""
while getopts "hgdkmpsu:c:nl:o:O:" opt; do
case "${opt}" in
h )
usage
;;
g )
update_git=1
;;
d )
compile_dtb=1
install_opts+="-d "
;;
k )
compile_kernel=1
install_opts+="-k "
;;
m )
compile_modules=1
install_opts+="-m "
;;
p )
partial_compile=1
config_set=1
;;
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}"
;;
O )
output_name="${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;
if [ -n "$update_git" ]; then
git pull;
fi
if [ -z "$partial_compile" ]; then
# 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
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 describe --tags)
if [ -z "$output_name" ]; then
output_name=${kernel_version}_kernel${output_str}
fi
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"
#!/bin/bash
usage() {
echo "Usage: $0 [-hdkm] -i ARCHIVE_PATH HOST_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 [ -n "$1" ]; then
host_name=$1
fi
archive_name="$(basename -- $archive_path)"
echo "Copying to ${host_name}...";
scp $archive_path $host_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 $host_name"
ssh -t $host_name "$heredoc"
echo "Installation done, rebooting...";
sleep 4;
until ssh $host_name uname -r;
do
sleep 1;
done
echo "Successful installation"
#!/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 [-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
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