Skip to content
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: 3 additions & 0 deletions Kconfig.defaults.bluetooth
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ configdefault BT_CTLR_ADV_DATA_LEN_MAX
# switch PHY's results in iPhones having problems connecting to devices.
configdefault BT_PHY_UPDATE
default y
# But we don't want the PHY update to be triggered automatically by the peripheral
configdefault BT_AUTO_PHY_UPDATE
default n

# Connection parameters should be pro-actively negotiated, not delayed by 5
# seconds as many connections are complete by then.
Expand Down
23 changes: 17 additions & 6 deletions apps/data_logger/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,31 @@ common:
build_only: true
required_snippets:
- infuse
platform_allow:
- thingy53/nrf5340/cpuapp/ns
- thingy53/nrf5340/cpuapp
integration_platforms:
- thingy53/nrf5340/cpuapp/ns
- thingy53/nrf5340/cpuapp
tests:
sample.app.data_logger:
tags: app
platform_allow:
- thingy53/nrf5340/cpuapp/ns
- thingy53/nrf5340/cpuapp
- tauro/nrf9151/ns
integration_platforms:
- thingy53/nrf5340/cpuapp/ns
- thingy53/nrf5340/cpuapp
- tauro/nrf9151/ns
sample.app.data_logger.wifi:
tags: app
extra_args: SHIELD=nrf7002eb
platform_allow:
- thingy53/nrf5340/cpuapp/ns
- thingy53/nrf5340/cpuapp
integration_platforms:
- thingy53/nrf5340/cpuapp/ns
sample.app.data_logger.wifi.sysbuild:
tags: app
sysbuild: true
filter: not CONFIG_BUILD_WITH_TFM
extra_args: data_logger_SHIELD=nrf7002eb
platform_allow:
- thingy53/nrf5340/cpuapp
integration_platforms:
- thingy53/nrf5340/cpuapp
4 changes: 4 additions & 0 deletions subsys/data_logger/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,8 @@ module = TDF_DATA_LOGGER
module-str = TDF data logger
source "subsys/logging/Kconfig.template.log_config"

config TDF_DATA_LOGGER_SERIAL_DUMMY_BACKEND
bool "Route `TDF_DATA_LOGGER_SERIAL to `dt_nodelabel(tdf_logger_dummy)"
depends on ZTEST

endif # TDF_DATA_LOGGER
4 changes: 4 additions & 0 deletions subsys/data_logger/high_level/tdf_data_logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ struct tdf_logger_data {
static const struct device *logger_mapping[] = {
[_TDF_DATA_LOGGER_FLASH_OFFSET] = LOGGER_GET(DT_NODELABEL(tdf_logger_flash)),
[_TDF_DATA_LOGGER_REMOVABLE_OFFSET] = LOGGER_GET(DT_NODELABEL(tdf_logger_removable)),
#ifdef CONFIG_TDF_DATA_LOGGER_SERIAL_DUMMY_BACKEND
[_TDF_DATA_LOGGER_SERIAL_OFFSET] = LOGGER_GET(DT_NODELABEL(tdf_logger_dummy)),
#else
[_TDF_DATA_LOGGER_SERIAL_OFFSET] = LOGGER_GET(DT_NODELABEL(tdf_logger_serial)),
#endif /* CONFIG_TDF_DATA_LOGGER_SERIAL_DUMMY_BACKEND */
[_TDF_DATA_LOGGER_UDP_OFFSET] = LOGGER_GET(DT_NODELABEL(tdf_logger_udp)),
[_TDF_DATA_LOGGER_BT_ADV_OFFSET] = LOGGER_GET(DT_NODELABEL(tdf_logger_bt_adv)),
};
Expand Down
6 changes: 6 additions & 0 deletions subsys/mgmt/mcumgr/os_mgmt_infuse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@

zephyr_library(mgmt_mcumgr_grp_os)
zephyr_library_sources(os_mgmt_infuse.c)

if (CONFIG_BOOTLOADER_MCUBOOT)
zephyr_include_directories(
${ZEPHYR_MCUBOOT_MODULE_DIR}/boot/bootutil/include
)
endif()
85 changes: 85 additions & 0 deletions subsys/mgmt/mcumgr/os_mgmt_infuse/os_mgmt_infuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,95 @@ static int os_mgmt_reset(struct smp_streamer *ctxt)
return MGMT_ERR_EOK;
}

