U-boot compilation for qemu-flash failed

I’m trying to build qemu arm with emulating flash memory.
I follow these instructions:

https://docs.mender.io/2.2/devices/yocto-project/raw-flash/example-qemu
https://hub.mender.io/t/qemu-the-fast-processor-emulator/420/2
https://docs.mender.io/2.2/devices/yocto-project/raw-flash

I added this options to local.conf:

MACHINE = "vexpress-qemu-flash"
MENDER_MTDIDS = "nand0=40000000.flash"
MENDER_IS_ON_MTDID = "40000000.flash"
MENDER_MTDPARTS = "40000000.flash:512k(u-boot),-(ubi)"

During bitbake core-image-minimal got these errors:

| drivers/mtd/built-in.o: In function `concat_get_unmapped_area':
| /home/devsrv/k/build_env/mender-qemu/build/tmp/work/vexpress_qemu_flash-poky-linux-gnueabi/u-boot/1_2018.01-r0/git/drivers/mtd/mtdconcat.c:674: undefined reference to `mtd_get_unmapped_area'
| drivers/mtd/built-in.o: In function `concat_unlock':
| /home/devsrv/k/build_env/mender-qemu/build/tmp/work/vexpress_qemu_flash-poky-linux-gnueabi/u-boot/1_2018.01-r0/git/drivers/mtd/mtdconcat.c:557: undefined reference to `mtd_unlock'
| drivers/mtd/built-in.o: In function `concat_lock':
| /home/devsrv/k/build_env/mender-qemu/build/tmp/work/vexpress_qemu_flash-poky-linux-gnueabi/u-boot/1_2018.01-r0/git/drivers/mtd/mtdconcat.c:523: undefined reference to `mtd_lock'
| drivers/mtd/built-in.o: In function `concat_write':
| /home/devsrv/k/build_env/mender-qemu/build/tmp/work/vexpress_qemu_flash-poky-linux-gnueabi/u-boot/1_2018.01-r0/git/drivers/mtd/mtdconcat.c:143: undefined reference to `mtd_write'
| drivers/mtd/built-in.o: In function `concat_read':
| /home/devsrv/k/build_env/mender-qemu/build/tmp/work/vexpress_qemu_flash-poky-linux-gnueabi/u-boot/1_2018.01-r0/git/drivers/mtd/mtdconcat.c:90: undefined reference to `mtd_read'
| drivers/mtd/built-in.o: In function `concat_block_markbad':
| /home/devsrv/k/build_env/mender-qemu/build/tmp/work/vexpress_qemu_flash-poky-linux-gnueabi/u-boot/1_2018.01-r0/git/drivers/mtd/mtdconcat.c:645: undefined reference to `mtd_block_markbad'
| drivers/mtd/built-in.o: In function `concat_block_isbad':
| /home/devsrv/k/build_env/mender-qemu/build/tmp/work/vexpress_qemu_flash-poky-linux-gnueabi/u-boot/1_2018.01-r0/git/drivers/mtd/mtdconcat.c:625: undefined reference to `mtd_block_isbad'
| drivers/mtd/built-in.o: In function `concat_read_oob':
| /home/devsrv/k/build_env/mender-qemu/build/tmp/work/vexpress_qemu_flash-poky-linux-gnueabi/u-boot/1_2018.01-r0/git/drivers/mtd/mtdconcat.c:257: undefined reference to `mtd_read_oob'
| drivers/mtd/built-in.o: In function `concat_dev_erase':
| /home/devsrv/k/build_env/mender-qemu/build/tmp/work/vexpress_qemu_flash-poky-linux-gnueabi/u-boot/1_2018.01-r0/git/drivers/mtd/mtdconcat.c:366: undefined reference to `mtd_erase'
| drivers/mtd/built-in.o: In function `cfi_mtd_init':
| /home/devsrv/k/build_env/mender-qemu/build/tmp/work/vexpress_qemu_flash-poky-linux-gnueabi/u-boot/1_2018.01-r0/git/drivers/mtd/cfi_mtd.c:239: undefined reference to `add_mtd_device'
| /home/devsrv/k/build_env/mender-qemu/build/tmp/work/vexpress_qemu_flash-poky-linux-gnueabi/u-boot/1_2018.01-r0/git/drivers/mtd/cfi_mtd.c:258: undefined reference to `add_mtd_device'
| /home/devsrv/k/build_env/mender-qemu/build/tmp/work/vexpress_qemu_flash-poky-linux-gnueabi/u-boot/1_2018.01-r0/git/Makefile:1261: recipe for target 'u-boot' failed.

Hi @sk-jame, which branch of Yocto are you building?

I’m using yocto sumo

I was able to build u-boot in this configuration using the warrior branch. Do you have a need to stay on sumo? We don’t do much with that branch any more so if you stick with it and fix it, we would love to have a PR.

May be later, but now I need to have some test env. Is everything else is fine in my settings? I will try to build it with warrior.
Also looks like script to run qemu - can’t work with flash. It have 1 switch related to nor memory, but this case can not be ever reached.

As far as I can tell yes, your settings should work with warrior just fine.

Drew

@drewmoseley thx for you advices.
it’s almost done with Warrior branch, but in the end I got error:

 core-image-minimal-1.0-r0 do_image_mender: Size of rootfs is greater than the calculated partition space (68059136 > 58458112). This image won't fit on a device with the current storage configuration. Try reducing IMAGE_OVERHEAD_FACTOR if it is higher than 1.0, or raise MENDER_STORAGE_TOTAL_SIZE_MB if the device in fact has more storage.

in my config:
MENDER_STORAGE_TOTAL_SIZE_MB = “256M”

How can I fix it?

upd:
I set overhead factor to 0, but now I got error with ext4. I dunno why it make ext4 at all %_%

ERROR: Task (/home/devsrv/k/build_env/mender-qemu/build/../sources/poky/meta/recipes-core/images/core-image-minimal.bb:do_image_ext4) failed with exit code '1'

I’m not sure. I know tweaking the UBI parameters is kind of a black art so I don’t have much to offer.
I also don’t know why it would be trying to build ext4. Does the bitbake IMAGE_FSTYPES variable have ext4 in it?

@drewmoseley where I can check IMAGE_FSTYPES content?

bitbake -e core-image-minimal 2>&1 | grep ‘^IMAGE_FSTYPES=’

If instead of grepping you redirect the entire output to a file, you can then search for IMAGE_FSTYPES= and see the entire history of how that variable is generated. ie which recipes and classes set it.

IMAGE_FSTYPES="vexpress-nor  mender mender.bmap   ubimg mtdimg ubimg.bmap  uefiimg uefiimg.bmap   uefiimg.bz2 "

Oh, try and edit conf/local.conf and change:

INHERIT += “mender-full-ubi”

to:

INHERIT += “mender-full-ubi”

you wrote same string
I think you mean
mender-full
to
mender-full-ubi

upd: it works! Build finished. But can’t run:

 QEMU_AUDIO_DRV=none qemu-system-arm -m 256M -kernel /home/devsrv/k/build_env/mender-qemu/build/tmp/deploy/images/vexpress-qemu-flash/u-boot.elf -net nic,macaddr=52:54:00:f2:8b:df -net user,hostfwd=tcp::8822-:22 -display vnc=:23 -nographic -M vexpress-a9 -drive file=/tmp/mender-qemu.X5pTeKdr/nor0,if=pflash,format=raw -drive file=/tmp/mender-qemu.X5pTeKdr/nor1,if=pflash,format=raw

What it should be instead of 40000000.flash ?

Loading Environment from UBI... Could not find a valid device for 40000000.flash
Partition ubi not found!

** Cannot find mtd partition "ubi"
In:    serial
Out:   serial
Err:   serial
Net:   smc911x-0
Hit any key to stop autoboot:  0
Saving Environment to UBI... Partition ubi not found!

** Cannot find mtd partition "ubi"
Failed (1)
Partition ubi not found!
UBIFS error (pid: 1): cannot open "ubi0:rootfsa", error -19
Error reading superblock on volume 'ubi0:rootfsa' errno=-19!
ubifsmount - mount UBIFS volume

So last tweaks in config resolve problem and it started!
This should be add:

INHERIT += "mender-full-ubi"
MACHINE = "vexpress-qemu-flash"
MENDER_MTDIDS = "nor2=40000000.flash"
MENDER_MTDPARTS = "40000000.flash:1m(u-boot)ro,1m(u-boot-env)ro,-(ubi)"

This should be removed:

INHERIT += "mender-full"

P.S. Thank you @drewmoseley

Excellent. Glad we could get you past this. Let us know what other progress you make.
Drew