Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.3 nrfconnect and zephyr platforms cherry picks #33352

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions config/nrfconnect/app/enable-gnu-std.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
add_library(gnu17 INTERFACE)
target_compile_options(gnu17
INTERFACE
$<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17>
-D_SYS__PTHREADTYPES_H_)
$<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17>)
target_link_libraries(app PRIVATE gnu17)
8 changes: 6 additions & 2 deletions config/nrfconnect/chip-module/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ config CHIP_MALLOC_SYS_HEAP
config CHIP_FACTORY_DATA
bool "Factory data provider"
select ZCBOR
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
Expand Down Expand Up @@ -149,7 +148,7 @@ 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
default y
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
Expand Down Expand Up @@ -302,4 +301,9 @@ config CHIP_FACTORY_RESET_ON_KEY_MIGRATION_FAILURE
Perform factory reset of the device if the operational key for Fabric has not been migrated
properly to PSA ITS storage.

config CHIP_PERSISTENT_SUBSCRIPTIONS
default n
# selecting experimental for this feature since there is an issue with multiple controllers.
select EXPERIMENTAL

endif # CHIP
26 changes: 21 additions & 5 deletions config/nrfconnect/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ if CHIP
# System configuration
# ==============================================================================

choice LIBC_IMPLEMENTATION
default NEWLIB_LIBC
endchoice

config ASSERT
default y

Expand Down Expand Up @@ -199,15 +203,27 @@ config CHIP_QSPI_NOR
default y if BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_NRF52840DK_NRF52840

# nRF7002DK uses SPI NOR external flash

if BOARD_NRF7002DK_NRF5340_CPUAPP || BOARD_NRF7002DK_NRF7001_NRF5340_CPUAPP

config CHIP_SPI_NOR
default y if BOARD_NRF7002DK_NRF5340_CPUAPP
default y

endif # BOARD_NRF7002DK_NRF5340_CPUAPP || BOARD_NRF7002DK_NRF7001_NRF5340_CPUAPP

config BOOT_IMAGE_ACCESS_HOOKS
default y if SOC_SERIES_NRF53X

config UPDATEABLE_IMAGE_NUMBER
default 3 if NRF_WIFI_PATCHES_EXT_FLASH_STORE
default 2 if SOC_SERIES_NRF53X

config DFU_MULTI_IMAGE_MAX_IMAGE_COUNT
default 3 if NRF_WIFI_PATCHES_EXT_FLASH_STORE

config NRF_WIFI_FW_PATCH_DFU
default y if NRF_WIFI_PATCHES_EXT_FLASH_STORE

# ==============================================================================
# OpenThread configuration
# ==============================================================================
Expand Down Expand Up @@ -318,13 +334,13 @@ if PSA_CRYPTO_DRIVER_CC3XX && PSA_CRYPTO_DRIVER_OBERON
config PSA_USE_CC3XX_HASH_DRIVER
default n

endif
endif # PSA_CRYPTO_DRIVER_CC3XX && PSA_CRYPTO_DRIVER_OBERON

# Spake2+ support
config MBEDTLS_MD_C
default y

endif
endif # CHIP_CRYPTO_PSA

if !CHIP_CRYPTO_PSA

Expand Down Expand Up @@ -367,7 +383,7 @@ config MBEDTLS_ECP_C
config MBEDTLS_ECP_DP_SECP256R1_ENABLED
default y

endif
endif # !CHIP_CRYPTO_PSA

config MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
default n if CHIP_WIFI
Expand Down Expand Up @@ -487,4 +503,4 @@ config OPENTHREAD_SHELL

endif # SHELL

endif
endif # CHIP
8 changes: 3 additions & 5 deletions config/nrfconnect/chip-module/Kconfig.features
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if CHIP

