Hi Folks,
I’ve completed the integration steps for UBI mender integration on release 1.2. I wanted to share a few notes about the ubi integration with Mender on a TI AM3517 platform, in case these are useful to anyone else.
I’m using a custom u-boot build based on ti-u-boot.
1) I wasn’t able to get the qemu flash build working for some reason, although I didn’t spend much time trying to figure it out. The build succeeded but attempt to boot gave me
```
Booting from NOR...
ubi0: attaching mtd3
ubi0: scanning is finished
ubi0: volume table was restored
UBI init error 12
```
I did see the note about using latest qemu and did build qemu 2.10.0. My qemu start commands were:
```
QEMU_SYSTEM_ARM=~/qemu-2.10.0/arm-softmmu/qemu-system-arm
VEXPRESS_IMG=tmp/deploy/images/vexpress-qemu-flash/core-image-minimal-vexpress-qemu-flash.vexpress-nor \
MACHINE=vexpress-qemu-flash \
../meta-mender/meta-mender-qemu/scripts/mender-qemu
```
After this failed I went straight to the integration steps for my hardware, so there could be a simple fix for this. It's not blocking me at the moment but if you'd like more information I can provide it.
2) I noticed errors like this when attempting to run bitbake - note that this is for the u-boot recipe I’m *not* using, the default one in the yocto meta layer:
```
ERROR: ExpansionError during parsing /home/dan/CCC/Yocto/build-am3517/../meta/recipes-bsp/u-boot/
u-boot_2017.01.bb | ETA: 0:00:02
Traceback (most recent call last):
bb.data_smart.ExpansionError: Failure expanding variable MENDER_BOOTENV_TOTAL_ALIGNED_SIZE, expression was ${@mender_get_env_total_aligned_size(0x200000, 128)} which triggered exception NameError: name 'mender_get_env_total_aligned_size' is not defined
```
I fixed this with this small patch on u-boot-mender-common.inc:
...
diff --git a/meta-mender-core/recipes-bsp/u-boot/u-boot-mender-common.inc b/meta-mender-core/recipes-bsp/u-boot/u-boot-mender-common.inc
index 46b158a..c7dcd1b 100644
--- a/meta-mender-core/recipes-bsp/u-boot/u-boot-mender-common.inc
+++ b/meta-mender-core/recipes-bsp/u-boot/u-boot-mender-common.inc
@@ -1,4 +1,4 @@
-inherit mender-helpers
+inherit mender-helpers mender-uboot
…
I’m not sure if this is the correct fix or if there’s something different I should be doing to resolve.
3) I noticed this error when building the u-boot-fw-utils
...
ERROR: u-boot-fw-utils-ccc.2016.05-1.0-r0 do_package: objcopy failed with exit code 1 (cmd was 'arm-poky-linux-gnueabi-objcopy' --only-keep-debug '/home/dan/CCC/Yocto/build-am3517/tmp/work/prod_am3517-poky-linux-gnueabi/u-boot-fw-utils-ccc.2016.05/1.0-r0/package/sbin/fw_setenv' '/home/dan/CCC/Yocto/build-am3517/tmp/work/prod_am3517-poky-linux-gnueabi/u-boot-fw-utils-ccc.2016.05/1.0-r0/package/sbin/.debug/fw_setenv'):
arm-poky-linux-gnueabi-objcopy:/home/dan/CCC/Yocto/build-am3517/tmp/work/prod_am3517-poky-linux-gnueabi/u-boot-fw-utils-ccc.2016.05/1.0-r0/package/sbin/fw_setenv: File format not recognized
ERROR: u-boot-fw-utils-ccc.2016.05-1.0-r0 do_package: Function failed: split_and_strip_files
ERROR: Logfile of failure stored in: /home/dan/CCC/Yocto/build-am3517/tmp/work/prod_am3517-poky-linux-gnueabi/u-boot-fw-utils-ccc.2016.05/1.0-r0/temp/log.do_package.13334
ERROR: Task (/home/dan/CCC/Yocto/build-am3517/../meta-ccc/recipes-bsp/u-boot/u-boot-fw-utils-ccc.2016.05.bb:do_package) failed with exit code '1'
...
If I look at the file output I could see that /home/dan/CCC/Yocto/build-am3517/tmp/work/prod_am3517-poky-linux-gnueabi/u-boot-fw-utils-ccc.2016.05/1.0-r0/package/sbin/fw_setenv was not being cross compiled.
4) I’m having trouble setting up the correct build of fw_env.config for my configuration.
I’m using a partition layout for mtd which looks like this:
```
root@prod-am3517:~# cat /proc/mtd
dev: size erasesize name
mtd0: 00020000 00020000 "MLO"
mtd1: 00100000 00020000 "u-boot"
mtd2: 00040000 00020000 "u-boot-env"
mtd3: 1fea0000 00020000 "ubi"
```
With u-boot-env at 0x120000 length 0x40000 or 2 0x20000 sized erase sectors. Partition mtd3 is the mtd partition containing each of my rootfs partitions and the data partition.
Based on the instructions at
https://docs.mender.io/1.2/devices/partition-layout I’m supposed to use a MENDER_STORAGE_DEVICE setting that represents the entire device, not any single partition. However it’s not clear how to do that with my current mtdparts configuration. I think I would need to define mtd0 as the entire device in this case and remove definitions for u-boot, u-boot-env, and ubi which seems wrong. The default setting for MENDER_STORAGE_DEVICE, ubi0, won’t work because I don’t have a ubi0 device defined. If I use /dev/ubi0 instead I get
```
root@prod-am3517:~# fw_printenv
Cannot get MTD information for /dev/ubi0
```
Which makes sense because ubi0 isn’t an mtd device.
If I try to use /dev/mtd0 as MENDER_STORAGE_DEVICE instead of ubi0 with this content for fw_env.config:
```
/dev/mtd0 0x120000 0x20000
/dev/mtd0 0x140000 0x20000
```
I get
```
root@prod-am3517:~# fw_printenv
Cannot read bad block mark: Invalid argument
```
Presumably because the offsets are outside the range for device /dev/mtd0.
I need to use this setting with my current fw_env.config:
```
root@prod-am3517:~# cat /data/u-boot/fw_env.config
/dev/mtd2 0x0000 0x20000 0x20000
/dev/mtd2 0x20000 0x20000 0x20000
```
If there’s a better way to fix these issues I’d greatly appreciate any suggestions. if you’d like me to prepare pull requests for any code or documentation changes based on these observations please let me know.