January 9, 2021 Kernel 5.10.4+ for Raspberry Pi4 Compiled on host board Rock64, running EasyOS Pyro-series 1.0.4 64-bit. Synopsis -------- The script 'compile-rpi4.sh' will patch the kernel with 'aufs' and 'cap_sys_mount' patches, then compile it, then create: linux_headers-5.10.4+.pet linux_kernel-5.10.4+-rpi4.pet kernel_5.10.4+-p1_src.sfs and kernel_5.10.4+-p1_src.specs The two PET packages can be used by woofQ to build EasyOS for the Pi4. How to download kernel source ----------------------------- This has already been done, but here is how... The 5.10.x kernel source for the raspberry pi was downloaded: git clone --depth=1 --branch rpi-5.10.y https://github.com/raspberrypi/linux Downloads as folder 'linux', I renamed it to 'linux-5.10' and ran: # dir2tgz linux-5.10 HOWEVER, this is actually "5.10.4+". The build script that I use, requires an actual 'linux-5.10.tar.bz2', and build-kernel/patches/patch-5.10.4.bz2 would provide the .4 update. However, in this case, 'patch-5.10.4+.bz2' is empty, does nothing -- it is just there for the logical requirement of the 'compile-rpi4.sh' script. How to compile kernel --------------------- The host OS must be aarch64, preferably the same gcc version as the target system. However, Barry compiled on a Rock64 board, 4GB RAM, running EasyOS Pyro 1.0.4, which has gcc 6.3.0 and kernel 4.4.x headers -- which is probably the reason an error occurred during compile, as documented below. The intention is to compile the kernel on a running EasyOS Dunfell-series on the Pi4 later. Of course, with EasyOS, the 'devx' SFS must be loaded. With any other Linux, gcc must be installed. Create a folder somewhere in an ext4 partition on a hard drive or SSD. Barry used a USB3 500GB SSD, that can be plugged into the Rock64. Previous experience is that a 1TB USB3 HDD also worked, with the standard power supply for the Rock64 (from the Pine64 company). Expand the tarball: # tar -xf build-kernel.tar.gz # cd build-kernel # cp -f ../linux-5.10.tar.bz2 ./ Link /usr/src to the 'build-kernel' folder: # pwd # ln -snf /usr/src # cd /usr/src An important little detail: Unfortunately, the kernel compile somewhere has hardcoded 'awk' to be at /usr/bin. In EasyOS it is at /bin, so create a symlink: # ln -s /bin/awk /usr/bin/awk You are now ready to compile: # ./compile-rpi4.sh As mentioned above, the compile fails. See the file 'error.txt'. You need to comment-out the conflicting type definitions in /usr/include/stdint.h Then press ENTER to continue the compile. HOWEVER, the compile fails again. Restore /usr/include/stdint.h to its original state, save, then hit ENTER. Compile will then go to completion, and you will have two PETs and an SFS. Hopefully, by the time you are reading this, you can be running a EasyOS Dunfell-series, and the failure will have gone away. All of the above can be attempted on some other aarch64 host Linux OS, but do read through the 'compile-rpi4.sh' script to make sure that everything is OK for your host system. There are some scripts used, such as 'dir2tgz' and 'tgz2pet' that are only in Puppy Linux and derivatives. Performance note: Build takes a long time on the Rock64. 'make' is run without "-j " and that would probably speed things up. Blog reference: https://bkhome.org/news/202101/compiling-on-arm-board-is-like-watching-grass-grow.html Regards, Barry Kauler January 9, 2021 bkhome.org/news