config CHIP_WIFI
bool "Enable nrfconnect Wi-Fi support"
default y if SHIELD_NRF7002EK || BOARD_NRF7002DK_NRF5340_CPUAPP || SHIELD_NRF7002EB
default y if SHIELD_NRF7002EK || BOARD_NRF7002DK_NRF5340_CPUAPP || SHIELD_NRF7002EB || BOARD_NRF7002DK_NRF7001_NRF5340_CPUAPP
select WIFI_NRF700X
select WIFI
select WPA_SUPP
Expand All @@ -42,15 +42,13 @@ config CHIP_WIFI

config CHIP_QSPI_NOR
bool "Enable QSPI NOR feature set"
imply NORDIC_QSPI_NOR
help
Enables QSPI NOR flash with a set of options for configuring pages and
buffer sizes.

if CHIP_QSPI_NOR

config NORDIC_QSPI_NOR
default y

config NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE
default 16

Expand Down Expand Up @@ -151,7 +149,7 @@ 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 CHIP_SPI_NOR if BOARD_NRF7002DK_NRF5340_CPUAPP || BOARD_NRF7002DK_NRF7001_NRF5340_CPUAPP
imply BOOTLOADER_MCUBOOT
select MCUMGR
select MCUMGR_TRANSPORT_BT
Expand Down
19 changes: 2 additions & 17 deletions config/nrfconnect/chip-module/Kconfig.mcuboot.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,7 @@
config MAIN_STACK_SIZE
default 10240

config BOOT_SWAP_SAVE_ENCTLV
default n

config BOOT_ENCRYPT_RSA
default n

config BOOT_ENCRYPT_EC256
default n

config BOOT_ENCRYPT_X25519
config BOOT_ENCRYPT_IMAGE
default n

config BOOT_BOOTSTRAP
Expand All @@ -48,14 +39,11 @@ choice LIBC_IMPLEMENTATION
endchoice

# nRF7002DK uses SPI NOR external flash
if BOARD_NRF7002DK_NRF5340_CPUAPP
if BOARD_NRF7002DK_NRF5340_CPUAPP || BOARD_NRF7002DK_NRF7001_NRF5340_CPUAPP

config SPI
default y

config SPI_NOR
default y

choice SPI_NOR_SFDP
default SPI_NOR_SFDP_DEVICETREE
endchoice
Expand All @@ -74,9 +62,6 @@ endif
# All boards beside nRF7002DK use QSPI NOR external flash
if BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_NRF52840DK_NRF52840

config NORDIC_QSPI_NOR
default y

config NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE
default 4096

Expand Down
31 changes: 24 additions & 7 deletions config/nrfconnect/chip-module/generate_factory_data.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,21 @@ set(factory_data_output_path ${output_path}/${factory_data_target})
string(APPEND script_args "-o \"${factory_data_output_path}\"\n")
string(APPEND script_args "-s \"${schema_path}\"\n")

# Add optional offset and size arguments to generate both .hex and .json files.
string(APPEND script_args "--offset $<TARGET_PROPERTY:partition_manager,PM_FACTORY_DATA_ADDRESS>\n")
string(APPEND script_args "--size $<TARGET_PROPERTY:partition_manager,PM_FACTORY_DATA_OFFSET>\n")
# Add optional offset and size arguments to generate .hex file as well as .json.
if(CONFIG_PARTITION_MANAGER_ENABLED)
string(APPEND script_args "--offset $<TARGET_PROPERTY:partition_manager,PM_FACTORY_DATA_ADDRESS>\n")
string(APPEND script_args "--size $<TARGET_PROPERTY:partition_manager,PM_FACTORY_DATA_OFFSET>\n")
else()
dt_alias(factory_data_alias PROPERTY "factory-data")
dt_node_exists(factory_data_exists PATH "${factory_data_alias}")
if(NOT ${factory_data_exists})
message(FATAL_ERROR "factory-data alias does not exist in DTS")
endif()
dt_reg_addr(factory_data_addr PATH ${factory_data_alias})
dt_reg_size(factory_data_size PATH ${factory_data_alias})
string(APPEND script_args "--offset ${factory_data_addr}\n")
string(APPEND script_args "--size ${factory_data_size}\n")
endif()

