Rockchip env partitions scarthgap

Hi,

I’m trying add support for radxa cm3 using yocto meta-rockchip layer (with mainline u-boot and kernel). I have integration almost done but have an issue with env writing.

I have following in local.conf:

    # move to 4M instead of default 8M
    MENDER_PARTITION_ALIGNMENT = "4161536"
    BOOTENV_SIZE = "0x4000"

env offset is move due to the fact that according https://opensource.rock-chips.com/wiki_Partitions is on offset 8128*512.

When image is build fw_enc.config shows:

/dev/mmcblk0 0x3f8000 0x4000
/dev/mmcblk0 0x7f0000 0x4000

where IMO second line is invalid as redundant env should be + 0x4000. I think I’m missing some piece but I’m not sure which one. Any idea how to set it properly or is there some other issue pls?

I have this patch for cm3 mender :

From 8703700cd396cdeecc6d7dde39e0b2e8080188d8 Mon Sep 17 00:00:00 2001
From: Marek Belisko <marek.belisko@gmail.com>
Date: Thu, 4 Jul 2024 15:34:13 +0200
Subject: [PATCH] cm3 mender

Upstream-Status: Inappropriate [mender specific]

Signed-off-by: Marek Belisko <marek.belisko@gmail.com>
---
 configs/radxa-cm3-io-rk3566_defconfig | 1 +
 env/Kconfig                           | 2 +-
 include/configs/rockchip-common.h     | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/configs/radxa-cm3-io-rk3566_defconfig b/configs/radxa-cm3-io-rk3566_defconfig
index 4b606dcb8e..b5eeb90f61 100644
--- a/configs/radxa-cm3-io-rk3566_defconfig
+++ b/configs/radxa-cm3-io-rk3566_defconfig
@@ -82,3 +82,4 @@ CONFIG_USB_EHCI_GENERIC=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GENERIC=y
 CONFIG_ERRNO_STR=y
+CONFIG_ENV_IS_IN_MMC=y
diff --git a/env/Kconfig b/env/Kconfig
index f5f0969233..1e9c3d1788 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -603,7 +603,7 @@ config ENV_SIZE
        default 0x40000 if ENV_IS_IN_SPI_FLASH && ARCH_ZYNQMP
        default 0x20000 if ARCH_ZYNQ || ARCH_OMAP2PLUS || ARCH_AT91
        default 0x10000 if ARCH_SUNXI
-       default 0x8000 if ARCH_ROCKCHIP && ENV_IS_IN_MMC
+       default 0x4000 if ARCH_ROCKCHIP && ENV_IS_IN_MMC
        default 0x2000 if ARCH_ROCKCHIP && ENV_IS_IN_SPI_FLASH
        default 0x8000 if ARCH_ZYNQMP || ARCH_VERSAL || ARCH_VERSAL_NET
        default 0x4000 if ARC
diff --git a/include/configs/rockchip-common.h b/include/configs/rockchip-common.h
index 9121bba373..67a1c3cb90 100644
--- a/include/configs/rockchip-common.h
+++ b/include/configs/rockchip-common.h
@@ -30,4 +30,9 @@

 #endif

+/*mender defines*/
+#define CONFIG_BOOTCOUNT_LIMIT
+#define CONFIG_BOOTCOUNT_ENV
+#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
+
 #endif /* _ROCKCHIP_COMMON_H_ */
--
2.25.1

and also custom class which add back SPL + u-boot:

inherit image_types

# It is not possible to specific this using MENDER_IMAGE_BOOTLOADER_FILE/OFFSET,
# instead we use an append to "gptimg" to embedd the bootloader
IMAGE_CMD:gptimg:append() {
    outimgname="${IMGDEPLOYDIR}/${IMAGE_NAME}.$suffix"
    dd if=${DEPLOY_DIR_IMAGE}/${SPL_BINARY} of=${outimgname} conv=notrunc seek=64
    dd if=${DEPLOY_DIR_IMAGE}/u-boot.itb of=${outimgname} conv=notrunc seek=16384
}

Thanks.

Hi @MarekBelisko,

the values in fw_env.config are based on the u-boot config, namely:

  • CONFIG_ENV_OFFSET
  • CONFIG_ENV_OFFSET_REDUND

So check the u-boot defconfig for the board and make sure those are set to the desired values of 0x3f8000 and 0x3fc000.

Greets,
Josef

Hi @TheYoctoJester ,

that is true but in u-boot config I found this line:

#define CONFIG_ENV_OFFSET_REDUND MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET_2

and MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET_2 is set to:
0x3f8000 + 0x3f8000 based on code in u-boot-mender-helpers.inc.

Ah gotcha @MarekBelisko!

In that case, I’d suggest to just understand the setting in u-boot-mender-helpers.inc as an educated guess for default value, and adjust it in the recipe as desired.

Greets,
Josef

The was na issue in mainline u-boot, this patch fix the issue: rockchip: rk35xx: Remove use of eMMC DDR52 mode (ebe293ba) · Commits · U-Boot / U-Boot · GitLab

1 Like

@MarekBelisko thanks for sharing, but just so I understand correctly: incorrect DDR initialisation made env writing fail? :exploding_head:

Hi @TheYoctoJester it’s not DDR memory it’s regarding some eMMC setting :slight_smile: (see: radxa cm3 2024.01 mmc write error)

1 Like

Ah got it now. Thanks! @MarekBelisko

I’ll add integration to meta-mender-community soon. Thanks!

1 Like