Hi Drew,
Thanks a lot for looking into this, its really appreciated
So on my side, I am trying to integrate Mender on:
1-Apalis-iMX8QM running Boot2Qt based on Zeus (uboot-toradex_2018.3) on Apalis Evaluation Board V1.1C
2-Colibri iMX6ULL running Boot2Qt based on Zeus (uboot-toradex_ 2019.7) on Colibri Evaluation Board V3.2B
For the Aplis-iMX8, I have the image compiled and it no longer complained about mender-grow-data.service but I still have two issues:
1- When I run mender daemon, I get this error:
ERRO[0000] Failed to read the current active partition: No match between boot and root partitions.: Failed mender_saveenv_canary check. There is an error in the U-Boot setup. Likely causes are: 1) Mismatch between the U-Boot boot loader environment location and the location specified in /etc/fw_env.config. 2) ‘mender_setup’ is not run by the U-Boot boot script: exit status 1
The reason could be either that fw_env.config is set with the correct Device name , Device offset , and Env. size so that they match those U-Boot is using or (what is think is the case) that mender_setup’ is not run by the U-Boot boot script.
2- The 2nd issue is that after the board finishes booting, I get this message repeatedly:
mmcblk1: response CRC error sending SET_BLOCK_COUNT command, card status 0xc00b00
To get to this point, I made modifications to the mender-community patches:
0001-configs-apalis-imx8-mender-integration.patch
diff --git a/configs/apalis-imx8_defconfig b/configs/apalis-imx8_defconfig
index 4f1266ed6f..0b93d0935a 100644
--- a/configs/apalis-imx8_defconfig
+++ b/configs/apalis-imx8_defconfig
@@ -71,3 +71,7 @@ CONFIG_VIDEO=y
CONFIG_VIDEO_IMX_HDP_LOAD=y
CONFIG_OF_LIBFDT_OVERLAY=y
# CONFIG_EFI_LOADER is not set
+CONFIG_ENV_SIZE=0x2000
+CONFIG_ENV_OFFSET=0x2000
+CONFIG_ENV_OFFSET_REDUND=0x4000
+
diff --git a/include/configs/apalis-imx8.h b/include/configs/apalis-imx8.h
index 0d81069394..84802548c8 100644
--- a/include/configs/apalis-imx8.h
+++ b/include/configs/apalis-imx8.h
@@ -149,15 +149,15 @@
/* Environment in eMMC, before config block at the end of 1st "boot sector" */
#define CONFIG_ENV_SIZE 0x2000
-#define CONFIG_ENV_OFFSET (-CONFIG_ENV_SIZE + \
- CONFIG_TDX_CFG_BLOCK_OFFSET)
-#define CONFIG_SYS_MMC_ENV_DEV 0
-#define CONFIG_SYS_MMC_ENV_PART 1
+
+#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
+#define CONFIG_SYS_MMC_ENV_PART 1
+#define CONFIG_SYS_MMC_ENV_DEV 1 /* USDHC2 is 8-bit */
#define CONFIG_SYS_MMC_IMG_LOAD_PART 1
/* On Apalis iMX8 USDHC1 is eMMC, USDHC2 is 8-bit SD and USDHC3 is 4-bit SD */
-#define CONFIG_MMCROOT "/dev/mmcblk0p2" /* USDHC1 eMMC */
+#define CONFIG_MMCROOT "/dev/mmcblk1p2" /* USDHC1 eMMC */
#define CONFIG_SYS_FSL_USDHC_NUM 3
#define CONFIG_SYS_BOOTM_LEN (64 << 20) /* Increase max gunzip size */
0001-toradex-Integration-of-Mender-boot-code-into-U-Boot.patch
diff --git a/include/env_default.h b/include/env_default.h
index 86b639d3e2..f56a1135f8 100644
--- a/include/env_default.h
+++ b/include/env_default.h
@@ -9,7 +9,7 @@
*/
#include <env_callback.h>
-
+#include <env_mender.h>
#ifdef DEFAULT_ENV_INSTANCE_EMBEDDED
env_t environment __UBOOT_ENV_SECTION__ = {
ENV_CRC, /* CRC Sum */
@@ -22,6 +22,7 @@ static char default_environment[] = {
#else
const uchar default_environment[] = {
#endif
+ MENDER_ENV_SETTINGS
#ifdef CONFIG_ENV_CALLBACK_LIST_DEFAULT
ENV_CALLBACK_VAR "=" CONFIG_ENV_CALLBACK_LIST_DEFAULT "\0"
#endif
diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf
index 00b8fb34aa..e312c8037d 100644
--- a/scripts/Makefile.autoconf
+++ b/scripts/Makefile.autoconf
@@ -109,7 +109,8 @@ define filechk_config_h
echo \#include \<configs/$(CONFIG_SYS_CONFIG_NAME).h\>; \
echo \#include \<asm/config.h\>; \
echo \#include \<linux/kconfig.h\>; \
- echo \#include \<config_fallbacks.h\>;)
+ echo \#include \<config_fallbacks.h\>; \
+ echo \#include \<config_mender.h\>;)
endef
include/config.h: scripts/Makefile.autoconf create_symlink FORCE
local.conf
ACCEPT_FSL_EULA = "1"
IMAGE_POSTPROCESS_COMMAND_remove = "do_qbsp_image;"
MENDER_ARTIFACT_NAME = "Test-1"
MENDER_DEVICE_TYPE = "Test"
INHERIT += "mender-full"
PREFERRED_PROVIDER_u-boot_mender-uboot = "u-boot-toradex"
PREFERRED_PROVIDER_virtual/bootloader_mender-uboot = "u-boot-toradex"
DISTRO_FEATURES_append = " systemd"
VIRTUAL-RUNTIME_init_manager = "systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
VIRTUAL-RUNTIME_initscripts = ""
ARTIFACTIMG_FSTYPE = "ext4"
MENDER_SERVER_URL = "https://hosted.mender.io"
MENDER_TENANT_TOKEN = "Removed token for posting on Mender Hub"
MENDER_FEATURES_ENABLE_append = " mender-uboot mender-image-sd"
MENDER_FEATURES_DISABLE_append = " mender-grub mender-image-uefi"
IMAGE_FSTYPES_remove = "tar.gz wic.gz wic.bmap mender.bmap sdimg.bmap sdcard.gz wic"
MENDER_STORAGE_DEVICE = "/dev/mmcblk1"
MENDER_STORAGE_TOTAL_SIZE_MB = "12288"
MENDER_IMAGE_BOOTLOADER_BOOTSECTOR_OFFSET = "66"
MENDER_BOOT_PART_SIZE_MB="32"
UBOOT_CONFIG_aplis-imx8 = "sd"
MENDER_UBOOT_STORAGE_DEVICE = "1"
MENDER_UBOOT_STORAGE_INTERFACE = "mmc"
#MENDER_BOOT_PART = "${MENDER_STORAGE_DEVICE}1"
#MENDER_DATA_PART = "${MENDER_STORAGE_DEVICE}4"
#MENDER_ROOTFS_PART_A = "${MENDER_STORAGE_DEVICE}2"
#MENDER_ROOTFS_PART_B = "${MENDER_STORAGE_DEVICE}3"
#MENDER_DATA_PART_SIZE_MB = "12288"
#MENDER_FEATURES_DISABLE_append = " mender-growfs-data"
With this conf file and patches I have the following observations:
1- if I set:
MENDER_BOOT_PART_SIZE_MB=“0”
I get 3 partitions inseated of 4 (no boot partition), but the board doesnt boot. During compiling, i get this warning message:
WARNING: b2qt-embedded-qt5-image-1.0-r0 do_image_sdimg: MENDER_BOOT_PART_SIZE_MB is set to zero, but IMAGE_BOOT_FILES is not empty. The files are being omitted from the image.
Which is strange because IMAGE_BOOT_FILES is empty in local.conf. Any ideas where else it is getting set ?
2- if I print the uboot environemnt variables, I dont find any Mender variables even though those variables exist in the env.txt file produced by compiling u-boot. Is it possible that the default variables are loaded instead? I believe this is the reason I get the first issue I mentioned above, since mender-setup is not called during booting.
arch=arm
baudrate=115200
board=apalis-imx8
board_name=Apalis iMX8QM
board_rev=v1.0
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}extlinux/extlinux.conf
boot_fdt=try
boot_net_usb_start=usb start
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_targets=mmc1 mmc2 mmc0 usb0 dhcp
bootcmd=run distro_bootcmd
bootcmd_dhcp=run boot_net_usb_start; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;
bootcmd_mfg=select_dt_from_module_version && fastboot 0
bootcmd_mmc0=setenv devnum 0; run mmc_boot
bootcmd_mmc1=setenv devnum 1; run mmc_boot
bootcmd_mmc2=setenv devnum 2; run mmc_boot
bootcmd_usb0=setenv devnum 0; run usb_boot
bootcount=1
bootdelay=1
commit_atf=bb209a0
commit_mkimage=d7f9440d
commit_scfw=b929edfe
commit_secofw=27167ff2
console=ttyLP1,115200 earlycon=lpuart32,0x5a070000,115200
cpu=armv8
defargs=pci=nomsi
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
ethaddr=00:14:2d:68:8e:4c
ethprime=FEC
fastboot_dev=mmc0
fdt_addr=0x83000000
fdt_addr_r=0x84000000
fdtcontroladdr=fd67e368
fdtfile=fsl-imx8qm-apalis-v1.1-eval.dtb
hdp_addr=0x84000000
hdp_file=hdmitxfw.bin
image=Image
initrd_addr=0x83800000
initrd_high=0xffffffffffffffff
ipaddr=192.168.10.2
kernel_addr_r=0x82000000
kernel_image=Image
loadaddr=0x80280000
loadhdp=fatload mmc ${mmcdev}:${mmcpart} ${hdp_addr} ${hdp_file}
loadm4image_0=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${m4_0_image}
loadm4image_1=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${m4_1_image}
m4_0_image=m4_0.bin
m4_1_image=m4_1.bin
m4boot_0=run loadm4image_0; dcache flush; bootaux ${loadaddr} 0
m4boot_1=run loadm4image_1; dcache flush; bootaux ${loadaddr} 1
mmc_boot=if mmc dev ${devnum}; then setenv devtype mmc; run scan_dev_for_boot_part; fi
mmcargs=setenv bootargs console=${console},${baudrate} root=${mmcroot} video=imxdpufb5:off video=imxdpufb6:off video=imxdpufb7:off
mmcautodetect=yes
mmcdev=0
mmcpart=1
mmcroot=/dev/mmcblk0p2 rootwait rw
netmask=255.255.255.0
panel=NULL
ramdisk_addr_r=0x86400000
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}extlinux/extlinux.conf; then echo Found ${prefix}extlinux/extlinux.conf; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
script=boot.scr
scriptaddr=0x86000000
sec_boot=no
serial#=06852172
serverip=192.168.10.1
setup=run loadhdp; hdp load ${hdp_addr}; run mmcargs
soc=imx8
soc_type=imx8qm
usb_boot=usb start; if usb dev ${devnum}; then setenv devtype usb; run scan_dev_for_boot_part; fi
vendor=toradex
ver=U-Boot 2018.03-toradex_imx_v2018.03_4.14.98_2.3.0_bringup+g52f89f8382 (Apr 15 2021 - 17:12:01 +0000)