# NanoPi Neo2 Porting Mender to Openwrt

**URL:** <https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300>\
**Category:** General Discussions\
**Tags:** yocto, thud\
**Created:** [March 5, 2019, 7:35pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300 "2019-03-05T19:35:27Z")\
**Posts on this page:** 20\
**Page:** 1

<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:** [March 5, 2019, 7:35pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/1 "2019-03-05T19:35:27Z")

</div>

Hi;

I am in the process of porting Mender for the NanoPi Neo2 using openwrt. Yocto is not an option, but do have the go compiler available. I am starting with u-boot, since porting the Mender app seems straightforward.

I am following these guides:  
[https://docs.mender.io/1.7/devices](https://docs.mender.io/1.7/devices) (Yocto buildsystem)  
[https://mender.io/blog/porting-mender-to-a-non-yocto-build-system](https://mender.io/blog/porting-mender-to-a-non-yocto-build-system)

Thus far, I have accomplished this:

- added “config\_mender\_defines.h” to uboot/include
- added CONFIG\_BOOTCOUNT\_LIMIT=y, CONFIG\_BOOTCOUNT\_ENV=y, CONFIG\_ENV\_IS\_IN\_MMC=y to default uboot config for my board (nanopi\_neo2\_defconfig)

When compiling uboot, get this error:  
“include/config\_mender.h:59:5: error: #error CONFIG\_ENV\_OFFSET is not the same as MENDER\_UBOOT\_ENV\_STORAGE\_DEVICE\_OFFSET\_1. Either set it to the same value (check for example in the defconfig file), or make sure it is not defined at all…”

Looking into this, MENDER\_UBOOT\_ENV\_STORAGE\_DEVICE\_OFFSET\_1 appears to come from the uboot environment and I see no config value for it.

Question: what should I set CONFIG\_ENV\_OFFSET to, to get past this?, Or, is there something else I should be doing?

If this question is in wrong place, please move it and let me know.

Thanks;  
Bill

---

<div class="post-metadata">

**Author:** ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)\
**Post date:** [March 5, 2019, 7:54pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/2 "2019-03-05T19:54:31Z")

</div>

You can get some inspiration about values in : [https://github.com/mendersoftware/uboot-mender/commits/mender-rpi-2017.09](https://github.com/mendersoftware/uboot-mender/commits/mender-rpi-2017.09) (specifically commit [https://github.com/mendersoftware/uboot-mender/commit/5226dbc3870fd621d8a5fcd3463e0b16a88c7698](https://github.com/mendersoftware/uboot-mender/commit/5226dbc3870fd621d8a5fcd3463e0b16a88c7698) - please note that it’s extracted from generated yocto image). Basically mender using for storing u-boot env unpartitioned (raw) sdcard space with specific offset + also same for redundant env. I think you can copy values from mentioned commit but please adjust then partition layout (keep ~ 10M of free space at the beginning of SDcard).

---

<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:** [March 5, 2019, 8:34pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/3 "2019-03-05T20:34:49Z")

</div>

Thanks; That was incredibly helpful, in terms of defines I had not yet got to.

I still have the error above, here’s my updated config\_mender\_defines.h:

#ifndef HEADER\_CONFIG\_MENDER\_DEFINES\_H  
#define HEADER\_CONFIG\_MENDER\_DEFINES\_H

#include \<generated/autoconf.h\>

/\* Shell variables \*/  
#define MENDER\_BOOT\_PART\_NUMBER 1  
#define MENDER\_BOOT\_PART\_NUMBER\_HEX $MENDER\_BOOT\_PART\_NUMBER\_HEX  
#define MENDER\_ROOTFS\_PART\_A\_NUMBER 2  
#define MENDER\_ROOTFS\_PART\_A\_NUMBER\_HEX $MENDER\_ROOTFS\_PART\_A\_NUMBER\_HEX  
#define MENDER\_ROOTFS\_PART\_B\_NUMBER 3  
#define MENDER\_ROOTFS\_PART\_B\_NUMBER\_HEX $MENDER\_ROOTFS\_PART\_B\_NUMBER\_HEX  
#define MENDER\_UBOOT\_STORAGE\_INTERFACE “mmc”  
#define MENDER\_UBOOT\_STORAGE\_DEVICE 0

/\* BB variables. \*/  
#define MENDER\_STORAGE\_DEVICE\_BASE “/dev/mmcblk0”  
#define MENDER\_UBOOT\_ENV\_STORAGE\_DEVICE\_OFFSET\_1 0x400000  
#define MENDER\_UBOOT\_ENV\_STORAGE\_DEVICE\_OFFSET\_2 0x800000  
#define MENDER\_ROOTFS\_PART\_A\_NAME “/dev/mmcblk0p2”  
#define MENDER\_ROOTFS\_PART\_B\_NAME “/dev/mmcblk0p3”  
#define MENDER\_MTD\_UBI\_DEVICE\_NAME “”

/\* For sanity checks. _/  
/_ #define MENDER\_BOOTENV\_SIZE ${BOOTENV\_SIZE} \*/  
#define MENDER\_BOOTENV\_SIZE CONFIG\_ENV\_SIZE

#define MENDER\_BOOT\_KERNEL\_TYPE “bootm”  
#define MENDER\_KERNEL\_NAME “uImage”  
#define MENDER\_DTB\_NAME “dtb”  
#define MENDER\_UBOOT\_PRE\_SETUP\_COMMANDS “$MENDER\_UBOOT\_PRE\_SETUP\_COMMANDS”  
#define MENDER\_UBOOT\_POST\_SETUP\_COMMANDS “$MENDER\_UBOOT\_POST\_SETUP\_COMMANDS”

#endif /\* HEADER\_CONFIG\_MENDER\_DEFINES\_H \*/

do I need the defines defined in terms of “$MENDER\_\*”?

Thanks;  
Bill

---

<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:** [March 5, 2019, 8:46pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/4 "2019-03-05T20:46:39Z")

</div>

> [@rossbcan](#):
>
> CONFIG\_ENV\_OFFSET

set CONFIG\_ENV\_OFFSET = 0x400000 (same as MENDER\_UBOOT\_ENV\_STORAGE\_DEVICE\_OFFSET\_1)  
U-boot compiled OK, now have this error, which means I have to do my math…

start=$(aarch64-openwrt-linux-gnu-nm u-boot | grep \_\_rel\_dyn\_start | cut -f 1 -d ’ '); end=$(aarch64-openwrt-linux-gnu-nm u-boot | grep \_\_rel\_dyn\_end | cut -f 1 -d ’ '); tools/relocate-rela u-boot-nodtb.bin 0x4a000000 $start $end  
u-boot-nodtb.bin exceeds file size limit:  
limit: 516096 bytes  
actual: 522544 bytes  
excess: 6448 bytes

---

<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:** [March 5, 2019, 8:50pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/5 "2019-03-05T20:50:48Z")

</div>

> [@rossbcan](#):
>
> u-boot-nodtb.bin exceeds file size limit:

apparently, u-boot on arm64 has a bloat issue:  
[http://u-boot.10912.n7.nabble.com/PATCH-00-11-sunxi-arm64-binary-size-fixes-td315480.html](http://u-boot.10912.n7.nabble.com/PATCH-00-11-sunxi-arm64-binary-size-fixes-td315480.html)

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [March 5, 2019, 9:22pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/6 "2019-03-05T21:22:26Z")

</div>

We do have patches for sunxi boards in Yocto,

> **[mendersoftware/meta-mender-community](https://github.com/mendersoftware/meta-mender-community/tree/sumo/meta-mender-sunxi/recipes-bsp/u-boot/files)**
>
> Community supported integration layers for Mender on various boards - mendersoftware/meta-mender-community

Some inspiration hopefully

---

<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:** [March 5, 2019, 10:04pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/7 "2019-03-05T22:04:01Z")

</div>

> [@rossbcan](#):
>
> 400000

You guys have been incredibly helpful, THANKS!

Still dealing with this:  
start=$(aarch64-openwrt-linux-gnu-nm u-boot | grep \_\_rel\_dyn\_start | cut -f 1 -d ’ '); end=$(aarch64-openwrt-linux-gnu-nm u-boot | grep \_\_rel\_dyn\_end | cut -f 1 -d ’ '); tools/relocate-rela u-boot-nodtb.bin 0x4a000000 $start $end  
u-boot-nodtb.bin exceeds file size limit:  
limit: 516096 bytes  
actual: 521000 bytes  
excess: 4904 bytes  
make[3]: \*\*\* [u-boot-nodtb.bin] Error 1

but, thanks to your help, I am days ahead

---

<div class="post-metadata">

**Author:** ![mrsch](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mrsch/32/145_2.png) [@mrsch](https://hub.mender.io/u/mrsch)\
**Post date:** [March 6, 2019, 7:31am UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/8 "2019-03-06T07:31:11Z")

</div>

I’m trying to integrate mender for the Nanopi Neo Plus 2 right now and have the same problem with the u-boot size.  
I found the patch that fixed the size issue for u-boot 2018.01, see: [http://u-boot.10912.n7.nabble.com/PATCH-00-11-sunxi-arm64-binary-size-fixes-td315480.html](http://u-boot.10912.n7.nabble.com/PATCH-00-11-sunxi-arm64-binary-size-fixes-td315480.html)

The commit was later reverted (2018.05): [https://github.com/u-boot/u-boot/commit/d14db11d76e154a03e3fbaedb2fe4f13da7bb65f#diff-e249c6d66723fe56e388892f0fa8e482](https://github.com/u-boot/u-boot/commit/d14db11d76e154a03e3fbaedb2fe4f13da7bb65f#diff-e249c6d66723fe56e388892f0fa8e482)

So you can try to use u-boot 2018.03

---

<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:** [March 7, 2019, 5:02pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/9 "2019-03-07T17:02:07Z")

</div>

I’m sticking to u-boot 2018-11 (current openwrt trunk) and had to refresh the Mender patches:  
[root@localhost trunk]# ls Custom/package/boot/uboot-sunxi/files/\*.patch  
Custom/package/boot/uboot-sunxi/files/0001-env-Kconfig-remove-defaults-for-SUNXI.patch  
Custom/package/boot/uboot-sunxi/files/0002-configs-sunxi-add-Mender-required-options.patch  
Custom/package/boot/uboot-sunxi/files/0002-Generic-boot-code-for-Mender.patch  
Custom/package/boot/uboot-sunxi/files/0003-Integration-of-Mender-boot-code-into-U-Boot.patch

I got around the u-boot size issue by un-reverting some of the (feature removal) patches in mrsch’s link above.

now, I am stuck at many gpio\* link failures, for example:  
aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `sunxi_mmc_getcd_legacy': /home/rossb/OpenWrt/trunk/build_dir/target-aarch64_cortex-a53_glibc/u-boot-nanopi_neo2/u-boot-2018.11/drivers/mmc/sunxi_mmc.c:478: undefined reference to`gpio\_get\_value’

@mrsch: what is your build system?

any insight?  
Thanks;  
Bill

---

<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:** [March 7, 2019, 5:26pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/10 "2019-03-07T17:26:26Z")

</div>

Had a discussion with my employer. They are willing to place my openwrt changes in public domain. Are you interested in hosting this and maintaining once done?

---

<div class="post-metadata">

**Author:** ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)\
**Post date:** [March 7, 2019, 9:47pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/11 "2019-03-07T21:47:19Z")

</div>

@rossbcan did you try to build u-boot without mender patches first? It looks like that there are some missing symbols which should be fixable. I’ll check tomorrow and get back to you. Thanks.

---

<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:** [March 7, 2019, 9:51pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/12 "2019-03-07T21:51:50Z")

</div>

> [@rossbcan](#):
>
> gpio\_get\_value

Yes, It builds correctly without patches. Currently pursuing whether CONFIG\_DM\_MMC should be set  
Here’s the errors (legacy is what make me suspect DM issues):  
aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `sunxi_mmc_getcd_legacy': /home/rossb/OpenWrt/trunk/build_dir/target-aarch64_cortex-a53_glibc/u-boot-nanopi_neo2/u-boot-2018.11/drivers/mmc/sunxi_mmc.c:478: undefined reference to `gpio\_get\_value’  
aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `mmc_resource_init': /home/rossb/OpenWrt/trunk/build_dir/target-aarch64_cortex-a53_glibc/u-boot-nanopi_neo2/u-boot-2018.11/drivers/mmc/sunxi_mmc.c:87: undefined reference to `gpio\_request’  
aarch64-openwrt-linux-gnu-ld.bfd: /home/rossb/OpenWrt/trunk/build\_dir/target-aarch64\_cortex-a53\_glibc/u-boot-nanopi\_neo2/u-boot-2018.11/drivers/mmc/sunxi\_mmc.c:90: undefined reference to `gpio_direction_input' aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `ns16550\_serial\_setbrg’:  
/home/rossb/OpenWrt/trunk/build\_dir/target-aarch64\_cortex-a53\_glibc/u-boot-nanopi\_neo2/u-boot-2018.11/drivers/serial/ns16550.c:326: undefined reference to `dev_get_priv' aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `ns16550\_serial\_pending’:  
/home/rossb/OpenWrt/trunk/build\_dir/target-aarch64\_cortex-a53\_glibc/u-boot-nanopi\_neo2/u-boot-2018.11/drivers/serial/ns16550.c:306: undefined reference to `dev_get_priv' aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `ns16550\_serial\_putc’:  
/home/rossb/OpenWrt/trunk/build\_dir/target-aarch64\_cortex-a53\_glibc/u-boot-nanopi\_neo2/u-boot-2018.11/drivers/serial/ns16550.c:286: undefined reference to `dev_get_priv' aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `ns16550\_serial\_getc’:  
/home/rossb/OpenWrt/trunk/build\_dir/target-aarch64\_cortex-a53\_glibc/u-boot-nanopi\_neo2/u-boot-2018.11/drivers/serial/ns16550.c:316: undefined reference to `dev_get_priv' aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `ns16550\_serial\_probe’:  
/home/rossb/OpenWrt/trunk/build\_dir/target-aarch64\_cortex-a53\_glibc/u-boot-nanopi\_neo2/u-boot-2018.11/drivers/serial/ns16550.c:339: undefined reference to `dev_get_priv' aarch64-openwrt-linux-gnu-ld.bfd: /home/rossb/OpenWrt/trunk/build_dir/target-aarch64_cortex-a53_glibc/u-boot-nanopi_neo2/u-boot-2018.11/drivers/serial/ns16550.c:347: undefined reference to `dev\_get\_platdata’  
aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `sunxi_gpio_set_value': /home/rossb/OpenWrt/trunk/build_dir/target-aarch64_cortex-a53_glibc/u-boot-nanopi_neo2/u-boot-2018.11/drivers/gpio/sunxi_gpio.c:195: undefined reference to `dev\_get\_platdata’  
aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `sunxi_gpio_get_value': /home/rossb/OpenWrt/trunk/build_dir/target-aarch64_cortex-a53_glibc/u-boot-nanopi_neo2/u-boot-2018.11/drivers/gpio/sunxi_gpio.c:182: undefined reference to `dev\_get\_platdata’  
aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `sunxi_gpio_get_function': /home/rossb/OpenWrt/trunk/build_dir/target-aarch64_cortex-a53_glibc/u-boot-nanopi_neo2/u-boot-2018.11/drivers/gpio/sunxi_gpio.c:204: undefined reference to `dev\_get\_platdata’  
aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `sunxi_gpio_direction_output': /home/rossb/OpenWrt/trunk/build_dir/target-aarch64_cortex-a53_glibc/u-boot-nanopi_neo2/u-boot-2018.11/drivers/gpio/sunxi_gpio.c:171: undefined reference to `dev\_get\_platdata’  
aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o:/home/rossb/OpenWrt/trunk/build\_dir/target-aarch64\_cortex-a53\_glibc/u-boot-nanopi\_neo2/u-boot-2018.11/drivers/gpio/sunxi\_gpio.c:161: more undefined references to `dev_get_platdata' follow aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `gpio\_sunxi\_probe’:  
/home/rossb/OpenWrt/trunk/build\_dir/target-aarch64\_cortex-a53\_glibc/u-boot-nanopi\_neo2/u-boot-2018.11/drivers/gpio/sunxi\_gpio.c:264: undefined reference to `dev_get_uclass_priv' aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `gpio\_sunxi\_bind’:  
/home/rossb/OpenWrt/trunk/build\_dir/target-aarch64\_cortex-a53\_glibc/u-boot-nanopi\_neo2/u-boot-2018.11/drivers/gpio/sunxi\_gpio.c:287: undefined reference to `dev_get_driver_data' aarch64-openwrt-linux-gnu-ld.bfd: /home/rossb/OpenWrt/trunk/build_dir/target-aarch64_cortex-a53_glibc/u-boot-nanopi_neo2/u-boot-2018.11/drivers/gpio/sunxi_gpio.c:296: undefined reference to `devfdt\_get\_addr’  
aarch64-openwrt-linux-gnu-ld.bfd: /home/rossb/OpenWrt/trunk/build\_dir/target-aarch64\_cortex-a53\_glibc/u-boot-nanopi\_neo2/u-boot-2018.11/drivers/gpio/sunxi\_gpio.c:308: undefined reference to `device_bind' aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `sunxi\_gpio\_xlate’:  
/home/rossb/OpenWrt/trunk/build\_dir/target-aarch64\_cortex-a53\_glibc/u-boot-nanopi\_neo2/u-boot-2018.11/drivers/gpio/sunxi\_gpio.c:221: undefined reference to `device_get_child' aarch64-openwrt-linux-gnu-ld.bfd: drivers/built-in.o: in function `sunxi\_name\_to\_gpio’:  
/home/rossb/OpenWrt/trunk/build\_dir/target-aarch64\_cortex-a53\_glibc/u-boot-nanopi\_neo2/u-boot-2018.11/drivers/gpio/sunxi\_gpio.c:154: undefined reference to `gpio\_lookup\_name’

---

<div class="post-metadata">

**Author:** ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)\
**Post date:** [March 7, 2019, 10:27pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/13 "2019-03-07T22:27:29Z")

</div>

I’m bit confused now. Without mender patches it builds or not (in previous post it still shows some issues)? Because mender didn’t add anything to sunxi mmc stuff. Do you use nanopi\_neo2\_defconfig and which toolchain version? Thanks.

---

<div class="post-metadata">

**Author:** ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)\
**Post date:** [March 8, 2019, 7:32am UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/14 "2019-03-08T07:32:41Z")

</div>

@rossbcan can you please share updated patches. Thanks.

---

<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:** [March 8, 2019, 11:05am UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/15 "2019-03-08T11:05:29Z")

</div>

Hi Marek;

As requested…  
Instructions, config changes, config\_mender\_defines.h, patches:  
[https://www.rossco.org/Downloads/OpenWrt/Mender\_U-boot.tar.gz](https://www.rossco.org/Downloads/OpenWrt/Mender_U-boot.tar.gz)

Questions answered:

- Using nanopi\_neo2\_defconfig with additions defined in ReadMe.rtf (in tar.gz, above)
- Toolchain: toolchain-aarch64\_cortex-a53\_gcc-7.4.0\_glibc
- Target: target-aarch64\_cortex-a53\_glibc/u-boot-nanopi\_neo2/u-boot-2018.11
- Build or not: Without Mender patches, (with and without defconfig changes) builds OK. With Mender patches, two issues. (a) size, stripped some features (extra defconfig, ReadMe.rtf), (b) once past size issue, gpio\* related link errors as above.

Caveat: apply patches after regular u-boot patches.

Thanks & Regards;  
Bill

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [March 8, 2019, 11:55am UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/16 "2019-03-08T11:55:38Z")

</div>

Had a quick look at your patches, this is a bit strange

```auto
/* Shell variables */
#define MENDER_BOOT_PART_NUMBER 1
#define MENDER_BOOT_PART_NUMBER_HEX $MENDER_BOOT_PART_NUMBER_HEX
#define MENDER_ROOTFS_PART_A_NUMBER 2
#define MENDER_ROOTFS_PART_A_NUMBER_HEX $MENDER_ROOTFS_PART_A_NUMBER_HEX
#define MENDER_ROOTFS_PART_B_NUMBER 3
#define MENDER_ROOTFS_PART_B_NUMBER_HEX $MENDER_ROOTFS_PART_B_NUMBER_HEX
#define MENDER_UBOOT_STORAGE_INTERFACE "mmc"
#define MENDER_UBOOT_STORAGE_DEVICE 0

```

The `MENDER_ROOTFS_PART_A/B_NUMBER_HEX` should be assigned a number, or is `$MENDER_ROOTFS_PART_A_NUMBER_HEX` something specific to OpenWRT, meaning that they will resolved to something somehow?

Same applies to the `MENDER_UBOOT_PRE/POST_SETUP_COMMANDS` commands.

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [March 8, 2019, 11:58am UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/17 "2019-03-08T11:58:01Z")

</div>

Also in `0001-env-Kconfig-remove-defaults-for-SUNXI.patch` you are missing this change,

> <https://github.com/mendersoftware/meta-mender-community/blob/thud/meta-mender-sunxi/recipes-bsp/u-boot/files/0002-env-Kconfig-remove-defaults-for-SUNXI.patch#L31>

---

<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:** [March 8, 2019, 12:39pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/18 "2019-03-08T12:39:44Z")

</div>

> [@mirzak](#):
>
> $MENDER\_

Thanks mirzak;

The `$MENDER_` defines came from Mender and are not part of openwrt. I note from the RPi example ([add config\_mender\_defines.h · mendersoftware/uboot-mender@5226dbc · GitHub](https://github.com/mendersoftware/uboot-mender/commit/5226dbc3870fd621d8a5fcd3463e0b16a88c7698)) that \*\_HEX (also from Mender) are not defined. Perhaps I should remove all of them?

I have updated the tarfile (config\_mender\_defines.h, 0001-env-Kconfig-remove-defaults-for-SUNXI.patch), cleaned and rebuilt.

Same gpio\*, dev\* link errors as shown above

Regards;  
Bill

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [March 8, 2019, 12:42pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/19 "2019-03-08T12:42:06Z")

</div>

This is a better reference and is on a “closer” U-boot version,

> <https://github.com/mendersoftware/uboot-mender/commit/89d8b278e084b1daa81d783077d3e3c47695b31b>

So keep them.

---

<div class="post-metadata">

**Author:** ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)\
**Post date:** [March 8, 2019, 1:18pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/20 "2019-03-08T13:18:14Z")

</div>

@rossbcan I have refreshed patches and build fine (I still get issue with max size but you should have workaround for that). Psl test attached [patches](https://www.dropbox.com/s/efosth35fywoajz/test_mbox.tar.gz?dl=0)

[Next page](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300.md?page=2)
