Grub2 can't find command `multiboot' and `module'

I was able to compile Xen 4.7 on the HiKey, but I encountered the following problem with Grub2 v2.02~beta2-33.linarojessie.6:


Loading Xen xen ...
error: can't find command 

multiboot’.
Loading Linux 4.4.0-135-arm64 …
error: can’t find command module'. Loading initial ramdisk ... error: can't find command module’.

Press any key to continue…
`

is there any solution to fix that issue?

How did you set things up to load Xen?

Looking at the instructions on the Xen wiki I don’t see why grub2 would be loading either of these commands. If I understood things correctly grub2 will simply chain load xen from the SD card.

@danielt the instructions on the Xen wiki use the SD card to load Xen. The instructions are based on the assumption that HiKey looks first at the SD card and then at the internal eMMC storage.

By the way, by following the instructions you will end up with an CentOS system.

Another method is to use grub2 chainloading.

I had success with the instructions on the Xen wiki.

Furthermore I was able to create a custom Grub2 entry for Xen, but was not able to actually load Xen.

Generally speaking it would be nice to have the multiboot module available in Grub2 on HiKey. I don’t know why it is not available.

@danielt the instructions on the Xen wiki assumptions are based on the HiKey UEFI boot sequence HiKey UEFI boot sequence.

I see. So you have got Xen working on Hikey but are simply trying to finesse your installation a bit?

In that regard I don’t believe the AArch64 version of grub actually supports the multiboot command. Patches were submitted for review but ended being renamed during the review process (renamed from multiboot to xen_hypervisor). See http://www.gossamer-threads.com/lists/xen/devel/390040 for details. Note that the thread also included an example grub config file using this command.

However…

I’m afraid the verison of grub2 supplied for the Hikey is derived from the grub2 version found in Debian jessie (2.02~beta2). The xen_hypervisor and xen_module commands didn’t land until ~beta3 so you’ll need to compile grub2 yourself if you want to use these commands.

@danielt thanks a lot for the clarification and the links. I would like to compile group myself. Do you have any directions on how to build grub2 for HiKey or on ARM in general?

1 Like

Try in a script:


GRUB_FLAGS="CC=gcc \
	TARGET_CC=aarch64-linux-gnu-gcc \
	TARGET_OBJCOPY=aarch64-linux-gnu-objcopy \
	TARGET_NM=aarch64-linux-gnu-nm \
	TARGET_RANLIB=aarch64-linux-gnu-ranlib \
	TARGET_STRIP=aarch64-linux-gnu-strip"

GRUB_MODULES="boot chain configfile echo efinet eval ext2 fat font gettext gfxterm gzio help linux loadenv lsefi normal part_gpt part_msdos read regexp search search_fs_file search_fs_uuid search_label terminal terminfo test tftp time"

cd <grub dir>
mkdir out

#sd card
cat << EOF > out/grub-sd.configfile
set root=(hd1,msdos2)
set prefix=(\$root)'/boot/grub'
configfile \$prefix/grub.cfg
EOF

#emmc
cat << EOF > out/grub.configfile
search.fs_label rootfs root
set prefix=(\$root)'/boot/grub'
configfile \$prefix/grub.cfg
EOF

./autogen.sh
./configure --target=aarch64 --enable-boot-time $GRUB_FLAGS
make

#sd card
./grub-mkimage \
		--verbose \
		--output=out/grubaa64-sd.efi \
		--config=out/grub-sd.configfile \
		--format=arm64-efi \
		$GRUB_MODULES

#emmc
./grub-mkimage \
		--verbose \
		--output=out/grubaa64.efi \
		--config=out/grub.configfile \
		--format=arm64-efi \
		$GRUB_MODULES

Guessing you would add xen_hypervisor and xen_module to GRUB_MODULES.

HTH

@vchong: I tried to cross-compile with the help of your script. The issue is that the ./grub-mkimage command can not be found.

Do you run your script directly on HiKey?

@vchong: Okay, I was missing some dependencies. Now, I am able to build grub2 completely. However, I still have issues with grub-mkimage. If I compile Grub2 on HiKey grub-mkimage has problems with the arguments. If I cross compile it, I get the following error message:

grub-mkimage: error: cannot open `/usr/lib/grub/arm64-efi/moddep.lst’: No such file or director

The instructions are for a cross compile, so can’t be run directly on HiKey. For cross compiling, do you have a copy of an aarch64 toolchain downloaded, extracted and added to the PATH of your PC?

For building natively on HiKey, you don’t have to build grub-mkimage. You can just apt-get install it (assuming Debian) and then run the rest of the instructions, i.e.


echo "deb http://repo.linaro.org/ubuntu/linaro-overlay jessie main" > local.list
sudo apt-get update
sudo apt-get install -y grub-efi-arm64-bin

GRUB_MODULES="boot chain configfile echo efinet eval ext2 fat font gettext gfxterm gzio help linux loadenv lsefi normal part_gpt part_msdos read regexp search search_fs_file search_fs_uuid search_label terminal terminfo test tftp time"

mkdir out

#sd card
cat << EOF > out/grub-sd.configfile
set root=(hd1,msdos2)
set prefix=(\$root)'/boot/grub'
configfile \$prefix/grub.cfg
EOF

#emmc
cat << EOF > out/grub.configfile
search.fs_label rootfs root
set prefix=(\$root)'/boot/grub'
configfile \$prefix/grub.cfg
EOF

#sd card
grub-mkimage \
		--verbose \
		--output=out/grubaa64-sd.efi \
		--config=out/grub-sd.configfile \
		--format=arm64-efi \
		$GRUB_MODULES

#emmc
grub-mkimage \
		--verbose \
		--output=out/grubaa64.efi \
		--config=out/grub.configfile \
		--format=arm64-efi \
		$GRUB_MODULES

@vchong: thanks for the additional repository information. I found the key here: https://wiki.linaro.org/Platform/Systems/Repository

The only problem with this key is you use SHA1 to sign the packages. The Debian project started to replace SHA1 with SHA256 or SHA512: Teams/Apt/Sha1Removal - Debian Wiki. This is the reason why I get the following warning:

W: http://repo.linaro.org/ubuntu/linaro-overlay/dists/jessie/InRelease: Signature by key 6D88237DABB21B7559A1B43EE13D88F7E3C1D56C uses weak digest algorithm (SHA1)

I would be happy if you could upgrade the hashing algorithm to SHA2 (SHA256 or SHA512)

You’re welcome. I’ve notified the repo owner, but until that is updated, you can maybe try just skipping the first ‘echo overlay…’ step and use the package from Debian directly. However, going over this thread again from the top, it looks like neither package will work anyway because that was the reason you were trying to build from source in the first place! Sorry for going down the wrong path. :s So, again, for building natively:


GRUB_MODULES="boot chain configfile echo efinet eval ext2 fat font gettext gfxterm gzio help linux loadenv lsefi normal part_gpt part_msdos read regexp search search_fs_file search_fs_uuid search_label terminal terminfo test tftp time xen_hypervisor xen_module"

git clone http://git.savannah.gnu.org/r/grub.git -b grub-2.02-beta3
cd grub
mkdir out

#sd card
cat << EOF > out/grub-sd.configfile
set root=(hd1,msdos2)
set prefix=(\$root)'/boot/grub'
configfile \$prefix/grub.cfg
EOF

#emmc
cat << EOF > out/grub.configfile
search.fs_label rootfs root
set prefix=(\$root)'/boot/grub'
configfile \$prefix/grub.cfg
EOF

./autogen.sh
./configure
make

#sd card
./grub-mkimage \
		--verbose \
		--output=out/grubaa64-sd.efi \
		--config=out/grub-sd.configfile \
		--format=arm64-efi \
		$GRUB_MODULES

#emmc
./grub-mkimage \
		--verbose \
		--output=out/grubaa64.efi \
		--config=out/grub.configfile \
		--format=arm64-efi \
		$GRUB_MODULES

Please note that these instructions have not been tested so you might have some debugging to do.

@vchong: thanks for informing the owner of the repo.

I thought the instructions are well tested and I am missing something trivial. I am pretty thankful to have some instructions, so I do not have to start from zero.

The cross compile instructions are well tested. The original native instructions just builds the grub image but not grub itself. This is sort of an in-between I guess. :s Good luck.

I would be happy if you could upgrade the hashing algorithm to SHA2 (SHA256 or SHA512)

Hashing algos updated on repo.linaro.org. But notice that this repository is for Jessie, while you are probably using something newer (jessie apt wouldn’t show the error you gave). So be aware that you are on uncharted territory.

@suihkulokki: Thanks for updating the hashing algos on repo.linaro.org.

Yes, you are right I am using Debian testing (Stretch/Kali) on my compilation VM. I am well aware that I am in uncharted territory.

However, I think that from a security perspective switching to SHA2 is the right step, regardless of whatever I do on my compilation VM.