Part 1
요약·해설
Polling·manual mode, CE·Cloud/DTLS, Ethernet·Wi-Fi·802.15.4·OpenThread, uhu package와 rollout을 한 흐름으로 설명합니다.
UpdateHub-CE · Cloud/DTLS
CoAP/UDP · CoAPS/DTLS
MCUboot 1.0.0 → 2.0.0
Sign → Package → Publish → Reboot
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
51CB1AD81C8B41632EB083620AE70CD7C96490288030CA509407138527E3E290
.. zephyr:code-sample:: updatehub-fota
:name: UpdateHub embedded Firmware Over-The-Air (FOTA) update
:relevant-api: updatehub
Perform Firmware Over-The-Air (FOTA) updates using UpdateHub.
Overview
********
UpdateHub is an enterprise-grade solution which makes it simple to remotely
update all your embedded devices. It handles all aspects related to sending
Firmware Over-the-Air (FOTA) updates with maximum security and efficiency,
while you focus on adding value to your product. It is possible to read more
about at `docs.updatehub.io`_.
This sample shows how to use UpdateHub in both a polling and manual update
mode.
Polling mode runs automatically on a predefined period, probing the server
for updates and installing them without requiring user intervention.
Manual mode requires the user to call the server probe and then, if there is
an available update, also requires the user to decide if it is appropriate to
update now or later.
You can access the sample source code at
:zephyr_file:`samples/subsys/mgmt/updatehub/src/main.c`.
Caveats
*******
* The Zephyr port of ``UpdateHub`` was initially developed to run on a
:ref:`Freedom-K64F <frdm_k64f>` kit using the ethernet connectivity. The
application should build and run for other platforms with same connectivity.
* The sample provides overlay files to enable other technologies like WIFI,
802.15.4 or OpenThread. These technologies depends on
hardware resources and the correspondent overlay was designed to be generic
instead full optimized.
* It is important understand that some wireless technologies may require a
gateway or some sort of border router. It is out of scope provide such
configuration in details.
* The MCUboot bootloader is required for ``UpdateHub`` function properly.
Before chose a platform to test, make sure that SoC and board have support
to it. UpdateHub currently uses two slots to perform the upgrade. More
information about Device Firmware Upgrade subsystem and MCUboot can be found
in :ref:`mcuboot`.
* ``UpdateHub`` acts like a service on Zephyr. It is heavily dependent on
Zephyr sub-systems and it uses CoAP over UDP.
Building and Running
********************
The below steps describe how to build and run the ``UpdateHub`` sample in
Zephyr. Open a terminal ``terminal 1`` and navigate to your Zephyr project
directory. This allows to construct and run everything from a common place.
.. code-block:: console
ls
bootloader modules tools zephyr
Step 1: Build/Flash MCUboot
===========================
The MCUboot can be build following the instructions in the :ref:`mcuboot`
documentation page. Flash the resulting image file using west on
``terminal 1``.
.. zephyr-app-commands::
:zephyr-app: bootloader/mcuboot/boot/zephyr
:board: frdm_k64f
:build-dir: mcuboot-frdm_k64f
:goals: build flash
Step 2: Start the UpdateHub Server
==================================
Step 2.1: UpdateHub-CE (Community Edition)
------------------------------------------
The Zephyr sample application is configured by default to use the UpdateHub-CE
server edition. This version implies you need run your own server. The
UpdateHub-CE is distributed as a docker container and can be on your local
network or even installed on a service provider like Digital Ocean, Vultr etc.
To start using the UpdateHub-CE simple execute the docker command with the
following parameters on another terminal ``terminal 2``.
.. code-block:: console
docker run -it -p 8080:8080 -p 5683:5683/udp --rm
updatehub/updatehub-ce:latest
Step 2.2: UpdateHub Cloud
-------------------------
The UpdateHub Cloud is an enterprise-grade solution. It provides almost same
resources than UpdateHub-CE with the DTLS as main diferential. For more
details on how to use the UpdateHub Cloud please refer to the documentation on
`updatehub.io`_. The UpdateHub Cloud has the option to use CoAPS/DTLS or not.
If you want to use the CoAPS/DTLS, simply add the ``overlay-dtls.conf`` when
building the sample. You can use the provided certificate for test this
example or create your own. The below procedure instruct how create a new
certificate using openssl on a Linux machine on terminal ``terminal 2``.
.. code-block:: console
openssl genrsa -out privkey.pem 512
openssl req -new -x509 -key privkey.pem -out servercert.pem
The ``servercert`` and ``privkey`` files must be embedded in the application
by ``certificates.h`` file. The following procedure can be used to generated
the required ``der`` files:
.. code-block:: console
openssl x509 -in servercert.pem -outform DER -out servercert.der
openssl pkcs8 -topk8 -inform PEM -outform DER -nocrypt -in privkey.pem
-out privkey.der
The ``der`` files should be placed on the sample source at certificates
directory.
.. note::
When using UpdateHub Cloud server it is necessary update your own
``overlay-prj.conf`` with option :kconfig:option:`CONFIG_UPDATEHUB_CE` equal ``n``.
Step 3: Configure UpdateHub Sample
==================================
The updatehub have several Kconfig options that are necessary configure to
make it work or tune communication.
Set :kconfig:option:`CONFIG_UPDATEHUB_CE` select between UpdateHub edition. The ``y``
value will select UpdateHub-CE otherwise ``n`` selects UpdateHub Cloud.
Set :kconfig:option:`CONFIG_UPDATEHUB_SERVER` with your local IP address that runs the
UpdateHub-CE server edition. If your are using a service provider a DNS name
is a valid option too. This option is only valid when using UpdateHub-CE.
Set :kconfig:option:`CONFIG_UPDATEHUB_POLL_INTERVAL` with the polling period of your
preference, remembering that the limit is between 0 and 43200 minutes
(30 days). The default value is 1440 minutes (24h).
Set :kconfig:option:`CONFIG_UPDATEHUB_PRODUCT_UID` with your product ID. When using
UpdateHub-CE the valid is available at ``overlay-prj.conf.example`` file.
Step 4: Build UpdateHub App
===========================
In order to correctly build UpdateHub the overlay files must be use correctly.
More information about overlay files in :ref:`important-build-vars`.
.. note::
It is out of scope at this moment provide support for experimental
features. However, the configuration and use is similar to the start
point indicated on the experimental network interface.
Step 4.1: Build for Ethernet
----------------------------
The ethernet depends only from base configuration.
.. zephyr-app-commands::
:zephyr-app: zephyr/samples/subsys/mgmt/updatehub
:board: [ frdm_k64f | nucleo_f767zi ]
:build-dir: app
:gen-args: -DEXTRA_CONF_FILE=overlay-prj.conf
:goals: build
:compact:
Step 4.2: Build for WiFi
------------------------
For WiFi, it needs add ``overlay-wifi.conf``. Here a shield provides WiFi
connectivity using, for instance, arduino headers. See :ref:`module_esp_8266`
for details.
.. zephyr-app-commands::
:zephyr-app: zephyr/samples/subsys/mgmt/updatehub
:board: [ frdm_k64f | nrf52840dk/nrf52840 | nucleo_f767zi ]
:build-dir: app
:gen-args: -DEXTRA_CONF_FILE="overlay-wifi.conf;overlay-prj.conf"
:shield: esp_8266_arduino
:goals: build
:compact:
.. note::
The board disco_l475_iot1 is not supported. The es-WIFI driver currently
doesn't support UDP.
Step 4.3: Build for IEEE 802.15.4 [experimental]
------------------------------------------------
For IEEE 802.15.4 needs add ``overlay-802154.conf``. This requires two nodes:
one will be the host and the second one will be the device under test. The
validation needs a Linux kernel >= 4.9 with all 6loWPAN support. The start
point is try reproduce the Zephyr :zephyr:code-sample:`wpan-usb`. It is out of scope
at this moment provide support since it is experimental. The gateway was
tested with both native linux driver and ``atusb`` and with ``wpanusb`` sample.
.. zephyr-app-commands::
:zephyr-app: zephyr/samples/subsys/mgmt/updatehub
:board: nrf52840dk/nrf52840
:build-dir: app
:gen-args: -DEXTRA_CONF_FILE="overlay-802154.conf;overlay-prj.conf"
:goals: build
:compact:
.. zephyr-app-commands::
:zephyr-app: zephyr/samples/subsys/mgmt/updatehub
:board: [ frdm_k64f | nucleo_f767zi ]
:build-dir: app
:gen-args: -DEXTRA_CONF_FILE="overlay-802154.conf;overlay-prj.conf"
:shield: atmel_rf2xx_arduino
:goals: build
:compact:
Step 4.4: Build for OpenThread Network [experimental]
-----------------------------------------------------
The OpenThread requires the ``overlay-ot.conf``. It requires two nodes:
one will be the host NCP and the second one will be the device under test. The
validation needs a Linux kernel >= 4.9 with optional NAT-64 support. The
start point is try reproduce the `OpenThread Router`_. It is
out of scope at this moment provide support since it is experimental. The
gateway was tested using two boards with OpenThread 1.1.1 on NCP mode.
.. zephyr-app-commands::
:zephyr-app: zephyr/samples/subsys/mgmt/updatehub
:board: nrf52840dk/nrf52840
:build-dir: app
:gen-args: -DEXTRA_CONF_FILE="overlay-ot.conf;overlay-prj.conf"
:goals: build
:compact:
Step 5: Sign the app image
==========================
The app image is the application itself that will be on the board. This app
will connect to UpdateHub server and check for new images. The image will be
loaded on the board with version 1.0.0. It is important check what file
format you SoC tools uses. In general, Zephyr can create images with binary
(``.bin``) image format or Intel's (``.hex``) image format.
The Zephyr provide the ``west`` tool that simplify the signing process. Just
call west with proper parameter values:
.. code-block:: console
west sign -t imgtool -d build/app -- --version 1.0.0 --pad
--key bootloader/mcuboot/root-rsa-2048.pem
=== image configuration:
partition offset: 131072 (0x20000)
partition size: 393216 (0x60000)
rom start offset: 512 (0x200)
=== signing binaries
unsigned bin: <zephyrdir>/build/app/zephyr/zephyr.bin
signed bin: <zephyrdir>/build/app/zephyr/zephyr.signed.bin
Step 6: Flash the app image
===========================
.. code-block:: console
west flash -d build/app --bin-file build/app/zephyr/zephyr.signed.bin
.. note:: Command variation to flash a ``hex`` file:
``west flash -d build/app --hex-file build/app/zephyr/zephyr.signed.hex``
At this point you can access a third terminal ``terminal 3`` to check if image
is running. Open the ``terminal 3`` and press reset on your board:
.. code-block:: console
minicom -D /dev/ttyACM0
Step 7: Signing the binary test image
=====================================
The test image needs different parameters to add the signature. Pay attention
to make sure you are creating the right signed image. The test image will be
created with version 2.0.0 in this tutorial:
.. code-block:: console
west sign --no-hex --bin -B build/zephyr-2.0.0.bin -t imgtool -d build/app --
--version 2.0.0 --key bootloader/mcuboot/root-rsa-2048.pem
=== image configuration:
partition offset: 131072 (0x20000)
partition size: 393216 (0x60000)
rom start offset: 512 (0x200)
=== signing binaries
unsigned bin: <zephyrdir>/build/app/zephyr/zephyr.bin
signed bin: build/zephyr-2.0.0.bin
Step 8: Create a package with UpdateHub Utilities (uhu)
=======================================================
First, install UpdateHub Utilities (``uhu``) on your system, using:
.. code-block:: console
pip3 install --user uhu
After installing uhu you will need to set the ``product-uid``. The value for
UpdateHub-CE can be found at ``overlay-prj.conf.example`` file. For UpdateHub
Cloud, you need copy the value from the web interface.
.. code-block:: console
uhu product use "e4d37cfe6ec48a2d069cc0bbb8b078677e9a0d8df3a027c4d8ea131130c4265f"
Then, add the package and its mode (``zephyr``):
.. code-block:: console
uhu package add build/zephyr-2.0.0.bin -m zephyr
Then inform what ``version`` this image is:
.. code-block:: console
uhu package version 2.0.0
And finally you can build the package by running:
.. code-block:: console
uhu package archive --output build/zephyr-2.0.0.pkg
The remaining steps are dedicated to UpdateHub-CE. If you are using UpdateHub
Cloud you can find the proper procedure at `docs.updatehub.io`_.
Step 9: Add the package to server
=================================
Now, add the package to the updatehub server. Open your browser to the server
URL, ``<your-ip-address>:8080``, and logging into the server using ``admin``
as the login and password by default. After logging in, click on the package
menu, then ``UPLOAD PACKAGE``, and select the package built in step 8.
Step 10: Register device on server
==================================
If you chose ``Manual``, register your device at updatehub server by using the
terminal session where you are debugging the board ``terminal 3``. Type the
following command:
.. code-block:: console
updatehub run
If everything is alright, it will print on the screen ``No update available``.
For ``Polling`` mode, the system will automatically register your device after
:kconfig:option:`CONFIG_UPDATEHUB_POLL_INTERVAL` minutes. The ``updatehub run`` can
be used to speed-up.
.. note::
The message ``Could not receive data`` means that the application was not
able to reached the updatehub server for some reason. The most common
cases are server down, missing network routes and forget to change the
content of ``overlay-prj.conf`` file.
Step 11: Create a rollout
=========================
In the browser where the UpdateHub-CE is open, click on ``menu Rollout``
and then ``CREATE ROLLOUT``. Select the version of the package that you added
in step 9. With that, the update is published, and the server is ready to
accept update requests.
Step 12: Run the update
=======================
Back in the terminal session that you used for debugging the board, type the
following command:
.. code-block:: console
updatehub run
And then wait. The board will probe the server, check if there are any new
updates, and then download the update package you've just created. If
everything goes fine the message ``Image flashed successfully, you can reboot
now`` will be printed on the terminal. If you are using the ``Polling`` mode
the board will reboot automatically and Step 13 can be skipped.
Step 13: Reboot the system
==========================
In the terminal you used for debugging the board, type the following command:
.. code-block:: console
kernel reboot cold
Your board will reboot and then start with the new image. After rebooting,
the board will automatically ping the server again and the message ``No update
available`` will be printed on the terminal. You can check the newer version
using the following command:
.. code-block:: console
uart:~$ updatehub info
Unique device id: acbdef0123456789
Firmware Version: 2.0.0
Product uid: e4d37cfe6ec48a2d069cc0bbb8b078677e9a0d8df3a027c4d8ea131130c4265f
UpdateHub Server: <server ip/dns>
uart:~$
Hardware
********
The below list of hardware have been used by UpdateHub team.
.. csv-table::
:header: "ID", "Network Interface", "Shield / Device"
:widths: 5, 45, 50
:width: 800px
1, Ethernet, Native
2, WIFI, :ref:`ESP-8266 <module_esp_8266>`
3, "MODEM (PPP)", "SIMCOM 808"
4, "IEEE 802.15.4 (6loWPAN)", "Native,
:ref:`RF2XX <atmel_at86rf2xx_transceivers>`"
6, "OpenThread Network", Native
.. csv-table::
:header: "Board", "Network Interface"
:widths: 50, 50
:width: 800px
:ref:`frdm_k64f`, "1, 2, 3, 4"
:ref:`nrf52840dk_nrf52840`, "2, 3, 4, 5, 6"
:ref:`nucleo_f767zi_board`, "1, 2, 3, 4"
.. _updatehub.io: https://updatehub.io
.. _docs.updatehub.io: https://docs.updatehub.io/
.. _OpenThread Router: https://openthread.io/guides/border-router
Part 3
한국어 전문 번역
개요
UpdateHub는 embedded device 전체를 원격으로 update하기 쉽게 만든 enterprise-grade solution입니다. 제품 기능 개발에 집중할 수 있도록 Firmware Over-the-Air(FOTA) update 전송에 필요한 보안과 효율 관련 절차를 처리합니다. 자세한 제품 문서는 docs.updatehub.io에서 확인할 수 있습니다.
이 sample은 polling mode와 manual update mode 두 가지 UpdateHub 사용법을 보여 줍니다. Polling mode는 미리 정한 주기마다 자동으로 server를 probe하고, update가 있으면 사용자 개입 없이 설치합니다. Manual mode에서는 사용자가 server probe를 호출하고, update가 발견되면 지금 설치할지 나중에 설치할지 직접 결정합니다.
Sample source는 samples/subsys/mgmt/updatehub/src/main.c에 있습니다.
주의 사항
- Zephyr의 UpdateHub port는 처음에 Ethernet을 사용하는 Freedom-K64F(
frdm_k64f) kit용으로 개발되었습니다. 같은 연결 방식을 지원하는 다른 platform에서도 build·실행할 수 있습니다. - Wi-Fi, IEEE 802.15.4, OpenThread 같은 다른 기술용 overlay file을 제공합니다. 각 방식은 hardware resource에 의존하며 제공 overlay는 완전한 최적화본이 아니라 범용 시작점입니다.
- 일부 wireless technology에는 gateway 또는 border router가 필요합니다. 이 network infrastructure의 상세 구성은 sample 범위 밖입니다.
- UpdateHub가 올바르게 동작하려면 MCUboot bootloader를 지원하는 SoC와 board가 필요합니다. Upgrade에는 두 image slot을 사용합니다.
- UpdateHub는 Zephyr service처럼 동작하며 여러 Zephyr subsystem에 크게 의존합니다. 전송에는 UDP 위의 CoAP를 사용합니다.
빌드 및 실행
다음 단계는 Zephyr에서 UpdateHub sample을 build하고 실행하는 전체 절차입니다. 첫 terminal인 terminal 1에서 Zephyr project directory로 이동해 bootloader, module, tool과 Zephyr tree를 같은 위치에서 다룹니다.
ls
bootloader modules tools zephyr
1단계: MCUboot 빌드 및 플래시
MCUboot 문서에 따라 Freedom-K64F용 bootloader를 build하고, terminal 1에서 결과 image를 west flash로 board에 기록합니다.
# From the root of the zephyr repository
west build -b frdm_k64f -d build/mcuboot-frdm_k64f bootloader/mcuboot/boot/zephyr
west flash -d build/mcuboot-frdm_k64f
2단계: UpdateHub 서버 시작
2.1단계: UpdateHub-CE(Community Edition)
Zephyr sample의 기본 설정은 UpdateHub-CE server edition을 사용합니다. 이 edition은 사용자가 직접 server를 운영해야 하며 Docker container로 배포됩니다. Local network에서 실행하거나 DigitalOcean, Vultr 같은 service provider에 설치할 수 있습니다.
두 번째 terminal인 terminal 2에서 HTTP port 8080과 CoAP UDP port 5683을 공개해 Community Edition container를 시작합니다.
docker run -it -p 8080:8080 -p 5683:5683/udp --rm
updatehub/updatehub-ce:latest
2.2단계: UpdateHub Cloud
UpdateHub Cloud는 UpdateHub-CE와 거의 같은 resource를 제공하는 enterprise-grade service이며, 주요 차이는 DTLS 지원입니다. Cloud에서는 CoAPS/DTLS 사용 여부를 선택할 수 있습니다. DTLS를 사용하려면 sample build에 overlay-dtls.conf를 추가합니다.
시험용으로 제공 certificate를 사용할 수도 있고 직접 만들 수도 있습니다. Linux의 terminal 2에서 512-bit RSA private key와 self-signed X.509 server certificate를 생성합니다.
openssl genrsa -out privkey.pem 512
openssl req -new -x509 -key privkey.pem -out servercert.pem
servercert와 privkey는 certificates.h를 통해 application에 embed해야 합니다. PEM certificate는 DER certificate로, private key는 암호화하지 않은 PKCS#8 DER로 변환합니다.
openssl x509 -in servercert.pem -outform DER -out servercert.der
openssl pkcs8 -topk8 -inform PEM -outform DER -nocrypt -in privkey.pem
-out privkey.der
생성된 DER file을 sample source의 certificates directory에 둡니다. UpdateHub Cloud를 사용할 때는 자신의 overlay-prj.conf에서 CONFIG_UPDATEHUB_CE=n으로 설정해야 합니다. 문서의 512-bit key는 sample 재현용 값이므로 실제 deployment에서는 service 요구 사항과 현재 보안 정책에 맞는 key size와 certificate를 사용해야 합니다.
3단계: UpdateHub 샘플 구성
UpdateHub 동작과 통신 tuning에 필요한 Kconfig option을 설정합니다.
CONFIG_UPDATEHUB_CE:y면 UpdateHub-CE,n이면 UpdateHub Cloud를 선택합니다.CONFIG_UPDATEHUB_SERVER: UpdateHub-CE가 실행되는 local IP address를 지정합니다. Service provider를 사용한다면 DNS name도 가능하며 CE에서만 유효합니다.CONFIG_UPDATEHUB_POLL_INTERVAL: polling period를 분 단위로 정합니다. 범위는 0~43,200분(30일), 기본값은 1,440분(24시간)입니다.CONFIG_UPDATEHUB_PRODUCT_UID: product ID를 지정합니다. CE용 example 값은overlay-prj.conf.example에 있고, Cloud 값은 web interface에서 가져옵니다.
4단계: UpdateHub 애플리케이션 빌드
UpdateHub를 올바르게 build하려면 network interface에 맞는 overlay file을 정확히 조합해야 합니다. Experimental interface는 정식 지원 범위 밖이지만 다음 구성을 출발점으로 사용할 수 있습니다.
4.1단계: Ethernet용 빌드
Ethernet은 base configuration과 overlay-prj.conf만 사용합니다. Target은 frdm_k64f 또는 nucleo_f767zi입니다.
west build -b [ frdm_k64f | nucleo_f767zi ] -d build/app zephyr/samples/subsys/mgmt/updatehub -- -DEXTRA_CONF_FILE=overlay-prj.conf
4.2단계: Wi-Fi용 빌드
Wi-Fi에는 overlay-wifi.conf를 추가합니다. Example은 Arduino header에 연결한 esp_8266_arduino shield를 사용하며 Freedom-K64F, nRF52840 DK 또는 Nucleo F767ZI를 대상으로 합니다.
west build -b [ frdm_k64f | nrf52840dk/nrf52840 | nucleo_f767zi ] --shield esp_8266_arduino -d build/app zephyr/samples/subsys/mgmt/updatehub -- -DEXTRA_CONF_FILE="overlay-wifi.conf;overlay-prj.conf"
disco_l475_iot1 board는 지원하지 않습니다. 현재 es-WIFI driver가 UDP를 지원하지 않기 때문입니다.
4.3단계: IEEE 802.15.4용 빌드 [실험적]
IEEE 802.15.4에는 overlay-802154.conf가 필요합니다. Host와 device under test 두 node를 구성하고, Linux kernel 4.9 이상에서 전체 6LoWPAN 지원을 준비해야 합니다. Zephyr wpan-usb sample을 재현하는 것이 시작점입니다.
Gateway는 native Linux driver 및 atusb, 그리고 wpanusb sample 조합으로 시험되었습니다. 첫 build는 native radio를 사용하는 nRF52840 DK용입니다.
west build -b nrf52840dk/nrf52840 -d build/app zephyr/samples/subsys/mgmt/updatehub -- -DEXTRA_CONF_FILE="overlay-802154.conf;overlay-prj.conf"
두 번째 build는 Freedom-K64F 또는 Nucleo F767ZI에 atmel_rf2xx_arduino shield를 연결합니다.
west build -b [ frdm_k64f | nucleo_f767zi ] --shield atmel_rf2xx_arduino -d build/app zephyr/samples/subsys/mgmt/updatehub -- -DEXTRA_CONF_FILE="overlay-802154.conf;overlay-prj.conf"
4.4단계: OpenThread Network용 빌드 [실험적]
OpenThread에는 overlay-ot.conf가 필요합니다. Host NCP와 device under test 두 node를 사용하며, Linux kernel 4.9 이상과 선택적인 NAT64 지원이 필요합니다. OpenThread Border Router 구성을 재현하는 것이 출발점입니다.
Gateway는 OpenThread 1.1.1 NCP mode로 동작하는 board 두 개를 사용해 시험되었습니다. nRF52840 DK용 sample을 다음처럼 build합니다.
west build -b nrf52840dk/nrf52840 -d build/app zephyr/samples/subsys/mgmt/updatehub -- -DEXTRA_CONF_FILE="overlay-ot.conf;overlay-prj.conf"
5단계: 애플리케이션 이미지 서명
Application image는 board에서 실행되며 UpdateHub server에 연결해 새 image를 확인합니다. 첫 version은 1.0.0으로 준비합니다. SoC flashing tool이 binary(.bin)와 Intel HEX(.hex) 중 어느 형식을 사용하는지 확인해야 합니다.
west sign과 MCUboot imgtool로 image에 version, padding과 root-rsa-2048.pem signing key를 적용합니다. 출력은 partition offset·size, ROM start offset과 signed file 경로를 보여 줍니다.
west sign -t imgtool -d build/app -- --version 1.0.0 --pad
--key bootloader/mcuboot/root-rsa-2048.pem
=== image configuration:
partition offset: 131072 (0x20000)
partition size: 393216 (0x60000)
rom start offset: 512 (0x200)
=== signing binaries
unsigned bin: <zephyrdir>/build/app/zephyr/zephyr.bin
signed bin: <zephyrdir>/build/app/zephyr/zephyr.signed.bin
6단계: 애플리케이션 이미지 플래시
서명된 zephyr.signed.bin을 board에 flash합니다.
west flash -d build/app --bin-file build/app/zephyr/zephyr.signed.bin
HEX file을 사용하는 경우 command는 west flash -d build/app --hex-file build/app/zephyr/zephyr.signed.hex로 바꿉니다. 세 번째 terminal인 terminal 3에서 serial console을 열고 board를 reset해 image가 실행되는지 확인합니다.
minicom -D /dev/ttyACM0
7단계: 테스트 바이너리 이미지 서명
Update용 test image는 다른 output 이름과 version을 사용해야 합니다. Tutorial에서는 HEX 생성을 끄고 binary만 만들어 build/zephyr-2.0.0.bin에 version 2.0.0을 서명합니다. 올바른 image와 key를 사용했는지 output을 확인합니다.
west sign --no-hex --bin -B build/zephyr-2.0.0.bin -t imgtool -d build/app --
--version 2.0.0 --key bootloader/mcuboot/root-rsa-2048.pem
=== image configuration:
partition offset: 131072 (0x20000)
partition size: 393216 (0x60000)
rom start offset: 512 (0x200)
=== signing binaries
unsigned bin: <zephyrdir>/build/app/zephyr/zephyr.bin
signed bin: build/zephyr-2.0.0.bin
8단계: UpdateHub Utilities(uhu)로 패키지 생성
먼저 system에 UpdateHub Utilities인 uhu를 user 범위로 설치합니다.
pip3 install --user uhu
UpdateHub-CE의 product-uid는 overlay-prj.conf.example에서 찾고, Cloud에서는 web interface에서 복사합니다. 다음 example UID를 active product로 선택합니다.
uhu product use "e4d37cfe6ec48a2d069cc0bbb8b078677e9a0d8df3a027c4d8ea131130c4265f"
Version 2.0.0 signed binary를 zephyr mode의 package content로 추가합니다.
uhu package add build/zephyr-2.0.0.bin -m zephyr
Package image version을 2.0.0으로 지정합니다.
uhu package version 2.0.0
마지막으로 배포 가능한 zephyr-2.0.0.pkg archive를 생성합니다.
uhu package archive --output build/zephyr-2.0.0.pkg
이후 단계는 UpdateHub-CE 기준입니다. Cloud를 사용한다면 UpdateHub 공식 Cloud 절차를 따릅니다.
9단계: 서버에 패키지 추가
Browser에서 <your-ip-address>:8080을 열고 기본 login과 password에 각각 admin을 입력합니다. Package menu에서 UPLOAD PACKAGE를 선택하고 8단계에서 만든 package를 upload합니다. 기본 credential은 시험 환경용이며 실제 server에서는 변경해야 합니다.
10단계: 서버에 장치 등록
Manual mode를 선택했다면 board를 debug 중인 terminal 3에서 server probe를 실행해 device를 등록합니다.
updatehub run
정상이면 No update available이 출력됩니다. Polling mode에서는 CONFIG_UPDATEHUB_POLL_INTERVAL분 뒤 자동 등록되며, updatehub run으로 즉시 진행할 수도 있습니다.
Could not receive data가 나오면 application이 server에 도달하지 못한 것입니다. Server 중단, network route 누락, overlay-prj.conf 값 미변경을 우선 확인합니다.
11단계: Rollout 생성
UpdateHub-CE browser에서 Rollout menu와 CREATE ROLLOUT을 차례로 선택합니다. 9단계에서 올린 package version을 선택하면 update가 publish되고 server가 device request를 받을 준비를 마칩니다.
12단계: 업데이트 실행
Board debug terminal에서 다시 server probe를 실행합니다.
updatehub run
Board는 server를 probe해 새 update를 확인하고 package를 download합니다. 성공하면 Image flashed successfully, you can reboot now가 출력됩니다. Polling mode에서는 board가 자동으로 reboot하므로 13단계를 생략할 수 있습니다.
13단계: 시스템 재부팅
Manual mode에서는 board debug terminal에서 cold reboot를 요청합니다.
kernel reboot cold
Board는 새 image로 시작하고 server를 다시 자동 probe합니다. 더 최신 update가 없으면 No update available이 표시됩니다. updatehub info로 unique device ID, firmware version 2.0.0, product UID와 server address를 확인합니다.
uart:~$ updatehub info
Unique device id: acbdef0123456789
Firmware Version: 2.0.0
Product uid: e4d37cfe6ec48a2d069cc0bbb8b078677e9a0d8df3a027c4d8ea131130c4265f
UpdateHub Server: <server ip/dns>
uart:~$
하드웨어
UpdateHub team이 사용한 network interface와 shield/device 조합은 다음과 같습니다. 공식 표에는 ID 5에 해당하는 interface 행이 없지만 board mapping에는 5가 포함되어 있으므로, 여기서 임의로 의미를 추정하지 않고 원문 번호를 그대로 보존합니다.
| ID | Network Interface | Shield / Device |
|---|---|---|
| 1 | Ethernet | Native |
| 2 | Wi-Fi | ESP-8266 |
| 3 | MODEM(PPP) | SIMCOM 808 |
| 4 | IEEE 802.15.4(6LoWPAN) | Native, RF2XX |
| 6 | OpenThread Network | Native |
각 board에서 사용한 network interface ID mapping은 다음과 같습니다.
| Board | Network Interface ID |
|---|---|
frdm_k64f | 1, 2, 3, 4 |
nrf52840dk/nrf52840 | 2, 3, 4, 5, 6 |
nucleo_f767zi | 1, 2, 3, 4 |
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.