Skip to content

Commit

Permalink
[nxp fromtree][NXP] Initial enablement of NXP Matter over WiFi with Z…
Browse files Browse the repository at this point in the history
…ephyr (project-chip#31648)

* [zephyr] Update deprecated Kconfig

CPLUSPLUS is deprecated and should be replaced with CPP
LIB_CPLUSPLUS is deprecated and should be replaced with REQUIRES_FULL_LIBCPP

Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>

* [NXP] Initial enablement of NXP Matter over WiFi with Zephyr

Features:
* Matter over WiFi
* BLE commissioning
* Storage
* Factory data
* OTA
* MbedTLS PSA API

Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

* Restyled by prettier-markdown

* Fix misspell error

Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>

* Update copyrights to date contributed

Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>

---------

Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>
Co-authored-by: Restyled.io <commits@restyled.io>
Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>
  • Loading branch information
axelnxp and restyled-commits committed Jan 29, 2024
1 parent f7517ba commit 82b5361
Show file tree
Hide file tree
Showing 42 changed files with 110 additions and 96 deletions.
4 changes: 2 additions & 2 deletions config/nxp/app/bootloader.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2023 Project CHIP Authors
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,7 @@

# The default signature key used by MCUBOOT is located on their repository,
# change this to the appropriate one.
# NOTE: This option needs to contain a path to the same file used by
# NOTE: This option needs to contain a path to the same file used by
# MCUBOOT_SIGNATURE_KEY_FILE.
#CONFIG_BOOT_SIGNATURE_KEY_FILE="root-rsa-2048.pem"

Expand Down
2 changes: 1 addition & 1 deletion config/nxp/app/enable-gnu-std.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2023 Project CHIP Authors
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion config/nxp/app/pre-zephyr.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2023 Project CHIP Authors
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion config/nxp/chip-gn/.gn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Project CHIP Authors
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion config/nxp/chip-gn/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Project CHIP Authors
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion config/nxp/chip-gn/args.gni
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Project CHIP Authors
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion config/nxp/chip-gn/toolchain/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Project CHIP Authors
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion config/nxp/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2023-2024 Project CHIP Authors
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion config/nxp/chip-module/Kconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2023 Project CHIP Authors
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion config/nxp/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2023-2024 Project CHIP Authors
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion config/nxp/chip-module/Kconfig.features
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2023 Project CHIP Authors
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion config/nxp/chip-module/generate_factory_data.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2023 Project CHIP Authors
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion config/nxp/chip-module/zephyr/module.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2023 Project CHIP Authors
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
94 changes: 55 additions & 39 deletions docs/guides/nxp_zephyr_ota_software_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,23 @@ The Flash is divided into different regions as follow :
- Secondary application partition : Update image received with the OTA
(candidate application).

The size reserved for each partition can be found in `src/platform/nxp/zephyr/boards/board.overlay`.
The size reserved for each partition can be found in
`src/platform/nxp/zephyr/boards/board.overlay`.

Notes :

- When applicable, BLE/15.4/Wi-Fi firmwares are embedded in the application
- When applicable, BLE/15.4/Wi-Fi firmware are embedded in the application
binary, ensuring compatibility between the application and the controllers.
- The sizes of the primary and secondary applications are provided as an
example. The size can be changed by overriding the partitions located at `board.overlay`.(example: `src/platform/nxp/zephyr/boards/rd_rw612_bga.overlay`)
example. The size can be changed by overriding the partitions located at
`board.overlay`.(example:
`src/platform/nxp/zephyr/boards/rd_rw612_bga.overlay`)

### MCUBoot Bootloader

Current OTA solution is using MCUBoot Bootloader. MCUBoot is an open-source secure bootloader
used to apply the self-upgrade. For more details, please refer to the
Current OTA solution is using MCUBoot Bootloader. MCUBoot is an open-source
secure bootloader used to apply the self-upgrade. For more details, please refer
to the
[MCUBoot documentation](https://github.com/mcu-tools/mcuboot/blob/main/docs/design.md).

In our use case, the bootloader runs the application residing in the primary
Expand All @@ -56,18 +60,22 @@ called swap-move and is the default upgrade configured by MCUBoot.

### Generating and flashing application image

The all cluster app is able to demonstrate the usage of OTA. To have this
OTA support, prj_ota.conf configurations needs to be used. This can be done
by adding `-DEXTRA_CONF_FILE=prj_ota.conf` to the west build command.
The all cluster app is able to demonstrate the usage of OTA. To have this OTA
support, prj_ota.conf configurations needs to be used. This can be done by
adding `-DEXTRA_CONF_FILE=prj_ota.conf` to the west build command.

Current OTA implementation automates the following procedures:
- Generation of MCUBOOT image (File generated: `modules/connectedhomeip/build_mcuboot/zephyr/zephyr.bin`)*
- Generation of Matter application image (File generated: `zephyr/zephyr.bin`)*
- Signature of the application image (File generated: `zephyr/zephyr.signed.bin`)*
- Generation of a single binary merging the signed application
with the MCUBoot Image (File generated: `zephyr/zephyr_full.bin`)*

>**Note**: *All paths are relative to the output folder.
- Generation of MCUBOOT image (File generated:
`modules/connectedhomeip/build_mcuboot/zephyr/zephyr.bin`)\*
- Generation of Matter application image (File generated:
`zephyr/zephyr.bin`)\*
- Signature of the application image (File generated:
`zephyr/zephyr.signed.bin`)\*
- Generation of a single binary merging the signed application with the
MCUBoot Image (File generated: `zephyr/zephyr_full.bin`)\*

> **Note**: \*All paths are relative to the output folder.
The final binary to be used is `zephyr_full.bin`.

Expand All @@ -79,11 +87,12 @@ The application image have the following format :
- Trailer : contains metadata needed by the bootloader such as the image
signature, the upgrade type, the swap status...

In the all-cluster-app example, the image is signed with the default private key provided by MCUBoot(`/zephyrproject/bootloader/mcuboot/root-rsa-2048.pem`).
MCUBoot is built with its corresponding public key which would be used to
verify the integrity of the image. It is possible to generate a new pair of
keys using the following commands. This procedure should be done prior to
building the mcuboot application.
In the all-cluster-app example, the image is signed with the default private key
provided by MCUBoot(`/zephyrproject/bootloader/mcuboot/root-rsa-2048.pem`).
MCUBoot is built with its corresponding public key which would be used to verify
the integrity of the image. It is possible to generate a new pair of keys using
the following commands. This procedure should be done prior to building the
mcuboot application.

- To generate the private key :

Expand All @@ -96,24 +105,27 @@ user@ubuntu: python3 imgtool.py keygen -k priv_key.pem -t rsa-2048
```
user@ubuntu: python3 imgtool.py getpub -k priv_key.pem
```

To use a different key than the default one, `CONFIG_BOOT_SIGNATURE_KEY_FILE`
and `CONFIG_MCUBOOT_SIGNATURE_KEY_FILE` needs to point to that same key.

- `CONFIG_BOOT_SIGNATURE_KEY_FILE`: This is used for the MCUboot bootloader
image. The path to the key can be either absolute or relative. Relative paths
starts from the MCUBoot repository root.
This option can be changed in: `config/nxp/app/bootloader.conf`
image. The path to the key can be either absolute or relative. Relative
paths starts from the MCUBoot repository root. This option can be changed
in: `config/nxp/app/bootloader.conf`

- `CONFIG_BOOT_SIGNATURE_KEY_FILE`: This is used for the application to be
loaded by the bootloader. The path can be either absolute or relative. Relative paths starts from the west workspace location.
This option can be changed in the application .conf files.
loaded by the bootloader. The path can be either absolute or relative.
Relative paths starts from the west workspace location. This option can be
changed in the application .conf files.

Refer to those two files for more information:

- [MCUBoot Config used for the MCUBoot Image](https://github.com/zephyrproject-rtos/mcuboot/blob/main/boot/zephyr/Kconfig)
- [MCUBoot Config used for the application](https://github.com/zephyrproject-rtos/zephyr/blob/main/modules/Kconfig.mcuboot)

JLink can be used to flash the mixed binary at the base address 0x8000000, using the
command :
JLink can be used to flash the mixed binary at the base address 0x8000000, using
the command :

```
J-Link > loadbin zephyr_full.bin 0x8000000
Expand All @@ -124,22 +136,27 @@ application and run it.

### Generating the OTA Update Image

The same procedure can be followed from the
The same procedure can be followed from the
[Generating and flashing application image](#generating-and-flashing-application-image)
sub-section, replacing `CONFIG_CHIP_DEVICE_SOFTWARE_VERSION` with a number greater than the initial one used on the active application (Candidate application version number
should be greater than the one used on the active application). By default the value is set
to 0, try resetting this option to 1 to generate the OTA update Image.
You can do this by adding `-DCONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1` to the west
build command.
sub-section, replacing `CONFIG_CHIP_DEVICE_SOFTWARE_VERSION` with a number
greater than the initial one used on the active application (Candidate
application version number should be greater than the one used on the active
application). By default the value is set to 0, try resetting this option to 1
to generate the OTA update Image. You can do this by adding
`-DCONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1` to the west build command.

The current implementation automates the following procedures:
- Generation of the Image to be used for update (File generated: `zephyr/zephyr.bin`)*
- Signature of the Image (File generated: `zephyr/zephyr.signed.bin`)*
- Conversion of the signed Image into the OTA format (.ota file) (File generated: `zephyr/matter.ota`)*

>**Note**: *All paths are relative to the output folder.
- Generation of the Image to be used for update (File generated:
`zephyr/zephyr.bin`)\*
- Signature of the Image (File generated: `zephyr/zephyr.signed.bin`)\*
- Conversion of the signed Image into the OTA format (.ota file) (File
generated: `zephyr/matter.ota`)\*

> **Note**: \*All paths are relative to the output folder.
The generated OTA file `matter.ota` can be used to perform the OTA Software Update. The instructions below describes the procedure step-by-step.
The generated OTA file `matter.ota` can be used to perform the OTA Software
Update. The instructions below describes the procedure step-by-step.

### Performing the OTA Software Update

Expand All @@ -148,8 +165,7 @@ Setup example :
- [Chip-tool](../../examples/chip-tool/README.md) application running on the
RPi.
- OTA Provider application built on the same RPi (as explained below).
- Board programmed with the example application (with the instructions
above).
- Board programmed with the example application (with the instructions above).

Before starting the OTA process, the Linux OTA Provider application can be built
on the RPi (if not already present in the pre-installed apps) :
Expand Down
2 changes: 1 addition & 1 deletion src/platform/nxp/zephyr/BLEManagerImpl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
* Copyright (c) 2024 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
26 changes: 13 additions & 13 deletions src/platform/nxp/zephyr/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Project CHIP Authors
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -22,36 +22,36 @@ assert(chip_device_platform == "nxp_zephyr")
static_library("nxp_zephyr") {
defines = []
sources = [
"../common/CHIPNXPPlatformDefaultConfig.h",
"../common/CHIPDeviceNXPPlatformDefaultConfig.h",
"../../SingletonConfigurationManager.cpp",
"../../Zephyr/BLEAdvertisingArbiter.cpp",
"../../Zephyr/BLEAdvertisingArbiter.h",
"../../Zephyr/BLEManagerImpl.cpp",
"../../Zephyr/ConfigurationManagerImpl.cpp",
"../../Zephyr/DiagnosticDataProviderImpl.cpp",
"../../Zephyr/DiagnosticDataProviderImpl.h",
"../../Zephyr/KeyValueStoreManagerImpl.cpp",
"../../Zephyr/Logging.cpp",
"../../Zephyr/PlatformManagerImpl.cpp",
"../../Zephyr/SysHeapMalloc.h",
"../../Zephyr/SystemTimeSupport.cpp",
"../../Zephyr/ZephyrConfig.cpp",
"../../Zephyr/ZephyrConfig.h",
"../common/CHIPDeviceNXPPlatformDefaultConfig.h",
"../common/CHIPNXPPlatformDefaultConfig.h",
"BLEManagerImpl.h",
"BlePlatformConfig.h",
"CHIPDevicePlatformConfig.h",
"CHIPDevicePlatformEvent.h",
"CHIPPlatformConfig.h",
"../../Zephyr/ConfigurationManagerImpl.cpp",
"ConfigurationManagerImpl.h",
"ConnectivityManagerImpl.cpp",
"ConnectivityManagerImpl.h",
"../../Zephyr/DiagnosticDataProviderImpl.cpp",
"../../Zephyr/DiagnosticDataProviderImpl.h",
"DiagnosticDataProviderImplNxp.cpp",
"DiagnosticDataProviderImplNxp.h",
"InetPlatformConfig.h",
"../../Zephyr/KeyValueStoreManagerImpl.cpp",
"KeyValueStoreManagerImpl.h",
"../../Zephyr/Logging.cpp",
"../../Zephyr/PlatformManagerImpl.cpp",
"PlatformManagerImpl.h",
"../../Zephyr/SysHeapMalloc.h",
"SystemPlatformConfig.h",
"../../Zephyr/SystemTimeSupport.cpp",
"../../Zephyr/ZephyrConfig.cpp",
"../../Zephyr/ZephyrConfig.h",
]

public = [
Expand Down
2 changes: 1 addition & 1 deletion src/platform/nxp/zephyr/BlePlatformConfig.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
* Copyright (c) 2024 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/platform/nxp/zephyr/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
* Copyright (c) 2024 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/platform/nxp/zephyr/CHIPDevicePlatformEvent.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
* Copyright (c) 2024 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/platform/nxp/zephyr/CHIPPlatformConfig.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2023-2024 Project CHIP Authors
* Copyright (c) 2024 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/platform/nxp/zephyr/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
* Copyright (c) 2024 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/platform/nxp/zephyr/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
* Copyright (c) 2024 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/platform/nxp/zephyr/ConnectivityManagerImpl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
* Copyright (c) 2024 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/platform/nxp/zephyr/DeviceInstanceInfoProviderImpl.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/platform/nxp/zephyr/DeviceInstanceInfoProviderImpl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Loading

0 comments on commit 82b5361

Please sign in to comment.