# LS1021a custom board mender integration

**URL:** <https://hub.mender.io/t/ls1021a-custom-board-mender-integration/4352>\
**Category:** OpenWrt\
**Tags:** nxp\
**Created:** [November 29, 2021, 6:13pm UTC](https://hub.mender.io/t/ls1021a-custom-board-mender-integration/4352 "2021-11-29T18:13:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kele6ra](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kele6ra/32/1375_2.png) [@kele6ra](https://hub.mender.io/u/kele6ra)\
**Post date:** [November 29, 2021, 6:13pm UTC](https://hub.mender.io/t/ls1021a-custom-board-mender-integration/4352/1 "2021-11-29T18:13:27Z")

</div>

Hello, I want to integrate mender to our custom ls1021a board.  
Now I have u-boot with all patches and I need to make wright config\_mender\_defines.h file. I will have 8 mb (now 128 mb) spi nor flash as a u-boot source and 128 mb nand flash as a rootfs+data storage.

> **mtd list**
>
> ```auto
> => mtd list
> List of MTD devices:
> * nand0
> - type: NAND flash
> - block size: 0x20000 bytes
> - min I/O: 0x800 bytes
> - OOB size: 64 bytes
> - OOB available: 30 bytes
> - ECC strength: 4 bits
> - ECC step size: 512 bytes
> - bitflip threshold: 3 bits
> - 0x000000000000-0x000008000000 : "nand0"
> - 0x000000000000-0x000008000000 : "ubi"
> * nor0
> - type: NOR flash
> - block size: 0x40000 bytes
> - min I/O: 0x1 bytes
> - 0x000000000000-0x000004000000 : "nor0"
> - 0x000000000000-0x000000100000 : "rcw"
> - 0x000000100000-0x000000300000 : "u-boot"
> - 0x000000300000-0x000000380000 : "u-boot-env-1"
> - 0x000000380000-0x000000400000 : "u-boot-env-2"
> 
> ```

I need to set environment variables according to this scheme. Basic config\_mender\_defines.h was compiled for the sd boot.

> **config\_mender\_defines**
>
> ```auto
> #define MENDER_UBI
> #define MENDER_MTD_UBI_DEVICE_NAME "nand0"
> 
> /* Shell variables */
> #define MENDER_BOOT_PART_NUMBER ??
> #define MENDER_BOOT_PART_NUMBER_HEX ??
> #define MENDER_ROOTFS_PART_A_NUMBER 0
> #define MENDER_ROOTFS_PART_A_NUMBER_HEX 0
> #define MENDER_ROOTFS_PART_B_NUMBER 1
> #define MENDER_ROOTFS_PART_B_NUMBER_HEX 1
> #define MENDER_UBOOT_STORAGE_INTERFACE "ubi"
> #define MENDER_UBOOT_STORAGE_DEVICE 0
> 
> /* BB variables. */
> 
> #define MENDER_STORAGE_DEVICE_BASE "??"
> #define MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET_1 0x300000
> #define MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET_2 0x380000
> #define MENDER_ROOTFS_PART_A_NAME "/dev/ubi0"
> #define MENDER_ROOTFS_PART_B_NAME "/dev/ubi1"
> 
> /* For sanity checks. */
> 
> #define MENDER_BOOTENV_SIZE 0x80000
> #define MENDER_BOOT_KERNEL_TYPE "bootm"
> #define MENDER_KERNEL_NAME "uImage"
> #define MENDER_DTB_NAME "ls1021a-custom.dtb"
> #define MENDER_UBOOT_PRE_SETUP_COMMANDS ""
> #define MENDER_UBOOT_POST_SETUP_COMMANDS ""
> 
> ```

I wrote ?? where I can’t understand what should I st there.  
And other problem is that I can’t find how to make ubimg with openwrt builder, maybe somebody know how to do it or even have rite script?  
Or maybe you can help me with only nand memory uboot? When uboot, uboot-env will be written to the nand.

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [December 1, 2021, 9:13am UTC](https://hub.mender.io/t/ls1021a-custom-board-mender-integration/4352/2 "2021-12-01T09:13:24Z")

</div>

At least when using Yocto, Mender only supports having the U-Boot environment in a UBI volume inside the same UBI partition as the rootfs volumes. It’s not a hard requirement in the sense that Mender can work with whatever you choose, but the build process only supports setting up the environment in UBI. For this reason the `MENDER_STORAGE_DEVICE` needs to be set to the UBI partition prefix, in your case this will be `/dev/ubi` (without the numbers), and this will be used for both rootfs setup and environment setup.

I’m afraid I don’t know the OpenWRT builder.

---

<div class="post-metadata">

**Author:** ![kele6ra](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kele6ra/32/1375_2.png) [@kele6ra](https://hub.mender.io/u/kele6ra)\
**Post date:** [December 1, 2021, 9:47am UTC](https://hub.mender.io/t/ls1021a-custom-board-mender-integration/4352/3 "2021-12-01T09:47:41Z")

</div>

Thank you, now I am trying to make only nand memory image. Can you help me with flash layout?  
As I understand, I need to make ubi partition in me nand memory, from the start there will be raw uboot+environment. Then I should create first ubi (/dev/ubi1 - ro rootfs1) volume with offset (10 mb for example) and after second ubi (/dev/ubi1 - ro rootfs2) volume. Then I should make third ubi volume (/dev/ubi3 - rw rootfsdata).  
I have some questions:

1. About kernel and dtd placement. Should I write them to the /boot/uImage and /boot/uImage.dtb or I need to create other volume for them?
2. Is rootfsdata an overlay/extroot partition or a just data storage partition, need I create a special fstab config with such a layout?

---

<div class="post-metadata">

**Author:** ![kele6ra](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kele6ra/32/1375_2.png) [@kele6ra](https://hub.mender.io/u/kele6ra)\
**Post date:** [December 3, 2021, 7:21am UTC](https://hub.mender.io/t/ls1021a-custom-board-mender-integration/4352/4 "2021-12-03T07:21:34Z")

</div>

Hello again, now I am trying to make mender integration with sdacrd (trying to integrate sdacard first to have workable openwrt mender solution at first).  
The integration from [NanoPi NEO2 - OpenWrt](https://hub.mender.io/t/nanopi-neo2-openwrt/790) is not available. Openwrt with mender was deleted and link has 404 error.  
Maybe somebody have copy of that integration file?

---

<div class="post-metadata">

**Author:** ![rossbcan](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rossbcan/32/1441_2.png) [@rossbcan](https://hub.mender.io/u/rossbcan)\
**Post date:** [December 3, 2021, 1:14pm UTC](https://hub.mender.io/t/ls1021a-custom-board-mender-integration/4352/5 "2021-12-03T13:14:19Z")

</div>

@kele6ra et-al

I also verified with sdcard first, so, supported.

Sorry 'bout that. Missed these files during server re-org. Should be OK now. Let me know if access issues.

I have moved on, busy, so don’t expect support / questions answered apart from initial mender integration thread. Can always be bribed for paid support, other integrations.

Regards;  
Bill

---

<div class="post-metadata">

**Author:** ![kele6ra](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kele6ra/32/1375_2.png) [@kele6ra](https://hub.mender.io/u/kele6ra)\
**Post date:** [December 3, 2021, 1:33pm UTC](https://hub.mender.io/t/ls1021a-custom-board-mender-integration/4352/6 "2021-12-03T13:33:46Z")

</div>

Hello, thank you for help. I have access to files now. I think that I will make recipes for layerscape boards with OpenWRT to make mender more universal.

---

<div class="post-metadata">

**Author:** ![rossbcan](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rossbcan/32/1441_2.png) [@rossbcan](https://hub.mender.io/u/rossbcan)\
**Post date:** [December 3, 2021, 1:36pm UTC](https://hub.mender.io/t/ls1021a-custom-board-mender-integration/4352/7 "2021-12-03T13:36:29Z")

</div>

@mender: Please consider hosting these files locally for redundancy if my site is down.