# execute first script to create a JSON file
separate_arguments(separated_script_args NATIVE_COMMAND ${script_args})
Expand Down Expand Up @@ -175,10 +187,15 @@ nrfconnect_create_factory_data(factory_data
${FACTORY_DATA_SCHEMA_PATH}
${OUTPUT_FILE_PATH})

if(CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE)
# set custom target for merging factory_data hex file
set_property(GLOBAL PROPERTY factory_data_PM_HEX_FILE ${OUTPUT_FILE_PATH}/factory_data.hex)
set_property(GLOBAL PROPERTY factory_data_PM_TARGET factory_data)
if(CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE)
if(CONFIG_PARTITION_MANAGER_ENABLED)
# set custom target for merging factory_data hex file
set_property(GLOBAL PROPERTY factory_data_PM_HEX_FILE ${OUTPUT_FILE_PATH}/factory_data.hex)
set_property(GLOBAL PROPERTY factory_data_PM_TARGET factory_data)
else()
set_property(GLOBAL APPEND PROPERTY HEX_FILES_TO_MERGE ${OUTPUT_FILE_PATH}/factory_data.hex ${OUTPUT_FILE_PATH}/zephyr.hex)
set_property(TARGET runners_yaml_props_target PROPERTY hex_file ${OUTPUT_FILE_PATH}/merged.hex)
endif()
endif()


Expand Down
9 changes: 7 additions & 2 deletions config/zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ config CHIP_DEVICE_HARDWARE_VERSION_STRING
hardware version string is exposed as an attribute of the Basic
Information cluster.

if "$(APPVERSION)"=""
config CHIP_DEVICE_SOFTWARE_VERSION
int "Software version"
default 0
Expand All @@ -116,6 +117,7 @@ config CHIP_DEVICE_SOFTWARE_VERSION_STRING
software version string is exposed as an attribute of the Basic
Information cluster, and included in the header of the generated Matter
over-the-air (OTA) update image.
endif

config CHIP_DEVICE_MANUFACTURING_DATE
string "Manufacturing date (ISO 8601 format)"
Expand Down Expand Up @@ -309,7 +311,8 @@ config CHIP_PROJECT_CONFIG

config CHIP_ENABLE_DNSSD_SRP
bool "OpenThread Service Registration Protocol"
default y if NET_L2_OPENTHREAD
default y
depends on NET_L2_OPENTHREAD
imply OPENTHREAD_ECDSA
imply OPENTHREAD_SRP_CLIENT
help
Expand All @@ -318,7 +321,8 @@ config CHIP_ENABLE_DNSSD_SRP

config CHIP_ENABLE_DNS_CLIENT
bool "OpenThread DNS client"
default y if NET_L2_OPENTHREAD
default y
depends on NET_L2_OPENTHREAD
imply OPENTHREAD_DNS_CLIENT
help
Enables using the OpenThread DNS client for the Matter service discovery.
Expand Down Expand Up @@ -413,6 +417,7 @@ config CHIP_THREAD_SSED

config CHIP_OPENTHREAD_CONFIG
string "Custom OpenThread configuration file"
depends on NET_L2_OPENTHREAD
help
Provides a path to an OpenThread configuration file. The path can be
either absolute or relative to the application directory. When this option
Expand Down
39 changes: 27 additions & 12 deletions config/zephyr/ota-image.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,33 @@ function(chip_ota_image TARGET_NAME)
endif()

