The officially official Devuan Forum!

You are not logged in.

#1 2021-08-08 19:35:36

Registered: 2020-02-09
Posts: 31  

ARM (Banana Pi R2): Booting Linux kernel via u-boot and Grub


I'm currently trying to boot a kernel on an ARM board (Banana Pi R2) using u-boot as first stage, followed by Grub. The job of u-boot in this setup is to initialise the hardware and to setup an UEFI environment. It then loads Grub (from the grub-arm-efi package in the Devuan repository) which in turn shall load an installed Linux kernel.

The basic receipe for this setup is the following (work in progress, may be incomplete):

  • Build a Devuan GNU root-fs using multistrap. It must have the necessary packages like the grub-arm-efi package, basic system tools (shell, your favourite editor, apt, ...).

  • Build u-boot from source.

  • Build the kernel for your board from source.

  • Create an SD card where you install u-Boot onto.

  • Copy the zImage from your compiled kernel to the boot partition of the SD card and name it vmlinuz-(kernel version string).

  • Copy the kernel modules folder of your compiled kernel into the /lib/modules/ in your root-fs.

  • Copy the content of your root-fs onto the root partition of the SD card.

  • Copy qemu-system-arm into /usr/bin into the root-fs on the SD card, then chroot into it, mount /dev, /sys, /proc and /boot (the boot partition on the SD card, not the boot partition from your current computer) and run update-initramfs -c -k (kernel version string)

  • Run grub-install to get grub onto the boot partition. In case that doesn't work, you may need to use grub-mkimage. The latter can be a bit tricky because you have to hand-select the modules. This invocation might work:

    grub-mkimage -p '(hd0,msdos1)/grub/' -O arm-efi -o /boot/efi/boot/bootarm.efi fat ext2 probe terminal scsi ls linux elf part_msdos search normal help echo loadenv parttool boot configfile disk fdt file fshelp gfxmenu halt jpeg lsefi msdospart png reboot search_fs_file search_fs_uuid test
  • Run update-grub to generate a configuration file for grub. It should find your kernel and the initrd-image you made with update-initramfs.

  • unmount everything mounted in your SD card partitions and then unmont them, too.

  • Put the SD card into your ARM board. It should be able to boot to Grub.

This is where I'm stuck at the moment: I can get to the point where Grub is loading a kernel and the ramdisk, but then the board restarts after a few seconds. The kernel I use is version 5.12 from this repository:
These are the last lines I get via the serial console before the board reboots:

Loading Linux 5.12.0-bpi-r2+ ...
Loading initial ramdisk ...

Press any key to continue
EFI stub: Booting Linux Kernel...
EFI stub: usind DTB from configuration table
EFI stub: Exiting boot services and installing virtual address map...

Is it just the hardware support for the Banana Pi R2 that prevents the kernel from booting or can this be reproduced on other ARM boards besides the Raspberry Pi*? Is an adtitional step required to get the kernel to work?

*= Note: The Raspberry Pi cannot be booted using Grub, see:


Board footer