[Meta-mender] Add new partition

Hi all,

I try to add a new partition for store a application code.

This partition can be used to store application code. For example, quite sensitive code can be stored there. This partition can be encrypted and decrypted at startup.

can not attach the .patch , How to share it ?

I will also like help to understand an error. when I test the image on the target the system mounts the slot / dev / mmcblk0p5 3 times :

root@ls1012afrwy:~# cat /etc/fstab 
#stock fstab - you probably want to override this with a machine specific one

/dev/root            /                    auto       defaults              1  1
proc                 /proc                proc       defaults              0  0
devpts               /dev/pts             devpts     mode=0620,gid=5       0  0
tmpfs                /run                 tmpfs      mode=0755,nodev,nosuid,strictatime 0  0
tmpfs                /var/volatile        tmpfs      defaults              0  0

#uncomment this if your device has a SD/MMC/Transflash slot
#/dev/mmcblk0p1       /media/card          auto       defaults,sync,noauto  0  0

#Where the U-Boot environment resides; for devices with SD card support ONLY!
/dev/mmcblk0p1       /uboot               auto       defaults,sync         0  0
/dev/mmcblk0p5       /data                auto       defaults              0  0
/dev/mmcblk0p6       /appfs                auto       defaults              0  0

root@ls1012afrwy:~# mount | grep mmc
/dev/mmcblk0p2 on / type ext4 (rw,relatime,data=ordered)
/dev/mmcblk0p1 on /uboot type vfat (rw,relatime,sync,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/mmcblk0p5 on /appfs type ext4 (rw,relatime,data=ordered)
/dev/mmcblk0p5 on /data type ext4 (rw,relatime,data=ordered)
root@ls1012afrwy:~#

Edit: @mirzak: Prettify :slight_smile:

Hi,

Please use pre-formated text for terminal output.

That is wrap the things that you want to “highlight” with:

 ```
 Code or copy paste from terminal
 ```

You can use the same method for a patch, that is

```diff
paste your patch here
```

Which should produce correct syntax highlighting of a patch/diff.

Thanks Mirzak.
This is a patch for add new partition

From d08e69080e4b0559948fa5f26002ee92bcec7bdb Mon Sep 17 00:00:00 2001
From: Joris Offouga <joris.offouga@huandco.com>
Date: Tue, 12 Feb 2019 10:25:48 +0100
Subject: [PATCH] Add Mender Application partition

This Pacth enable new partition in Mender.

This partition can be used to store application code.
For example, quite sensitive code can be stored there.
This partition can be encrypted and decrypted at startup.

Signed-off-by: Joris Offouga <joris.offouga@huandco.com>
---
 meta-mender-core/classes/mender-part-images.bbclass |  3 +++
 meta-mender-core/classes/mender-setup-image.inc     |  6 +++++-
 meta-mender-core/classes/mender-setup-install.inc   |  4 +++-
 meta-mender-core/classes/mender-setup.bbclass       | 14 ++++++++++++++
 meta-mender-core/conf/mender-vars.json              | 12 ++++++++++++
 5 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/meta-mender-core/classes/mender-part-images.bbclass b/meta-mender-core/classes/mender-part-images.bbclass
index d6dda7f..cd55c4f 100644
--- a/meta-mender-core/classes/mender-part-images.bbclass
+++ b/meta-mender-core/classes/mender-part-images.bbclass
@@ -8,6 +8,7 @@
 #    part3: second rootfs, inactive, mirror of first,
 #           available as failsafe for when some update fails
 #    part4: persistent data partition
+#    part5: application data partition
 
 python() {
     deprecated_vars = ['SDIMG_DATA_PART_DIR', 'SDIMG_DATA_PART_SIZE_MB',
@@ -167,6 +168,7 @@ EOF
 part --source rootfs --ondisk "$ondisk_dev" --fstype=${ARTIFACTIMG_FSTYPE} --label primary --align $alignment_kb --fixed-size ${MENDER_CALC_ROOTFS_SIZE}k $exclude_path_options
 part --source rootfs --ondisk "$ondisk_dev" --fstype=${ARTIFACTIMG_FSTYPE} --label secondary --align $alignment_kb --fixed-size ${MENDER_CALC_ROOTFS_SIZE}k $exclude_path_options
 part --source rootfs --rootfs-dir ${IMAGE_ROOTFS}/data --ondisk "$ondisk_dev" --fstype=${ARTIFACTIMG_FSTYPE} --label data --align $alignment_kb --fixed-size ${MENDER_DATA_PART_SIZE_MB}
+part --source rootfs --rootfs-dir ${IMAGE_ROOTFS}/appfs --ondisk "$ondisk_dev" --fstype=${ARTIFACTIMG_FSTYPE} --label appfs --align $alignment_kb --fixed-size ${MENDER_APP_PART_SIZE_MB}
 bootloader --ptable $part_type
 EOF
 
@@ -215,6 +217,7 @@ EOF
             sgdisk -u ${MENDER_ROOTFS_PART_A_NUMBER}:${@mender_get_partuuid_from_device(d, '${MENDER_ROOTFS_PART_A}')} "$outimgname"
             sgdisk -u ${MENDER_ROOTFS_PART_B_NUMBER}:${@mender_get_partuuid_from_device(d, '${MENDER_ROOTFS_PART_B}')} "$outimgname"
             sgdisk -u ${MENDER_DATA_PART_NUMBER}:${@mender_get_partuuid_from_device(d, '${MENDER_DATA_PART}')} "$outimgname"
+            sgdisk -u ${MENDER_APP_PART_NUMBER}:${@mender_get_partuuid_from_device(d, '${MENDER_APP_PART}')} "$outimgname"
         else
             diskIdent=$(echo ${@mender_get_partuuid_from_device(d, '${MENDER_ROOTFS_PART_A}')} | cut -d- -f1)
             # For MBR Set the Disk Identifier.  Drives follow the pattern of <Disk Identifier>-<Part Number>
diff --git a/meta-mender-core/classes/mender-setup-image.inc b/meta-mender-core/classes/mender-setup-image.inc
index 99ea163..8f8890c 100644
--- a/meta-mender-core/classes/mender-setup-image.inc
+++ b/meta-mender-core/classes/mender-setup-image.inc
@@ -27,9 +27,11 @@ ROOTFS_POSTPROCESS_COMMAND_append = " mender_update_fstab_file;"
 mender_update_fstab_file() {
     local tmpBootPart="${MENDER_BOOT_PART}"
     local tmpDataPart="${MENDER_DATA_PART}"
+    local tmpAppPart="${MENDER_APP_PART}"
     if ${@bb.utils.contains('DISTRO_FEATURES', 'mender-partuuid', 'true', 'false', d)}; then
         tmpBootPart="PARTUUID=${@mender_get_partuuid_from_device(d, '${MENDER_BOOT_PART}')}"
         tmpDataPart="PARTUUID=${@mender_get_partuuid_from_device(d, '${MENDER_DATA_PART}')}"
+        tmpAppPart="PARTUUID=${@mender_get_partuuid_from_device(d, '${MENDER_APP_PART}')}"
     fi
 
     if ! ${@bb.utils.contains('DISTRO_FEATURES', 'mender-image-ubi', 'true', 'false', d)}; then
@@ -44,6 +46,8 @@ mender_update_fstab_file() {
 
     mkdir -p ${IMAGE_ROOTFS}/data
     printf "%-20s %-20s %-10s %-21s %-2s %s\n" ${tmpDataPart} /data ${MENDER_DATA_PART_FSTYPE} defaults 0 0 >> ${IMAGE_ROOTFS}${sysconfdir}/fstab
+    mkdir -p ${IMAGE_ROOTFS}/appfs
+    printf "%-20s %-20s %-10s %-21s %-2s %s\n" ${tmpAppPart} /appfs ${MENDER_APP_PART_FSTYPE} defaults 0 0 >> ${IMAGE_ROOTFS}${sysconfdir}/fstab
 }
 
 # Setup state script version file.
@@ -55,7 +59,7 @@ mender_create_scripts_version_file() {
     echo -n "${MENDER_STATE_SCRIPTS_VERSION}" > ${IMAGE_ROOTFS}${sysconfdir}/mender/scripts/version
 }
 
-IMAGE_ROOTFS_EXCLUDE_PATH_append_mender-image = " data/ ${@d.getVar('MENDER_BOOT_PART_MOUNT_LOCATION')[1:]}/"
+IMAGE_ROOTFS_EXCLUDE_PATH_append_mender-image = " data/ appfs/ ${@d.getVar('MENDER_BOOT_PART_MOUNT_LOCATION')[1:]}/"
 
 
 ################################################################################
diff --git a/meta-mender-core/classes/mender-setup-install.inc b/meta-mender-core/classes/mender-setup-install.inc
index 490a3ca..f91c485 100644
--- a/meta-mender-core/classes/mender-setup-install.inc
+++ b/meta-mender-core/classes/mender-setup-install.inc
@@ -14,12 +14,13 @@ def mender_get_part_overhead_kb(d):
 MENDER_PARTITIONING_OVERHEAD_KB ??= "${MENDER_PARTITIONING_OVERHEAD_KB_DEFAULT}"
 MENDER_PARTITIONING_OVERHEAD_KB_DEFAULT = "${@mender_get_part_overhead_kb(d)}"
 
-def mender_calculate_rootfs_size_kb(total_mb, boot_mb, data_mb, alignment, overhead_kb, reserved_space_size):
+def mender_calculate_rootfs_size_kb(total_mb, boot_mb, data_mb, app_mb, alignment, overhead_kb, reserved_space_size):
     import math
 
     # Space used by each of the partitions, aligned to partition alignment
     calc_space = math.ceil(boot_mb * 1048576 / alignment) * alignment
     calc_space += math.ceil(data_mb * 1048576 / alignment) * alignment
+    calc_space += math.ceil(app_mb * 1048576 / alignment) * alignment
 
     # Remaining space after partitions and overhead are subtracted.
     calc_space = total_mb * 1048576 - calc_space - overhead_kb * 1024
@@ -42,6 +43,7 @@ def mender_calculate_rootfs_size_kb(total_mb, boot_mb, data_mb, alignment, overh
 MENDER_CALC_ROOTFS_SIZE = "${@mender_calculate_rootfs_size_kb(${MENDER_STORAGE_TOTAL_SIZE_MB}, \
                                                               ${MENDER_BOOT_PART_SIZE_MB}, \
                                                               ${MENDER_DATA_PART_SIZE_MB}, \
+                                                              ${MENDER_APP_PART_SIZE_MB}, \
                                                               ${MENDER_PARTITION_ALIGNMENT}, \
                                                               ${MENDER_PARTITIONING_OVERHEAD_KB}, \
                                                               ${MENDER_RESERVED_SPACE_BOOTLOADER_DATA})}"
diff --git a/meta-mender-core/classes/mender-setup.bbclass b/meta-mender-core/classes/mender-setup.bbclass
index b014d6d..9a97833 100644
--- a/meta-mender-core/classes/mender-setup.bbclass
+++ b/meta-mender-core/classes/mender-setup.bbclass
@@ -58,6 +58,15 @@ MENDER_DATA_PART_NUMBER_DEFAULT = "${@bb.utils.contains('MENDER_BOOT_PART_SIZE_M
 MENDER_DATA_PART ??= "${MENDER_DATA_PART_DEFAULT}"
 MENDER_DATA_PART_DEFAULT = "${MENDER_STORAGE_DEVICE_BASE}${MENDER_DATA_PART_NUMBER}"
 
+# The string path of the the app partition.
+MENDER_APP_PART ??= "${MENDER_APP_PART_DEFAULT}"
+MENDER_APP_PART_DEFAULT = "${MENDER_STORAGE_DEVICE_BASE}${MENDER_APP_PART_NUMBER}"
+
+# The partition number holding the app partition.
+MENDER_APP_PART_NUMBER ??= "${MENDER_APP_PART_NUMBER_DEFAULT}"
+MENDER_APP_PART_NUMBER_DEFAULT = "${@bb.utils.contains('MENDER_BOOT_PART_SIZE_MB', '0', '4', '5', d)}"
+
+
 # The name of of the MTD part holding your UBI volumes.
 MENDER_MTD_UBI_DEVICE_NAME ??= "${MENDER_MTD_UBI_DEVICE_NAME_DEFAULT}"
 MENDER_MTD_UBI_DEVICE_NAME_DEFAULT = ""
@@ -69,6 +78,8 @@ MENDER_DATA_PART_FSTYPE ??= "${MENDER_DATA_PART_FSTYPE_DEFAULT}"
 MENDER_DATA_PART_FSTYPE_DEFAULT = "auto"
 MENDER_BOOT_PART_FSTYPE ??= "${MENDER_BOOT_PART_FSTYPE_DEFAULT}"
 MENDER_BOOT_PART_FSTYPE_DEFAULT = "auto"
+MENDER_APP_PART_FSTYPE ??= "${MENDER_APP_PART_FSTYPE_DEFAULT}"
+MENDER_APP_PART_FSTYPE_DEFAULT = "auto"
 
 # Device type of device when making an initial partitioned image.
 MENDER_DEVICE_TYPE ??= "${MENDER_DEVICE_TYPE_DEFAULT}"
@@ -92,6 +103,9 @@ MENDER_STORAGE_TOTAL_SIZE_MB_DEFAULT ?= "1024"
 MENDER_DATA_PART_SIZE_MB ??= "${MENDER_DATA_PART_SIZE_MB_DEFAULT}"
 MENDER_DATA_PART_SIZE_MB_DEFAULT = "128"
 
+MENDER_APP_PART_SIZE_MB ??= "${MENDER_APP_PART_SIZE_MB_DEFAULT}"
+MENDER_APP_PART_SIZE_MB_DEFAULT = "128"
+
 # Size of the first (FAT) partition, that contains the bootloader
 MENDER_BOOT_PART_SIZE_MB ??= "${MENDER_BOOT_PART_SIZE_MB_DEFAULT}"
 MENDER_BOOT_PART_SIZE_MB_DEFAULT = "16"
diff --git a/meta-mender-core/conf/mender-vars.json b/meta-mender-core/conf/mender-vars.json
index 6aa1982..5dba129 100644
--- a/meta-mender-core/conf/mender-vars.json
+++ b/meta-mender-core/conf/mender-vars.json
@@ -47,6 +47,18 @@
     "MENDER_DATA_PART_FSTYPE_DEFAULT": "",
     "MENDER_DATA_PART_SIZE_MB": "",
     "MENDER_DATA_PART_SIZE_MB_DEFAULT": "",
+    "MENDER_APP_PART": "",
+    "MENDER_APP_PART_DEFAULT": "",
+    "MENDER_APP_PART_NUMBER": "",
+    "MENDER_APP_PART_NUMBER_DEFAULT": "",
+    "MENDER_APP_PART_DIR": "",
+    "MENDER_APP_PART_DIR_DEFAULT": "",
+    "MENDER_APP_PART_FSTAB_ENTRY": "",
+    "MENDER_APP_PART_FSTAB_ENTRY_DEFAULT": "",
+    "MENDER_APP_PART_FSTYPE": "",
+    "MENDER_APP_PART_FSTYPE_DEFAULT": "",
+    "MENDER_APP_PART_SIZE_MB": "",
+    "MENDER_APP_PART_SIZE_MB_DEFAULT": "",
     "MENDER_DEMO_HOST_IP_ADDRESS": "",
     "MENDER_DEVICE_TYPE": "",
     "MENDER_DEVICE_TYPES_COMPATIBLE": "",
-- 
2.1.4

1 Like

I do not see anything obvious.

Thinking if you have another service running that is mounting devices beside systemd and what is in fstab.

Can you also show the output of fdisk -l /dev/mmcblk0.

See the log:

root@ls1012afrwy:~# fdisk -l /dev/mmcblk0 
Disk /dev/mmcblk0: 14 GB, 15502147584 bytes, 30277632 sectors
236544 cylinders, 4 heads, 32 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device       Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/mmcblk0p1 *  384,0,1     1023,3,32        49152     151551     102400 50.0M  c Win95 FAT32 (LBA)
/dev/mmcblk0p2    1023,3,32   1023,3,32       163840    3997695    3833856 1872M 83 Linux
/dev/mmcblk0p3    1023,3,32   1023,3,32      3997696    7831551    3833856 1872M 83 Linux
/dev/mmcblk0p4    1023,3,32   1023,3,32      7847935    8388607     540673  264M  f Win95 Ext'd (LBA)
/dev/mmcblk0p5    1023,3,32   1023,3,32      7847936    8110079     262144  128M 83 Linux
/dev/mmcblk0p6    1023,3,32   1023,3,32      8126464    8388607     262144  128M 83 Linux

I’m not familiar with your setup but:
isn’t data partition supposed to be mmcblk0p4 or mmcblk0p3 depending upon whether you have a boot partition? your fstab is mapping it to mmcblk0p5
And why is there 6 partitions if your only adding 1 more? :grinning:
calculation issue somewhere in the patch?

Ah, hang on closer inspection it looks like an extended partition is automatically being created as you want 5 partitions. could it be that the mender code calulations is not taking into account this auto generated extended partition?

Yes there must be a problem for the calculation of the entire image. the sdmig. That’s why I asked for a review;

Thank you for your remark in fact I had to re-adjust the fstab to start otherwise I fell on the console of rescue

Below partitions overlap as well.

/dev/mmcblk0p4    1023,3,32   1023,3,32      7847935    8388607     540673  264M  f Win95 Ext'd (LBA)
/dev/mmcblk0p5    1023,3,32   1023,3,32      7847936    8110079     262144  128M 83 Linux

Looked over the patch once again, and can not find anything that would produce something like this.

I would suggest to check the log of sdimg, to see what is going on.

How to see the log ? With bitbake -e ?

You can run:

bitbake -c cleansstate core-image-base
bitbake -c image_sdimg core-image-base

and the log should end up at:

cat tmp/work/<MACHINE>/core-image-base/1.0-r0/temp/log.do_image_sdimg

Note that above path depends on which distro and machine you are using + which image you are building. But I think you get the hint :slight_smile:

as an aside, this problem does not exist if using GPT as i am currently working on arm and x86_64 projects at the same time and added extra partitions to mender build fine for the x86_64 GPT image.

@mirzak see the log , thanks for your help

DEBUG: Executing python function prepare_excluded_directories
DEBUG: 'IMAGE_ROOTFS_EXCLUDE_PATH' is set but 'respect_exclude_path' variable flag is 0 for this image type, so ignoring it
DEBUG: Python function prepare_excluded_directories finished
DEBUG: Executing python function set_image_size
DEBUG: 1014756.000000 = 1014756 * 1.000000
DEBUG: 1916928.000000 = max(1014756.000000, 1814528)[1814528.000000] + 1
DEBUG: 1916928.000000 = int(1916928.000000)
DEBUG: 1916928 = aligned(1916928)
DEBUG: returning 1916928
DEBUG: Python function set_image_size finished
DEBUG: Executing python function extend_recipe_sysroot
NOTE: Direct dependencies are ['/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/gcc/libgcc_8.2.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/mtools/mtools_4.0.18.bb:do_populate_sysroot', '/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/python/python-native_2.7.15.bb:do_populate_sysroot', '/home/joris/yocto-bsp/sources/poky/meta/recipes-core/glibc/cross-localedef-native_2.28.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/prelink/prelink_git.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-extended/parted/parted_3.2.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/bison/bison_3.0.4.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-extended/pigz/pigz_2.4.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/swig/swig_3.0.12.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-support/bmap-tools/bmap-tools_3.4.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/dosfstools/dosfstools_4.1.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-kernel/dtc/dtc_1.4.7.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/createrepo-c/createrepo-c_git.bb:do_populate_sysroot', '/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/mklibs/mklibs-native_0.1.43.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/pseudo/pseudo_git.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-extended/bc/bc_1.07.1.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-core/coreutils/coreutils_8.30.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-core/update-rc.d/update-rc.d_0.8.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/tcltk/tcl_8.6.8.bb:do_populate_sysroot', '/home/joris/yocto-bsp/sources/poky/meta/recipes-core/glibc/ldconfig-native_2.12.1.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-connectivity/openssl/openssl_1.1.1a.bb:do_populate_sysroot', '/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/qemu/qemuwrapper-cross_1.0.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/opkg/opkg_0.3.6.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/rpm/rpm_4.14.2.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/dnf/dnf_2.7.5.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/meta-freescale/recipes-bsp/change-file-endianess/change-file-endianess.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/makedevs/makedevs_1.0.1.bb:do_populate_sysroot', '/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/gcc/gcc-cross_8.2.bb:do_populate_sysroot', '/home/joris/yocto-bsp/sources/poky/meta/recipes-core/meta/wic-tools.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/opkg-utils/opkg-utils_0.3.6.bb:do_populate_sysroot', '/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/quilt/quilt-native_0.65.bb:do_populate_sysroot', '/home/joris/yocto-bsp/sources/poky/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb:do_populate_sysroot', 'virtual:native:/home/joris/yocto-bsp/sources/poky/meta/recipes-devtools/fdisk/gptfdisk_1.0.4.bb:do_populate_sysroot']
NOTE: Installed into sysroot: []
NOTE: Skipping as already exists in sysroot: ['libgcc', 'mtools-native', 'python-native', 'cross-localedef-native', 'prelink-native', 'parted-native', 'bison-native', 'pigz-native', 'swig-native', 'bmap-tools-native', 'dosfstools-native', 'dtc-native', 'createrepo-c-native', 'mklibs-native', 'pseudo-native', 'bc-native', 'coreutils-native', 'update-rc.d-native', 'tcl-native', 'ldconfig-native', 'openssl-native', 'qemuwrapper-cross', 'opkg-native', 'rpm-native', 'dnf-native', 'change-file-endianess-native', 'makedevs-native', 'gcc-cross-aarch64', 'wic-tools', 'opkg-utils-native', 'quilt-native', 'depmodwrapper-cross', 'gptfdisk-native', 'systemd-systemctl-native', 'linux-libc-headers', 'glibc', 'gnu-config-native', 'texinfo-dummy-native', 'autoconf-native', 'automake-native', 'libtool-native', 'pkgconfig-native', 'xz-native', 'zlib-native', 'gdbm-native', 'readline-native', 'bzip2-native', 'sqlite3-native', 'expat-native', 'db-native', 'shadow-native', 'binutils-native', 'elfutils-native', 'ncurses-native', 'util-linux-native', 'gettext-minimal-native', 'flex-native', 'libpcre-native', 'python3-native', 'python3-setuptools-native', 'debianutils-native', 'file-native', 'curl-native', 'cmake-native', 'libxml2-native', 'ninja-native', 'glib-2.0-native', 'attr-native', 'qemu-native', 'libarchive-native', 'libsolv-native', 'dbus-native', 'nss-native', 'popt-native', 'kmod-native', 'python3-iniparse-native', 'libcomps-native', 'libdnf-native', 'librepo-native', 'gmp-native', 'libmpc-native', 'binutils-cross-aarch64', 'mpfr-native', 'm4-native', 'lzo-native', 'unzip-native', 're2c-native', 'gettext-native', 'libffi-native', 'gtk-doc-native', 'pixman-native', 'alsa-lib-native', 'libsdl2-native', 'e2fsprogs-native', 'nspr-native', 'python3-six-native', 'libcheck-native', 'gobject-introspection-native', 'gpgme-native', 'libpng-native', 'util-macros-native', 'libxrandr-native', 'libxrender-native', 'libxext-native', 'libx11-native', 'libgpg-error-native', 'libassuan-native', 'xorgproto-native', 'xtrans-native', 'libxcb-native', 'libxau-native', 'xcb-proto-native', 'libxdmcp-native', 'libpthread-stubs-native']
DEBUG: Python function extend_recipe_sysroot finished
DEBUG: Executing shell function do_image_sdimg
+ mkdir -p /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0
+ true
+ install -m 0644 /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/deploy/images/ls1012afrwy/uboot.env /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/
+ basename /dev/mmcblk0
+ ondisk_dev=mmcblk0
+ wks=/home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/mender-sdimg.wks
+ rm -f /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/mender-sdimg.wks
+ [ -n  ]
+ true
+ [ -n 8388608 ]
+ expr 8388608 / 1024
+ boot_env_align_kb=8192
+ cat
+ expr 8388608 % 1024
+ true
+ [ 0 -ne 0 ]
+ expr 8388608 / 1024
+ alignment_kb=8192
+ [ 50 -ne 0 ]
+ mender_merge_bootfs_and_image_boot_files
+ W=/home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/bootfs.image_sdimg
+ rm -rf /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/bootfs.image_sdimg
+ cp -al /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/rootfs//uboot /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/bootfs.image_sdimg
+ image_boot_files= Image fsl-ls1012a-frwy.dtb  
+ echo Image
+ grep -q ;
+ dest=./
+ echo ./
+ grep -q /$
+ dest_is_dir=1
+ mkdir -p /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/bootfs.image_sdimg/./
+ [ 1 -eq 1 ]
+ basename /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/deploy/images/ls1012afrwy/Image
+ destfile=/home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/bootfs.image_sdimg/./Image
+ [ -e /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/bootfs.image_sdimg/./Image ]
+ cp -l /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/deploy/images/ls1012afrwy/Image /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/bootfs.image_sdimg/./Image
+ echo fsl-ls1012a-frwy.dtb
+ grep -q ;
+ dest=./
+ echo ./
+ grep -q /$
+ dest_is_dir=1
+ mkdir -p /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/bootfs.image_sdimg/./
+ [ 1 -eq 1 ]
+ basename /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/deploy/images/ls1012afrwy/fsl-ls1012a-frwy.dtb
+ destfile=/home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/bootfs.image_sdimg/./fsl-ls1012a-frwy.dtb
+ [ -e /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/bootfs.image_sdimg/./fsl-ls1012a-frwy.dtb ]
+ cp -l /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/deploy/images/ls1012afrwy/fsl-ls1012a-frwy.dtb /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/bootfs.image_sdimg/./fsl-ls1012a-frwy.dtb
+ cat
+ exclude_path_options=--exclude-path data/ appfs/ uboot/
+ cat
+ echo ### Contents of wks file ###
### Contents of wks file ###
+ cat /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/mender-sdimg.wks
part --source rawcopy --sourceparams="file=/home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/uboot.env" --ondisk "mmcblk0" --align 8192 --no-table
part --source rootfs --rootfs-dir /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/bootfs.image_sdimg --ondisk "mmcblk0" --fstype=vfat --label boot --align 8192 --fixed-size 50 --active
part --source rootfs --ondisk "mmcblk0" --fstype=ext4 --label primary --align 8192 --fixed-size 1916928k --exclude-path data/ appfs/ uboot/
part --source rootfs --ondisk "mmcblk0" --fstype=ext4 --label secondary --align 8192 --fixed-size 1916928k --exclude-path data/ appfs/ uboot/
part --source rootfs --rootfs-dir /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/rootfs/data --ondisk "mmcblk0" --fstype=ext4 --label data --align 8192 --fixed-size 128
part --source rootfs --rootfs-dir /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/rootfs/appfs --ondisk "mmcblk0" --fstype=ext4 --label appfs --align 8192 --fixed-size 128
bootloader --ptable msdos
+ echo ### End of contents of wks file ###
### End of contents of wks file ###
+ outimgname=/home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/deploy-base-image-image-complete/base-image-ls1012afrwy--20190212131619.sdimg
+ wicout=/home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/deploy-base-image-image-complete/base-image-ls1012afrwy--20190212131619-sdimg
+ BUILDDIR=/home/joris/yocto-bsp/ls1012afrwy-mender-build wic create /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/mender-sdimg.wks --vars /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/sysroots/ls1012afrwy/imgdata/ -e base-image -o /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/deploy-base-image-image-complete/base-image-ls1012afrwy--20190212131619-sdimg/ --no-fstab-update
INFO: Creating image(s)...

WARNING: overhead-factor was specified, but size was not, so bitbake variables will be used for the size. In this case both IMAGE_OVERHEAD_FACTOR and --overhead-factor will be applied
WARNING: overhead-factor was specified, but size was not, so bitbake variables will be used for the size. In this case both IMAGE_OVERHEAD_FACTOR and --overhead-factor will be applied
WARNING: overhead-factor was specified, but size was not, so bitbake variables will be used for the size. In this case both IMAGE_OVERHEAD_FACTOR and --overhead-factor will be applied
WARNING: overhead-factor was specified, but size was not, so bitbake variables will be used for the size. In this case both IMAGE_OVERHEAD_FACTOR and --overhead-factor will be applied
WARNING: overhead-factor was specified, but size was not, so bitbake variables will be used for the size. In this case both IMAGE_OVERHEAD_FACTOR and --overhead-factor will be applied
INFO: The new image(s) can be found here:
  /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/deploy-base-image-image-complete/base-image-ls1012afrwy--20190212131619-sdimg/mender-sdimg-201902121320-mmcblk0.direct

The following build artifacts were used to create the image(s):
  ROOTFS_DIR["boot"]:           /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/bootfs.image_sdimg
  ROOTFS_DIR["primary"]:        /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/rootfs
  ROOTFS_DIR["secondary"]:      /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/rootfs
  ROOTFS_DIR["data"]:           /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/rootfs/data
  ROOTFS_DIR["appfs"]:          /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/rootfs/appfs
  BOOTIMG_DIR:                  /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/recipe-sysroot/usr/share
  KERNEL_DIR:                   /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/deploy/images/ls1012afrwy
  NATIVE_SYSROOT:               /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/recipe-sysroot-native

INFO: The image(s) were created using OE kickstart file:
  /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/mender-sdimg.wks
+ basename /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/mender-sdimg
+ mv /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/deploy-base-image-image-complete/base-image-ls1012afrwy--20190212131619-sdimg/mender-sdimg-201902121320-mmcblk0.direct /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/deploy-base-image-image-complete/base-image-ls1012afrwy--20190212131619.sdimg
+ [ -n  ]
+ [ -n  ]
+ rm -rf /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/deploy-base-image-image-complete/base-image-ls1012afrwy--20190212131619-sdimg/
+ alignment=8388608
+ stat -c %s /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/deploy-base-image-image-complete/base-image-ls1012afrwy--20190212131619.sdimg
+ expr ( 4294967296 + 8388608 - 1 ) / 8388608 * 8388608
+ pad_size=4294967296
+ truncate -s 4294967296 /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/deploy-base-image-image-complete/base-image-ls1012afrwy--20190212131619.sdimg
+ [ msdos = gpt ]
+ false
+ cd /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/deploy-base-image-image-complete
+ bmaptool create base-image-ls1012afrwy--20190212131619.sdimg -o base-image-ls1012afrwy--20190212131619.sdimg.bmap
+ ret=0
+ trap  0
+ exit 0
DEBUG: Shell function do_image_sdimg finished
DEBUG: Executing python function create_symlinks
NOTE: Creating symlink: /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/deploy-base-image-image-complete/base-image-ls1012afrwy.sdimg.bmap -> base-image-ls1012afrwy--20190212131619.sdimg.bmap
NOTE: Creating symlink: /home/joris/yocto-bsp/ls1012afrwy-mender-build/tmp/work/ls1012afrwy-poky-linux/base-image/1.0-r0/deploy-base-image-image-complete/base-image-ls1012afrwy.sdimg -> base-image-ls1012afrwy--20190212131619.sdimg
DEBUG: Python function create_symlinks finished
DEBUG: Executing python function cleanup_excluded_directories
DEBUG: Python function cleanup_excluded_directories finished

Is the overlapping, not because mmcblk0p4 is the last allowable primary partition for MBR partition tables and the partitions mmcblk0p5 and mmcblk0p6 are logical partitions inside of mmcblk0p4?

Also looks like wic is detecting when you cross the MBR 4 partition limit and accounting for it and increment internally the partition number of the logical partitions. Possibly mender code needs to be updated to detect if partition table is msdos and increment partitions greater than 4 by 1.

meta-mender bug? should an issue be raised?

http://cgit.openembedded.org/openembedded-core/tree/scripts/lib/wic/plugins/imager/direct.py

I agree with you that I work on sd I did a dmesg with to look at the scores and I see this :

[114306.944433]  sdc: sdc1 sdc2 sdc3 sdc4 < sdc5 sdc6 >
[114306.956527] sd 4:0:0:0: [sdc] Attached SCSI removable disk
[114307.368635] EXT4-fs (sdc3): mounted filesystem with ordered data mode. Opts: (null)
[114307.386627] EXT4-fs (sdc5): mounted filesystem with ordered data mode. Opts: (null)
[114307.403806] EXT4-fs (sdc2): mounted filesystem with ordered data mode. Opts: (null)
[114307.427282] EXT4-fs (sdc6): mounted filesystem with ordered data mode. Opts: (null)

I used a gptimg and the worry does not arise. As dellgreen the underlined above the MBR can have only 4 partition max and if there is more 4 th it is a partion extended containing the additional ones in logical partition. By passing in gpt the number of partition increase.

Glad to hear.
I am generally working an updates to meta-mender to facilitate adding extra partitions so i will be looking into a fix for this problem on Friday as it also affects a pending pull-request i submitted.

https://github.com/mendersoftware/meta-mender/pull/696

Ah yes a partition swap is a good idea to see if you also add in your patch mine can be?

Also will be working on this

https://tracker.mender.io/browse/MEN-2362

where the aim will be that adding partitions wont need to be patched in but instead added to local.conf or machine conf for example

I do not have access to jira, I see the approach to do. It has been defined a max partition number?