[nrfconnect] Update nRF Connect SDK version to 2.4.0 (#27010)
* [nrfconnect] Updated nRF Connect SDK to 2.4.0
Bumped recommended nRF Connect SDK version to 2.4.0
and included several bug fixes and improvements:
1. Extend the connection request log with RSSI.
This comes in handy especially during tests related to TX/RX power.
Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
2. Support disabling Wi-Fi LPM during the OTA DFU.
Added subclass of OTAImageProcessorImpl whcih implements Wi-Fi
specific optimization for LPM which should be disabled during OTA
due to the high throughput requirements. This allows applications
to use the OTAImageProcessorImplWiFi to do the job.
Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
3. Provide configs for Matter NUS feature
Matter NUS feature allows to add of BLE Nordic UART Service and
register commands which allow controlling the Matter device via
BLE.
This can be useful when the device loses connection with a
Matter Controller but it should be controlled in another way
for e.g. a Door Lock.
4. FactoryDataProvider: align the fprotect memory block
Due to the smallest atomic SPU block (16k for nRF53)
which can be protected we need to calculate proper
offsets to include factory data partition.
Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
5. nrfconnect: migrate to new MCUmgr Kconfig options
Migrate to new MCUmgr Kconfig options using:
$ZEPHYR_BASE/scripts/utils/migrate_mcumgr_kconfigs.py
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
6. Added IMAGE_ACCESS_HOOKS config to nRF53 config set
CONFIG_IMAGE_ACCESS_HOOKS is required for nRF53 to confirm
image during DFU over BLE after the changes provided by the
recent Zephyr's upmerge.
Signed-off-by: Arkadiusz Balys <arkadiusz.balys@nordicsemi.no>
7. Changed WPA SUPP logs level to error
* Changed default log level to error
* Changed WPA supplicant log levet to error. This is a workaround
and it will be removed once default log levels fix to Zephyr will
be merged.
Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
8. Fixed dependencies for CHIP_DFU_OVER_BT_SMP kconfig
Some Kconfigs selected by the CHIP_DFU_OVER_BT_SMP have unmet
dependencies.
Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
9. Set BLE connection to 1 for NUS
We decided to work with single BLE connection when NUS is active.
10. Repair a path within error messages in FD ptyhon script
Two paths were set wrongly in the factory data python script.
11. Fixed system workqueue stack overflow for Wi-Fi
After failing to connect to the Wi-Fi network (e.g. due to bad
password) the application falls into stack overflow.
Increased the stack size to handle the connection failure
properly.
Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
12. Disable bonding for NUS
Matter NUS should require providing a PIN code before each
pairing, so we do not want to store anything in persistent storage
and we should disable the Bluetooth LE bonding feature.
13. Disable unnecessary assert information
Limit assert information for Matter applications to file name and
file number.
Signed-off-by: Lukasz Duda <lukasz.duda@nordicsemi.no>
14. Introduce workaround to Wi-Fi connection recovery
It was observed that sometimes WPA supplicant may stuck in the
reconnection process. This change introduces a workaround and
fixes for existing recovery mechanism:
* Changed is-Recovery-Aborted approach to is-Recovery-started.
* Distinguished disconnects requested by the application from the
disconnects coming from the supplicant.
* Added scheduling recovery procedure if supplicant was not able
to re-connect to the network for given amount of time (60 s).
Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
15. Adapt WiFiManager to the new wifi_ps_config API
The wifi_ps_config has been extended in Zephyr so this patch
is need to avoid build errors.
Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
16. Integrated new Wi-Fi disconnect completed event
Integrated handling new Wi-Fi disconnect completed event,
what should fix occassional failures observed during connection
recovery.
Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
17. Fixed nRF7002 EK shield kconfig name
Due to introduction of new nRF7002 shields, the nRF7002 EK shield
kconfig name was changed and we have to align our configuration.
Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
18. [nrfconnect] Use default number of RTC channels
The default number of RTC channels on nRF5340 was increased
from 2 to 3 some time ago, but Matter applications are still
built with 2 user channels. This causes that CSL transmitter
does not work properly on Matter Thread Router devices.
19 Add a workaround to WiFi recovery
During the recovery procedure, if the net_mgmt function returns
the value "-16" the device cannot recover the WiFi network
until the reboot is called.
This workaround allows the device to try to rescan the WiFi
network even if the net_mgmt function returned an error.
This workaround works only, when the WiFi recovery mechanism
is active.
20. moved bt_fixed_passkey config to the features set
BT_FIXED_PASSKEY cannot be added to prj_release.conf file because
it causes a CMAKE warning. The config has been moved to
the Kconfig.feature file.
Fix the build warning in door-lock-server
This fixes the uninitialized variable warning appearing
when compiling the door lock app.
Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
21. Fixed nrf7002 kconfig name again
nRF7002 EK kconfig name changed once again, so we need to align
our kconfigs to that.
Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
* [zephyr] Remove device argument from SYS_INIT() callbacks.
The SYS_INIT() callback API changed in Zephyr and Matter code
alignments were needed.
* [nrfconnect] Stop using Zephyr POSIX layer
After recent changes in Zephyr, the Zephyr POSIX layer
no longer includes missing POSIX definitions from the
standard library. Given that and that the Zephyr POSIX
layer is very incomplete, it is no longer possible to
build Matter samples using that layer.
Disable Zephyr socket layer, and use NET_SOCKETS_POSIX_NAMES
which only wraps the socket functions with POSIX names.
Make sure that proper headers are included when using this
configuration.
* [nrfconnect] Removed obsolete MCUMGR SMP BT config
Replaced CONFIG_MCUMGR_SMP_BT that is no longer supported
with the CONFIG_MCUMGR_TRANSPORT_BT
* Addressed review comments
* Added CHIP_NRF_PLATFORM symbol to conditionally modify generic
Zephyr configuration
* Updated docker versions for cloud builds
* Updated sdk-zephyr toolchain version to 0.16.0 in build scripts
for nrf platform.
* Restyled by whitespace
* Restyled by clang-format
* Restyled by gn
* Fixed chef CI workflow
* Fixed compilation errors
* Fixed typo in wake event
* Removed ifdef leading to compilation errors for Darwin and Linux
and added ifdef for usleep usage that is a root cause of problems
on Zephyr.
* Fix more compilation errors
* [chef] fixes to Zephyr environment variables
1. Use Zephyr SDK toolchain.
2. Use proper shell configuration.
---------
Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
Co-authored-by: Damian Krolik <damian.krolik@nordicsemi.no>
Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml
index 42dba7c..671eb2a 100644
--- a/.github/workflows/chef.yaml
+++ b/.github/workflows/chef.yaml
@@ -35,7 +35,7 @@
if: github.actor != 'restyled-io[bot]'
container:
- image: connectedhomeip/chip-build:0.7.3
+ image: connectedhomeip/chip-build:0.7.16
options: --user root
steps:
@@ -71,7 +71,7 @@
if: github.actor != 'restyled-io[bot]'
container:
- image: connectedhomeip/chip-build-esp32:0.7.3
+ image: connectedhomeip/chip-build-esp32:0.7.16
options: --user root
steps:
@@ -107,7 +107,7 @@
if: github.actor != 'restyled-io[bot]'
container:
- image: connectedhomeip/chip-build-nrf-platform:0.7.3
+ image: connectedhomeip/chip-build-nrf-platform:0.7.16
options: --user root
steps:
diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml
index 7f66809..caba783 100644
--- a/.github/workflows/examples-nrfconnect.yaml
+++ b/.github/workflows/examples-nrfconnect.yaml
@@ -40,7 +40,7 @@
if: github.actor != 'restyled-io[bot]'
container:
- image: connectedhomeip/chip-build-nrf-platform:0.7.3
+ image: connectedhomeip/chip-build-nrf-platform:0.7.16
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
diff --git a/config/nrfconnect/.nrfconnect-recommended-revision b/config/nrfconnect/.nrfconnect-recommended-revision
index b1d18bc..8721bbc 100644
--- a/config/nrfconnect/.nrfconnect-recommended-revision
+++ b/config/nrfconnect/.nrfconnect-recommended-revision
@@ -1 +1 @@
-v2.3.0
+v2.4.0
diff --git a/config/nrfconnect/chip-module/CMakeLists.txt b/config/nrfconnect/chip-module/CMakeLists.txt
index 2511fa3..43149d2 100644
--- a/config/nrfconnect/chip-module/CMakeLists.txt
+++ b/config/nrfconnect/chip-module/CMakeLists.txt
@@ -50,21 +50,16 @@
include(${COMMON_CMAKE_SOURCE_DIR}/chip_gn.cmake)
# Prepare compiler flags
-matter_add_flags(-D_DEFAULT_SOURCE)
-
if (CHIP_CFLAGS)
matter_add_flags("${CHIP_CFLAGS}")
endif()
+matter_add_flags(-D_POSIX_C_SOURCE=200809)
+
if (CONFIG_ARM)
matter_add_cflags(--specs=nosys.specs)
endif()
-if (CONFIG_POSIX_API)
- matter_add_flags(-D_SYS__PTHREADTYPES_H_)
- matter_add_flags(-isystem${ZEPHYR_BASE}/include/zephyr/posix)
-endif()
-
if (CONFIG_NORDIC_SECURITY_BACKEND)
zephyr_include_directories($<TARGET_PROPERTY:mbedtls_external,INTERFACE_INCLUDE_DIRECTORIES>)
zephyr_include_directories($<TARGET_PROPERTY:mbedcrypto_common,INTERFACE_INCLUDE_DIRECTORIES>)
@@ -197,8 +192,12 @@
DEVICE_INFO_EXAMPLE_PROVIDER ${CONFIG_CHIP_EXAMPLE_DEVICE_INFO_PROVIDER}
GN_DEPENDENCIES kernel
)
+
set_property(GLOBAL APPEND PROPERTY ZEPHYR_INTERFACE_LIBS chip)
-target_compile_definitions(chip INTERFACE _DEFAULT_SOURCE)
+# Enable visibility of POSIX.1-2008 functions, such as strnlen
+target_compile_definitions(chip INTERFACE _POSIX_C_SOURCE=200809)
+# Make sure that kernel symbols that are only referenced by the Matter libraries are resolved.
+target_link_libraries(chip INTERFACE $<TARGET_FILE:kernel>)
if (CONFIG_CHIP_MALLOC_SYS_HEAP_OVERRIDE)
target_link_options(chip INTERFACE
diff --git a/config/nrfconnect/chip-module/Kconfig b/config/nrfconnect/chip-module/Kconfig
index 34143ed..059d511 100644
--- a/config/nrfconnect/chip-module/Kconfig
+++ b/config/nrfconnect/chip-module/Kconfig
@@ -18,6 +18,14 @@
if CHIP
+config CHIP_NRF_PLATFORM
+ bool
+ default y
+ help
+ States that the configuration uses Matter nRF platform,
+ what can be used to conditionally deviate from Zephyr generic configuration
+ for nRF platform related purposes.
+
# See config/zephyr/Kconfig for full definition
config CHIP_DEVICE_VENDOR_NAME
default "Nordic Semiconductor ASA"
@@ -94,7 +102,7 @@
config CHIP_FACTORY_DATA
bool "Factory data provider"
select ZCBOR
- select FPROTECT
+ imply FPROTECT
help
Enables the default nRF Connect factory data provider implementation that
supports reading the factory data encoded in the CBOR format from the
@@ -134,6 +142,20 @@
help
Maximum acceptable length of rotating device ID unique ID in bytes.
+config CHIP_FACTORY_DATA_WRITE_PROTECT
+ bool "Enable Factory Data write protection"
+ select FPROTECT
+ depends on CHIP_FACTORY_DATA
+ default y if CHIP_FACTORY_DATA
+ help
+ Enables the write protection of the Factory Data partition in the flash memory.
+ This is a recommended feature, but it requires the Settings partition size to be
+ a multiple of FPROTECT_BLOCK_SIZE and the Factory Data partition to be placed
+ right after the application partition in the address space (the Factory Data
+ partition offset must be equal to the last address of the application partition).
+ The second requirement is valid only when the FPROTECT_BLOCK_SIZE is bigger than
+ the flash memory page size.
+
if CHIP_FACTORY_DATA_BUILD
# Factory data definitions
diff --git a/config/nrfconnect/chip-module/Kconfig.defaults b/config/nrfconnect/chip-module/Kconfig.defaults
index bf7b494..d275d93 100644
--- a/config/nrfconnect/chip-module/Kconfig.defaults
+++ b/config/nrfconnect/chip-module/Kconfig.defaults
@@ -37,7 +37,7 @@
default 4 # debug
config LOG_DEFAULT_LEVEL
- default 2 # warning
+ default 1 # error
config CHIP_LOG_SIZE_OPTIMIZATION
default y
@@ -50,6 +50,12 @@
config ASSERT
default y
+config ASSERT_NO_COND_INFO
+ default y
+
+config ASSERT_NO_MSG_INFO
+ default y
+
config HW_STACK_PROTECTION
default y
@@ -63,9 +69,9 @@
bool
default n
-# Generic networking options
-config NET_SOCKETS_POSIX_NAMES
- default n
+config POSIX_MAX_FDS
+ int
+ default 16
# Application stack size
config MAIN_STACK_SIZE
@@ -216,6 +222,10 @@
if CHIP_WIFI
+choice WPA_SUPP_LOG_LEVEL_CHOICE
+ default WPA_SUPP_LOG_LEVEL_ERR
+endchoice
+
config NRF_WIFI_LOW_POWER
default n
@@ -223,7 +233,7 @@
default n
config SYSTEM_WORKQUEUE_STACK_SIZE
- default 2048
+ default 2560
# align these numbers to match the OpenThread config
config NET_IF_UNICAST_IPV6_ADDR_COUNT
@@ -232,9 +242,6 @@
config NET_IF_MCAST_IPV6_ADDR_COUNT
default 8
-config NET_SOCKETS_POSIX_NAMES
- default n
-
config NET_SOCKETS_POLL_MAX
default 4
@@ -436,6 +443,9 @@
if SOC_SERIES_NRF53X
+config BOOT_IMAGE_ACCESS_HOOKS
+ default y
+
config UPDATEABLE_IMAGE_NUMBER
default 2
diff --git a/config/nrfconnect/chip-module/Kconfig.features b/config/nrfconnect/chip-module/Kconfig.features
index 0501e35..84390e3 100644
--- a/config/nrfconnect/chip-module/Kconfig.features
+++ b/config/nrfconnect/chip-module/Kconfig.features
@@ -21,7 +21,7 @@
config CHIP_WIFI
bool "Enable nrfconnect Wi-Fi support"
- default y if SHIELD_NRF7002_EK || BOARD_NRF7002DK_NRF5340_CPUAPP
+ default y if SHIELD_NRF7002EK || BOARD_NRF7002DK_NRF5340_CPUAPP
select WIFI_NRF700X
select WIFI
select WPA_SUPP
@@ -73,18 +73,77 @@
endif # CHIP_SPI_NOR
+config CHIP_NUS
+ bool "Enable Nordic UART service for Matter purposes"
+ select BT_NUS
+ select BT_SMP
+ select BT_NUS_AUTHEN
+ help
+ Enables Nordic UART service (NUS) for Matter samples.
+ Using NUS service you can control a Matter sample using pre-defined BLE commands
+ and do defined operations. The CHIP NUS service can be useful to keep communication
+ with a smart home device when a connection within Matter network is lost.
+
+if CHIP_NUS
+
+# Requires providing a PIN for each pair request
+config BT_BONDABLE
+ default n
+
+config BT_RX_STACK_SIZE
+ default 1536
+
+config SYSTEM_WORKQUEUE_STACK_SIZE
+ default 2048
+
+config BT_DEVICE_APPEARANCE
+ default 833
+
+if !LOG
+
+config BT_FIXED_PASSKEY
+ default y
+
+endif
+
+config CHIP_NUS_MAX_COMMAND_LEN
+ int "Maximum length of single command in Bytes"
+ default 10
+ help
+ Maximum length of single command. This command will be send via Bluetooth LE to
+ a paired smart home device.
+
+config CHIP_NUS_FIXED_PASSKEY
+ int "Define the default passkey for NUS"
+ depends on BT_FIXED_PASSKEY
+ default 123456
+ help
+ Define the default password for pairing with the Bluetooth LE device.
+
+config CHIP_NUS_MAX_COMMANDS
+ int "Define maximum NUS commands amount"
+ default 2
+ help
+ Define the maximum number of NUS commands to declare by user.
+
+endif
+
+
config CHIP_DFU_OVER_BT_SMP
bool "Enable DFU over Bluetooth LE SMP feature set"
imply CHIP_QSPI_NOR if BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_NRF52840DK_NRF52840
imply CHIP_SPI_NOR if BOARD_NRF7002DK_NRF5340_CPUAPP
imply BOOTLOADER_MCUBOOT
select MCUMGR
- select MCUMGR_SMP_BT
- select MCUMGR_CMD_IMG_MGMT
- select MCUMGR_CMD_OS_MGMT
+ select MCUMGR_TRANSPORT_BT
+ select IMG_MANAGER
+ select STREAM_FLASH
+ select ZCBOR
+ select MCUMGR_GRP_IMG
+ select MCUMGR_GRP_OS
# Enable custom SMP request to erase settings partition.
- select MCUMGR_GRP_ZEPHYR_BASIC
- select MCUMGR_GRP_BASIC_CMD_STORAGE_ERASE
+ select MCUMGR_GRP_ZBASIC
+ select MCUMGR_GRP_ZBASIC_STORAGE_ERASE
help
Enables Device Firmware Upgrade over Bluetooth LE with SMP and configures
the set of options related to that feature.
@@ -92,10 +151,10 @@
if CHIP_DFU_OVER_BT_SMP
# MCU Manager and SMP configuration
-config MCUMGR_SMP_BT_AUTHEN
+config MCUMGR_TRANSPORT_BT_AUTHEN
default n
-config MCUMGR_BUF_COUNT
+config MCUMGR_TRANSPORT_NETBUF_COUNT
default 6
config MCUMGR_MGMT_NOTIFICATION_HOOKS
@@ -117,8 +176,8 @@
config BT_BUF_ACL_RX_SIZE
default 502
-# Increase MCUMGR_BUF_SIZE, as it must be big enough to fit MAX MTU + overhead and for single-image DFU default is 384 B
-config MCUMGR_BUF_SIZE
+# Increase MCUMGR_TRANSPORT_NETBUF_SIZE, as it must be big enough to fit MAX MTU + overhead and for single-image DFU default is 384 B
+config MCUMGR_TRANSPORT_NETBUF_SIZE
default 1024
# Increase system workqueue size, as SMP is processed within it
@@ -128,10 +187,10 @@
if SOC_SERIES_NRF53X
# Enable custom SMP request to erase settings partition.
-config MCUMGR_GRP_ZEPHYR_BASIC
+config MCUMGR_GRP_ZBASIC
default y
-config MCUMGR_GRP_BASIC_CMD_STORAGE_ERASE
+config MCUMGR_GRP_ZBASIC_STORAGE_ERASE
default y
endif # SOC_SERIES_NRF53X
diff --git a/config/nrfconnect/chip-module/Kconfig.multiprotocol_rpmsg.defaults b/config/nrfconnect/chip-module/Kconfig.multiprotocol_rpmsg.defaults
index 9fee38c..eb0b01e 100644
--- a/config/nrfconnect/chip-module/Kconfig.multiprotocol_rpmsg.defaults
+++ b/config/nrfconnect/chip-module/Kconfig.multiprotocol_rpmsg.defaults
@@ -75,8 +75,5 @@
config NRF_802154_SER_RADIO
default y
-config NRF_RTC_TIMER_USER_CHAN_COUNT
- default 2
-
config NRF_802154_ENCRYPTION
default y
diff --git a/config/zephyr/Kconfig b/config/zephyr/Kconfig
index f0e8d9e..3ea261d 100644
--- a/config/zephyr/Kconfig
+++ b/config/zephyr/Kconfig
@@ -22,7 +22,7 @@
imply REQUIRES_FULL_LIBC
imply NEWLIB_LIBC_NANO
imply CBPRINTF_LIBC_SUBSTS
- imply POSIX_API if !ARCH_POSIX
+ imply POSIX_API if !ARCH_POSIX && !CHIP_NRF_PLATFORM
imply EVENTFD if !ARCH_POSIX
imply REBOOT
imply ENTROPY_GENERATOR
@@ -30,6 +30,7 @@
imply NET_IPV6
imply NET_CONFIG_NEED_IPV6
imply NET_SOCKETS
+ imply NET_SOCKETS_POSIX_NAMES if !ARCH_POSIX && CHIP_NRF_PLATFORM
imply NETWORKING
imply HWINFO
imply FLASH
diff --git a/config/zephyr/chip-module/Kconfig.features b/config/zephyr/chip-module/Kconfig.features
index bc80009..1fa6e05 100644
--- a/config/zephyr/chip-module/Kconfig.features
+++ b/config/zephyr/chip-module/Kconfig.features
@@ -24,23 +24,23 @@
bool
default y
-config MCUMGR_CMD_IMG_MGMT
+config MCUMGR_GRP_IMG
bool
default y
-config MCUMGR_CMD_OS_MGMT
+config MCUMGR_GRP_OS
bool
default y
-config MCUMGR_SMP_BT
+config MCUMGR_TRANSPORT_BT
bool
default y
-config MCUMGR_SMP_BT_AUTHEN
+config MCUMGR_TRANSPORT_BT_AUTHEN
bool
default n
-config MCUMGR_BUF_COUNT
+config MCUMGR_TRANSPORT_NETBUF_COUNT
int
default 6
@@ -53,8 +53,8 @@
int
default 502
-# Increase MCUMGR_BUF_SIZE, as it must be big enough to fit MAX MTU + overhead and for single-image DFU default is 384 B
-config MCUMGR_BUF_SIZE
+# Increase MCUMGR_TRANSPORT_NETBUF_SIZE, as it must be big enough to fit MAX MTU + overhead and for single-image DFU default is 384 B
+config MCUMGR_TRANSPORT_NETBUF_SIZE
int
default 1024
diff --git a/examples/all-clusters-app/nrfconnect/CMakeLists.txt b/examples/all-clusters-app/nrfconnect/CMakeLists.txt
index fc50ade..6b28a6e 100644
--- a/examples/all-clusters-app/nrfconnect/CMakeLists.txt
+++ b/examples/all-clusters-app/nrfconnect/CMakeLists.txt
@@ -67,7 +67,7 @@
ZAP_FILE ${ALL_CLUSTERS_COMMON_DIR}/all-clusters-app.zap
)
-if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_SMP_BT)
+if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/OTAUtil.cpp)
endif()
diff --git a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp
index a5fbf9b..cb30872 100644
--- a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp
+++ b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp
@@ -358,7 +358,7 @@
Instance().CancelTimer();
Instance().mFunction = FunctionEvent::NoneSelected;
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
GetDFUOverSMP().StartServer();
#else
LOG_INF("Software update is disabled");
diff --git a/examples/all-clusters-app/nrfconnect/main/include/AppTask.h b/examples/all-clusters-app/nrfconnect/main/include/AppTask.h
index 4b57d1d..4db18db 100644
--- a/examples/all-clusters-app/nrfconnect/main/include/AppTask.h
+++ b/examples/all-clusters-app/nrfconnect/main/include/AppTask.h
@@ -28,7 +28,7 @@
#include <platform/nrfconnect/DeviceInstanceInfoProviderImpl.h>
#endif
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
#include "DFUOverSMP.h"
#endif
diff --git a/examples/all-clusters-minimal-app/nrfconnect/CMakeLists.txt b/examples/all-clusters-minimal-app/nrfconnect/CMakeLists.txt
index 6fdc49b..00ecc2c 100644
--- a/examples/all-clusters-minimal-app/nrfconnect/CMakeLists.txt
+++ b/examples/all-clusters-minimal-app/nrfconnect/CMakeLists.txt
@@ -65,7 +65,7 @@
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../all-clusters-common/all-clusters-minimal-app.zap
)
-if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_SMP_BT)
+if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/OTAUtil.cpp)
endif()
diff --git a/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp b/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp
index 19ce364..3307789 100644
--- a/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp
+++ b/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp
@@ -279,7 +279,7 @@
{
Instance().CancelTimer();
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
GetDFUOverSMP().StartServer();
#else
LOG_INF("Software update is disabled");
diff --git a/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h b/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h
index 9921de5..0d5a9f1 100644
--- a/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h
+++ b/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h
@@ -28,7 +28,7 @@
#include <platform/nrfconnect/DeviceInstanceInfoProviderImpl.h>
#endif
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
#include "DFUOverSMP.h"
#endif
diff --git a/examples/chef/chef.py b/examples/chef/chef.py
index b663a49..7e8de18 100755
--- a/examples/chef/chef.py
+++ b/examples/chef/chef.py
@@ -75,6 +75,8 @@
"for the vendor's SDK")
configStream = open(configFile, 'w')
config["nrfconnect"]["ZEPHYR_BASE"] = os.environ.get('ZEPHYR_BASE')
+ config["nrfconnect"]["ZEPHYR_SDK_INSTALL_DIR"] = os.environ.get(
+ 'ZEPHYR_SDK_INSTALL_DIR')
config["nrfconnect"]["TTY"] = None
config["esp32"]["IDF_PATH"] = os.environ.get('IDF_PATH')
config["esp32"]["TTY"] = None
@@ -374,9 +376,6 @@
flush_print(
f"{device_name} in CICD config but not {_DEVICE_FOLDER}!")
exit(1)
- if options.build_target == "nrfconnect":
- shell.run_cmd(
- "export GNUARMEMB_TOOLCHAIN_PATH=\"$PW_ARM_CIPD_INSTALL_DIR\"")
shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}")
command = f"./chef.py -cbr -d {device_name} -t {options.build_target}"
flush_print(f"Building {command}", with_border=True)
@@ -412,8 +411,6 @@
command += " ".join(args)
flush_print(f"Building {command}", with_border=True)
shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}")
- shell.run_cmd(
- "export GNUARMEMB_TOOLCHAIN_PATH=\"$PW_ARM_CIPD_INSTALL_DIR\"")
try:
shell.run_cmd(command)
except RuntimeError as build_fail_error:
@@ -469,11 +466,29 @@
elif options.build_target == "nrfconnect":
if config['nrfconnect']['ZEPHYR_BASE'] is None:
flush_print(
- 'Path for nrfconnect SDK was not found. Make sure nrfconnect.ZEPHYR_BASE is set on your config.yaml file')
+ 'The path for nrfconnect SDK was not found. Make sure nrfconnect.ZEPHYR_BASE is set on your config.yaml file. This is typically <NCS INSTALL PATH>/ncs/vX.X.X/zephyr')
exit(1)
- shell.run_cmd(
- f'source {config["nrfconnect"]["ZEPHYR_BASE"]}/zephyr-env.sh')
- shell.run_cmd("export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb")
+ if config['nrfconnect']['ZEPHYR_SDK_INSTALL_DIR'] is None:
+ flush_print(
+ 'The path for nrfconnect toolchain was not found. Make sure nrfconnect.ZEPHYR_SDK_INSTALL_DIR is set on your config.yaml file. This is typically <NCS INSTALL PATH>/ncs/toolchains/vX.X.X/opt/zephyr-sdk')
+ exit(1)
+ zephyr_sdk_dir = config['nrfconnect']['ZEPHYR_SDK_INSTALL_DIR']
+ shell.run_cmd("export ZEPHYR_TOOLCHAIN_VARIANT=zephyr")
+ shell.run_cmd(f"export ZEPHYR_SDK_INSTALL_DIR={zephyr_sdk_dir}")
+ shell.run_cmd(f"export ZEPHYR_BASE={config['nrfconnect']['ZEPHYR_BASE']}")
+ shell.run_cmd(f'source {config["nrfconnect"]["ZEPHYR_BASE"]}/zephyr-env.sh')
+ # QUIRK:
+ # When the Zephyr SDK is installed as a part of the NCS toolchain, the build system will use
+ # build tools from the NCS toolchain, but it will not update the PATH and LD_LIBRARY_PATH
+ # and hence the build will fail. This ideally, should be handled automatically by the NCS
+ # build system but until it is fixed, set the variables manually.
+ ncs_toolchain_dir = os.path.abspath(f"{zephyr_sdk_dir}/../..")
+ if os.path.exists(os.path.join(ncs_toolchain_dir, 'manifest.json')):
+ shell.run_cmd(f"export PATH=$PATH:{ncs_toolchain_dir}/usr/bin")
+ shell.run_cmd(f"export PATH=$PATH:{ncs_toolchain_dir}/usr/local/bin")
+ shell.run_cmd(f"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:{ncs_toolchain_dir}/usr/lib")
+ shell.run_cmd(
+ f"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:{ncs_toolchain_dir}/usr/local/lib")
elif options.build_target == "linux":
pass
elif options.build_target == "silabs-thread":
diff --git a/examples/chef/nrfconnect/CMakeLists.txt b/examples/chef/nrfconnect/CMakeLists.txt
index 4249001..c813a31 100644
--- a/examples/chef/nrfconnect/CMakeLists.txt
+++ b/examples/chef/nrfconnect/CMakeLists.txt
@@ -32,7 +32,6 @@
if(NOT ${CONFIG_DEVICE_PRODUCT_NAME} STREQUAL "")
set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME=\"${CONFIG_DEVICE_PRODUCT_NAME}\"")
endif()
-set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_PLATFORM_NRFCONNECT=1")
if(NOT ${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING} STREQUAL "")
set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING=\"${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING}\"")
endif()
@@ -76,7 +75,7 @@
${NRFCONNECT_COMMON}/app/include
)
-if (CONFIG_ENABLE_CHIP_SHELL)
+if (CONFIG_CHIP_LIB_SHELL)
target_sources(app PRIVATE
${CHEF}/shell_common/globals.cpp
${CHEF}/shell_common/cmd_misc.cpp
@@ -86,7 +85,7 @@
target_include_directories(app PRIVATE
${CHEF}/shell_common/include
)
-endif (CONFIG_ENABLE_CHIP_SHELL)
+endif()
target_sources(app PRIVATE
${CHEF}/nrfconnect/main.cpp
diff --git a/examples/chef/nrfconnect/main.cpp b/examples/chef/nrfconnect/main.cpp
index 17e207e..c415779 100644
--- a/examples/chef/nrfconnect/main.cpp
+++ b/examples/chef/nrfconnect/main.cpp
@@ -138,7 +138,7 @@
ChipLogError(AppServer, "OpenBasicCommissioningWindow() failed");
}
-#if CONFIG_ENABLE_CHIP_SHELL || CONFIG_CHIP_LIB_SHELL
+#if CONFIG_CHIP_LIB_SHELL
int rc = Engine::Root().Init();
if (rc != 0)
{
@@ -154,7 +154,7 @@
cmd_app_server_init();
#endif
-#if CONFIG_ENABLE_CHIP_SHELL || CONFIG_CHIP_LIB_SHELL
+#if CONFIG_CHIP_LIB_SHELL
Engine::Root().RunMainLoop();
#endif
diff --git a/examples/light-switch-app/nrfconnect/CMakeLists.txt b/examples/light-switch-app/nrfconnect/CMakeLists.txt
index 7512e45..2e71907 100644
--- a/examples/light-switch-app/nrfconnect/CMakeLists.txt
+++ b/examples/light-switch-app/nrfconnect/CMakeLists.txt
@@ -62,11 +62,11 @@
${NRFCONNECT_COMMON}/util/LEDWidget.cpp)
-if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_SMP_BT)
+if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/OTAUtil.cpp)
endif()
-if(CONFIG_MCUMGR_SMP_BT)
+if(CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUOverSMP.cpp)
endif()
diff --git a/examples/light-switch-app/nrfconnect/main/AppTask.cpp b/examples/light-switch-app/nrfconnect/main/AppTask.cpp
index 9bc8422..405664a 100644
--- a/examples/light-switch-app/nrfconnect/main/AppTask.cpp
+++ b/examples/light-switch-app/nrfconnect/main/AppTask.cpp
@@ -188,7 +188,7 @@
k_timer_user_data_set(&sFunctionTimer, this);
// Initialize DFU
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
GetDFUOverSMP().Init();
GetDFUOverSMP().ConfirmNewImage();
#endif
@@ -300,7 +300,7 @@
Instance().CancelTimer(Timer::Function);
Instance().mFunction = FunctionEvent::NoneSelected;
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
GetDFUOverSMP().StartServer();
UpdateStatusLED();
#else
diff --git a/examples/light-switch-app/nrfconnect/main/include/AppTask.h b/examples/light-switch-app/nrfconnect/main/include/AppTask.h
index a40c5e8..240ac58 100644
--- a/examples/light-switch-app/nrfconnect/main/include/AppTask.h
+++ b/examples/light-switch-app/nrfconnect/main/include/AppTask.h
@@ -29,7 +29,7 @@
#include <platform/nrfconnect/DeviceInstanceInfoProviderImpl.h>
#endif
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
#include "DFUOverSMP.h"
#endif
diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt
index 94996c7..bf378bc 100644
--- a/examples/lighting-app/nrfconnect/CMakeLists.txt
+++ b/examples/lighting-app/nrfconnect/CMakeLists.txt
@@ -67,11 +67,11 @@
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../lighting-common/lighting-app.zap
)
-if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_SMP_BT)
+if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/OTAUtil.cpp)
endif()
-if(CONFIG_MCUMGR_SMP_BT)
+if(CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUOverSMP.cpp)
endif()
diff --git a/examples/lighting-app/nrfconnect/main/AppTask.cpp b/examples/lighting-app/nrfconnect/main/AppTask.cpp
index 5ff0c6a..e16230e 100644
--- a/examples/lighting-app/nrfconnect/main/AppTask.cpp
+++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp
@@ -197,7 +197,7 @@
k_timer_init(&sFunctionTimer, &AppTask::FunctionTimerTimeoutCallback, nullptr);
k_timer_user_data_set(&sFunctionTimer, this);
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
// Initialize DFU over SMP
GetDFUOverSMP().Init();
GetDFUOverSMP().ConfirmNewImage();
@@ -474,7 +474,7 @@
Instance().CancelTimer();
Instance().mFunction = FunctionEvent::NoneSelected;
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
GetDFUOverSMP().StartServer();
#else
LOG_INF("Software update is disabled");
diff --git a/examples/lighting-app/nrfconnect/main/include/AppTask.h b/examples/lighting-app/nrfconnect/main/include/AppTask.h
index 51df03f..37be9a0 100644
--- a/examples/lighting-app/nrfconnect/main/include/AppTask.h
+++ b/examples/lighting-app/nrfconnect/main/include/AppTask.h
@@ -34,7 +34,7 @@
#include "Rpc.h"
#endif
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
#include "DFUOverSMP.h"
#endif
diff --git a/examples/lock-app/nrfconnect/CMakeLists.txt b/examples/lock-app/nrfconnect/CMakeLists.txt
index 4be8f99..e1b3e8f 100644
--- a/examples/lock-app/nrfconnect/CMakeLists.txt
+++ b/examples/lock-app/nrfconnect/CMakeLists.txt
@@ -64,11 +64,11 @@
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../lock-common/lock-app.zap
)
-if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_SMP_BT)
+if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/OTAUtil.cpp)
endif()
-if(CONFIG_MCUMGR_SMP_BT)
+if(CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUOverSMP.cpp)
endif()
diff --git a/examples/lock-app/nrfconnect/main/AppTask.cpp b/examples/lock-app/nrfconnect/main/AppTask.cpp
index 8acf7d6..aa65236 100644
--- a/examples/lock-app/nrfconnect/main/AppTask.cpp
+++ b/examples/lock-app/nrfconnect/main/AppTask.cpp
@@ -179,7 +179,7 @@
k_timer_init(&sFunctionTimer, &AppTask::FunctionTimerTimeoutCallback, nullptr);
k_timer_user_data_set(&sFunctionTimer, this);
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
// Initialize DFU over SMP
GetDFUOverSMP().Init();
GetDFUOverSMP().ConfirmNewImage();
@@ -433,7 +433,7 @@
Instance().CancelTimer();
Instance().mFunction = FunctionEvent::NoneSelected;
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
GetDFUOverSMP().StartServer();
#else
LOG_INF("Software update is disabled");
diff --git a/examples/lock-app/nrfconnect/main/include/AppTask.h b/examples/lock-app/nrfconnect/main/include/AppTask.h
index 76738ac..01d1536 100644
--- a/examples/lock-app/nrfconnect/main/include/AppTask.h
+++ b/examples/lock-app/nrfconnect/main/include/AppTask.h
@@ -31,7 +31,7 @@
#include <platform/nrfconnect/DeviceInstanceInfoProviderImpl.h>
#endif
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
#include "DFUOverSMP.h"
#endif
diff --git a/examples/pigweed-app/nrfconnect/prj.conf b/examples/pigweed-app/nrfconnect/prj.conf
index bb86ae1..fad3772 100644
--- a/examples/pigweed-app/nrfconnect/prj.conf
+++ b/examples/pigweed-app/nrfconnect/prj.conf
@@ -20,9 +20,6 @@
# samples. This file should contain only options specific for this sample
# or overrides of default values.
-# Export POSIX names for functions implementing a subset of POSIX standard in Zephyr
-CONFIG_POSIX_API=y
-
# Add support for LEDs and buttons on Nordic development kits
CONFIG_DK_LIBRARY=y
diff --git a/examples/platform/nrfconnect/util/DFUOverSMP.cpp b/examples/platform/nrfconnect/util/DFUOverSMP.cpp
index 1720a58..ac59171 100644
--- a/examples/platform/nrfconnect/util/DFUOverSMP.cpp
+++ b/examples/platform/nrfconnect/util/DFUOverSMP.cpp
@@ -17,7 +17,7 @@
#include "DFUOverSMP.h"
-#if !defined(CONFIG_MCUMGR_SMP_BT) || !defined(CONFIG_MCUMGR_CMD_IMG_MGMT) || !defined(CONFIG_MCUMGR_CMD_OS_MGMT)
+#if !defined(CONFIG_MCUMGR_TRANSPORT_BT) || !defined(CONFIG_MCUMGR_GRP_IMG) || !defined(CONFIG_MCUMGR_GRP_OS)
#error "DFUOverSMP requires MCUMGR module configs enabled"
#endif
diff --git a/examples/pump-app/nrfconnect/CMakeLists.txt b/examples/pump-app/nrfconnect/CMakeLists.txt
index 59ac365..94ae918 100644
--- a/examples/pump-app/nrfconnect/CMakeLists.txt
+++ b/examples/pump-app/nrfconnect/CMakeLists.txt
@@ -63,10 +63,10 @@
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../pump-common/pump-app.zap
)
-if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_SMP_BT)
+if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/OTAUtil.cpp)
endif()
-if(CONFIG_MCUMGR_SMP_BT)
+if(CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUOverSMP.cpp)
endif()
diff --git a/examples/pump-app/nrfconnect/main/AppTask.cpp b/examples/pump-app/nrfconnect/main/AppTask.cpp
index 1a45d22..9c75c54 100644
--- a/examples/pump-app/nrfconnect/main/AppTask.cpp
+++ b/examples/pump-app/nrfconnect/main/AppTask.cpp
@@ -154,7 +154,7 @@
k_timer_init(&sFunctionTimer, &AppTask::FunctionTimerTimeoutCallback, nullptr);
k_timer_user_data_set(&sFunctionTimer, this);
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
// Initialize DFU over SMP
GetDFUOverSMP().Init();
GetDFUOverSMP().ConfirmNewImage();
@@ -342,7 +342,7 @@
{
Instance().CancelTimer();
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
GetDFUOverSMP().StartServer();
#else
LOG_INF("Software update is disabled");
diff --git a/examples/pump-app/nrfconnect/main/include/AppTask.h b/examples/pump-app/nrfconnect/main/include/AppTask.h
index bcf2d1e..fb2fe2c 100644
--- a/examples/pump-app/nrfconnect/main/include/AppTask.h
+++ b/examples/pump-app/nrfconnect/main/include/AppTask.h
@@ -31,7 +31,7 @@
#include <platform/nrfconnect/DeviceInstanceInfoProviderImpl.h>
#endif
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
#include "DFUOverSMP.h"
#endif
diff --git a/examples/pump-controller-app/nrfconnect/CMakeLists.txt b/examples/pump-controller-app/nrfconnect/CMakeLists.txt
index 3534eb8..8a5b8f4 100644
--- a/examples/pump-controller-app/nrfconnect/CMakeLists.txt
+++ b/examples/pump-controller-app/nrfconnect/CMakeLists.txt
@@ -63,10 +63,10 @@
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../pump-controller-common/pump-controller-app.zap
)
-if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_SMP_BT)
+if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/OTAUtil.cpp)
endif()
-if(CONFIG_MCUMGR_SMP_BT)
+if(CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUOverSMP.cpp)
endif()
diff --git a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp
index 6a8954c..9580af6 100644
--- a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp
+++ b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp
@@ -152,7 +152,7 @@
k_timer_init(&sFunctionTimer, &AppTask::FunctionTimerTimeoutCallback, nullptr);
k_timer_user_data_set(&sFunctionTimer, this);
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
// Initialize DFU over SMP
GetDFUOverSMP().Init();
GetDFUOverSMP().ConfirmNewImage();
@@ -339,7 +339,7 @@
{
Instance().CancelTimer();
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
GetDFUOverSMP().StartServer();
#else
LOG_INF("Software update is disabled");
diff --git a/examples/pump-controller-app/nrfconnect/main/include/AppTask.h b/examples/pump-controller-app/nrfconnect/main/include/AppTask.h
index 02e7f0a..8ca4a69 100644
--- a/examples/pump-controller-app/nrfconnect/main/include/AppTask.h
+++ b/examples/pump-controller-app/nrfconnect/main/include/AppTask.h
@@ -31,7 +31,7 @@
#include <platform/nrfconnect/DeviceInstanceInfoProviderImpl.h>
#endif
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
#include "DFUOverSMP.h"
#endif
diff --git a/examples/window-app/nrfconnect/CMakeLists.txt b/examples/window-app/nrfconnect/CMakeLists.txt
index 21bb4ca..441adc7 100644
--- a/examples/window-app/nrfconnect/CMakeLists.txt
+++ b/examples/window-app/nrfconnect/CMakeLists.txt
@@ -66,11 +66,11 @@
ZAP_FILE ${WIN_APP_COMMON_DIR}/window-app.zap
)
-if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_SMP_BT)
+if(CONFIG_CHIP_OTA_REQUESTOR OR CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/OTAUtil.cpp)
endif()
-if(CONFIG_MCUMGR_SMP_BT)
+if(CONFIG_MCUMGR_TRANSPORT_BT)
target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUOverSMP.cpp)
endif()
diff --git a/examples/window-app/nrfconnect/main/AppTask.cpp b/examples/window-app/nrfconnect/main/AppTask.cpp
index fca63e3..38e20fd 100644
--- a/examples/window-app/nrfconnect/main/AppTask.cpp
+++ b/examples/window-app/nrfconnect/main/AppTask.cpp
@@ -159,7 +159,7 @@
k_timer_init(&sFunctionTimer, &AppTask::FunctionTimerTimeoutCallback, nullptr);
k_timer_user_data_set(&sFunctionTimer, this);
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
// Initialize DFU over SMP
GetDFUOverSMP().Init();
GetDFUOverSMP().ConfirmNewImage();
@@ -367,7 +367,7 @@
{
Instance().CancelTimer();
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
GetDFUOverSMP().StartServer();
#else
LOG_INF("Software update is disabled");
diff --git a/examples/window-app/nrfconnect/main/include/AppTask.h b/examples/window-app/nrfconnect/main/include/AppTask.h
index 28a7331..64410f9 100644
--- a/examples/window-app/nrfconnect/main/include/AppTask.h
+++ b/examples/window-app/nrfconnect/main/include/AppTask.h
@@ -28,7 +28,7 @@
#include <platform/nrfconnect/DeviceInstanceInfoProviderImpl.h>
#endif
-#ifdef CONFIG_MCUMGR_SMP_BT
+#ifdef CONFIG_MCUMGR_TRANSPORT_BT
#include "DFUOverSMP.h"
#endif
diff --git a/integrations/cloudbuild/build-all.yaml b/integrations/cloudbuild/build-all.yaml
index 38430a4..8920348 100644
--- a/integrations/cloudbuild/build-all.yaml
+++ b/integrations/cloudbuild/build-all.yaml
@@ -6,7 +6,7 @@
- "--init"
- "--recursive"
id: Submodules
- - name: "connectedhomeip/chip-build-vscode:0.7.3"
+ - name: "connectedhomeip/chip-build-vscode:0.7.16"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
@@ -21,7 +21,7 @@
path: /pwenv
timeout: 900s
- - name: "connectedhomeip/chip-build-vscode:0.7.3"
+ - name: "connectedhomeip/chip-build-vscode:0.7.16"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
@@ -84,7 +84,7 @@
--target k32w-shell
build
--create-archives /workspace/artifacts/
- - name: "connectedhomeip/chip-build-vscode:0.7.3"
+ - name: "connectedhomeip/chip-build-vscode:0.7.16"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
diff --git a/integrations/cloudbuild/chef.yaml b/integrations/cloudbuild/chef.yaml
index 4db1c7a..bde0b7a 100644
--- a/integrations/cloudbuild/chef.yaml
+++ b/integrations/cloudbuild/chef.yaml
@@ -1,5 +1,5 @@
steps:
- - name: "connectedhomeip/chip-build-vscode:0.7.3"
+ - name: "connectedhomeip/chip-build-vscode:0.7.16"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
@@ -12,7 +12,7 @@
path: /pwenv
timeout: 2700s
- - name: "connectedhomeip/chip-build-vscode:0.7.3"
+ - name: "connectedhomeip/chip-build-vscode:0.7.16"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
@@ -26,7 +26,7 @@
- name: pwenv
path: /pwenv
- - name: "connectedhomeip/chip-build-vscode:0.7.3"
+ - name: "connectedhomeip/chip-build-vscode:0.7.16"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
diff --git a/integrations/cloudbuild/smoke-test.yaml b/integrations/cloudbuild/smoke-test.yaml
index e951a4d..89a0df2 100644
--- a/integrations/cloudbuild/smoke-test.yaml
+++ b/integrations/cloudbuild/smoke-test.yaml
@@ -1,5 +1,5 @@
steps:
- - name: "connectedhomeip/chip-build-vscode:0.7.3"
+ - name: "connectedhomeip/chip-build-vscode:0.7.16"
entrypoint: "bash"
args:
- "-c"
@@ -22,7 +22,7 @@
path: /pwenv
timeout: 900s
- - name: "connectedhomeip/chip-build-vscode:0.7.3"
+ - name: "connectedhomeip/chip-build-vscode:0.7.16"
id: ESP32
env:
- PW_ENVIRONMENT_ROOT=/pwenv
@@ -42,7 +42,7 @@
volumes:
- name: pwenv
path: /pwenv
- - name: "connectedhomeip/chip-build-vscode:0.7.3"
+ - name: "connectedhomeip/chip-build-vscode:0.7.16"
id: NRFConnect
env:
- PW_ENVIRONMENT_ROOT=/pwenv
@@ -63,7 +63,7 @@
- name: pwenv
path: /pwenv
- - name: "connectedhomeip/chip-build-vscode:0.7.3"
+ - name: "connectedhomeip/chip-build-vscode:0.7.16"
id: EFR32
env:
- PW_ENVIRONMENT_ROOT=/pwenv
@@ -85,7 +85,7 @@
- name: pwenv
path: /pwenv
- - name: "connectedhomeip/chip-build-vscode:0.7.3"
+ - name: "connectedhomeip/chip-build-vscode:0.7.16"
id: Linux
env:
- PW_ENVIRONMENT_ROOT=/pwenv
@@ -143,7 +143,7 @@
- name: pwenv
path: /pwenv
- - name: "connectedhomeip/chip-build-vscode:0.7.3"
+ - name: "connectedhomeip/chip-build-vscode:0.7.16"
id: Android
env:
- PW_ENVIRONMENT_ROOT=/pwenv
diff --git a/scripts/build/builders/nrf.py b/scripts/build/builders/nrf.py
index 6357a1e..d699d60 100644
--- a/scripts/build/builders/nrf.py
+++ b/scripts/build/builders/nrf.py
@@ -161,7 +161,7 @@
zephyr_base = os.environ['ZEPHYR_BASE']
nrfconnect_sdk = os.path.dirname(zephyr_base)
zephyr_sdk_dir = os.environ.get('ZEPHYR_SDK_INSTALL_DIR') or os.path.join(
- os.environ['NRF5_TOOLS_ROOT'], 'zephyr-sdk-0.15.2')
+ os.environ['NRF5_TOOLS_ROOT'], 'zephyr-sdk-0.16.0')
# NRF builds will both try to change .west/config in nrfconnect and
# overall perform a git fetch on that location
diff --git a/scripts/examples/nrfconnect_example.sh b/scripts/examples/nrfconnect_example.sh
index 072ecad..db1c850 100755
--- a/scripts/examples/nrfconnect_example.sh
+++ b/scripts/examples/nrfconnect_example.sh
@@ -44,7 +44,7 @@
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
if [[ -z "$ZEPHYR_SDK_INSTALL_DIR" && -n "$NRF5_TOOLS_ROOT" ]]; then
- export ZEPHYR_SDK_INSTALL_DIR="$NRF5_TOOLS_ROOT"/zephyr-sdk-0.15.2
+ export ZEPHYR_SDK_INSTALL_DIR="$NRF5_TOOLS_ROOT"/zephyr-sdk-0.16.0
fi
# Set ccache base directory to improve the cache hit ratio
diff --git a/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py b/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py
index c013bbb..6c2af9d 100644
--- a/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py
+++ b/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py
@@ -545,13 +545,13 @@
log.error(("Requested verification of the JSON file using jsonschema, but the module is not installed. \n"
"Install only the module by invoking: pip3 install jsonschema \n"
"Alternatively, install it with all dependencies for Matter by invoking: pip3 install "
- "-r ./scripts/requirements.nrfconnect.txt from the Matter root directory."))
+ "-r ./scripts/setup/requirements.nrfconnect.txt from the Matter root directory."))
return
if args.generate_onboarding and no_onboarding_modules:
log.error(("Requested generation of onboarding codes, but the some modules are not installed. \n"
"Install all dependencies for Matter by invoking: pip3 install "
- "-r ./scripts/requirements.nrfconnect.txt from the Matter root directory."))
+ "-r ./scripts/setup/requirements.nrfconnect.txt from the Matter root directory."))
return
generator = FactoryDataGenerator(args)
diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h
index 88d98ec..70b382f 100644
--- a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h
+++ b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h
@@ -26,7 +26,14 @@
#include <platform/CHIPDeviceConfig.h>
#include <platform/internal/GenericPlatformManagerImpl.h>
+#if CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS
#include <sys/select.h>
+#endif
+
+#if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
+#include <zephyr/net/socket.h>
+#endif
+
#include <zephyr/kernel.h>
namespace chip {
diff --git a/src/inet/IPAddress-StringFuncts.cpp b/src/inet/IPAddress-StringFuncts.cpp
index 1f15e05..12beec2 100644
--- a/src/inet/IPAddress-StringFuncts.cpp
+++ b/src/inet/IPAddress-StringFuncts.cpp
@@ -34,7 +34,7 @@
#include <inet/IPAddress.h>
#include <lib/support/CodeUtils.h>
-#if CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
+#if CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
#include <arpa/inet.h>
#endif
diff --git a/src/inet/IPAddress.h b/src/inet/IPAddress.h
index 661d0f8..c97f25d 100644
--- a/src/inet/IPAddress.h
+++ b/src/inet/IPAddress.h
@@ -56,14 +56,18 @@
#include <openthread/ip6.h>
#endif // CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
-#if CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
+#if CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
#include <net/if.h>
#include <netinet/in.h>
-#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
+#endif // CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
-#if CHIP_SYSTEM_CONFIG_USE_SOCKETS
+#if CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS
#include <sys/socket.h>
-#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS
+#endif // CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS
+
+#if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
+#include <zephyr/net/socket.h>
+#endif // CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT && INET_CONFIG_ENABLE_IPV4
#error Forbidden : native Open Thread implementation with IPV4 enabled
diff --git a/src/inet/UDPEndPointImplSockets.cpp b/src/inet/UDPEndPointImplSockets.cpp
index 6c85906..5c9748d 100644
--- a/src/inet/UDPEndPointImplSockets.cpp
+++ b/src/inet/UDPEndPointImplSockets.cpp
@@ -30,14 +30,20 @@
#include <lib/support/SafeInt.h>
#include <lib/support/logging/CHIPLogging.h>
+#if CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif // HAVE_SYS_SOCKET_H
-
-#include <cerrno>
#include <net/if.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
+#endif // CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS
+
+#if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
+#include <zephyr/net/socket.h>
+#endif // CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
+
+#include <cerrno>
#include <unistd.h>
#include <utility>
diff --git a/src/inet/ZephyrSocket.h b/src/inet/ZephyrSocket.h
index 56cc9dc..93e4c05 100644
--- a/src/inet/ZephyrSocket.h
+++ b/src/inet/ZephyrSocket.h
@@ -23,7 +23,13 @@
#pragma once
-#include <sys/socket.h>
+#if CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS
+#include <sys/select.h>
+#endif
+
+#if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
+#include <zephyr/net/socket.h>
+#endif
static inline ssize_t recvmsg(int sock, struct msghdr * msg, int flags)
{
diff --git a/src/inet/arpa-inet-compatibility.h b/src/inet/arpa-inet-compatibility.h
index 56d9121..ce4f2f9 100644
--- a/src/inet/arpa-inet-compatibility.h
+++ b/src/inet/arpa-inet-compatibility.h
@@ -20,7 +20,7 @@
#include <system/SystemConfig.h>
-#if CHIP_SYSTEM_CONFIG_USE_SOCKETS
+#if CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS
#include <arpa/inet.h>
#else // !CHIP_SYSTEM_CONFIG_USE_SOCKETS
diff --git a/src/lib/shell/MainLoopZephyr.cpp b/src/lib/shell/MainLoopZephyr.cpp
index 5308006..d106bfa 100644
--- a/src/lib/shell/MainLoopZephyr.cpp
+++ b/src/lib/shell/MainLoopZephyr.cpp
@@ -28,11 +28,8 @@
chip::Shell::streamer_set_shell(shell);
return (Engine::Root().ExecCommand(argc - 1, argv + 1) == CHIP_NO_ERROR) ? 0 : -ENOEXEC;
}
-#ifdef CONFIG_BOARD_TLSR9518ADK80D
-static int RegisterCommands(void)
-#else
-static int RegisterCommands(const struct device * dev)
-#endif /* CONFIG_BOARD_TLSR9518ADK80D */
+
+static int RegisterCommands()
{
Engine::Root().RegisterDefaultCommands();
return 0;
diff --git a/src/platform/Zephyr/BLEAdvertisingArbiter.cpp b/src/platform/Zephyr/BLEAdvertisingArbiter.cpp
index 24f7b27..29f5516 100644
--- a/src/platform/Zephyr/BLEAdvertisingArbiter.cpp
+++ b/src/platform/Zephyr/BLEAdvertisingArbiter.cpp
@@ -38,6 +38,8 @@
// Notify application about stopped advertising if the callback has been provided
void NotifyAdvertisingStopped(const sys_snode_t * node)
{
+ VerifyOrReturn(node);
+
const Request & request = ToRequest(node);
if (request.onStopped != nullptr)
diff --git a/src/platform/Zephyr/SysHeapMalloc.cpp b/src/platform/Zephyr/SysHeapMalloc.cpp
index 1a80fad..d4f65b0 100644
--- a/src/platform/Zephyr/SysHeapMalloc.cpp
+++ b/src/platform/Zephyr/SysHeapMalloc.cpp
@@ -67,7 +67,7 @@
}
}
-int initHeap(const device *)
+int initHeap()
{
sys_heap_init(&sHeap, sHeapMemory, sizeof(sHeapMemory));
return 0;
diff --git a/src/platform/nrfconnect/BUILD.gn b/src/platform/nrfconnect/BUILD.gn
index 7b1a887..65167ac 100644
--- a/src/platform/nrfconnect/BUILD.gn
+++ b/src/platform/nrfconnect/BUILD.gn
@@ -97,6 +97,7 @@
sources += [
"../Zephyr/InetUtils.cpp",
"../Zephyr/InetUtils.h",
+ "OTAImageProcessorImplWiFi.h",
"wifi/ConnectivityManagerImplWiFi.cpp",
"wifi/ConnectivityManagerImplWiFi.h",
"wifi/NrfWiFiDriver.cpp",
diff --git a/src/platform/nrfconnect/FactoryDataProvider.h b/src/platform/nrfconnect/FactoryDataProvider.h
index 368ec95..15dae3a 100644
--- a/src/platform/nrfconnect/FactoryDataProvider.h
+++ b/src/platform/nrfconnect/FactoryDataProvider.h
@@ -40,11 +40,43 @@
return CHIP_NO_ERROR;
}
+#ifdef CONFIG_CHIP_FACTORY_DATA_WRITE_PROTECT
+#define TO_STR_IMPL(x) #x
+#define TO_STR(x) TO_STR_IMPL(x)
+ // These two helpers allows to get the factory data memory block which shall be protected with fprotect, so that:
+ // 1) it is aligned to the multiple of CONFIG_FPROTECT_BLOCK_SIZE (which differs between nRF families)
+ // 2) it does not exceed the settings partition start address
+ // Note that this block can overlap with app partition but this is not a problem since we do not aim to modify
+ // the application code at runtime anyway.
+ constexpr size_t FactoryDataBlockBegin()
+ {
+ // calculate the nearest multiple of CONFIG_FPROTECT_BLOCK_SIZE smaller than PM_FACTORY_DATA_ADDRESS
+ return PM_FACTORY_DATA_ADDRESS & (-CONFIG_FPROTECT_BLOCK_SIZE);
+ }
+
+ constexpr size_t FactoryDataBlockSize()
+ {
+ // calculate the factory data end address rounded up to the nearest multiple of CONFIG_FPROTECT_BLOCK_SIZE
+ // and make sure we do not overlap with settings partition
+ constexpr size_t kFactoryDataBlockEnd =
+ (PM_FACTORY_DATA_ADDRESS + PM_FACTORY_DATA_SIZE + CONFIG_FPROTECT_BLOCK_SIZE - 1) & (-CONFIG_FPROTECT_BLOCK_SIZE);
+ static_assert(kFactoryDataBlockEnd <= PM_SETTINGS_STORAGE_ADDRESS,
+ "FPROTECT memory block, which contains factory data"
+ "partition overlaps with the settings partition."
+ "Probably your settings partition size is not a multiple"
+ "of the atomic FPROTECT block size of " TO_STR(CONFIG_FPROTECT_BLOCK_SIZE) "kB");
+ return kFactoryDataBlockEnd - FactoryDataBlockBegin();
+ }
+#undef TO_STR
+#undef TO_STR_IMPL
CHIP_ERROR ProtectFactoryDataPartitionAgainstWrite()
{
- int ret = fprotect_area(PM_FACTORY_DATA_ADDRESS, PM_FACTORY_DATA_SIZE);
+ int ret = fprotect_area(FactoryDataBlockBegin(), FactoryDataBlockSize());
return System::MapErrorZephyr(ret);
}
+#else
+ CHIP_ERROR ProtectFactoryDataPartitionAgainstWrite() { return CHIP_ERROR_NOT_IMPLEMENTED; }
+#endif
};
struct ExternalFlashFactoryData
diff --git a/src/platform/nrfconnect/OTAImageProcessorImplWiFi.h b/src/platform/nrfconnect/OTAImageProcessorImplWiFi.h
new file mode 100644
index 0000000..f746531
--- /dev/null
+++ b/src/platform/nrfconnect/OTAImageProcessorImplWiFi.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2023 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include "OTAImageProcessorImpl.h"
+#include "wifi/WiFiManager.h"
+
+namespace chip {
+
+namespace DeviceLayer {
+
+class OTAImageProcessorImplWiFi : public OTAImageProcessorImpl
+{
+public:
+ explicit OTAImageProcessorImplWiFi(ExternalFlashManager * flashHandler = nullptr) : OTAImageProcessorImpl(flashHandler) {}
+
+ CHIP_ERROR PrepareDownload() override
+ {
+ CHIP_ERROR err = WiFiManager::Instance().SetLowPowerMode(false);
+ if (err == CHIP_NO_ERROR)
+ {
+ return OTAImageProcessorImpl::PrepareDownload();
+ }
+ return err;
+ };
+
+ CHIP_ERROR Abort() override
+ {
+ CHIP_ERROR err = OTAImageProcessorImpl::Abort();
+ if (err == CHIP_NO_ERROR)
+ {
+ return WiFiManager::Instance().SetLowPowerMode(true);
+ }
+ return err;
+ };
+
+ CHIP_ERROR Apply() override
+ {
+ CHIP_ERROR err = OTAImageProcessorImpl::Apply();
+ if (err == CHIP_NO_ERROR)
+ {
+ return WiFiManager::Instance().SetLowPowerMode(true);
+ }
+ return err;
+ };
+};
+
+} // namespace DeviceLayer
+} // namespace chip
diff --git a/src/platform/nrfconnect/wifi/WiFiManager.cpp b/src/platform/nrfconnect/wifi/WiFiManager.cpp
index d8e60ba..6819251 100644
--- a/src/platform/nrfconnect/wifi/WiFiManager.cpp
+++ b/src/platform/nrfconnect/wifi/WiFiManager.cpp
@@ -138,11 +138,12 @@
{ WIFI_STATE_GROUP_HANDSHAKE, WiFiManager::StationStatus::PROVISIONING },
{ WIFI_STATE_COMPLETED, WiFiManager::StationStatus::FULLY_PROVISIONED } });
-const Map<uint32_t, WiFiManager::NetEventHandler, 4>
+const Map<uint32_t, WiFiManager::NetEventHandler, 5>
WiFiManager::sEventHandlerMap({ { NET_EVENT_WIFI_SCAN_RESULT, WiFiManager::ScanResultHandler },
{ NET_EVENT_WIFI_SCAN_DONE, WiFiManager::ScanDoneHandler },
{ NET_EVENT_WIFI_CONNECT_RESULT, WiFiManager::ConnectHandler },
- { NET_EVENT_WIFI_DISCONNECT_RESULT, WiFiManager::DisconnectHandler } });
+ { NET_EVENT_WIFI_DISCONNECT_RESULT, WiFiManager::NetworkDrivenDisconnectHandler },
+ { NET_EVENT_WIFI_DISCONNECT_COMPLETE, WiFiManager::ApplicationDrivenDisconnectHandler } });
void WiFiManager::WifiMgmtEventHandler(net_mgmt_event_callback * cb, uint32_t mgmtEvent, net_if * iface)
{
@@ -205,10 +206,32 @@
mCachedWiFiState = mWiFiState;
mWiFiState = WIFI_STATE_SCANNING;
mSsidFound = false;
+ mRecoveryArmed = true;
+ // TODO Workaround for recovery mechanism to wait before the next scan request until the WiFi supplicant is not busy.
+ static bool workaroundDone;
- if (net_mgmt(NET_REQUEST_WIFI_SCAN, iface, NULL, 0))
+ int ret = net_mgmt(NET_REQUEST_WIFI_SCAN, iface, NULL, 0);
+
+ if (ret)
{
- ChipLogError(DeviceLayer, "Scan request failed");
+ ChipLogError(DeviceLayer, "Scan request failed %d", ret);
+ if (ret == -EBUSY && !workaroundDone)
+ {
+ // TODO Wi-Fi driver returned an error during recovery.
+ // As a workaround schedule the recovery timer one more time in WifiSupplicantWorkaroundTime time.
+ // This allows the device to run the Scan method without
+ // rebooting when the "Device or resource busy" error occurs.
+ DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(kWifiSupplicantWorkaroundTime), Recover, nullptr);
+ workaroundDone = true;
+ return CHIP_NO_ERROR;
+ }
+ else
+ {
+ // TODO The workaround has not worked, so reboot the device
+ ChipLogError(DeviceLayer, "WiFi driver does not respond, resetting the device...");
+ workaroundDone = false;
+ PlatformMgr().Shutdown();
+ }
return CHIP_ERROR_INTERNAL;
}
@@ -250,10 +273,12 @@
net_if * iface = InetUtils::GetInterface();
VerifyOrReturnError(nullptr != iface, CHIP_ERROR_INTERNAL);
- int status = net_mgmt(NET_REQUEST_WIFI_DISCONNECT, iface, NULL, 0);
+ mApplicationDisconnectRequested = true;
+ int status = net_mgmt(NET_REQUEST_WIFI_DISCONNECT, iface, NULL, 0);
if (status)
{
+ mApplicationDisconnectRequested = false;
if (status == -EALREADY)
{
ChipLogDetail(DeviceLayer, "Already disconnected");
@@ -387,15 +412,21 @@
// Internal scan is supposed to be followed by a connection request if the SSID has been found
if (Instance().mInternalScan)
{
- if (!Instance().mSsidFound && !Instance().mRecoveryTimerAborted)
+ if (Instance().mRecoveryArmed)
{
- ChipLogProgress(DeviceLayer, "No requested SSID found");
- auto currentTimeout = Instance().CalculateNextRecoveryTime();
- ChipLogProgress(DeviceLayer, "Starting connection recover: re-scanning... (next attempt in %d ms)",
- currentTimeout.count());
- Instance().mRecoveryTimerAborted = false;
- DeviceLayer::SystemLayer().StartTimer(currentTimeout, Recover, nullptr);
- return;
+ if (!Instance().mSsidFound)
+ {
+ ChipLogProgress(DeviceLayer, "No requested SSID found");
+ auto currentTimeout = Instance().CalculateNextRecoveryTime();
+ ChipLogProgress(DeviceLayer, "Starting connection recover: re-scanning... (next attempt in %d ms)",
+ currentTimeout.count());
+ DeviceLayer::SystemLayer().StartTimer(currentTimeout, Recover, nullptr);
+ return;
+ }
+ else
+ {
+ Instance().AbortConnectionRecovery();
+ }
}
Instance().mWiFiState = WIFI_STATE_ASSOCIATING;
@@ -412,8 +443,8 @@
Instance().mWiFiState = WIFI_STATE_DISCONNECTED;
return;
}
- ChipLogProgress(DeviceLayer, "Connection to %*s requested", Instance().mWiFiParams.mParams.ssid_length,
- Instance().mWiFiParams.mParams.ssid);
+ ChipLogProgress(DeviceLayer, "Connection to %*s requested [RSSI=%d]", Instance().mWiFiParams.mParams.ssid_length,
+ Instance().mWiFiParams.mParams.ssid, Instance().mWiFiParams.mRssi);
Instance().mInternalScan = false;
}
});
@@ -499,17 +530,43 @@
}
}
-void WiFiManager::DisconnectHandler(Platform::UniquePtr<uint8_t>)
+void WiFiManager::NetworkDrivenDisconnectHandler(Platform::UniquePtr<uint8_t>)
{
+ // Workaround: schedule the application level connection recovery in kSupplicantReconnectionTimeoutMs to give WPA supplicant
+ // some time to restore it.
+ if (!Instance().mRecoveryArmed)
+ {
+ Instance().mRecoveryArmed = true;
+ DeviceLayer::SystemLayer().StartTimer(
+ System::Clock::Milliseconds32(kSupplicantReconnectionTimeoutMs),
+ [](System::Layer * layer, void * param) { Instance().Disconnect(); }, nullptr);
+ }
+
SystemLayer().ScheduleLambda([] {
ChipLogProgress(DeviceLayer, "WiFi station disconnected");
Instance().mWiFiState = WIFI_STATE_DISCONNECTED;
Instance().PostConnectivityStatusChange(kConnectivity_Lost);
- // Ensure fresh recovery for future connection requests.
- Instance().ResetRecoveryTime();
});
}
+void WiFiManager::ApplicationDrivenDisconnectHandler(Platform::UniquePtr<uint8_t>)
+{
+ if (!Instance().mRecoveryArmed)
+ {
+ return;
+ }
+
+ if (!Instance().mApplicationDisconnectRequested)
+ {
+ Instance().AbortConnectionRecovery();
+ }
+ else
+ {
+ Instance().mApplicationDisconnectRequested = false;
+ SystemLayer().ScheduleLambda([] { Recover(nullptr, nullptr); });
+ }
+}
+
WiFiManager::StationStatus WiFiManager::GetStationStatus() const
{
return WiFiManager::sStatusMap[mWiFiState];
@@ -542,6 +599,13 @@
void WiFiManager::Recover(System::Layer *, void *)
{
+ // Prevent scheduling recovery if we are already connected to the network.
+ if (Instance().mWiFiState == WIFI_STATE_COMPLETED)
+ {
+ Instance().AbortConnectionRecovery();
+ return;
+ }
+
// If kConnectionRecoveryMaxOverallInterval has a non-zero value prevent endless re-scan.
if (0 != kConnectionRecoveryMaxRetries && (++Instance().mConnectionRecoveryCounter >= kConnectionRecoveryMaxRetries))
{
@@ -562,7 +626,36 @@
{
DeviceLayer::SystemLayer().CancelTimer(Recover, nullptr);
Instance().ResetRecoveryTime();
- Instance().mRecoveryTimerAborted = true;
+ Instance().mRecoveryArmed = false;
+}
+
+CHIP_ERROR WiFiManager::SetLowPowerMode(bool onoff)
+{
+ net_if * iface = InetUtils::GetInterface();
+ VerifyOrReturnError(nullptr != iface, CHIP_ERROR_INTERNAL);
+
+ wifi_ps_config currentConfig{};
+ if (net_mgmt(NET_REQUEST_WIFI_PS_CONFIG, iface, ¤tConfig, sizeof(currentConfig)))
+ {
+ ChipLogError(DeviceLayer, "Get current low power mode config request failed");
+ return CHIP_ERROR_INTERNAL;
+ }
+
+ if ((currentConfig.ps_params.enabled == WIFI_PS_ENABLED && onoff == false) ||
+ (currentConfig.ps_params.enabled == WIFI_PS_DISABLED && onoff == true))
+ {
+ wifi_ps_params params{ .enabled = onoff ? WIFI_PS_ENABLED : WIFI_PS_DISABLED };
+ if (net_mgmt(NET_REQUEST_WIFI_PS, iface, ¶ms, sizeof(params)))
+ {
+ ChipLogError(DeviceLayer, "Set low power mode request failed");
+ return CHIP_ERROR_INTERNAL;
+ }
+ ChipLogProgress(DeviceLayer, "Successfully set low power mode [%d]", onoff);
+ return CHIP_NO_ERROR;
+ }
+
+ ChipLogDetail(DeviceLayer, "Low power mode is already in requested state [%d]", onoff);
+ return CHIP_NO_ERROR;
}
} // namespace DeviceLayer
diff --git a/src/platform/nrfconnect/wifi/WiFiManager.h b/src/platform/nrfconnect/wifi/WiFiManager.h
index 880ab4c..5c477d7 100644
--- a/src/platform/nrfconnect/wifi/WiFiManager.h
+++ b/src/platform/nrfconnect/wifi/WiFiManager.h
@@ -173,6 +173,7 @@
static constexpr uint32_t kConnectionRecoveryMaxIntervalMs = CONFIG_CHIP_WIFI_CONNECTION_RECOVERY_MAXIMUM_INTERVAL;
static constexpr uint32_t kConnectionRecoveryJitterMs = CONFIG_CHIP_WIFI_CONNECTION_RECOVERY_JITTER;
static constexpr uint32_t kConnectionRecoveryMaxRetries = CONFIG_CHIP_WIFI_CONNECTION_RECOVERY_MAX_RETRIES_NUMBER;
+ static constexpr uint32_t kSupplicantReconnectionTimeoutMs = 60000;
static_assert(kConnectionRecoveryMinIntervalMs < kConnectionRecoveryMaxIntervalMs);
static_assert(kConnectionRecoveryJitterMs <= kConnectionRecoveryMaxIntervalMs);
@@ -192,6 +193,7 @@
CHIP_ERROR GetWiFiInfo(WiFiInfo & info) const;
CHIP_ERROR GetNetworkStatistics(NetworkStatistics & stats) const;
void AbortConnectionRecovery();
+ CHIP_ERROR SetLowPowerMode(bool onoff);
private:
using NetEventHandler = void (*)(Platform::UniquePtr<uint8_t>);
@@ -203,14 +205,16 @@
};
constexpr static uint32_t kWifiManagementEvents = NET_EVENT_WIFI_SCAN_RESULT | NET_EVENT_WIFI_SCAN_DONE |
- NET_EVENT_WIFI_CONNECT_RESULT | NET_EVENT_WIFI_DISCONNECT_RESULT | NET_EVENT_WIFI_IFACE_STATUS;
+ NET_EVENT_WIFI_CONNECT_RESULT | NET_EVENT_WIFI_DISCONNECT_RESULT | NET_EVENT_WIFI_DISCONNECT_COMPLETE |
+ NET_EVENT_WIFI_IFACE_STATUS;
// Event handling
static void WifiMgmtEventHandler(net_mgmt_event_callback * cb, uint32_t mgmtEvent, net_if * iface);
static void ScanResultHandler(Platform::UniquePtr<uint8_t> data);
static void ScanDoneHandler(Platform::UniquePtr<uint8_t> data);
static void ConnectHandler(Platform::UniquePtr<uint8_t> data);
- static void DisconnectHandler(Platform::UniquePtr<uint8_t> data);
+ static void NetworkDrivenDisconnectHandler(Platform::UniquePtr<uint8_t> data);
+ static void ApplicationDrivenDisconnectHandler(Platform::UniquePtr<uint8_t> data);
static void PostConnectivityStatusChange(ConnectivityChange changeType);
static void SendRouterSolicitation(System::Layer * layer, void * param);
@@ -240,10 +244,13 @@
bool mSsidFound{ false };
uint32_t mConnectionRecoveryCounter{ 0 };
uint32_t mConnectionRecoveryTimeMs{ kConnectionRecoveryMinIntervalMs };
- bool mRecoveryTimerAborted{ false };
+ bool mRecoveryArmed{ false };
+ bool mApplicationDisconnectRequested{ false };
+ // TODO Workaround for recovery mechanism to wait before the next scan request until the WiFi supplicant is not busy.
+ static constexpr uint32_t kWifiSupplicantWorkaroundTime = 8000;
static const Map<wifi_iface_state, StationStatus, 10> sStatusMap;
- static const Map<uint32_t, NetEventHandler, 4> sEventHandlerMap;
+ static const Map<uint32_t, NetEventHandler, 5> sEventHandlerMap;
};
} // namespace DeviceLayer
diff --git a/src/protocols/user_directed_commissioning/UserDirectedCommissioningClient.cpp b/src/protocols/user_directed_commissioning/UserDirectedCommissioningClient.cpp
index 5701c82..831a7bc 100644
--- a/src/protocols/user_directed_commissioning/UserDirectedCommissioningClient.cpp
+++ b/src/protocols/user_directed_commissioning/UserDirectedCommissioningClient.cpp
@@ -25,6 +25,10 @@
#include "UserDirectedCommissioning.h"
+#ifdef __ZEPHYR__
+#include <zephyr/kernel.h>
+#endif // __ZEPHYR__
+
#include <unistd.h>
namespace chip {
@@ -50,7 +54,12 @@
ChipLogError(AppServer, "UDC SendMessage failed: %" CHIP_ERROR_FORMAT, err.Format());
return err;
}
+ // Zephyr doesn't provide usleep implementation.
+#ifdef __ZEPHYR__
+ k_usleep(100 * 1000); // 100ms
+#else
usleep(100 * 1000); // 100ms
+#endif // __ZEPHYR__
}
ChipLogProgress(Inet, "UDC msg sent");
diff --git a/src/system/SystemClock.h b/src/system/SystemClock.h
index dfc54e8..d669200 100644
--- a/src/system/SystemClock.h
+++ b/src/system/SystemClock.h
@@ -32,9 +32,13 @@
#include <lib/support/TimeUtils.h>
#include <system/SystemError.h>
-#if CHIP_SYSTEM_CONFIG_USE_POSIX_TIME_FUNCTS || CHIP_SYSTEM_CONFIG_USE_SOCKETS
+#if CHIP_SYSTEM_CONFIG_USE_POSIX_TIME_FUNCTS || CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS
#include <sys/time.h>
-#endif // CHIP_SYSTEM_CONFIG_USE_POSIX_TIME_FUNCTS || CHIP_SYSTEM_CONFIG_USE_SOCKETS
+#endif // CHIP_SYSTEM_CONFIG_USE_POSIX_TIME_FUNCTS || CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS
+
+#if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
+#include <zephyr/net/socket.h>
+#endif
#include <chrono>
#include <stdint.h>
diff --git a/src/system/SystemConfig.h b/src/system/SystemConfig.h
index 17fbe26..d0188ca 100644
--- a/src/system/SystemConfig.h
+++ b/src/system/SystemConfig.h
@@ -715,3 +715,51 @@
#define CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS 0
#endif
#endif // CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
+
+/**
+ * @def CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
+ *
+ * @brief
+ * Use Zephyr socket API.
+ *
+ * Defaults to enabled on Zephyr platforms that do not enable Zephyr POSIX layer.
+ */
+#ifndef CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
+#if CHIP_SYSTEM_CONFIG_USE_SOCKETS && __ZEPHYR__ && CONFIG_NET_SOCKETS_POSIX_NAMES
+#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS 1
+#else
+#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS 0
+#endif
+#endif // CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
+
+/**
+ * @def CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS
+ *
+ * @brief
+ * Use POSIX socket API.
+ *
+ * Defaults to enabled on platforms that use sockets other than Zephyr sockets.
+ */
+#ifndef CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS
+#if CHIP_SYSTEM_CONFIG_USE_SOCKETS && !CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
+#define CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS 1
+#else
+#define CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS 0
+#endif
+#endif // CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS
+
+/**
+ * @def CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD
+ *
+ * @brief
+ * Use Zephyr eventfd API.
+ *
+ * Defaults to enabled on Zephyr platforms that enable CONFIG_EVENTFD.
+ */
+#ifndef CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD
+#if __ZEPHYR__ && CONFIG_EVENTFD
+#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD 1
+#else
+#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD 0
+#endif
+#endif // CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD
diff --git a/src/system/SystemLayerImplSelect.h b/src/system/SystemLayerImplSelect.h
index 0eb930e..552e8d9 100644
--- a/src/system/SystemLayerImplSelect.h
+++ b/src/system/SystemLayerImplSelect.h
@@ -22,7 +22,13 @@
#pragma once
+#if CHIP_SYSTEM_CONFIG_USE_POSIX_SOCKETS
#include <sys/select.h>
+#endif
+
+#if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
+#include <zephyr/net/socket.h>
+#endif
#if CHIP_SYSTEM_CONFIG_POSIX_LOCKING
#include <atomic>
diff --git a/src/system/WakeEvent.cpp b/src/system/WakeEvent.cpp
index ab11502..4b5d7c2 100644
--- a/src/system/WakeEvent.cpp
+++ b/src/system/WakeEvent.cpp
@@ -38,8 +38,12 @@
#include <unistd.h>
#if !CHIP_SYSTEM_CONFIG_USE_POSIX_PIPE
+#if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD
+#include <zephyr/posix/sys/eventfd.h>
+#else
#include <sys/eventfd.h>
#endif
+#endif // !CHIP_SYSTEM_CONFIG_USE_POSIX_PIPE
namespace chip {
namespace System {
@@ -122,6 +126,42 @@
#else // CHIP_SYSTEM_CONFIG_USE_POSIX_PIPE
+namespace {
+
+#if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD
+
+int ReadEvent(int eventFd)
+{
+ eventfd_t value;
+
+ return eventfd_read(eventFd, &value);
+}
+
+int WriteEvent(int eventFd)
+{
+ return eventfd_write(eventFd, 1);
+}
+
+#else
+
+ssize_t ReadEvent(int eventFd)
+{
+ uint64_t value;
+
+ return ::read(eventFd, &value, sizeof(value));
+}
+
+ssize_t WriteEvent(int eventFd)
+{
+ uint64_t value = 1;
+
+ return ::write(eventFd, &value, sizeof(value));
+}
+
+#endif
+
+} // namespace
+
CHIP_ERROR WakeEvent::Open(LayerSockets & systemLayer)
{
mReadFD = ::eventfd(0, 0);
@@ -146,9 +186,7 @@
void WakeEvent::Confirm() const
{
- uint64_t value;
-
- if (::read(mReadFD, &value, sizeof(value)) < 0 && errno != EAGAIN && errno != EWOULDBLOCK)
+ if (ReadEvent(mReadFD) < 0 && errno != EAGAIN && errno != EWOULDBLOCK)
{
ChipLogError(chipSystemLayer, "System wake event confirm failed: %" CHIP_ERROR_FORMAT, CHIP_ERROR_POSIX(errno).Format());
}
@@ -156,9 +194,7 @@
CHIP_ERROR WakeEvent::Notify() const
{
- uint64_t value = 1;
-
- if (::write(mReadFD, &value, sizeof(value)) < 0 && errno != EAGAIN && errno != EWOULDBLOCK)
+ if (WriteEvent(mReadFD) < 0 && errno != EAGAIN && errno != EWOULDBLOCK)
{
return CHIP_ERROR_POSIX(errno);
}