Vanilla qemuarm full multi partition emulation?

Basically I want to emulate a typical setup with boot + 2x rootfs + data on qemuarm, so I can properly test that my configs etc are populated correctly on /data running on standard runqemu script from yocto.

I followed QEMU, the FAST! processor emulator but ran into problems, since I am running the build inside a VM in hyper-V, then the KVM part fails.

When adding:

MACHINE = “qemuarm”
INHERIT += “mender-full-bios rm_work”

then it only creates ext4, and no uefiimg.

When trying:

https://docs.mender.io/2.2/devices/yocto-project/raw-flash/example-qemu

INHERIT += “mender-full-ubi”
MACHINE = “vexpress-qemu-flash”

I get error to set “MENDER_IS_ON_MTDID”.

So I used:

MENDER_MTDIDS = “nand0=40000000.flash,nand1=60000000.flash”
MENDER_IS_ON_MTDID = “60000000.flash”

After that I got warnings:

WARNING: gkcontroller-emulated-1.0-r0 do_image_tar: Unknown MTDID type 40000000.flash,nand, setting UBI block overhead to 0
WARNING: gkcontroller-emulated-1.0-r0 do_image_tar: Unknown MTDID type 40000000.flash,nand, setting UBI overhead to 0
WARNING: gkcontroller-emulated-1.0-r0 do_image_tar: Could not find MENDER_IS_ON_MTDID (60000000.flash) in MENDER_MTDPARTS (). Returning UBI size of zero.

Then I get failure on do_image_ext4:

DEBUG: Executing python function prepare_excluded_directories
DEBUG: Python function prepare_excluded_directories finished
DEBUG: Executing python function set_image_size
WARNING: Unknown MTDID type 40000000.flash,nand, setting UBI block overhead to 0
WARNING: Unknown MTDID type 40000000.flash,nand, setting UBI overhead to 0
WARNING: Could not find MENDER_IS_ON_MTDID (60000000.flash) in MENDER_MTDPARTS (). Returning UBI size of zero.
WARNING: Could not find MENDER_IS_ON_MTDID (60000000.flash) in MENDER_MTDPARTS (). Returning UBI size of zero.
WARNING: Could not find MENDER_IS_ON_MTDID (60000000.flash) in MENDER_MTDPARTS (). Returning UBI size of zero.
DEBUG: 322636.000000 = 322636 * 1.000000
DEBUG: 322636.000000 = max(322636.000000, -90112)[322636.000000] + 1
DEBUG: 322636.000000 = int(322636.000000)
DEBUG: 322636 = aligned(322636)
DEBUG: returning 322636
DEBUG: Python function set_image_size finished
DEBUG: Executing python function extend_recipe_sysroot
NOTE: Direct dependencies are [‘virtual:native:/build/…/poky/meta/recipes-extended/pigz/pigz_2.4.bb:do_populate_sysroot’, '/home/emil$
NOTE: Installed into sysroot: []
NOTE: Skipping as already exists in sysroot: [‘pigz-native’, ‘depmodwrapper-cross’, ‘update-rc.d-native’, ‘cross-localedef-native’, ‘pbzip2-native’, 'opkg-utils-nat$
DEBUG: Python function extend_recipe_sysroot finished
DEBUG: Executing shell function do_image_ubifs
Error: too large LEB size 8388608, maximum is 2097152
WARNING: exit code 255 from a shell command.
ERROR: Function failed: do_image_ubifs (log file is located at /build/tmp-glibc/work/vexpress_qemu-oe-linux-gnueabi/gkcontroller-emula$

Then, going back to a straight qemuarm build, it does not produce the uefiimg as mentioned (no imagetypes variable specified, should I):

MACHINE = “qemuarm”
INHERIT += “mender-full-bios rm_work”
RM_WORK_EXCLUDE = “wic-tools”
PATCHRESOLVE = “noop”

MENDER_STORAGE_TOTAL_SIZE_MB = “2048”
MENDER_BOOT_PART_SIZE_MB = “40”
MENDER_DATA_PART_SIZE_MB = “512”

So no matter which machine / image combination I try I run into different problems. I really tried to follow the guides and try every combination of config partition variables etc, but I always run into some error.

Then I tried adding:

MENDER_FEATURES_ENABLE_append = " mender-image-uefi"

But then I got:

ERROR: Nothing PROVIDES ‘u-boot’
u-boot was skipped: Either UBOOT_MACHINE or UBOOT_CONFIG must be set in the qemuarm machine configuration.
ERROR: Required build target ‘gkcontroller-emulated’ has no buildable providers.
Missing or unbuildable dependency chain was: [‘my-distro-image’, ‘u-boot’]

So I guess that’s why you chose x86-64 as an example because it has:

UBOOT_MACHINE ?= “qemu-x86_64_defconfig”
KERNEL_IMAGETYPE = “bzImage”

Hope someone can help, thanks! :slight_smile:

We use all of the qemu targets internally in our Q/A so they should all work, but might require getting the variables correct.

We do provide custom machines for our testing, and you can take a look here,

To get everything setup correctly.

Thanks for the quick response

I try:

MACHINE = “vexpress-qemu”
INHERIT += “mender-full-ubi”

MENDER_STORAGE_TOTAL_SIZE_MB = “2048”
MENDER_DATA_PART_SIZE_MB = “512”

Then I get “MENDER_MTDIDS must be defined”.

I add:

MENDER_MTDIDS = “nor0=40000000.flash”

Then I get:

| DEBUG: Python function extend_recipe_sysroot finished
| DEBUG: Executing shell function do_image_ubifs
| Error: too large LEB size 8388480, maximum is 2097152
| WARNING: exit code 255 from a shell command.

You do not need this for the vexpress-qemu

Thank you so much!

Is there a reason why there is no qemuarm but vexpress?

The reason is that it has it’s own patch to reduce to 256M RAM and other things I don’t want, like the custom kernel config. Is it straight forward to use qemuarm as a machine or is it something I should worry about?

Thanks!

Yes, it is because qemuarm doesn’t support U-Boot, only direct kernel boot. We need to be able to test U-Boot inside QEMU.

Understood, thanks.

What do you suggest if I need more than 256M RAM? I was thinking of pulling out the bits so it works with UBOOT/GRUB without being vexpress specific, so it’s not constrained to that RAM etc.

Or is it enough to override the recipe with a patch file with the same name? (meta-mender/meta-mender-qemu/recipes-kernel/linux/linux-yocto/reduce-memory-to-256m.patch)

You will need the revert that patch yes, and also change this line. I was doing this very recently myself for some debugging work, so I know it works.

1 Like

Thanks again.

I did:
SRC_URI_remove = " file://reduce-memory-to-256m.patch"
In my layer which has higher priority.

Then I saw that it was untouched, which is what I want, right?:

memory@60000000 {
device_type = “memory”;
reg = <0x60000000 0x40000000>;
};

However, it never manages to load , it stopped at:

## Starting EFI application at 60100000 ...
Welcome to GRUB!

lock: OK
lock: OK

error: not a regular file.

How are you launching QEMU? Can you give me the full output?

Hello and thanks for your quick reply!

qemu-system-arm -m 512M -kernel /home/emil/yoctoroot/build/tmp-glibc/deploy/images/vexpress-qemu/u-boot.elf -net nic,macaddr=52:54:00:76:75:ef -net user,hostfwd=tcp::8822-:22 -display vnc=:23 -nographic -M vexpress-a9 -drive file=/home/emil/yoctoroot/build/tmp-glibc/deploy/images/vexpress-qemu/myimage-vexpress-qemu-grub.uefiimg,if=sd,format=raw

pulseaudio: set_sink_input_volume() failed
pulseaudio: Reason: Invalid argument
pulseaudio: set_sink_input_mute() failed
pulseaudio: Reason: Invalid argument


U-Boot 2019.01 (Dec 09 2019 - 21:59:56 +0000)

DRAM:  512 MiB
WARNING: Caches not enabled
Flash: 128 MiB
MMC:   MMC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   smc911x-0
Hit any key to stop autoboot:  0
MMC Device 1 not found
no mmc device at slot 1
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
** Unable to read file / **
Found EFI removable media binary efi/boot/bootarm.efi
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
Scanning disks on mmc...
MMC Device 1 not found
MMC Device 2 not found
MMC Device 3 not found
Found 5 disks
WARNING: booting without device tree
447488 bytes read in 155 ms (2.8 MiB/s)
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
WARNING: booting without device tree
## Starting EFI application at 60100000 ...
Welcome to GRUB!

lock: OK
lock: OK

error: not a regular file.

This runs with the 256M patch applied. Hangs when not.

You need to set this to 1G because that is what is recorded in the device tree after you removed the patch. Otherwise the OS will try to write into memory which doesn’t exist.

1 Like

Nice catch! And thanks for the quick answer! :slight_smile: