# (MENDER\_STORAGE\_DEVICE: not found) Mender u-boot patches for Toradex U-boot on Apalis imx8x

**URL:** https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539
**Category:** Yocto Project
**Tags:** nxp, u-boot, toradex
**Created:** [April 23, 2021, 7:14am UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539 "2021-04-23T07:14:07Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![riktw](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@riktw](https://hub.mender.io/u/riktw)
#### Post date: [April 23, 2021, 7:14am UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/1 "2021-04-23T07:14:07Z")

</div>

Hello,

I am working on getting Mender to run on a Toradex Apalis IMX8X SoM (using their Ixora board) using Yocto.  
I followed the guide on setting up Mender in a Yocto project but I am running in an issue regarding U-Boot.  
The U-boot is provided by Toradex and called u-boot-Toradex, I added the “require recipes-bsp/u-boot/u-boot-mender.inc” to the .bb of u-boot-toradex but I am running into a compile error.

```
ERROR: u-boot-toradex-2020.04-r0 do_provide_mender_defines: Execution of '/home/developer/apalis/build/tmp/work/apalis_imx8x-tdx-linux/u-boot-toradex/2020.04-r0/temp/run.do_provide_mender_defines.31694' failed with exit code 1:
+ true
+ [! -e /home/developer/apalis/build/tmp/work/apalis_imx8x-tdx-linux/u-boot-toradex/2020.04-r0/fw_env.config.default]
+ [0 -eq 0]
+ expr 16777216 % ( 8388608 * 2 )
+ [0 -ne 0]
+ [16777216 -gt 16777216]
+ MENDER_STORAGE_DEVICE
/home/developer/apalis/build/tmp/work/apalis_imx8x-tdx-linux/u-boot-toradex/2020.04-r0/temp/run.do_provide_mender_defines.31694: 136: /home/developer/apalis/build/tmp/work/apalis_imx8x-tdx-linux/u-boot-toradex/2020.04-r0/temp/run.do_provide_mender_defines.31694: MENDER_STORAGE_DEVICE: not found

```

I do have MENDER\_STORAGE\_DEVICE specified in my local.conf file:

MENDER\_STORAGE\_DEVICE = “/dev/mmcblk0”

Does this error mean that MENDER\_STORAGE\_DEVICE or that u-boot tried to find a device called /dev/mmcblk0 and is not able to find it?

I did try adding the following but the error remains:

MENDER\_UBOOT\_STORAGE\_INTERFACE = “mmc”  
MENDER\_UBOOT\_STORAGE\_DEVICE = “0”

Without “require recipes-bsp/u-boot/u-boot-mender.inc” in the .bb file, the uboot compiles and works as expected, and my device nicely shows up in the [mender.io](http://mender.io) server, but of course updating does not work.

@drewmoseley edited formatting

---

<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: [April 23, 2021, 1:29pm UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/2 "2021-04-23T13:29:36Z")

</div>

Hi @riktw what version of Yocto are you building? Are you using the existing meta-mender-toradex layer from the meta-mender-community repository? It should be relatively straight-forward to add a new Toradex SOM to the existing layer and I think all the U-Boot changes should already be there. You may only need to add a few \_apalis-imx8 variable suffixes.

Drew

---

<div class="post-metadata">

### Author: ![riktw](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@riktw](https://hub.mender.io/u/riktw)
#### Post date: [April 26, 2021, 8:35am UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/3 "2021-04-26T08:35:20Z")

</div>

Hello Drew,

I am using Yocto 3.1 Dunfell (building on Debian 9) based on the Yocto examples from Toradex. I also tried the meta-mender-toradex one and I had to make one or two changes to the Integration of Mender boot code into Toradex U-boot patch file but after that I ended up with the exact same error sadly enough.

Best regards,

Rik

---

<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: [April 26, 2021, 2:47pm UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/4 "2021-04-26T14:47:49Z")

</div>

It _looks_ like it is complaining because the string `MENDER_STORAGE_DEVICE` is referenced in u-boot-mender.inc rather than the variable declaration `${MENDER_STORAGE_DEVICE}`.

Can you share your `local.conf` and any other related conf files if you use them (ie `auto.conf`)?

Can you confirm the commit hash you are using for the `meta-mender` and `meta-mender-community` repositories?

Can you also verify that `git diff` shows no local changes in your sources?

Drew

---

<div class="post-metadata">

### Author: ![riktw](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@riktw](https://hub.mender.io/u/riktw)
#### Post date: [April 28, 2021, 5:53pm UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/5 "2021-04-28T17:53:07Z")

</div>

Hello,

The local hashes are:  
meta-mender: bd5a6de7f3e79f1bb37e18d02595ff31d22584ae and no local changes  
meta-mender-community: fd3fafc3bd957b53b2dd0327c571b20e3341c465  
One local change to to file meta-mender-toradex-nxp/recipes-bsp/u-boot/files/0001-Integration-of-Mender-boot-code-into-toradex-U-Boot.patch

The diff:

```
@@ -2,14 +2,15 @@ Index: git/include/env_default.h
 ===================================================================
 --- git.orig/include/env_default.h
 +++ git/include/env_default.h
-@@ -8,6 +8,7 @@
- */
+@@ -9,6 +9,8 @@
  
  #include <env_callback.h>
-+#include <env_mender.h>
- #include <linux/stringify.h>
  
++#include <env_mender.h>
++
  #ifdef DEFAULT_ENV_INSTANCE_EMBEDDED
+ env_t embedded_environment __UBOOT_ENV_SECTION__ (environment) = {
+ ENV_CRC, /* CRC Sum */
 @@ -22,6 +23,7 @@ static char default_environment[] = {
  #else
  const uchar default_environment[] = {

```

And the local.conf: [MACHINE ?= "apalis-imx8x"## Where to place downloads## During a firs - Pastebin.com](https://pastebin.com/B9bwdz8k)

Rik

@drewmoseley: edited formatting

---

<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: [April 28, 2021, 9:43pm UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/6 "2021-04-28T21:43:14Z")

</div>

I think the issue is your syntax in declaring the MENDER\_ROOT\_FS\_PART\_\* variables. You are using parentheses instead of brackets:

ie You have

```
MENDER_ROOTFS_PART_A = "$(MENDER_STORAGE_DEVICE)2"
MENDER_ROOTFS_PART_B = "$(MENDER_STORAGE_DEVICE)3"

```

and you should have

```
MENDER_ROOTFS_PART_A = "${MENDER_STORAGE_DEVICE}2"
MENDER_ROOTFS_PART_B = "${MENDER_STORAGE_DEVICE}3"

```

Drew

---

<div class="post-metadata">

### Author: ![riktw](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@riktw](https://hub.mender.io/u/riktw)
#### Post date: [April 29, 2021, 11:21am UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/7 "2021-04-29T11:21:58Z")

</div>

Wow, I completely missed that, thanks a lot 🙂  
I had to make a patch file for things like the CONFIG\_ENV\_OFFSET setting in u-boot but I could copy that almost completely from the existing verdin patch. The build nor succeeds 😃

I can’t test it this week but I will validate it all works as expected next week. Thanks again

Rik

---

<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: [April 29, 2021, 1:47pm UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/8 "2021-04-29T13:47:47Z")

</div>

Excellent. Glad to hear we got you unstuck for now. I look forward to hearing if it is all working for you now.

Drew

---

<div class="post-metadata">

### Author: ![riktw](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@riktw](https://hub.mender.io/u/riktw)
#### Post date: [May 6, 2021, 9:39am UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/9 "2021-05-06T09:39:39Z")

</div>

I had to add a few more things to my patches (adding CONFIG\_BOOTCOUNT\_ENV, CONFIG\_ENV\_IS\_IN\_MMC and such in apalis include file) but I managed to get my apalis board to boot and update now, thanks again 🙂

Rik

---

<div class="post-metadata">

### Author: ![ABTP](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@ABTP](https://hub.mender.io/u/ABTP)
#### Post date: [June 10, 2021, 1:23pm UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/10 "2021-06-10T13:23:43Z")

</div>

Hi [riktw](https://hub.mender.io/u/riktw) and [drewmoseley](https://hub.mender.io/u/drewmoseley),

I am really happy to know you successfully managed to integrate it. I am currently trying to do the same, but rather for Zeus Linux, which uses u-boot-toradex\_2018.03. I followed your steps and created a patch for _apalis-imx8\_defconfig_ and _apalis-imx8.h_ to include the missing boot environment variables . This is the content of the patch:

```auto
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
+CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
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
@@ -148,11 +148,11 @@
 #define CONFIG_SYS_MEMTEST_END 0x89000000
 
 /* 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_MMC_IMG_LOAD_PART	1
 
@@ -160,6 +160,8 @@
 #define CONFIG_MMCROOT "/dev/mmcblk0p2" /* USDHC1 eMMC */
 #define CONFIG_SYS_FSL_USDHC_NUM	3
 
+#define CONFIG_BOOTCOUNT_ENV
+#define CONFIG_BOOTCOUNT_LIMIT
 #define CONFIG_SYS_BOOTM_LEN (64 << 20) /* Increase max gunzip size */
 
 /* Size of malloc() pool */

```

However, when compiling _u-boot-toradex_, I get the following error even though _CONFIG\_SYS\_REDUNDAND\_ENVIRONMENT_ was set in the patch:

```auto
Apalis-imx8/build-apalis-imx8/tmp/work/apalis_imx8-poky-linux/u-boot-toradex/2018.03-r0/git/include/config_mender.h:41:3: error: #error CONFIG_SYS_REDUNDAND_ENVIRONMENT is required for Mender to work. Make sure that: 1) All the instructions at https:
| 41 | # error CONFIG_SYS_REDUNDAND_ENVIRONMENT is required for Mender to work. Make sure that: 1) All the instructions at https://docs.mender.io/system-updates-yocto-project/board-integration/bootloader-support/u-boot have been followed. 2) All required layers are included in bblayers.conf, including any board specific layers such as meta-mender-<board>. Check also https://docs.mender.io/troubleshoot/yocto-project-build for Known Issues when upgrading.

```

I tried to also upgrade to _u-boot-toradex\_2019.07_, but it gives the exact same error. Have you come across this error or have you any suggestions on how to fix it?

Thank you for your support, its really appreciated 🙂

---

<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: [June 10, 2021, 1:46pm UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/11 "2021-06-10T13:46:37Z")

</div>

It looks like `meta-mender-core/recipes-bsp/u-boot/patches/0002-Generic-boot-code-for-Mender.patch` is checking for a C preprocessor define for CONFIG\_SYS\_REDUNDAND\_ENVIRONMENT rather than a defconfig setting. The [coral board integration](https://github.com/mendersoftware/meta-mender-community/blob/dunfell/meta-mender-coral/recipes-bsp/u-boot/patches/0001-imx8mq_phanbell-add-Mender-requirements.patch) shows how this is done. I’m not sure if that’s in addition to the defconfig setting or instead of it; you’ll need to experiment a bit.

Drew

---

<div class="post-metadata">

### Author: ![ABTP](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@ABTP](https://hub.mender.io/u/ABTP)
#### Post date: [June 10, 2021, 1:51pm UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/12 "2021-06-10T13:51:34Z")

</div>

Hi Drew,

Thanks for the hint, I will check it out.

---

<div class="post-metadata">

### Author: ![ABTP](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@ABTP](https://hub.mender.io/u/ABTP)
#### Post date: [June 16, 2021, 12:24pm UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/13 "2021-06-16T12:24:48Z")

</div>

Hi Drew

I implemented the changes to the patches, so now the uboot environment variables are patched as C preprocessor defines in _apalis-imx8.h_. Now I am able to compile and the board boots with Mender 🙂.

I have two issues though, the first one I am familiar with, but the 2nd issue I don’t know what it means or why its happening.

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

To fix this, I need to update _fw\_env.config_ with the correct _Device name_, _Device offset_, and _Env. size_ so that they match those U-Boot is using. How can I go about fixing this issue?

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

Do you have any idea what can be the cause of this message? I think both issues are related somehow .

Thank you 🙂

---

<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: [June 16, 2021, 1:28pm UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/14 "2021-06-16T13:28:05Z")

</div>

The first issue indicates that the U-Boot environment is incorrect, likely as you surmise caused by invalid values in fw\_env.config. You’ll need to dig through the configured U-Boot sources to figure out what values are needed.

I have no idea what would cause the second error. Are you using the Toradex BSP or a custom checkout? What branch?

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: [June 17, 2021, 12:37pm UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/15 "2021-06-17T12:37:03Z")

</div>

Hi Rik,

I am interested in running Mender on the Apalis IMX8/Ixora platform. I am curious to see how you got this to work for the Apalis IMX8X, as this may help my work. Is it possible to share your patches?

Best,  
Paul

---

<div class="post-metadata">

### Author: ![ABTP](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@ABTP](https://hub.mender.io/u/ABTP)
#### Post date: [June 18, 2021, 12:28pm UTC](https://hub.mender.io/t/mender-storage-device-not-found-mender-u-boot-patches-for-toradex-u-boot-on-apalis-imx8x/3539/16 "2021-06-18T12:28:09Z")

</div>

> [@ABTP](#):
>
> I have two issues though, the first one I am familiar with, but the 2nd issue I don’t know what it means or why its happening.
> 
> 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
> 
> To fix this, I need to update _fw\_env.config_ with the correct _Device name_ , _Device offset_ , and _Env. size_ so that they match those U-Boot is using. How can I go about fixing this issue?
> 
> 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

I provided more information about my setup and current stage in the following post:

[https://hub.mender.io/t/toradex-integration-updates/3763/3?u=abtp](https://hub.mender.io/t/toradex-integration-updates/3763/3)
