Commit 29fec63e authored by Ellen Wang's avatar Ellen Wang

Port to 64-bit ARM

The armhf build is still available as an option, for now.

u-boot config is just rpi_3_defconfig.  Version was bumped
up to 2017.11.

Kernel config is a pared-down version of defconfig.
Version is unchanged.

Compressed kernel is not supported an arm64, so for now it's
uncompressed.  If we want to, the kernel can be packaged with
initrd and dtb into a u-boot image, which can be compressed.

For some reason logger doesn't support --id anymore, so I had
to stop using it.

zerotier-one has to be compiled from scratch and linked
dynamically.  The statically linked version crashes
mysteriously in pthreads (on both arm64 and amd64), when
a network is created and joined.  I had known this on amd64
for a while now, but it wasn't a problem on armhf.
Instead building a zerotier debian package and installing
it in the build container, I chose to do the cheesy thing
of installing the standard package and copying our compiled
zerotier-one binary over it.  I feel only a little ashamed.

The latest version of docker forced some unrelated changes:
1. It's bigger so the boot image size has to be bigger.
2. "docker info" output format is different.
This happened today while I was preparing this commit,
so they get thrown in.
parent 47838779
......@@ -15,13 +15,15 @@ SHELL=/bin/bash #tarfile signature checking uses process redirection.
DEBIAN_RELEASE := stretch
KERNEL_VERSION = 4.14.30
UBOOT_VERSION = 2017.09
UBOOT_VERSION = 2017.11
BOOTFW_VERSION = 1.20170811
BUSYBOX_VERSION = 1.28.0-uclibc
ZEROTIER1_VERSION = 1.2.12
KERNEL_URL=http://cdn.kernel.org/pub/linux/kernel/v4.x/linux-$(KERNEL_VERSION).tar.xz
UBOOT_URL=http://ftp.denx.de/pub/u-boot/u-boot-$(UBOOT_VERSION).tar.bz2
BOOTFW_URL=http://github.com/raspberrypi/firmware/archive/$(BOOTFW_VERSION).tar.gz
ZEROTIER1_URL=http://github.com/zerotier/ZeroTierOne/archive/$(ZEROTIER1_VERSION).tar.gz
######################################################
# Pick/validate what target architectures we're building for.
......@@ -30,7 +32,7 @@ BOOTFW_URL=http://github.com/raspberrypi/firmware/archive/$(BOOTFW_VERSION).tar.
ARCHS := #Needed so ARCHS+=$(ARCH) expands $(ARCH) immediately, not recursively.
ARM_TARGETS:=rpi3_img rpi3_zip rip3_zip_clean rpi3_img_clean chip_img chip_img_clean
ifneq ($(filter $(ARM_TARGETS), $(MAKECMDGOALS)),)
override ARCH:=armhf
override ARCH:=arm64
ARCHS+=$(ARCH)
endif
AMD64_TARGETS:=pc_img pc_img_clean
......@@ -45,17 +47,26 @@ else ifeq ($(ARCH), armhf)
KERNEL_ARCH=arm
KERNEL_IMG=zImage
KERNEL_EXTRAS=dtbs
SERIAL_TTY=ttyAMA0
UBOOT_ARCH=arm
UBOOT_IMG=u-boot.bin
BOOT_MNT=/dev/mmcblk0p1
CROSS_PREFIX=arm-linux-gnueabihf-
FROM_PREFIX=arm32v7/
QEMU_ARCH=arm
else ifeq ($(ARCH), arm64)
KERNEL_ARCH=arm64
KERNEL_IMG=Image
KERNEL_EXTRAS=dtbs
UBOOT_ARCH=arm
UBOOT_IMG=u-boot.bin
BOOT_MNT=/dev/mmcblk0p1
CROSS_PREFIX=aarch64-linux-gnu-
FROM_PREFIX=arm64v8/
QEMU_ARCH=aarch64
else ifeq ($(ARCH), amd64)
KERNEL_ARCH=x86
KERNEL_IMG=bzImage
KERNEL_EXTRAS=
SERIAL_TTY=ttyS0
BOOT_MNT=LABEL=ISOLINUX
CROSS_PREFIX=
FROM_PREFIX=
......@@ -102,10 +113,11 @@ INITRDDIR := $(BUILDDIR)/initrd
FSDIR := $(BUILDDIR)/fs
OSFSDIR := $(FSDIR)/rootfs
KERNELDIR := $(BUILDDIR)/linux
ZEROTIER1DIR := $(BUILDDIR)/zerotier-one
IMGFSDIR := $(BUILDDIR)/imgfs
IMAGESDIR := $(BUILDDIR)/images
ifeq ($(ARCH), armhf)
ifeq ($(ARCH:arm%=),)
UBOOTDIR := $(BUILDDIR)/uboot
BOOTFWDIR := $(BUILDDIR)/bootfw
endif
......@@ -126,7 +138,7 @@ $(error Run "sudo script/qemu-arm-static.sh")
endif
#Make sure docker experimental is enabled for "docker build --squash"
ifneq ($(shell docker info 2>/dev/null | grep -c '^Experimental: true'),1)
ifneq ($(shell docker info 2>/dev/null | grep -c '^\s*Experimental: true'),1)
$(error Enable "experimental" in /etc/docker/daemon.json)
endif
......@@ -166,8 +178,12 @@ $(KERNEL): $(KERNEL_PATCH)
( cd $(KERNELDIR); $(MAKE) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_PREFIX) \
$(KERNEL_IMG) modules $(KERNEL_EXTRAS) )
ifeq ($(ARCH), armhf)
ifeq ($(ARCH:arm%=),)
ifeq ($(ARCH),armhf)
KERNEL_DTB := $(KERNELDIR)/arch/$(KERNEL_ARCH)/boot/dts/bcm2837-rpi-3-b.dtb
else
KERNEL_DTB := $(KERNELDIR)/arch/$(KERNEL_ARCH)/boot/dts/broadcom/bcm2837-rpi-3-b.dtb
endif
kernel_dtb: $(KERNEL_DTB)
$(KERNEL_DTB): $(KERNEL)
endif
......@@ -187,7 +203,7 @@ PHONY += kernel_clean
kernel_clean:
rm -rf $(KERNELDIR)
ifeq ($(ARCH), armhf) # {
ifeq ($(ARCH:arm%=),) # {
UBOOT_SRC := $(UBOOTDIR)/Makefile
uboot_src: $(UBOOT_SRC)
......@@ -238,7 +254,7 @@ bootfw_clean:
UBOOT_ENV := $(IMGFSDIR)/uboot.env
uboot_env: $(UBOOT_ENV)
$(UBOOT_ENV): $(SRCDIR)/rpi/ubootenv
$(UBOOT_ENV): $(SRCDIR)/rpi/$(ARCH)_ubootenv
@mkdir -p $(IMGFSDIR)
mkenvimage -o$(UBOOT_ENV) -s16384 -p0 $<
......@@ -246,8 +262,39 @@ PHONY += uboot_env_clean
uboot_env_clean:
rm -f $(UBOOT_ENV)
CONFIG_TXT := $(IMGFSDIR)/config.txt
config_txt: $(CONFIG_TXT)
$(CONFIG_TXT): $(SRCDIR)/rpi/$(ARCH)_config.txt
@mkdir -p $(IMGFSDIR)
cp $< $(CONFIG_TXT)
PHONY += config_txt_clean
config_txt_clean:
rm -f $(CONFIG_TXT)
endif # }
ZEROTIER1_SRC := $(ZEROTIER1DIR)/Makefile
zerotier1_src: $(ZEROTIER1_SRC)
$(ZEROTIER1_SRC):
@mkdir -p $(ZEROTIER1DIR)
wget -qO- $(ZEROTIER1_URL) | \
tar --strip-components=1 -xz -C $(ZEROTIER1DIR)
ZEROTIER1 = $(ZEROTIER1DIR)/zerotier-one
zerotier1: $(ZEROTIER1)
$(ZEROTIER1): $(ZEROTIER1_SRC)
( cd $(ZEROTIER1DIR); \
$(MAKE) CC=$(CROSS_PREFIX)gcc \
CXX=$(CROSS_PREFIX)g++ \
STRIP=$(CROSS_PREFIX)strip \
zerotier-one \
)
PHONY += zerotier1_clean
zerotier1_clean:
rm -rf $(ZEROTIER1DIR)
INITRD := $(IMGFSDIR)/initrd
initrd: $(INITRD)
$(INITRD): $(INITRDSRCDIR)/*
......@@ -340,15 +387,23 @@ storagemgr_clean:
ZEROTIER := $(IMGFSDIR)/layers/zerotier.off
zerotier: $(ZEROTIER)
$(ZEROTIER): $(PYTHON3) $(CONTAINERDIR)/zerotier/* $(SCRIPTDIR)/untar-docker-image
$(ZEROTIER): $(PYTHON3) $(CONTAINERDIR)/zerotier/* $(ZEROTIER1) \
$(SCRIPTDIR)/untar-docker-image
mkdir -p $(BUILDDIR)/zerotier
rsync -a --delete \
$(CONTAINERDIR)/zerotier/. \
$(ZEROTIER1) \
$(BUILDDIR)/zerotier
$(SCRIPTDIR)/mkcontainer -t zerotier '$(FROM_PREFIX)' \
$(CONTAINERDIR)/zerotier $(FSDIR) $(IMGFSDIR)/layers '$(DOCKER_BUILD_PROXY)'
$(BUILDDIR)/zerotier $(FSDIR) $(IMGFSDIR)/layers \
'$(DOCKER_BUILD_PROXY)'
CONTAINERS += $(ZEROTIER)
PHONY += zerotier_clean
zerotier_clean:
$(SCRIPTDIR)/mkcontainer -c zerotier '$(FROM_PREFIX)' \
$(FSDIR) $(IMGFSDIR)/layers
rm -rf $(BUILDDIR)/zerotier
HAPROXY := $(IMGFSDIR)/layers/haproxy.off
haproxy: $(HAPROXY)
......@@ -459,13 +514,13 @@ IMG_DEPS = \
$(SQUASHFS) \
$(filter-out %/. %.., $(wildcard $(DEVELDIR)/imgfs/.*)) \
$(wildcard $(DEVELDIR)/imgfs/*)
ifeq ($(ARCH), armhf)
ifeq ($(ARCH:arm%=),)
IMG_DEPS += \
$(KERNEL_DTB) \
$(UBOOT) \
$(UBOOT_ENV) \
$(BOOTFW) \
$(SRCDIR)/rpi/config.txt
$(CONFIG_TXT)
else ifeq ($(ARCH), amd64)
IMG_DEPS += $(SRCDIR)/pc/grub.cfg
endif
......@@ -475,7 +530,7 @@ rpi3_img: $(RPI3_IMG)
$(RPI3_IMG): $(IMG_DEPS) $(SCRIPTDIR)/mkfatimg
@mkdir -p $(IMAGESDIR)
cp -r $(filter-out $(IMGFSDIR)/%, $(IMG_DEPS)) $(IMGFSDIR)
$(SCRIPTDIR)/mkfatimg $(RPI3_IMG) 192 $(IMGFSDIR)/*
$(SCRIPTDIR)/mkfatimg $(RPI3_IMG) 256 $(IMGFSDIR)/*
PHONY += rpi3_img_clean
rpi3_img_clean:
......@@ -506,7 +561,7 @@ PHONY += pc_img_clean
pc_img_clean:
rm $(PC_IMG)
ifeq ($(ARCH), armhf)
ifeq ($(ARCH:arm%=),)
img: rpi3_img
else ifeq ($(ARCH), amd64)
img: pc_img
......@@ -523,12 +578,13 @@ deploy: $(RPI3_ZIP)
########################
# Qemu emulation targets
ifeq ($(ARCH), armhf)
ifeq ($(ARCH:arm%=),)
qemu-run: $(RPI3_IMG)
@echo -e "\nctrl-a x to exit qemu\n"
qemu-system-arm -nographic -M virt -kernel build/armhf/imgfs/zImage \
-initrd build/armhf/imgfs/initrd -m 2048 -no-reboot \
-drive if=sd,id=sd0,file=build/armhf/images/rpi3image.bin -device generic-sdhci,drive=sd0
qemu-system-$(QEMU_ARCH) -nographic -M virt \
-kernel $(IMGFSDIR)/$(KERNEL_IMG) \
-initrd $(INITRD) -m 2048 -no-reboot \
-drive if=sd,id=sd0,file=$(RPI3_IMG) -device generic-sdhci,drive=sd0
else ifeq ($(ARCH), amd64)
qemu-run: $(PC_IMG)
@echo -e "\nctrl-a x to exit qemu\n"
......
......@@ -10,5 +10,6 @@ RUN apt-key add /zt-gpg-key \
&& rm -rf /var/lib/apt/lists/*
COPY start clientd zerotier.py zerotier_allow.py handle_client.py /
COPY zerotier-one /usr/sbin
CMD ["/start"]
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -9,9 +9,9 @@ COPY *.pub /keys/
RUN apt-get update \
&& apt-get install -y --no-install-recommends gnupg apt-transport-https ca-certificates \
&& if [ "$ARCH" = armhf ]; then \
&& if [ "$ARCH" = armhf -o "$ARCH" = arm64 ]; then \
apt-key add /keys/raspbian.pub \
&& echo 'deb http://archive.raspberrypi.org/debian/ stretch main' \
&& echo 'deb [arch=armhf] http://archive.raspberrypi.org/debian/ stretch main' \
>/etc/apt/sources.list.d/raspbian.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends firmware-brcm80211 \
......
......@@ -470,7 +470,7 @@ log() {
echo "$*"
return
fi
logger -pdaemon."$prio" -t"$progname" --id=$$ "$*"
logger -pdaemon."$prio" -t"$progname" "$*"
}
error() {
......
......@@ -543,7 +543,7 @@ log() {
echo "$*"
return
fi
logger -pdaemon."$prio" -t"$progname" --id=$$ "$*"
logger -pdaemon."$prio" -t"$progname" "$*"
}
error() {
......@@ -571,7 +571,7 @@ run() {
local status
if [ "$dflag" ]; then
# this is how to get the exit status, don't ask
status=`(("$@" 9>&-; echo $? >&9) 2>&1 | logger -pdaemon.info -t"$1" --id=$$) 9>&1`
status=`(("$@" 9>&-; echo $? >&9) 2>&1 | logger -pdaemon.info -t"$1") 9>&1`
else
"$@"
status=$?
......
# Raspberry Pi 3 boot configuration
# 64-bit mode
arm_control=0x200
kernel=u-boot.bin
enable_uart=1
disable_overscan=1
# GPU memory size for each total memory size
gpu_mem_256=100
gpu_mem_512=100
gpu_mem_1024=100
arch=arm
baudrate=115200
board=rpi
boot_targets=mmc0
bootargs=8250.nr_uarts=1 bcm2708_fb.fbwidth=1920 bcm2708_fb.fbheight=1200 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 console=tty1 console=ttyS0,115200
bootcmd=run distro_bootcmd
bootcmd_mmc0=fatload mmc 0:1 ${kernel_addr_r} ${kernelfile}; fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; fatload mmc 0:1 ${initrd_addr_r} ${initrdfile}; setenv initrdsize ${filesize}; booti ${kernel_addr_r} ${initrd_addr_r}:${initrdsize} ${fdt_addr_r}
bootdelay=2
cpu=armv7
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
ethact=smsc95xx_eth
fdt_addr_r=0x03000000
fdt_high=0xffffffff
fdtfile=bcm2837-rpi-3-b.dtb
initrd_addr_r=0x03100000
initrd_high=0xffffffff
initrdfile=initrd
kernel_addr_r=0x01000000
kernelfile=Image
preboot=usb start
soc=bcm283x
stderr=serial,vidconsole
stdin=serial,usbkbd
stdout=serial,vidconsole
vendor=raspberrypi
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