This is a cache of https://discuss.96boards.org/t/grub-build-issue/5424. It is a snapshot of the page at 2024-11-01T09:01:50.052+0000.
Grub build issue - HiKey 960 - 96Boards Forum

Grub build issue

Hi

Downloaded the source code for Grub from the below link and followed the instruction to build it.
https://wiki.xenproject.org/wiki/HiKey960

Getting below issue.
gcc -DHAVE_CONFIG_H -I. -I… -I/home//Documents/Hikey960_wiki/grub/include -Wall -W -DGRUB_MACHINE_EFI=1 -DGRUB_MACHINE=ARM64_EFI -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/include -I…/include -I…/include -DGRUB_FILE=“loader/arm64/xen_boot.c” -I. -I. -I… -I… -I…/include -I…/include -I…/grub-core/lib/libgcrypt-grub/src/ -D_FILE_OFFSET_BITS=64 -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -freg-struct-return -msoft-float -fno-dwarf2-cfi-asm -mno-stack-arg-probe -fno-asynchronous-unwind-tables -fno-unwind-tables -Qn -fno-stack-protector -Wtrampolines -Werror -mcmodel=large -ffreestanding -MT loader/arm64/xen_boot_module-xen_boot.o -MD -MP -MF loader/arm64/.deps-core/xen_boot_module-xen_boot.Tpo -c -o loader/arm64/xen_boot_module-xen_boot.o test -f 'loader/arm64/xen_boot.c' || echo './'loader/arm64/xen_boot.c
loader/arm64/xen_boot.c: In function ‘xen_boot’:
loader/arm64/xen_boot.c:269:3: error: implicit declaration of function ‘grub_armxx_efi_linux_boot_image’ [-Werror=implicit-function-declaration]
return grub_armxx_efi_linux_boot_image (xen_hypervisor->start,
^
loader/arm64/xen_boot.c:269:3: error: nested extern declaration of ‘grub_armxx_efi_linux_boot_image’ [-Werror=nested-externs]
loader/arm64/xen_boot.c: In function ‘grub_cmd_xen_hypervisor’:
loader/arm64/xen_boot.c:473:7: error: implicit declaration of function ‘grub_armxx_efi_linux_check_image’ [-Werror=implicit-function-declaration]
((struct linux_armxx_kernel_header *) &sh) != GRUB_ERR_NONE)
^
loader/arm64/xen_boot.c:473:7: error: nested extern declaration of ‘grub_armxx_efi_linux_check_image’ [-Werror=nested-externs]

Hi

Downloaded the source code for Grub from the below link and followed the instruction to build it.
HiKey960 - Xen

Getting below issue.
gcc -DHAVE_CONFIG_H …

Why is this gcc rather than aarch64-linux-gnu-gcc ?

Daniel.

Thanks Daniel.

Able to build grub.

Have couple of questions.

  1. Where do we need to add below code. Either in grub.config or docs/grub.cfg?
    menuentry ‘Xen’ {
    xen_hypervisor /boot/xen.efi loglvl=all console=dtuart dtuart=/soc/serial@fff32000 efi=no-rs
    xen_module /boot/Image console=tty0 console=hvc0 root=/dev/sdd10 rw efi=noruntime
    devicetree /boot/Image.dtb
    }

  2. There is no grub.config file after building the grub.

As best as I can tell, grub.config is the config file that tells
grub-mkimage how to install grub (e.g. it is a config file for
grub-mkimage not grub)…

The menuentry stanza needs to go into the config file that grub reads
when it boots. Based on docs it looks like this would be in
/boot/grub/grub.cfg (e.g. the configfile option in grub.config).
Depending on which rootfs you are starting from, it may not exist
yet.

Daniel.

Thanks Daniel.

  1. Wiki page says we need to update boot.img, but we are not seeing any of the previous steps generating boot.img.

  2. Where can I find boot-0.0+AUTOINC+hikey960-.uefi.img ?
    Below is the link provided on Hikey 960 wiki page to download uefi image but it does not exists.
    https://snapshots.linaro.org/96boards//reference-platform/openembedded/morty/hikey960/rpb/latest/

  3. We need to update boot.img, as per my understanding we need to update this pre-built image with newly generated grubaa64.efi.

  4. Then we can use below command to flash Hikey960.
    $sudo fastboot flash boot boot-0.0+AUTOINC+hikey960-.uefi.img
    $sudo fastboot flash system rootfs.sparse.img

Once above commands are success, Xen will enabled and we can boot Linux as Dom0.

The wiki page looks a bit vague about both the boot and root
filesystems.

Where did you get your rootfs from? Best thing is probably to use the
boot image that comes with the rootfs.

Note the boot image is just an EFI system partition. For example this
only only contains two files:
http://snapshots.linaro.org/96boards/hikey/linaro/debian/latest/boot-linaro-stretch-developer-hikey-20180521-18.img.gz

I found the rootfs from the below link.
https://releases.linaro.org/debian/images/developer-arm64/17.07/

It contains entire file system rather than just two file.

It has only bootaa64.efi in /usr/lib/systemd/boot/efi/systemd-bootaa64.efi,
but there is no grubaa64.efi file.

Is there any other link we gives a proper instruction to build.
As a first step we want to enable Xen support and boot Linux as Dom0, secondly we want to flash Android as DomU.

Currently we are using ubuntu14.04 as build system. Whether it should be higher version?

I see. That its a standalone rootfs; it will work but grub is not installed in this rootfs meaning you have to “know” how to create a EFI system partition and populare grub.cfg from scratch.

I’m not aware of any better documentation for Xen than the projects own wiki but to be honest I’d recommend starting by installing a working Debian release on the board. This will give you a boot partition which shows you where you need to install your own grub, a populated /boot directory and a template grub.cfg for you to work with. Once you have this I think the wiki will start to make more sense.

Not that by default there is no HDMI support in this build so you will need to interact with it via a serial adaptor but you need that to interact with grub anyway. I think you will get HDMI working as part of the Xen work (the kernel they recommend building does have HDMI support although I’ve no idea if it working in Xen).