|
| 1 | +# NXP `MCXW71/K32W1` OTA guide |
| 2 | + |
| 3 | +### Convert `srec` into `sb3` file |
| 4 | + |
| 5 | +The OTA image files must be encrypted using Over The Air Programming Tool |
| 6 | +([OTAP](https://www.nxp.com/design/microcontrollers-developer-resources/connectivity-tool-suite:CONNECTIVITY-TOOL-SUITE?#downloads)). |
| 7 | +Bootloader will load the new OTA image only if it detects that the file was |
| 8 | +encrypted with the `OTAP` correct keys. |
| 9 | + |
| 10 | +`.srec` file is input for Over The air Programming (`OTAP`) application |
| 11 | +(unencrypted) and it's converted to `.sb3` format (encrypted). |
| 12 | + |
| 13 | +In `OTAP` application |
| 14 | + |
| 15 | +- select OTA protocol => `OTAP` Matter |
| 16 | +- Browse File |
| 17 | +- follow default options (KW45/K32W148, Preserve NVM) |
| 18 | +- image information: will update "Application Core (MCU)" - this will generate |
| 19 | + the image only for the CM33 core |
| 20 | +- keep other settings at default values |
| 21 | + |
| 22 | +### Generate `ota` file |
| 23 | + |
| 24 | +In order to build an OTA image, use the NXP wrapper over the standard tool |
| 25 | +`src/app/ota_image_tool.py`: |
| 26 | + |
| 27 | +- `scripts/tools/nxp/ota/ota_image_tool.py` |
| 28 | + |
| 29 | +The tool can be used to generate an OTA image with the following format: |
| 30 | + |
| 31 | +``` |
| 32 | + | OTA image header | TLV1 | TLV2 | ... | TLVn | |
| 33 | +``` |
| 34 | + |
| 35 | +where each TLV is in the form `|tag|length|value|`. |
| 36 | + |
| 37 | +Note that "standard" TLV format is used. Matter TLV format is only used for |
| 38 | +factory data TLV value. |
| 39 | + |
| 40 | +Please see more in the |
| 41 | +[OTA image tool guide](../../../scripts/tools/nxp/ota/README.md). |
| 42 | + |
| 43 | +Here is an example that generates an OTA image with application update TLV from |
| 44 | +an `.sb3` file: |
| 45 | + |
| 46 | +``` |
| 47 | +./scripts/tools/nxp/ota/ota_image_tool.py create -v 0xDEAD -p 0xBEEF -vn 2 -vs "2.0" -da sha256 --app-input-file ~/binaries/chip-mcxw71-app.sb3 ~/binaries/chip-mcxw71-app.ota |
| 48 | +
|
| 49 | +``` |
| 50 | + |
| 51 | +A note regarding OTA image header version (`-vn` option). An application binary |
| 52 | +has its own software version (given by |
| 53 | +`CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION`, which can be overwritten). In |
| 54 | +order to have a correct OTA process, the OTA header version should be the same |
| 55 | +as the binary embedded software version. A user can set a custom software |
| 56 | +version in the gn build args by setting `nxp_software_version` to the wanted |
| 57 | +version. |
| 58 | + |
| 59 | +### OTA factory data |
| 60 | + |
| 61 | +A user can update the factory data through OTA, at the same time the application |
| 62 | +firmware is updated by enabling the following processor in the `gn args`: |
| 63 | + |
| 64 | +- `chip_enable_ota_factory_data_processor=1` to enable default factory data |
| 65 | + update processor (disabled by default). |
| 66 | + |
| 67 | +The OTA image used must be updated to include the new factory data. |
| 68 | + |
| 69 | +[OTA image tool guide](../../../scripts/tools/nxp/ota/README.md). |
| 70 | + |
| 71 | +### Running OTA |
| 72 | + |
| 73 | +The OTA topology used for OTA testing is illustrated in the figure below. |
| 74 | +Topology is similar with the one used for Matter Test Events. |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | +The concept for OTA is the next one: |
| 79 | + |
| 80 | +- there is an OTA Provider Application that holds the OTA image. In our case, |
| 81 | + this is a Linux application running on an Ubuntu based-system; |
| 82 | +- the OTA Requestor functionality is embedded inside the reference |
| 83 | + application. It will be used for requesting OTA blocks from the OTA |
| 84 | + Provider; |
| 85 | +- the controller (a linux application called chip-tool) will be used for |
| 86 | + commissioning both the device and the OTA Provider App. The device will be |
| 87 | + commissioned using the standard Matter flow (BLE + IEEE 802.15.4) while the |
| 88 | + OTA Provider Application will be commissioned using the `onnetwork` option |
| 89 | + of `chip-tool`; |
| 90 | +- during commissioning, each device is assigned a node id by the chip-tool |
| 91 | + (can be specified manually by the user). Using the node id of the device and |
| 92 | + of the reference application, chip-tool triggers the OTA transfer by |
| 93 | + invoking the `announce-ota-provider` command - basically, the OTA Requestor |
| 94 | + is informed of the node id of the OTA Provider Application. |
| 95 | + |
| 96 | +_Computer #1_ can be any system running an Ubuntu distribution. We recommand |
| 97 | +using CSA official instructions from |
| 98 | +[here](https://groups.csa-iot.org/wg/matter-csg/document/28566), where RPi 4 are |
| 99 | +proposed. Also, CSA official instructions document point to the OS/Docker images |
| 100 | +that should be used on the RPis. For compatibility reasons, we recommand |
| 101 | +compiling chip-tool and OTA Provider applications with the same commit id that |
| 102 | +was used for compiling the reference application. Also, please note that there |
| 103 | +is a single controller (chip-tool) running on Computer #1 which is used for |
| 104 | +commissioning both the device and the OTA Provider Application. If needed, |
| 105 | +[these instructions](https://itsfoss.com/connect-wifi-terminal-ubuntu/) could be |
| 106 | +used for connecting the RPis to WiFi. |
| 107 | + |
| 108 | +Build the Linux OTA provider application: |
| 109 | + |
| 110 | +``` |
| 111 | +user@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/ota-provider-app chip_config_network_layer_ble=false |
| 112 | +``` |
| 113 | + |
| 114 | +Build Linux `chip-tool`: |
| 115 | + |
| 116 | +``` |
| 117 | +user@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/chip-tool out/chip-tool-app |
| 118 | +``` |
| 119 | + |
| 120 | +Start the OTA Provider Application: |
| 121 | + |
| 122 | +``` |
| 123 | +user@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_* |
| 124 | +user@computer1:~/connectedhomeip$ : ./out/ota-provider-app/chip-ota-provider-app -f chip-mcxw71-app.ota |
| 125 | +``` |
| 126 | + |
| 127 | +Provision the OTA provider application and assign node id _1_. Also, grant ACL |
| 128 | +entries to allow OTA requestors: |
| 129 | + |
| 130 | +``` |
| 131 | +user@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_* |
| 132 | +user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing onnetwork 1 20202021 |
| 133 | +user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": null, "targets": null}]' 1 0 |
| 134 | +``` |
| 135 | + |
| 136 | +Provision the device and assign node id _2_: |
| 137 | + |
| 138 | +``` |
| 139 | +user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing ble-thread 2 hex:<operationalDataset> 20202021 3840 |
| 140 | +``` |
| 141 | + |
| 142 | +Start the OTA process: |
| 143 | + |
| 144 | +``` |
| 145 | +user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool otasoftwareupdaterequestor announce-ota-provider 1 0 0 0 2 0 |
| 146 | +``` |
| 147 | + |
| 148 | +### Known issues |
| 149 | + |
| 150 | +- SRP cache on the openthread border router needs to flushed each time a new |
| 151 | + commissioning process is attempted. For this, factory reset the device, then |
| 152 | + execute `ot-ctl server disable` followed by `ot-ctl server enable`. After |
| 153 | + this step, the commissioning process of the device can start; |
| 154 | +- Due to some MDNS issues, the commissioning of the OTA Provider Application |
| 155 | + may fail. Please make sure that the SRP cache is disabled |
| 156 | + (`ot-ctl srp server disable`) on the openthread border router while |
| 157 | + commissioning the OTA Provider Application; |
| 158 | +- No other Docker image should be running (e.g.: Docker image needed by Test |
| 159 | + Harness) except the OTBR one. A docker image can be killed using the |
| 160 | + command: |
| 161 | + |
| 162 | + ``` |
| 163 | + user@computer1:~/connectedhomeip$ : sudo docker kill $container_id |
| 164 | + ``` |
| 165 | +
|
| 166 | +- In order to avoid MDNS issues, only one interface should be active at one |
| 167 | + time. E.g.: if WiFi is used then disable the Ethernet interface and also |
| 168 | + disable multicast on that interface: |
| 169 | +
|
| 170 | + ``` |
| 171 | + user@computer1:~/connectedhomeip$ sudo ip link set dev eth0 down |
| 172 | + user@computer1:~/connectedhomeip$ sudo ifconfig eth0 -multicast |
| 173 | + ``` |
| 174 | +
|
| 175 | +- If OTBR Docker image is used, then the "-B" parameter should point to the |
| 176 | + interface used for the backbone. |
| 177 | +
|
| 178 | +- If Wi-Fi is used on a RPI4, then a 5Ghz network should be selected. |
| 179 | + Otherwise, issues related to BLE-WiFi combo may appear. |
0 commit comments