# Toradex Apalis IMX8 Yocto with Mender

**URL:** https://hub.mender.io/t/toradex-apalis-imx8-yocto-with-mender/3759
**Category:** Yocto Project
**Created:** [June 17, 2021, 11:21am UTC](https://hub.mender.io/t/toradex-apalis-imx8-yocto-with-mender/3759 "2021-06-17T11:21:33Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![pgiangrossi](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/pgiangrossi/32/1247_2.png) [@pgiangrossi](https://hub.mender.io/u/pgiangrossi)
#### Post date: [June 17, 2021, 11:21am UTC](https://hub.mender.io/t/toradex-apalis-imx8-yocto-with-mender/3759/1 "2021-06-17T11:21:33Z")

</div>

I am trying to get a Yocto build on the Toradex Apalis IMX8 dev kit working with Mender.

I am using dunfell with:  
meta-mender-core = “HEAD:bd87ddf4b97ccca21044645094b407a5d7beeae5”  
meta-mender-toradex-nxp = “HEAD:390c061f4d56a6628135c0911d1164ce14327405”

[local.conf](https://pastebin.com/6RQdRHcx)

Changed 0001-Integration-of-Mender-boot-code-into-toradex-U-Boot.patch to work with current sources:

```auto
diff --git a/include/env_default.h b/include/env_default.h
index 56a8bae39a..b6cd139ce8 100644
--- a/include/env_default.h
+++ b/include/env_default.h
@@ -8,6 +8,7 @@
  */
 
 #include <env_callback.h>
+#include <env_mender.h>
 
 #ifdef DEFAULT_ENV_INSTANCE_EMBEDDED
 env_t embedded_environment __UBOOT_ENV_SECTION__ (environment) = {
@@ -21,6 +22,7 @@ static char default_environment[] = {
 #else
 const uchar default_environment[] = {
 #endif
+MENDER_ENV_SETTINGS
 #ifndef CONFIG_USE_DEFAULT_ENV_FILE
 #ifdef	CONFIG_ENV_CALLBACK_LIST_DEFAULT
 	ENV_CALLBACK_VAR "=" CONFIG_ENV_CALLBACK_LIST_DEFAULT "\0"
diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf
index 00b8fb34aa..d500c48405 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

```

Created a new patch for apalis-imx8:

```auto
diff --git a/configs/apalis-imx8_defconfig b/configs/apalis-imx8_defconfig
index 1cd2994622..f9da99c624 100644
--- a/configs/apalis-imx8_defconfig
+++ b/configs/apalis-imx8_defconfig
@@ -3,7 +3,9 @@ CONFIG_ARCH_IMX8=y
 CONFIG_SYS_TEXT_BASE=0x80020000
 CONFIG_SYS_MALLOC_F_LEN=0x8000
 CONFIG_ENV_SIZE=0x2000
-CONFIG_ENV_OFFSET=0xFFFFDE00
+CONFIG_ENV_OFFSET=0x800000
+CONFIG_ENV_OFFSET_REDUND=0x1000000
+CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_DM_GPIO=y
 CONFIG_BOOTAUX_RESERVED_MEM_BASE=0x88000000
 CONFIG_BOOTAUX_RESERVED_MEM_SIZE=0x08000000
diff --git a/include/configs/apalis-imx8.h b/include/configs/apalis-imx8.h
index 41b67d7a53..c27023dea6 100644
--- a/include/configs/apalis-imx8.h
+++ b/include/configs/apalis-imx8.h
@@ -127,9 +127,8 @@
 #define CONFIG_SYS_MEMTEST_START	0x90000000
 #define CONFIG_SYS_MEMTEST_END 0xc0000000
 
-/* Environment in eMMC, before config block at the end of 1st "boot sector" */
-#define CONFIG_SYS_MMC_ENV_DEV 0	/* USDHC1 eMMC */
-#define CONFIG_SYS_MMC_ENV_PART 1
+#define CONFIG_BOOTCOUNT_ENV
+#define CONFIG_BOOTCOUNT_LIMIT
 
 #define CONFIG_SYS_MMC_IMG_LOAD_PART	1

```

I get the following mender-grow-data.service error while running on the target:

```auto
-- Logs begin at Fri 2021-04-16 06:25:47 UTC, end at Fri 2021-04-16 06:29:17 UTC
. --
Apr 16 06:25:47 apalis-imx8 mender-client-resize-data-part[354]: cat: can't open
 '/sys/block/mmcblk0/mmcblk0p4/size': No such file or directory
Apr 16 06:25:47 apalis-imx8 systemd[1]: [[0;1;39m[[0;1;31m[[0;1;39mmender-grow-d
ata.service: Main process exited, code=exited, status=1/FAILURE[[0m
Apr 16 06:25:47 apalis-imx8 systemd[1]: [[0;1;38;5;185m[[0;1;39m[[0;1;38;5;185mm
ender-grow-data.service: Failed with result 'exit-code'.[[0m
Apr 16 06:25:47 apalis-imx8 systemd[1]: [[0;1;31m[[0;1;39m[[0;1;31mFailed to sta
rt Mender service to grow data partition size.[[0m
Apr 16 06:25:47 apalis-imx8 systemd[1]: Starting Mender service to grow data par
tition size...
Apr 16 06:25:47 apalis-imx8 mender-client-resize-data-part[467]: cat: can't open
 '/sys/block/mmcblk0/mmcblk0p4/size': No such file or directory
Apr 16 06:25:47 apalis-imx8 systemd[1]: [[0;1;39m[[0;1;31m[[0;1;39mmender-grow-d
ata.service: Main process exited, code=exited, status=1/FAILURE[[0m
Apr 16 06:25:47 apalis-imx8 systemd[1]: [[0;1;38;5;185m[[0;1;39m[[0;1;38;5;185mm
ender-grow-data.service: Failed with result 'exit-code'.[[0m
Apr 16 06:25:47 apalis-imx8 systemd[1]: [[0;1;31m[[0;1;39m[[0;1;31mFailed to sta
rt Mender service to grow data partition size.[[0m

```

I did some debugging on the target:

```auto
# fdisk -l
Disk /dev/mmcblk0: 14.84 GiB, 15913189376 bytes, 31080448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2f2e2c2f

Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 40959 32768 16M c W95 FAT32 (LBA)
/dev/mmcblk0p2 40960 31080447 31039488 14.8G 83 Linux

# cat /proc/cmdline
pci=nomsi root=/dev/mmcblk0p2 ro rootwait

# cat /proc/mtd
dev: size erasesize name

```

[Full console log.](https://pastebin.com/7WzTmhc9)

---

<div class="post-metadata">

### Author: ![pgiangrossi](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/pgiangrossi/32/1247_2.png) [@pgiangrossi](https://hub.mender.io/u/pgiangrossi)
#### Post date: [July 21, 2021, 6:59am UTC](https://hub.mender.io/t/toradex-apalis-imx8-yocto-with-mender/3759/2 "2021-07-21T06:59:08Z")

</div>

This works now with the latest updates to the mender-community layer.

See [Toradex integration updates - #19 by drewmoseley](https://hub.mender.io/t/toradex-integration-updates/3763/19)

---

<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: [July 21, 2021, 12:06pm UTC](https://hub.mender.io/t/toradex-apalis-imx8-yocto-with-mender/3759/3 "2021-07-21T12:06:22Z")

</div>

Hi @pgiangrossi,

What is the value of MENDER\_TOTAL\_SIZE\_MB with the larger image that fails with easy installer automated install? I’ll try to replicate here now that I have a working apalis-imx8 build.

Drew

---

<div class="post-metadata">

### Author: ![pgiangrossi](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/pgiangrossi/32/1247_2.png) [@pgiangrossi](https://hub.mender.io/u/pgiangrossi)
#### Post date: [July 21, 2021, 12:16pm UTC](https://hub.mender.io/t/toradex-apalis-imx8-yocto-with-mender/3759/4 "2021-07-21T12:16:36Z")

</div>

Hi Drew,

MENDER\_TOTAL\_SIZE\_MB is 12288

Thanks to your most recent post on the toradex discussion, I have fixed the problem. nginx was timing out on the large transfer. I added the following 4 lines to a new file called “/etc/nginx/conf.d/timeout.conf”

```auto
proxy_connect_timeout 1200;
proxy_send_timeout 1200;
proxy_read_timeout 1200;
send_timeout 1200;

```

Then I restarted the nginx server, and it worked like a charm. Thanks a lot!

I tried to post this on the other toradex chat, but it says that I do not have permissions to post a comment.

Paul

---

<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: [July 21, 2021, 12:35pm UTC](https://hub.mender.io/t/toradex-apalis-imx8-yocto-with-mender/3759/5 "2021-07-21T12:35:42Z")

</div>

OK. Great to hear.

I’ll see if I can figure out your permissions issue. Worst case I’ll post the details for you.

Drew

---

<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: [July 21, 2021, 12:42pm UTC](https://hub.mender.io/t/toradex-apalis-imx8-yocto-with-mender/3759/6 "2021-07-21T12:42:18Z")

</div>

Hi @pgiangrossi I just confirmed that the Toradex community site is read-only at the moment. We are migrating to a new platform. It should be live again soon.

---

<div class="post-metadata">

### Author: ![markf](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@markf](https://hub.mender.io/u/markf)
#### Post date: [August 16, 2021, 10:48pm UTC](https://hub.mender.io/t/toradex-apalis-imx8-yocto-with-mender/3759/7 "2021-08-16T22:48:45Z")

</div>

What’s the step by step for building this and is there a consensus that this fully works yet (as opposed to just builds)?

Most of the other Toradex integrations involve using the Mender manifests to start with and the Verdin iMX8M Mini uses a Toradex manifest. Attempted the latter to build for the Apalis and doesn’t seem to boot up (basically used the latest toradex manifest and followed the Verdin instructions building for Apalis iMX8 in my local.conf).

---

<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: [August 16, 2021, 11:41pm UTC](https://hub.mender.io/t/toradex-apalis-imx8-yocto-with-mender/3759/8 "2021-08-16T23:41:55Z")

</div>

Hi @markf, I have indeed verified that this works. At some point I need to put together a completely updated instruction sheet for this but my intention was that it basically follows a similar pattern with [the Verdin](https://hub.mender.io/t/toradex-verdin-imx8m-mini/2908). Basically, start with the Toradex 5.3.0 BSP, add the extra layers and local.conf settings and boot. That feels like a better approach since the Toradex BSP has been more thoroughly tested that the Mender manifest.

Drew
