# 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:** 3

<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 12, 2019, 12:32pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/41 "2019-03-12T12:32:46Z")

</div>

Hm, still works out-of-tree.

Can you also provide the `.config` file that is generated in OpenWRT.

---

<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 12, 2019, 12:50pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/42 "2019-03-12T12:50:26Z")

</div>

[https://www.rossco.org/Downloads/OpenWrt/u-boot\_config.txt](https://www.rossco.org/Downloads/OpenWrt/u-boot_config.txt)

---

<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 12, 2019, 12:56pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/43 "2019-03-12T12:56:12Z")

</div>

Yepp, definitely a diff. Unknown why though.

```auto
--- .config	2019-03-12 13:53:28.111224166 +0100
+++ openwrt-config	2019-03-12 13:53:24.551210606 +0100
@@ -147,7 +147,8 @@
 CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
 # CONFIG_SPL_DRIVERS_MISC_SUPPORT is not set
-CONFIG_ENV_SIZE=0x4000
+CONFIG_ENV_SIZE=0x20000
+CONFIG_ENV_OFFSET=0x88000
 CONFIG_SPL_SYS_MALLOC_F_LEN=0x400
 CONFIG_SPL=y
 CONFIG_IDENT_STRING=" Allwinner Technology"
@@ -709,16 +710,19 @@
 # Environment
 #
 # CONFIG_ENV_IS_IN_EEPROM is not set
-# CONFIG_ENV_IS_IN_FAT is not set
+CONFIG_ENV_IS_IN_FAT=y
 # CONFIG_ENV_IS_IN_EXT4 is not set
 # CONFIG_ENV_IS_IN_FLASH is not set
-CONFIG_ENV_IS_IN_MMC=y
+# CONFIG_ENV_IS_IN_MMC is not set
 # CONFIG_ENV_IS_IN_NAND is not set
 # CONFIG_ENV_IS_IN_NVRAM is not set
 # CONFIG_ENV_IS_IN_ONENAND is not set
 # CONFIG_ENV_IS_IN_REMOTE is not set
 # CONFIG_ENV_IS_IN_SPI_FLASH is not set
 # CONFIG_ENV_IS_IN_UBI is not set
+CONFIG_ENV_FAT_INTERFACE="mmc"
+CONFIG_ENV_FAT_DEVICE_AND_PART="0:auto"
+CONFIG_ENV_FAT_FILE="uboot.env"
 # CONFIG_USE_DEFAULT_ENV_FILE is not set
 # CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG is not set
 CONFIG_NET=y

```

---

<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 12, 2019, 1:00pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/44 "2019-03-12T13:00:55Z")

</div>

Noticed one thing, to fully re-produce your environment I need your `config_mender_defines.h` file,

which is copied in

```
  cp ./files/config_mender_defines.h /home/rossb/OpenWrt/trunk/build_dir/target-aarch64_cortex-a53_glibc/u-boot-nanopi_neo2/u-boot-2018.11/include
```

---

<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 12, 2019, 1:03pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/45 "2019-03-12T13:03:36Z")

</div>

> [@mirzak](#):
>
> CONFIG\_ENV\_SIZE

crap, I sent you .config from standard openwrt build, after I reverted, standby

---

<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 12, 2019, 1:09pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/46 "2019-03-12T13:09:03Z")

</div>

Ok, config updated (bootlin toolchain), same 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:** [March 12, 2019, 1:11pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/47 "2019-03-12T13:11:52Z")

</div>

[https://www.rossco.org/Downloads/OpenWrt/config\_mender\_defines.h](https://www.rossco.org/Downloads/OpenWrt/config_mender_defines.h)

---

<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 12, 2019, 1:15pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/48 "2019-03-12T13:15:11Z")

</div>

I was able to re-produce your error now.

And now I see the problem. You need to drop this line from `config_mender_defines.h`,

```
 #include <generated/autoconf.h>

```

Edit: To further explain, above file contains the U-boot configuration and by adding it here it was also included in the SPL and it enables `CONFIG_DM` among other things which does not build during SPL build.

---

<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 12, 2019, 1:42pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/49 "2019-03-12T13:42:37Z")

</div>