static int os_mgmt_mcumgr_params(struct smp_streamer *ctxt)
{
zcbor_state_t *zse = ctxt->writer->zs;
bool ok;

ok = zcbor_tstr_put_lit(zse, "buf_size") &&
zcbor_uint32_put(zse, CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE) &&
zcbor_tstr_put_lit(zse, "buf_count") &&
zcbor_uint32_put(zse, CONFIG_MCUMGR_TRANSPORT_NETBUF_COUNT);

return ok ? MGMT_ERR_EOK : MGMT_ERR_EMSGSIZE;
}

#if defined(CONFIG_TFM_BL2)
/* MCUBOOT_UPGRADE_STRATEGY from TF-M, defaults to "OVERWRITE_ONLY" */
#define BOOTLOADER_MODE 2
#elif defined(CONFIG_BOOTLOADER_MCUBOOT)
#include <bootutil/boot_status.h>
/* From zephyr/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c */
#if defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP)
#define BOOTLOADER_MODE MCUBOOT_MODE_SINGLE_SLOT
#elif defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_SWAP_SCRATCH)
#define BOOTLOADER_MODE MCUBOOT_MODE_SWAP_USING_SCRATCH
#elif defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_OVERWRITE_ONLY)
#define BOOTLOADER_MODE MCUBOOT_MODE_UPGRADE_ONLY
#elif defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_SWAP_WITHOUT_SCRATCH)
#define BOOTLOADER_MODE MCUBOOT_MODE_SWAP_USING_MOVE
#elif defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP)
#define BOOTLOADER_MODE MCUBOOT_MODE_DIRECT_XIP
#elif defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT)
#define BOOTLOADER_MODE MCUBOOT_MODE_DIRECT_XIP_WITH_REVERT
#elif defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER)
#define BOOTLOADER_MODE MCUBOOT_MODE_FIRMWARE_LOADER
#else
#define BOOTLOADER_MODE -1
#endif
#else
#define BOOTLOADER_MODE -1
#endif

#if defined(CONFIG_TFM_BL2)
/* MCUBOOT_HW_ROLLBACK_PROT from TF-M, defaults ON, not exposed to Zephyr build */
#define NO_DOWNGRADE
#elif defined(CONFIG_MCUBOOT_BOOTLOADER_NO_DOWNGRADE)
#define NO_DOWNGRADE
#endif

static int os_mgmt_bootloader_info(struct smp_streamer *ctxt)
{
zcbor_state_t *zse = ctxt->writer->zs;
zcbor_state_t *zsd = ctxt->reader->zs;
struct zcbor_string query = {0};
size_t decoded;
bool ok;

struct zcbor_map_decode_key_val bootloader_info[] = {
ZCBOR_MAP_DECODE_KEY_DECODER("query", zcbor_tstr_decode, &query),
};

if (zcbor_map_decode_bulk(zsd, bootloader_info, ARRAY_SIZE(bootloader_info), &decoded)) {
return MGMT_ERR_EINVAL;
}

/* If no parameter is recognized then just introduce the bootloader. */
if (decoded == 0) {
ok = zcbor_tstr_put_lit(zse, "bootloader") && zcbor_tstr_put_lit(zse, "MCUboot");
} else if (zcbor_map_decode_bulk_key_found(bootloader_info, ARRAY_SIZE(bootloader_info),
"query") &&
(sizeof("mode") - 1) == query.len &&
memcmp("mode", query.value, query.len) == 0) {

ok = zcbor_tstr_put_lit(zse, "mode") && zcbor_int32_put(zse, BOOTLOADER_MODE);
#ifdef NO_DOWNGRADE
ok = ok && zcbor_tstr_put_lit(zse, "no-downgrade") &&
zcbor_bool_encode(zse, &(bool){true});
#endif
} else {
return OS_MGMT_ERR_QUERY_YIELDS_NO_ANSWER;
}

return ok ? MGMT_ERR_EOK : MGMT_ERR_EMSGSIZE;
}

static const struct mgmt_handler os_mgmt_group_handlers[] = {
[OS_MGMT_ID_ECHO] = {os_mgmt_echo, os_mgmt_echo},
[OS_MGMT_ID_DATETIME_STR] = {os_mgmt_datetime_read, NULL},
[OS_MGMT_ID_RESET] = {NULL, os_mgmt_reset},
[OS_MGMT_ID_MCUMGR_PARAMS] = {os_mgmt_mcumgr_params, NULL},
[OS_MGMT_ID_BOOTLOADER_INFO] = {os_mgmt_bootloader_info, NULL},
};

