Add ARM Support

Adds the necessary changes to docker, build,sh, and configs to allow FOS
to be built and operate on ARMv8.

NOTE: I have only tested this on arm64. I don't have any arm32 machines to test this on,
and so I make no promises
This commit is contained in:
ParkerBerberian
2018-03-15 13:49:55 -04:00
parent de8b8e211b
commit 4fb7fb2074
5 changed files with 11785 additions and 64 deletions

View File

@@ -51,7 +51,7 @@ for iface in $ifaces; do
done
# If we end up here something went wrong as we do exit the script as soon as we get an IP!
if [[ -z $ifaces ]]; then
if [[ -z "$(echo $ifaces | tr -d ' ')" ]]; then # because ifaces is constructed with a space, we must strip it
echo "No network interfaces found, your kernel is most probably missing the correct driver!"
else
echo "Failed to get an IP via DHCP! Tried on interfaces(s): $ifaces"

163
build.sh
View File

@@ -1,7 +1,7 @@
#!/bin/bash
Usage() {
echo -e "Usage: $0 [-knfvh?] [-a x64]"
echo -e "\t\t-a --arch [x86|x64] (optional) pick the architecture to build. Default is to build for all."
echo -e "\t\t-a --arch [x86|x64|arm|arm64] (optional) pick the architecture to build. Default is to build for all."
echo -e "\t\t-f --filesystem-only (optional) Build the FOG filesystem but not the kernel."
echo -e "\t\t-k --kernel-only (optional) Build the FOG kernel but not the filesystem."
echo -e "\t\t-v --version (optional) Specify a kernel version to build."
@@ -138,7 +138,7 @@ brVersion="2017.11.2"
brURL="https://buildroot.org/downloads/buildroot-$brVersion.tar.bz2"
kernelURL="https://www.kernel.org/pub/linux/kernel/v4.x/linux-$kernelVersion.tar.xz"
deps="subversion git mercurial meld build-essential rsync libncurses-dev gcc-multilib"
[[ -z $arch ]] && arch="x64 x86"
[[ -z $arch ]] && arch="x64 x86 arm arm64"
[[ -z $buildPath ]] && buildPath=$(dirname $(readlink -f $0))
[[ -z $confirm ]] && confirm="y"
#echo -n "Please wait while we check your and or install dependencies........"
@@ -195,12 +195,12 @@ function buildFilesystem() {
x86)
make ARCH=i486 menuconfig
;;
#arm)
# make ARCH=arm CROSS_COMPILE=arm-linux- menuconfig
# ;;
#arm64)
# make ARCH=arm64 menuconfig
# ;;
arm)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig
;;
arm64)
make ARCH=aarch64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
;;
*)
make menuconfig
;;
@@ -214,12 +214,12 @@ function buildFilesystem() {
x86)
make ARCH=i486 oldconfig
;;
#arm)
# make ARCH=arm CROSS_COMPILE=arm-linux- oldconfig
# ;;
#arm64)
# make ARCH=arm64 oldconfig
# ;;
arm)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- oldconfig
;;
arm64)
make ARCH=aarch64 CROSS_COMPILE=aarch64-linux-gnu- oldconfig
;;
*)
make oldconfig
;;
@@ -230,21 +230,21 @@ function buildFilesystem() {
echo "This make take a long time. Get some coffee, you'll be here a while!"
case "${arch}" in
x64)
make -j $(nproc) >buildroot$arch.log
make -j $(nproc) >buildroot$arch.log 2>&1
status=$?
[[ $status -gt 0 ]] && exit $status
;;
x86)
make ARCH=i486 -j $(nproc) >buildroot$arch.log
make ARCH=i486 -j $(nproc) >buildroot$arch.log 2>&1
status=$?
[[ $status -gt 0 ]] && exit $status
;;
#arm)
# make ARCH=arm CROSS_COMPILE=arm-linux- -j $(nproc) >buildroot$arch.log
# ;;
#arm64)
# make ARCH=arm64 -j $(nproc) >buildroot$arch.log
# ;;
arm)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j $(nproc) >buildroot$arch.log 2>&1
;;
arm64)
make ARCH=aarch64 CROSS_COMPILE=aarch64-linux-gnueabi- -j $(nproc) >buildroot$arch.log 2>&1
;;
*)
make -j $(nproc) > buildroot$arch.log
status=$?
@@ -260,27 +260,27 @@ function buildFilesystem() {
case "${arch}" in
x64)
make oldconfig
make -j $(nproc) >buildroot$arch.log
make -j $(nproc) >buildroot$arch.log 2>&1
status=$?
[[ $status -gt 0 ]] && exit $status
;;
x86)
make ARCH=i486 oldconfig
make ARCH=i486 -j $(nproc) >buildroot$arch.log
make ARCH=i486 -j $(nproc) >buildroot$arch.log 2>&1
status=$?
[[ $status -gt 0 ]] && exit $status
;;
#arm)
# make ARCH=arm CROSS_COMPILE=arm-linux- oldconfig
# make ARCH=arm CROSS_COMPILE=arm-linux- -j $(nproc) >buildroot$arch.log
# ;;
#arm64)
# make ARCH=arm64 oldconfig
# make ARCH=arm64 -j $(nproc) >buildroot$arch.log
# ;;
arm)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- oldconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j $(nproc) >buildroot$arch.log 2>&1
;;
arm64)
make ARCH=aarch64 CROSS_COMPILE=aarch64-linux-gnu- oldconfig
make ARCH=aarch64 CROSS_COMPILE=aarch64-linux-gnu- -j $(nproc) >buildroot$arch.log 2>&1
;;
*)
make oldconfig
make -j $(nproc) >buildroot$arch.log
make -j $(nproc) >buildroot$arch.log 2>&1
status=$?
[[ $status -gt 0 ]] && exit $status
;;
@@ -289,8 +289,29 @@ function buildFilesystem() {
cd ..
kill $PING_LOOP_PID
[[ ! -d dist ]] && mkdir dist
compiledfile="fssource$arch/output/images/rootfs.ext4.xz"
[[ $arch == x64 ]] && initfile='dist/init.xz' || initfile='dist/init_32.xz'
case "${arch}" in
x*)
compiledfile="fssource$arch/output/images/rootfs.ext4.xz"
;;
arm*)
compiledfile="fssource$arch/output/images/rootfs.cpio.gz"
;;
esac
case "${arch}" in
x64)
initfile='dist/init.xz'
;;
x86)
initfile='dist/init_32.xz'
;;
arm)
initfile='dist/arm_init_32.cpio.gz'
;;
arm64)
initfile='dist/arm_init.cpio.gz'
;;
esac
[[ ! -f $compiledfile ]] && echo 'File not found.' || cp $compiledfile $initfile
}
@@ -354,12 +375,12 @@ function buildKernel() {
x86)
make ARCH=i386 menuconfig
;;
#arm)
# make ARCH=arm CROSS_COMPILE=arm-linux- menuconfig
# ;;
#arm64)
# make ARCH=arm64 menuconfig
# ;;
arm)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig
;;
arm64)
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
;;
*)
make menuconfig
;;
@@ -373,12 +394,12 @@ function buildKernel() {
x86)
make ARCH=i386 oldconfig
;;
#arm)
# make ARCH=arm CROSS_COMPILE=arm-linux- oldconfig
# ;;
#arm64)
# make ARCH=arm64 oldconfig
# ;;
arm)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- oldconfig
;;
arm64)
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- oldconfig
;;
*)
make oldconfig
;;
@@ -397,12 +418,12 @@ function buildKernel() {
make ARCH=i386 -j $(nproc) bzImage
[[ $status -gt 0 ]] && exit $status
;;
#arm)
# make ARCH=arm CROSS_COMPILE=arm-linux- -j $(nproc) bzImage
# ;;
#arm64)
# make ARCH=arm64 -j $(nproc) bzImage
# ;;
arm)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j $(nproc) Image
;;
arm64)
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j $(nproc) Image
;;
*)
make -j $(nproc) bzImage
status=$?
@@ -428,14 +449,14 @@ function buildKernel() {
status=$?
[[ $status -gt 0 ]] && exit $status
;;
#arm)
# make ARCH=arm CROSS_COMPILE=arm-linux- oldconfig
# make ARCH=arm CROSS_COMPILE=arm-linux- -j $(nproc) bzImage
# ;;
#arm64)
# make ARCH=arm64 oldconfig
# make ARCH=arm64 -j $(nproc) bzImage
# ;;
arm)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- oldconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j $(nproc) Image
;;
arm64)
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- oldconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j $(nproc) Image
;;
*)
make oldconfig
make -j $(nproc) bzImage
@@ -446,8 +467,24 @@ function buildKernel() {
fi
cd ..
mkdir -p dist
compiledfile="kernelsource$arch/arch/x86/boot/bzImage"
[[ $arch == x64 ]] && cp $compiledfile dist/bzImage || cp $compiledfile dist/bzImage32
case "$arch" in
arm)
compiledfile="kernelsource$arch/arch/$arch/boot/Image"
cp $compiledfile dist/arm_Image32
;;
arm64)
compiledfile="kernelsource$arch/arch/$arch/boot/Image"
cp $compiledfile dist/arm_Image
;;
x64)
compiledfile="kernelsource$arch/arch/x86/boot/bzImage"
cp $compiledfile dist/bzImage32
;;
x86)
compiledfile="kernelsource$arch/arch/x86/boot/bzImage"
cp $compiledfile dist/bzImage
;;
esac
}

2607
configs/fsarm64.config Normal file

File diff suppressed because it is too large Load Diff

9075
configs/kernelarm64.config Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -5,6 +5,8 @@ RUN dpkg --add-architecture i386 && apt-get update\
&& DEBIAN_FRONTEND=noninteractive\
apt-get install -y wget subversion git mercurial meld build-essential rsync libncurses-dev gcc-multilib cpio bc unzip locales texinfo libelf-dev libelf-dev:i386
RUN apt -y install gcc-arm-linux-gnueabi gcc-aarch64-linux-gnu g++-aarch64-linux-gnu g++-arm-linux-gnueabi libssl-dev
RUN rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.utf8