Just reminder for myself how to build driver for arm64 having x64 based machine with ubuntu
Install right gcc
sudo apt-get install gcc-aarch64-linux-gnu
Build Kernel
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfigmake ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules
Patch Makefile
MACHINE ?= $(shell uname -m)
ifeq ($(MACHINE),x86_64)
but this gives you arch of host machine, so you must rewrite all such cases to use ARCH variable (and to setup make -C $(KROOT))
Building
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -f Makefile.arm64