xref: /OK3568_Linux_fs/buildroot/package/mender/readme.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun=== Notes on using Mender on Buildroot
2*4882a593Smuzhiyun======================================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunMender is an open source over-the-air (OTA) software updater for
5*4882a593Smuzhiyunembedded Linux devices. Mender comprises a client running at the
6*4882a593Smuzhiyunembedded device, as well as a server that manages deployments across
7*4882a593Smuzhiyunmany devices. There is also various tooling around the Mender project,
8*4882a593Smuzhiyunsuch as 'mender-artifact' which is used to create Mender Artifacts
9*4882a593Smuzhiyunthat are compatible with the Mender client and server.
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunMender aims to address this challenge with a robust and easy to use
12*4882a593Smuzhiyunupdater for embedded Linux devices, which is open source and available
13*4882a593Smuzhiyunto anyone.
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunRobustness is ensured with atomic image-based deployments using a dual
16*4882a593SmuzhiyunA/B rootfs partition layout. This makes it always possible to roll
17*4882a593Smuzhiyunback to a working state, even when losing power at any time during the
18*4882a593Smuzhiyunupdate process.
19*4882a593Smuzhiyun
20*4882a593SmuzhiyunThe official documentation is a good resource to get an in depth
21*4882a593Smuzhiyununderstanding of how Mender works:
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun    https://docs.mender.io
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunIn Buildroot the following packages are provided:
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun- BR2_PACKAGE_MENDER
28*4882a593Smuzhiyun    - This will install the client on target rootfs
29*4882a593Smuzhiyun- BR2_PACKAGE_HOST_MENDER_ARTIFACT
30*4882a593Smuzhiyun    - This will install the 'mender-artifact' tool in host rootfs.
31*4882a593Smuzhiyun
32*4882a593SmuzhiyunTo fully utilize atomic image-based deployments using the A/B update
33*4882a593Smuzhiyunstrategy, additional integration is required in the bootloader. This
34*4882a593Smuzhiyunintegration is board specific.
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunCurrently supported bootloaders are GRUB and U-boot, and for reference
37*4882a593Smuzhiyunintegrations please visit:
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun    https://github.com/mendersoftware/buildroot-mender
40*4882a593Smuzhiyun
41*4882a593SmuzhiyunDefault configurations files
42*4882a593Smuzhiyun----------------------------
43*4882a593Smuzhiyun
44*4882a593SmuzhiyunBuildroot comes with a default configuration and there a couple of
45*4882a593Smuzhiyunfiles that need your attention:
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun- /etc/mender/mender.conf
48*4882a593Smuzhiyun    - main configuration file for the Mender client
49*4882a593Smuzhiyun    - https://docs.mender.io/client-configuration/configuration-file/configuration-options
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun- /etc/mender/artifact_info
52*4882a593Smuzhiyun    - The name of the image or update that will be built. This is what the
53*4882a593Smuzhiyun      device will report that it is running, and different updates must have
54*4882a593Smuzhiyun      different names
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun- /var/lib/mender/device_type
57*4882a593Smuzhiyun    - A string that defines the type of device
58*4882a593Smuzhiyun
59*4882a593SmuzhiyunMender server configuration
60*4882a593Smuzhiyun---------------------------
61*4882a593Smuzhiyun
62*4882a593SmuzhiyunThe Mender server can be setup in different ways, and how you
63*4882a593Smuzhiyunconfigure the Mender client differs slightly depending on which server
64*4882a593Smuzhiyunenvironment is used.
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun- Mender demo environment
67*4882a593Smuzhiyun
68*4882a593SmuzhiyunThis is if you have followed the Getting started documentation where
69*4882a593Smuzhiyunyou launch a Mender server locally and to configure your environment
70*4882a593Smuzhiyunto connect to this local server you need to provide the IP address of
71*4882a593Smuzhiyunthe server on the local network.
72*4882a593Smuzhiyun
73*4882a593SmuzhiyunBy default the demo environment will connect to 'docker.mender.io' and
74*4882a593Smuzhiyun's3.docker.mender.io' and we need to make sure that these are resolved
75*4882a593Smuzhiyunto the local IP address of the running server by adding the following
76*4882a593Smuzhiyunentry to '/etc/hosts'
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun    <ip address of demo environment> docker.mender.io s3.docker.mender.io
79*4882a593Smuzhiyun
80*4882a593SmuzhiyunThis is required because the communication between client and server
81*4882a593Smuzhiyunis utilizing TLS and the provided demo server certificate (server.crt)
82*4882a593Smuzhiyunis only valid for 'docker.mender.io' and 's3.docker.mender.io'
83*4882a593Smuzhiyundomains.
84*4882a593Smuzhiyun
85*4882a593Smuzhiyun- Hosted Mender
86*4882a593Smuzhiyun
87*4882a593SmuzhiyunTo authenticate the Mender client with the Hosted Mender server you
88*4882a593Smuzhiyunneed a tenant token.
89*4882a593Smuzhiyun
90*4882a593SmuzhiyunTo get your tenant token:
91*4882a593Smuzhiyun
92*4882a593Smuzhiyun- log in to https://hosted.mender.io
93*4882a593Smuzhiyun- click your email at the top right and then “My organization”
94*4882a593Smuzhiyun- press the “COPY TO CLIPBOARD”
95*4882a593Smuzhiyun- assign content of clipboard to TenantToken
96*4882a593Smuzhiyun
97*4882a593SmuzhiyunExample mender.conf options for Hosted Mender:
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun    {
100*4882a593Smuzhiyun      ...
101*4882a593Smuzhiyun      "ServerURL": "https://hosted.mender.io",
102*4882a593Smuzhiyun      "TenantToken": "<paste tenant token here>"
103*4882a593Smuzhiyun      ...
104*4882a593Smuzhiyun    }
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun
107*4882a593SmuzhiyunCreating Mender Artifacts
108*4882a593Smuzhiyun-------------------------
109*4882a593Smuzhiyun
110*4882a593SmuzhiyunTo create Mender Artifacts based on Buildroot build output you must
111*4882a593Smuzhiyuninclude BR2_PACKAGE_HOST_MENDER_ARTIFACT in your configuration, and
112*4882a593Smuzhiyunthen you would typically create the Mender Artifact in a post image
113*4882a593Smuzhiyunscript (BR2_ROOTFS_POST_IMAGE_SCRIPT). Below is an example of such a
114*4882a593Smuzhiyunscript:
115*4882a593Smuzhiyun
116*4882a593Smuzhiyun    #!/bin/sh
117*4882a593Smuzhiyun
118*4882a593Smuzhiyun    set -e
119*4882a593Smuzhiyun    set -x
120*4882a593Smuzhiyun
121*4882a593Smuzhiyun    device_type=$(cat ${TARGET_DIR}/var/lib/mender/device_type | sed 's/[^=]*=//')
122*4882a593Smuzhiyun    artifact_name=$(cat ${TARGET_DIR}/etc/mender/artifact_info | sed 's/[^=]*=//')
123*4882a593Smuzhiyun
124*4882a593Smuzhiyun    if [ -z "${device_type}" ] || [ -z "${artifact_name}" ]; then
125*4882a593Smuzhiyun        echo "missing files required by Mender"
126*4882a593Smuzhiyun        exit 1
127*4882a593Smuzhiyun    fi
128*4882a593Smuzhiyun
129*4882a593Smuzhiyun    ${HOST_DIR}/usr/bin/mender-artifact write rootfs-image \
130*4882a593Smuzhiyun        --update ${BINARIES_DIR}/rootfs.ext4 \
131*4882a593Smuzhiyun        --output-path ${BINARIES_DIR}/${artifact_name}.mender \
132*4882a593Smuzhiyun        --artifact-name ${artifact_name} \
133*4882a593Smuzhiyun        --device-type ${device_type}
134*4882a593Smuzhiyun
135*4882a593SmuzhiyunAs you can see some properties are extracted from target rootfs, and
136*4882a593Smuzhiyunthis is because these values are used for compatibility checks,
137*4882a593Smuzhiyunmeaning that the information must be present in both rootfs and in
138*4882a593SmuzhiyunMender Artifact meta data.
139*4882a593Smuzhiyun
140*4882a593Smuzhiyun- device_type - must be an exact match between rootfs and Mender
141*4882a593Smuzhiyun                Artifact meta-data to apply update. You can set an
142*4882a593Smuzhiyun                array of devices here as well, e.g if your image is
143*4882a593Smuzhiyun                compatible with multiple hardware revisions
144*4882a593Smuzhiyun
145*4882a593Smuzhiyun- artifact_name - must be an exact match between rootfs and Mender
146*4882a593Smuzhiyun                  Artifact meta-data to apply update.
147*4882a593Smuzhiyun
148*4882a593SmuzhiyunConfiguring Mender with certificates
149*4882a593Smuzhiyun------------------------------------
150*4882a593Smuzhiyun
151*4882a593SmuzhiyunMender uses TLS to communicate with the management server, and if you
152*4882a593Smuzhiyunuse a CA-signed certificate on the server, you must include
153*4882a593SmuzhiyunBR2_PACKAGE_CA_CERTIFICATES in your configuration to authenticate TLS
154*4882a593Smuzhiyunconnections.
155