hm, that’s how I specifed env\_size (from .config)  
#define MENDER\_BOOTENV\_SIZE CONFIG\_ENV\_SIZE

and, in my Makefile:  
echo CONFIG\_ENV\_OFFSET=0x400000 \>\> (PKG\_BUILD\_DIR)/configs/nanopi\_neo2\_defconfig echo CONFIG\_ENV\_SIZE=0x4000 \>\> (PKG\_BUILD\_DIR)/configs/nanopi\_neo2\_defconfig  
…neither of which appear in .config

Removed #include \<generated/autoconf.h\>, added #define MENDER\_BOOTENV\_SIZE 0x4000

Result: SUCCESS for both toolchains

still have to sort out impact of missing CONFIG\_ENV\_OFFSET=0x400000, cleanup, re-org flash layout, port Mender app, test, test, test

Thank you very much! As promised, I will provide everything required for Mender / openwrt integration for you to freely publish and maintain, also with blessings and thanks of my employer. We will, of course, add credits to ourselves.

Regards;  
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 12, 2019, 2:15pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/50 "2019-03-12T14:15:28Z")

</div>

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

CONFIG\_ENV\_OFFSET is undefined and not used. Replaced by:  
#define MENDER\_UBOOT\_ENV\_STORAGE\_DEVICE\_OFFSET\_1 0x400000  
and, according to mender patch if defined must match above, else be undefined

---

<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 12, 2019, 2:20pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/51 "2019-03-12T14:20:58Z")

</div>

Yes, best is to not have it defined outside of the Mender files, and `config_mender_defines.h` && `config_mender.h` should take care of it

---

<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 13, 2019, 7:28am UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/52 "2019-03-13T07:28:24Z")

</div>

> [@rossbcan](#):
>
> Thank you very much! As promised, I will provide everything required for Mender / openwrt integration for you to freely publish and maintain, also with blessings and thanks of my employer. We will, of course, add credits to ourselves.

Makes sense and we will happily look in to this once you have something to share.

Can already now hint that we are looking for community maintainers 😉

---

<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 15, 2019, 2:17pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/53 "2019-03-15T14:17:30Z")

</div>

Status: Script to go from openwrt image to mender compliant image complete, boots with mender u-boot patches.  
Creating openwrt mender app package and host app

---

<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 15, 2019, 3:00pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/54 "2019-03-15T15:00:22Z")

</div>

Awesome, thanks for the update

---

<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 18, 2019, 8:06pm UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/55 "2019-03-18T20:06:15Z")

</div>

Hi;  
Need your feedback re descriptions (since its your product) - alter to taste

```auto
define Package/$(PKG_NAME)/description
  Mender client is an OTA updater for linux systems.
  Features include redundant boot, failsafe updates, rollback.
  Mender is a client normally connected to an update server for updates.
  Mender is capable of standalone updates.
endef

# mender configuration
menu "Configuration"
	depends on PACKAGE_mender
	config MENDER_SERVER_URL
		string "ServerURL"
		default ""
		help
			Internet URL of Mender update server.
	config MENDER_CERT_LOCATION
		string "ServerCertificate"
		default "/etc/ssl/certs"
		help
			Directory containing Mender SSL certificate.
	config MENDER_CERTIFICATE
		string "Certificate"
		default ""
		help
			File name of Mender client auth SSL certificate.
        config MENDER_KEY
                string "Key"
                default ""
                help
                    	File name of Mender client auth SSL key.
	config MENDER_ROOTFS_PART_A
		string "RootfsPartA"
		default "/dev/mmcblk0p2"
		help
			Device node of First rootfs partition.
	config MENDER_ROOTFS_PART_B
		string "RootfsPartB"
		default "/dev/mmcblk0p3"
		help
			Device node of First rootfs partition.
	config MENDER_UPDATE_POLL_INTERVAL_SECONDS
		int "UpdatePollIntervalSeconds"
		default 86400
		help
			How often to poll mender server for code updates. Default daily (86400 seconds).
	config MENDER_INVENTORY_POLL_INTERVAL_SECONDS
		int "InventoryPollIntervalSeconds"
		default 86400
		help
			How often to poll mender server	for inventory updates. Default daily (86400 seconds).
	config MENDER_RETRY_POLL_INTERVAL_SECONDS
		int "RetryPollIntervalSeconds"
		default 30
		help
			How often to retry polling mender server when connection failure. Default 30 seconds.
endmenu

```

