# U-boot compilation for qemu-flash failed

**URL:** <https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980>\
**Category:** General Discussions\
**Created:** [May 28, 2020, 1:02pm UTC](https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980 "2020-05-28T13:02:02Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![sk-jame](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/sk-jame/32/640_2.png) [@sk-jame](https://hub.mender.io/u/sk-jame)\
**Post date:** [May 28, 2020, 1:02pm UTC](https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980/1 "2020-05-28T13:02:02Z")

</div>

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

> [@Vanilla qemuarm full multi partition emulation?](https://hub.mender.io/t/vanilla-qemuarm-full-multi-partition-emulation/1339):
>
> 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](https://hub.mender.io/t/qemu-the-fast-processor-emulator/420) 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://doc…](https://docs.mender.io/2.2/devices/yocto-project/raw-flash/example-qemu)

[https://docs.mender.io/2.2/devices/yocto-project/raw-flash/example-qemu](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://hub.mender.io/t/qemu-the-fast-processor-emulator/420/2)  
[https://docs.mender.io/2.2/devices/yocto-project/raw-flash](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.

```

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [May 28, 2020, 2:08pm UTC](https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980/2 "2020-05-28T14:08:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sk-jame](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/sk-jame/32/640_2.png) [@sk-jame](https://hub.mender.io/u/sk-jame)\
**Post date:** [May 28, 2020, 2:32pm UTC](https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980/3 "2020-05-28T14:32:08Z")

</div>

I’m using yocto sumo

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [May 28, 2020, 4:09pm UTC](https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980/4 "2020-05-28T16:09:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sk-jame](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/sk-jame/32/640_2.png) [@sk-jame](https://hub.mender.io/u/sk-jame)\
**Post date:** [May 28, 2020, 5:06pm UTC](https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980/5 "2020-05-28T17:06:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [May 28, 2020, 5:22pm UTC](https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980/6 "2020-05-28T17:22:11Z")

</div>

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

Drew

---

<div class="post-metadata">

**Author:** ![sk-jame](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/sk-jame/32/640_2.png) [@sk-jame](https://hub.mender.io/u/sk-jame)\
**Post date:** [May 28, 2020, 6:40pm UTC](https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980/7 "2020-05-28T18:40:21Z")

</div>

@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'
```

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [May 28, 2020, 7:09pm UTC](https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980/8 "2020-05-28T19:09:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sk-jame](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/sk-jame/32/640_2.png) [@sk-jame](https://hub.mender.io/u/sk-jame)\
**Post date:** [May 28, 2020, 7:47pm UTC](https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980/9 "2020-05-28T19:47:04Z")

</div>

@drewmoseley where I can check IMAGE\_FSTYPES content?

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [May 28, 2020, 8:12pm UTC](https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980/10 "2020-05-28T20:12:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sk-jame](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/sk-jame/32/640_2.png) [@sk-jame](https://hub.mender.io/u/sk-jame)\
**Post date:** [May 28, 2020, 8:14pm UTC](https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980/11 "2020-05-28T20:14:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [May 28, 2020, 8:36pm UTC](https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980/12 "2020-05-28T20:36:05Z")

</div>

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

> INHERIT += “mender-full-ubi”

to:

> INHERIT += “mender-full-ubi”

---

<div class="post-metadata">

**Author:** ![sk-jame](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/sk-jame/32/640_2.png) [@sk-jame](https://hub.mender.io/u/sk-jame)\
**Post date:** [May 28, 2020, 8:45pm UTC](https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980/13 "2020-05-28T20:45:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [May 28, 2020, 9:10pm UTC](https://hub.mender.io/t/u-boot-compilation-for-qemu-flash-failed/1980/14 "2020-05-28T21:10:28Z")

</div>

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