static struct mgmt_group os_mgmt_group = {
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/auto/time_sync_log/app.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
compatible = "embeint,data-logger-epacket", "embeint,data-logger";
epacket = <&epacket_dummy>;

tdf_logger_serial: tdf_logger_serial {
tdf_logger_dummy: tdf_logger_dummy {
compatible = "embeint,tdf-data-logger";
};
};
Expand Down
1 change: 1 addition & 0 deletions tests/lib/auto/time_sync_log/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ CONFIG_NET_BUF=y
CONFIG_DATA_LOGGER=y
CONFIG_TDF=y
CONFIG_TDF_DATA_LOGGER=y
CONFIG_TDF_DATA_LOGGER_SERIAL_DUMMY_BACKEND=y
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/ {
data_logger_epacket: data_logger_epacket {
data_logger_dummy: data_logger_dummy {
compatible = "embeint,data-logger-epacket", "embeint,data-logger";
epacket = <&epacket_dummy>;

tdf_logger_serial: tdf_logger_serial {
tdf_logger_dummy: tdf_logger_dummy {
compatible = "embeint,tdf-data-logger";
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_INFUSE_SDK=y
CONFIG_INFUSE_REBOOT=y
CONFIG_EPACKET_PACKET_SIZE_MAX=64
CONFIG_TDF_DATA_LOGGER_SERIAL_DUMMY_BACKEND=y
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct logger_data {
struct test_tdf_buffer_state tdf_state;
uint8_t full_block_write;
uint8_t block_overhead;
uint8_t tdf_buffer[DATA_LOGGER_MAX_SIZE(DT_NODELABEL(data_logger_epacket))];
uint8_t tdf_buffer[DATA_LOGGER_MAX_SIZE(DT_NODELABEL(data_logger_dummy))];
uint32_t guard_tail;
};

Expand Down Expand Up @@ -97,7 +97,7 @@ static void tdf_reboot_info_log_expect(uint8_t reason)
ZTEST(tdf_data_logger_recovery, test_logger_recovery)
{
KV_KEY_TYPE(KV_KEY_REBOOTS) reboots;
const struct device *tdf_logger = DEVICE_DT_GET(DT_NODELABEL(tdf_logger_serial));
const struct device *tdf_logger = DEVICE_DT_GET(DT_NODELABEL(tdf_logger_dummy));
struct k_fifo *sent_queue = epacket_dummmy_transmit_fifo_get();
struct net_buf *buf;
int rc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ tests:
data_logger.tdf.reboot_recover:
required_snippets:
- infuse
platform_exclude:
- nrf9161dk/nrf9161/ns
- nrf9151dk/nrf9151/ns
integration_platforms:
- mps2/an385
23 changes: 23 additions & 0 deletions tests/subsys/mgmt/mcumgr/os_mgmt_bootloader_info/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
#

cmake_minimum_required(VERSION 3.20.0)

# Infuse-IoT application
if(NOT infuse IN_LIST SNIPPET)
set(SNIPPET infuse ${SNIPPET} CACHE STRING "" FORCE)
endif()

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(os_mgmt_infuse_bootloader_info)

FILE(GLOB app_sources
src/*.c
)

target_sources(app PRIVATE ${app_sources})
target_include_directories(app PRIVATE ${ZEPHYR_BASE}/subsys/mgmt/mcumgr/transport/include/mgmt/mcumgr/transport/)
target_include_directories(app PRIVATE ${ZEPHYR_BASE}/subsys/mgmt/mcumgr/grp/os_mgmt/include/)
18 changes: 18 additions & 0 deletions tests/subsys/mgmt/mcumgr/os_mgmt_bootloader_info/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
#
CONFIG_ZTEST=y
CONFIG_NET_BUF=y
CONFIG_BASE64=y
CONFIG_ZCBOR=y
CONFIG_CRC=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_MCUMGR=y
CONFIG_MCUMGR_TRANSPORT_DUMMY=y
CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE=256
CONFIG_MCUMGR_GRP_OS_INFUSE=y
CONFIG_INFUSE_SDK=y
CONFIG_INFUSE_REBOOT=y
CONFIG_INFUSE_SECURE_STORAGE=n
Loading
Loading