# Prepare ota_image_tool.py argument list
set(OTA_ARGS
"--vendor-id"
${CONFIG_CHIP_DEVICE_VENDOR_ID}
"--product-id"
${CONFIG_CHIP_DEVICE_PRODUCT_ID}
"--version"
${CONFIG_CHIP_DEVICE_SOFTWARE_VERSION}
"--version-str"
${CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING}
"--digest-algorithm"
"sha256"
)
if(DEFINED APPVERSION)
set(OTA_ARGS
"--vendor-id"
${CONFIG_CHIP_DEVICE_VENDOR_ID}
"--product-id"
${CONFIG_CHIP_DEVICE_PRODUCT_ID}
"--version"
${APPVERSION}
"--version-str"
${APP_VERSION_TWEAK_STRING}
"--digest-algorithm"
"sha256"
)
else()
set(OTA_ARGS
"--vendor-id"
${CONFIG_CHIP_DEVICE_VENDOR_ID}
"--product-id"
${CONFIG_CHIP_DEVICE_PRODUCT_ID}
"--version"
${CONFIG_CHIP_DEVICE_SOFTWARE_VERSION}
"--version-str"
${CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING}
"--digest-algorithm"
"sha256"
)
endif()

separate_arguments(OTA_EXTRA_ARGS NATIVE_COMMAND "${CHIP_OTA_IMAGE_EXTRA_ARGS}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,14 @@ template <class ImplClass>
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_AttachToThreadNetwork(
const Thread::OperationalDataset & dataset, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback)
{
Thread::OperationalDataset current_dataset;
// Validate the dataset change with the current state
ThreadStackMgrImpl().GetThreadProvision(current_dataset);
if (dataset.AsByteSpan().data_equal(current_dataset.AsByteSpan()) && callback == nullptr)
{
return CHIP_NO_ERROR;
}

// Reset the previously set callback since it will never be called in case incorrect dataset was supplied.
mpConnectCallback = nullptr;
ReturnErrorOnFailure(Impl()->SetThreadEnabled(false));
Expand Down
31 changes: 29 additions & 2 deletions src/platform/Zephyr/BLEAdvertisingArbiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ namespace {
// List of advertising requests ordered by priority
sys_slist_t sRequests;

bool sIsInitialized = false;
uint8_t sBtId = 0;

// Cast an intrusive list node to the containing request object
const BLEAdvertisingArbiter::Request & ToRequest(const sys_snode_t * node)
{
Expand All @@ -55,8 +58,9 @@ CHIP_ERROR RestartAdvertising()
ReturnErrorOnFailure(System::MapErrorZephyr(bt_le_adv_stop()));
ReturnErrorCodeIf(sys_slist_is_empty(&sRequests), CHIP_NO_ERROR);

const Request & top = ToRequest(sys_slist_peek_head(&sRequests));
const bt_le_adv_param params = BT_LE_ADV_PARAM_INIT(top.options, top.minInterval, top.maxInterval, nullptr);
const Request & top = ToRequest(sys_slist_peek_head(&sRequests));
bt_le_adv_param params = BT_LE_ADV_PARAM_INIT(top.options, top.minInterval, top.maxInterval, nullptr);
params.id = sBtId;
const int result = bt_le_adv_start(&params, top.advertisingData.data(), top.advertisingData.size(), top.scanResponseData.data(),
top.scanResponseData.size());

Expand All @@ -70,8 +74,26 @@ CHIP_ERROR RestartAdvertising()

} // namespace

CHIP_ERROR Init(uint8_t btId)
{
if (sIsInitialized)
{
return CHIP_ERROR_INCORRECT_STATE;
}

sBtId = btId;
sIsInitialized = true;

return CHIP_NO_ERROR;
}

CHIP_ERROR InsertRequest(Request & request)
{
if (!sIsInitialized)
{
return CHIP_ERROR_INCORRECT_STATE;
}

CancelRequest(request);

sys_snode_t * prev = nullptr;
Expand Down Expand Up @@ -109,6 +131,11 @@ CHIP_ERROR InsertRequest(Request & request)

void CancelRequest(Request & request)
{
if (!sIsInitialized)
{
return;
}

const bool isTopPriority = (sys_slist_peek_head(&sRequests) == &request);
VerifyOrReturn(sys_slist_find_and_remove(&sRequests, &request));

Expand Down
Loading
Loading