@MarekBelisko - added markdown

---

<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 19, 2019, 7:40am UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/56 "2019-03-19T07:40:26Z")

</div>

Updated (see below).

It is unclear to me why you need `MENDER_CERT_LOCATION` and `MENDER_KEY` so I have dropped them below.

It should be enough with `MENDER_CERTIFICATE` which is only needed if self-signed certs are used. Otherwise it is enough to install the “ca-certificates” package (might be named differently in OpenWRT)

```auto
define Package/$(PKG_NAME)/description
  Mender is an open source, Aparche 2.0 licensed
  over-the-air (OTA) software updater for embedded
  Linux devices. Mender comprises a client running
  at the embedded device, as well as a server that
  manages deployments across many devices.

  More information at https://docs.mender.io
endef

# mender configuration
menu "Configuration"
    depends on PACKAGE_mender
    config MENDER_SERVER_URL
        string "ServerURL"
        default ""
        help
             The server URL which is used as the basis
             for API requests. This should be set to the
             server that runs the Mender server services.
             It should include the whole URL, including
             https:// and a trailing slash
    config MENDER_CERTIFICATE
        string "Certificate"
        default ""
        help
            The location of the public certificate of
            the server, if any. If this certificate is
            missing, or the one presented by the server
            doesn't match the one specified in this
            setting, the server certificate will be
            validated using standard certificate trust
            chains.
    config MENDER_ROOTFS_PART_A
        string "RootfsPartA"
        default "/dev/mmcblk0p2"
        help
            The Linux device that contains root filesystem A.
    config MENDER_ROOTFS_PART_B
        string "RootfsPartB"
        default "/dev/mmcblk0p3"
        help
            The Linux device that contains root filesystem B.
    config MENDER_UPDATE_POLL_INTERVAL_SECONDS
        int "UpdatePollIntervalSeconds"
        default 86400
        help
            An integer that sets the number of seconds
            to wait between each check for a new update.
            Note that the client may occasionally check
            more often if there has been recent activity
            on the device.

            Default daily (86400 seconds).
    config MENDER_INVENTORY_POLL_INTERVAL_SECONDS
        int "InventoryPollIntervalSeconds"
        default 86400
        help
            An integer that sets the number of seconds
            to wait between each inventory update. Note
            that the client may occasionally post its
            inventory more often if there has been recent
            activity on the device.

            Default daily (86400 seconds).
    config MENDER_RETRY_POLL_INTERVAL_SECONDS
        int "RetryPollIntervalSeconds"
        default 30
        help
            An integer that sets the number of seconds
            to wait between each attempt to download an
            update file. Note that the client may attempt
            more often initially to enable rapid upgrades,
            but will gradually fall back to this value if
            the server is busy

            Default 30 seconds
endmenu

```

---

<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 19, 2019, 8:48am UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/57 "2019-03-19T08:48:28Z")

</div>

Thanks;

Just to be sure; MENDER\_CERT\_LOCATION and MENDER\_KEY were used to populate mender.conf values (example link below).

> <https://github.com/mendersoftware/meta-mender/blob/210bb9ea0c9e722d7c021b6978b5660e4e9b2a65/meta-mender-core/recipes-mender/mender/files/mender.conf>

so (correct me if wrong)

- MENDER\_CERTIFICATE is the full path and file name of the update server’s public key if self-signed keys are used, else, “”. This corresponds to the “Certificate” field of mender.conf (above link)
- MENDER\_CERT\_LOCATION. This corresponds to the “ServerCertificate” field of mender.conf and is unused, should always be “”. Is this a placeholder for something?
- MENDER\_KEY is unused. Suspect it is part of a placeholder mechanism for client to auth to server, or signing requests, not implemented? As pertains to mender.conf (link above), the “Key” field is unused and always an empty string. This implies that no mechanism is in place for clients to auth to mender update server.
- In terms of the above config variables, mender.conf looks like this:

```auto
{
  "ClientProtocol": "http",
  "HttpsClient": {
    "Certificate": "MENDER_CERTIFICATE",
    "Key": ""
  },
  "RootfsPartA": "MENDER_ROOTFS_PART_A",
  "RootfsPartB": "MENDER_ROOTFS_PART_B",
  "UpdatePollIntervalSeconds": MENDER_UPDATE_POLL_INTERVAL_SECONDS,
  "InventoryPollIntervalSeconds": MENDER_INVENTORY_POLL_INTERVAL_SECONDS,
  "RetryPollIntervalSeconds": MENDER_RETRY_POLL_INTERVAL_SECONDS,
  "ServerURL": "MENDER_SERVER_URL",
  "ServerCertificate": ""
}

```

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 19, 2019, 8:53am UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/58 "2019-03-19T08:53:16Z")

</div>

Just FYI, there is a section in our docs describing all the configuration options

[https://docs.mender.io/1.7/client-configuration/configuration-file/configuration-options](https://docs.mender.io/1.7/client-configuration/configuration-file/configuration-options)

It is actually unclear to me what these are used for:

> “ClientProtocol”: “http”,  
> “HttpsClient”: {  
> “Certificate”: “”,  
> “Key”: “”  
> },

@kacf, do you know the specifics for this?

> - MENDER\_CERT\_LOCATION. This corresponds to the “ServerCertificate” field of mender.conf and is unused, should always be “”. Is this a placeholder for something?

From the docs

“The location of the public certificate of the server, if any. If this certificate is missing, or the one presented by the server doesn’t match the one specified in this setting, the server certificate will be validated using standard certificate trust chains.”

And it is only used if you are using self-signed certificates. I would also only expect this value configuration option to be necessary.

---

<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:** [March 19, 2019, 9:22am UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/59 "2019-03-19T09:22:22Z")

</div>

> [@mirzak](#):
>
> @kacf, do you know the specifics for this?
> 
> > - MENDER\_CERT\_LOCATION. This corresponds to the “ServerCertificate” field of mender.conf and is unused, should always be “”. Is this a placeholder for something?
> 
> From the docs
> 
> “The location of the public certificate of the server, if any. If this certificate is missing, or the one presented by the server doesn’t match the one specified in this setting, the server certificate will be validated using standard certificate trust chains.”

I think the idea is that you should put `server.crt` in `SRC_URI` and leave that variable alone. But it is indeed phrased quite poorly.

---

<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 19, 2019, 9:31am UTC](https://hub.mender.io/t/nanopi-neo2-porting-mender-to-openwrt/300/60 "2019-03-19T09:31:22Z")

</div>

so, there is confusion regarding whether the mender server’s public key (if self-signed) should be in the “Certificate” or “ServerCertificate” field of mender.conf? Which is it?

Here’s mender.conf, generated by openwrt build (assumes using standard trust chains, letsencrypt certs in our case):  
{  
“ClientProtocol”: “http”,  
“HttpsClient”: {  
“Certificate”: “”,  
“Key”: “”  
},  
“RootfsPartA”: “/dev/mmcblk0p2”,  
“RootfsPartB”: “/dev/mmcblk0p3”,  
“UpdatePollIntervalSeconds”: 86400,  
“InventoryPollIntervalSeconds”: 86400,  
“RetryPollIntervalSeconds”: 30,  
“ServerURL”: “[https://mender.example.com/](https://mender.example.com/)”,  
“ServerCertificate”: “”  
}

Yes, this implies that I have successfully ported the mender app to openwrt:  
[rossb@localhost trunk]$ ls -la build\_dir/target-aarch64\_cortex-a53\_glibc/mender-1.7/ipkg-aarch64\_cortex-a53/mender/usr/bin  
total 6092  
drwxr-xr-x 2 rossb rossb 4096 Mar 19 05:15 .  
drwxr-xr-x 4 rossb rossb 4096 Mar 19 05:15 …  
-rwxr-xr-x 1 rossb rossb 6226584 Mar 19 05:15 mender

FYI and IMHO. Because golang is used for the mender app, it is bloated (6M+) by the statically included go libraries. This will be an impediment to mender usage on storage “challenged” devices. Suggestion: Create a C/C++ version of the mender app which can be linked to already existing standard libraries, reducing size, allowing deeper penetration into the embedded market. I’m sure you have heard this before.

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

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