# Yocto: Rockchip separate kernel/rootfs layout

**URL:** <https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721>\
**Category:** General Discussions\
**Tags:** yocto, partitioning, warrior\
**Created:** [October 22, 2020, 10:18pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721 "2020-10-22T22:18:24Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![sherlock](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sherlock](https://hub.mender.io/u/sherlock)\
**Post date:** [October 22, 2020, 10:18pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/1 "2020-10-22T22:18:24Z")

</div>

Hi all! I’m trying to setup mender on a Rockchip rk3399 board.  
I’ve followed Rockchip’s guide for partitioning and flashing and it’s working for us.

Now I’ve followed mender’s guide (2.5) for integrating into our Yocto (warrior) build system.

Rockchip has their partition layout as follows:  
DEVICE=mmcblk1  
PARTITIONS:

- p1 = loader (u-boot TPL+SPL)
- p2 = u-boot
- p3 = trust image
- p4 = kernel (extlinux)
- p5 = rootfs

I was going to change it to the following  
NEW PARTITIONS:

- p1 = loader
- p2 = u-boot
- p3 = trust
- p4 = data
- p5 = kernel
- p6 = rootfs\_a
- p7 = rootfs\_b

My first question is, what should I set MENDER\_BOOT\_PART to? Should it be set to partition 2?  
My second question is, do I need to have the kernel and rootfs in the same partition?

---

<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:** [October 23, 2020, 6:09pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/2 "2020-10-23T18:09:52Z")

</div>

I _think_ partition 2 would be correct for MENDER\_BOOT\_PART but I’ve never seen a setup like this. In the default layout, are the loader and u-boot partitions actually mountable filesystems?

With Mender, the kernel is normally moved into the root filesystem so that it can easily be updated with a full rootfs update. The default Mender boot logic assumes that the kernel is in the rootfs and will load it from there.

If you want it in a separate partition you need to ensure that there are two for redundancy. One to match each of the two rootfs partitions. We don’t have out-of-the-box support for this. There is [this layer](https://github.com/coreycothrum/meta-mender-kernel) which does have support for separate kernel partitions but I’ve never worked with it.

Drew

---

<div class="post-metadata">

**Author:** ![sherlock](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sherlock](https://hub.mender.io/u/sherlock)\
**Post date:** [October 26, 2020, 6:01pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/3 "2020-10-26T18:01:29Z")

</div>

The loader and the u-boot partition are not mountable. Do they need to be?  
The loader is the U-Boot TPL/SPL for initializing RAM and a jumping off point to U-Boot.  
I’ll try out the layer you mentioned, but in case that doesn’t work is there a detailed image on the partition layout for eMMC/flash?

---

<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:** [October 26, 2020, 7:51pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/4 "2020-10-26T19:51:25Z")

</div>

It depends on how uboot is configured. For instance on the Raspberry Pi, UBoot is actually a file on a fat partition so needs to be mountable. I don’t know about this platform though.

I’m not sure what you are looking for as far as a “detailed image”. The Mender layer is fairly configurable so as long as you have two rootfs partitions with [appropriate Yocto](https://docs.mender.io/system-updates-yocto-project/board-integration/partition-configuration) variable settings you should be ok.

---

<div class="post-metadata">

**Author:** ![sherlock](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sherlock](https://hub.mender.io/u/sherlock)\
**Post date:** [October 26, 2020, 8:48pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/5 "2020-10-26T20:48:45Z")

</div>

Yeah, so I’m working on trying to get everything configured properly for mender.  
We have our own separate patches for the u-boot to do some additional configuration, but I’m having a hard time applying some of the patches from mender for u-boot.  
Specifically right now is when we try to add kconfig options for CONFIG\_ENV\_OFFSET I end up with a python3 error:

```
  File "/poky/build/tmp/work/poky-linux/u-boot/1_2019.01-r0/add_kconfig_option_with_depends.py", line 38, in add_kconfig_option
    if re.match("^config\s*%s(\s|$)" % kconfig_key, line):
  File "/usr/lib/python3.6/re.py", line 172, in match
    return _compile(pattern, flags).match(string)
  File "/usr/lib/python3.6/re.py", line 301, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.6/sre_compile.py", line 562, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.6/sre_parse.py", line 855, in parse
    p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
  File "/usr/lib/python3.6/sre_parse.py", line 416, in _parse_sub
    not nested and not items))
  File "/usr/lib/python3.6/sre_parse.py", line 768, in _parse
    source.tell() - start)
sre_constants.error: missing ), unterminated subpattern at position 10 

```

If I print out the key and line variables at the place I see the following before it crashes

```
key=ENV_OFFSET, line=config ENV_OFFSET

key=ENV_OFFSET, line=	hex "Environment Offset"

key=ENV_OFFSET, line=	depends on (!ENV_IS_IN_UBI && !ENV_IS_NOWHERE) || ARCH_STM32MP

key=(!ENV_IS_IN_UBI, line=#
```

---

<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:** [October 26, 2020, 9:42pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/6 "2020-10-26T21:42:38Z")

</div>

Does [this patch](https://github.com/mendersoftware/meta-mender/blob/thud/meta-mender-core/recipes-bsp/u-boot/patches/0006-env-Kconfig-Add-descriptions-so-environment-options-.patch) help?

Drew

---

<div class="post-metadata">

**Author:** ![sherlock](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sherlock](https://hub.mender.io/u/sherlock)\
**Post date:** [October 26, 2020, 10:02pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/7 "2020-10-26T22:02:58Z")

</div>

Actually the env/Kconfig has that section patched, but what’s different is the lines proceeding it

```
config ENV_OFFSET
        hex "Environment Offset"
        depends on (!ENV_IS_IN_UBI && !ENV_IS_NOWHERE) || ARCH_STM32MP

```

The line with (!ENV\_IS\_IN\_UBI …  
is the line that caused the issue it seems.  
If I patch tge **add\_kconfig\_option\_with\_depends.py** file as so, then it works fine

```
diff --git a/meta-mender-core/recipes-bsp/u-boot/files/add_kconfig_option_with_depends.py b/meta-mender-core/recipes-bsp/u-boot/files/add_kconfig_option_with_depends.py
index 549a27eb..e4834988 100644
--- a/meta-mender-core/recipes-bsp/u-boot/files/add_kconfig_option_with_depends.py
+++ b/meta-mender-core/recipes-bsp/u-boot/files/add_kconfig_option_with_depends.py
@@ -34,6 +34,8 @@ def add_kconfig_option(option):
                 kconfig_key = key[len("CONFIG_"):]
                 inside_option = False
                 for line in fd.readlines():
+ kconfig_key = re.escape(kconfig_key)
+ line = re.escape(line)
                     if re.match("^config\s*%s(\s|$)" % kconfig_key, line):
                         inside_option = True
                         continue

```

To follow up, if the U-boot partition itself is not mountable then I assume the U-boot environment needs to be mountable, correct?

---

<div class="post-metadata">

**Author:** ![sherlock](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sherlock](https://hub.mender.io/u/sherlock)\
**Post date:** [October 26, 2020, 10:34pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/8 "2020-10-26T22:34:59Z")

</div>

I also get an error when building the core-image-minimal, during the execution of _do\_image\_sdimg_  
What am I missing here?

`| output: /poky/build/tmp/work/poky-linux/core-image-minimal/1.0-r0/bootfs.image_sdimg/*: No such file or directory`

---

<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:** [October 27, 2020, 3:42pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/9 "2020-10-27T15:42:16Z")

</div>

I don’t think so. Normally the environment is just a raw block of flash data and not a filesystem.

---

<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:** [October 27, 2020, 3:42pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/10 "2020-10-27T15:42:56Z")

</div>

No idea on that build error. Is there anything else in the build log of interest?

---

<div class="post-metadata">

**Author:** ![sherlock](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sherlock](https://hub.mender.io/u/sherlock)\
**Post date:** [October 27, 2020, 10:09pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/11 "2020-10-27T22:09:45Z")

</div>

I think I solved the second problem, it looks like the rootfs/uboot partition was not being populated because IMAGE\_BOOT\_FILES was not defined. This topic helped me solve that problem:

> [@Yocto Warrior build failing on do\_image\_sdimg for beaglebone](https://hub.mender.io/t/yocto-warrior-build-failing-on-do-image-sdimg-for-beaglebone/1706):
>
> Hi there, I’m trying to integrate Mender into a Yocto project based on Warrior. The target hardware is a BeagleBone Black. I was able to build the .sdimage following the tutorial on the Beaglebone Black board integration page. However, when I include the layers into my own project, I get the following error when it tries to generate the .sdimg: | DEBUG: Executing shell function do\_image\_sdimg | + mkdir -p /home/mikevoyt/ssd/Aclima/sundstrom-os/build/tmp-sundstrom-glibc/work/beaglebone-sunds…

Though, it begs the question as to why the u-boot.bin file needs to be included in the rootfs? I suppose I’m confused by what is required and what is not based on the guide.  
Do I need to define these?  
MENDER\_UBOOT\_ENV\_STORAGE\_DEVICE\_OFFSET\_1  
MENDER\_UBOOT\_ENV\_STORAGE\_DEVICE\_OFFSET\_2  
If so, how does Mender use them?

---

<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:** [October 28, 2020, 1:34pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/12 "2020-10-28T13:34:28Z")

</div>

Those variables are used when the U-Boot image is stored in unpartitioned space. It sounds like in your case, the SPL/TPL image is expecting to load the full U-Boot image as a file in a FAT partition so you probably don’t need them defined.  
Drew

---

<div class="post-metadata">

**Author:** ![sherlock](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sherlock](https://hub.mender.io/u/sherlock)\
**Post date:** [October 28, 2020, 5:09pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/13 "2020-10-28T17:09:31Z")

</div>

The U-Boot image is actually a combination of a trust image and u-boot device tree (see attached image, right hand side). So it sounds like I would need to define those environments. Is that right, or did I misunderstand?

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/1X/54234232c97dd2b5530352759eb4709b6f36b70b.png)

---

<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:** [October 28, 2020, 6:00pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/14 "2020-10-28T18:00:33Z")

</div>

That sounds right but I have never worked with trusted boot so you may be better off checking in with one of the U-Boot mailing lists.

Drew

---

<div class="post-metadata">

**Author:** ![sherlock](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sherlock](https://hub.mender.io/u/sherlock)\
**Post date:** [October 28, 2020, 8:25pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/15 "2020-10-28T20:25:25Z")

</div>

I’ll follow up with some of the maintainers of u-boot.  
A separate question from that, how can I specify the kernel bootargs that mender should pass once the kernel is loaded?

---

<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:** [October 29, 2020, 1:46pm UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/16 "2020-10-29T13:46:52Z")

</div>

It’s standard bootloader environment stuff.

If you are using U-Boot Mender integration then take a look at [pre](https://docs.mender.io/system-updates-yocto-project/variables#mender_uboot_pre_setup_commands) and [post](https://docs.mender.io/system-updates-yocto-project/variables#mender_uboot_post_setup_commands) setup commands.

If you are using grub Mender integration then take a look at the [grub-mender-grubenv recipe](https://github.com/mendersoftware/meta-mender/tree/master/meta-mender-core/recipes-bsp/grub-mender-grubenv).

---

<div class="post-metadata">

**Author:** ![sangamkrish](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/sangamkrish/32/2443_2.png) [@sangamkrish](https://hub.mender.io/u/sangamkrish)\
**Post date:** [March 12, 2025, 9:39am UTC](https://hub.mender.io/t/yocto-rockchip-separate-kernel-rootfs-layout/2721/17 "2025-03-12T09:39:19Z")

</div>

> [@sherlock](#):
>
> Rockchip’s guide for partitioning

Can you send the link of Rockchip’s guide for partitioning  
It will be a great help for me.
