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
22 changes: 20 additions & 2 deletions Kconfig.defaults.core
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,28 @@ configdefault INFUSE_EPOCH_TIME
default y

# Application management
if BOOTLOADER_MCUBOOT || BUILD_WITH_TFM
configdefault STREAM_FLASH
default y if BOOTLOADER_MCUBOOT
default y
configdefault IMG_MANAGER
default y if BOOTLOADER_MCUBOOT
default y

if BT_CONN
configdefault MCUMGR
default y
configdefault MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL
default n
configdefault MCUMGR_TRANSPORT_BT
default y
configdefault MCUMGR_GRP_OS_INFUSE
default y
configdefault MCUMGR_GRP_IMG
default y
configdefault ZCBOR
default y
endif # BT_CONN
endif # BOOTLOADER_MCUBOOT || BUILD_WITH_TFM


# KV store
configdefault FLASH
Expand Down
3 changes: 3 additions & 0 deletions Kconfig.defaults.ztest
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ configdefault ZTEST_STACK_SIZE
default 2048

endif # INFUSE_SECURITY

configdefault MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE
default 8192 if COVERAGE_GCOV
2 changes: 2 additions & 0 deletions include/infuse/reboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ enum infuse_reboot_reason {
INFUSE_REBOOT_RPC,
/* Internal LTE modem fault */
INFUSE_REBOOT_LTE_MODEM_FAULT,
/* MCUmgr request */
INFUSE_REBOOT_MCUMGR,
/* Unknown reboot reason */
INFUSE_REBOOT_UNKNOWN = 255,
};
Expand Down
8 changes: 4 additions & 4 deletions include/infuse/time/epoch.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include <zephyr/toolchain.h>
#include <zephyr/sys/timeutil.h>

/* Time conversion functions */
#include "epoch_units.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -145,7 +148,7 @@ static inline uint16_t epoch_time_subseconds(uint64_t epoch_time)
*/
static inline uint16_t epoch_time_milliseconds(uint64_t epoch_time)
{
return ((uint32_t)epoch_time_subseconds(epoch_time) * 1000) / 0x10000;
return k_epoch_to_ms_near32(epoch_time_subseconds(epoch_time));
}

/**
Expand Down Expand Up @@ -309,9 +312,6 @@ void epoch_time_reset(void);

#endif /* CONFIG_ZTEST */

/* Time conversion functions */
#include "epoch_units.h"

/**
* @}
*/
Expand Down
39 changes: 39 additions & 0 deletions include/infuse/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ extern "C" {
/* Use MCUboot semantic version definitions */
#define infuse_version mcuboot_img_sem_ver

/**
* @brief Convert version struct to sortable integer
*
* @param v struct infuse_version pointer
*
* @retval uint32_t equivalent integer
*/
#define INFUSE_VERSION_INT(v) \
((((uint32_t)(v)->major) << 24) | (((uint32_t)(v)->minor) << 16) | \
((uint32_t)(v)->revision))

/**
* @brief Get version of the currently running application
*
Expand Down Expand Up @@ -67,6 +78,34 @@ static inline struct infuse_version application_version_get(void)
};
}

/**
* @brief Compare two version structures
*
* Return value follows the convention of the C library `qsort` function.
*
* @note The `build_num` field is ignored for comparison purposes.
*
* @param a First version to compare
* @param b Second version to compare
*
* @retval 1 @a a is an earlier version than @a b
* @retval -1 @a a is a later version than @a b
* @retval 0 if @a a and @a b are the same version
*/
static inline int infuse_version_compare(struct infuse_version *a, struct infuse_version *b)
{
uint32_t a_int = INFUSE_VERSION_INT(a);
uint32_t b_int = INFUSE_VERSION_INT(b);

if (a_int < b_int) {
return 1;
}
if (a_int > b_int) {
return -1;
}
return 0;
}

/**
* @}
*/
Expand Down
4 changes: 2 additions & 2 deletions snippets/infuse/boards/nrf5340dk_nrf5340_cpuapp_ns.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
driver = "Driver_FLASH0";
complete = <&flash0>;
img-bl2 = <&boot_partition>;
img-primary-secure = <&slot0_partition>;
img-primary-secure = <&slot0_s_partition>;
img-primary-nonsecure = <&slot0_ns_partition>;
img-secondary-secure = <&slot1_partition>;
img-secondary-secure = <&slot1_s_partition>;
img-secondary-nonsecure = <&slot1_ns_partition>;
partition-ps = <&tfm_ps_partition>;
partition-its = <&tfm_its_partition>;
Expand Down
14 changes: 12 additions & 2 deletions snippets/infuse/boards/nrf7002dk_nrf5340_cpuapp_common.dtsi
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* MCUboot secondary on external flash */
/delete-node/ &slot0_partition;
/delete-node/ &slot0_s_partition;
/delete-node/ &slot0_ns_partition;
/delete-node/ &slot1_partition;
/delete-node/ &slot1_s_partition;
/delete-node/ &slot1_ns_partition;

/ {
Expand Down Expand Up @@ -63,9 +65,13 @@
};
slot0_partition: partition@10000 {
label = "image-0";
reg = <0x00010000 0x000F0000>;
};
slot0_s_partition: subpartition@10000 {
label = "image-0-secure";
reg = <0x00010000 0x00030000>;
};
slot0_ns_partition: partition@40000 {
slot0_ns_partition: subpartition@40000 {
label = "image-0-nonsecure";
reg = <0x00040000 0xC0000>;
};
Expand Down Expand Up @@ -96,7 +102,11 @@
label = "image-1";
reg = <0x00000000 0x30000>;
};
slot1_ns_partition: partition@30000 {
slot1_s_partition: subpartition@0 {
label = "image-1-secure";
reg = <0x00000000 0x30000>;
};
slot1_ns_partition: subpartition@30000 {
label = "image-1-nonsecure";
reg = <0x00030000 0xC0000>;
};
Expand Down
4 changes: 2 additions & 2 deletions snippets/infuse/boards/nrf7002dk_nrf5340_cpuapp_ns.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
driver = "Driver_FLASH0";
complete = <&flash0>;
img-bl2 = <&boot_partition>;
img-primary-secure = <&slot0_partition>;
img-primary-secure = <&slot0_s_partition>;
img-primary-nonsecure = <&slot0_ns_partition>;
partition-ps = <&tfm_ps_partition>;
partition-its = <&tfm_its_partition>;
Expand All @@ -33,7 +33,7 @@
complete = <&mx25r64>;
erase-block-size = <4096>;
write-block-size = <1>;
img-secondary-secure = <&slot1_partition>;
img-secondary-secure = <&slot1_s_partition>;
img-secondary-nonsecure = <&slot1_ns_partition>;
};
};
Expand Down
4 changes: 2 additions & 2 deletions snippets/infuse/boards/nrf9151dk_nrf9151_ns.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
driver = "Driver_FLASH0";
complete = <&flash0>;
img-bl2 = <&boot_partition>;
img-primary-secure = <&slot0_partition>;
img-primary-secure = <&slot0_s_partition>;
img-primary-nonsecure = <&slot0_ns_partition>;
img-secondary-secure = <&slot1_partition>;
img-secondary-secure = <&slot1_s_partition>;
img-secondary-nonsecure = <&slot1_ns_partition>;
partition-ps = <&tfm_ps_partition>;
partition-its = <&tfm_its_partition>;
Expand Down
4 changes: 2 additions & 2 deletions snippets/infuse/boards/nrf9161dk_nrf9161_ns.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
driver = "Driver_FLASH0";
complete = <&flash0>;
img-bl2 = <&boot_partition>;
img-primary-secure = <&slot0_partition>;
img-primary-secure = <&slot0_s_partition>;
img-primary-nonsecure = <&slot0_ns_partition>;
img-secondary-secure = <&slot1_partition>;
img-secondary-secure = <&slot1_s_partition>;
img-secondary-nonsecure = <&slot1_ns_partition>;
partition-ps = <&tfm_ps_partition>;
partition-its = <&tfm_its_partition>;
Expand Down
18 changes: 14 additions & 4 deletions snippets/infuse/boards/tauro_nrf9151_ns.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

/* MCUboot secondary on external flash */
/delete-node/ &slot0_partition;
/delete-node/ &slot0_s_partition;
/delete-node/ &slot0_ns_partition;
/delete-node/ &slot1_partition;
/delete-node/ &slot1_s_partition;
/delete-node/ &slot1_ns_partition;

/ {
Expand All @@ -19,7 +21,7 @@
driver = "Driver_FLASH0";
complete = <&flash0>;
img-bl2 = <&boot_partition>;
img-primary-secure = <&slot0_partition>;
img-primary-secure = <&slot0_s_partition>;
img-primary-nonsecure = <&slot0_ns_partition>;
partition-ps = <&tfm_ps_partition>;
partition-its = <&tfm_its_partition>;
Expand All @@ -33,7 +35,7 @@
complete = <&w25q128jv>;
erase-block-size = <4096>;
write-block-size = <1>;
img-secondary-secure = <&slot1_partition>;
img-secondary-secure = <&slot1_s_partition>;
img-secondary-nonsecure = <&slot1_ns_partition>;
};
};
Expand Down Expand Up @@ -105,9 +107,13 @@
};
slot0_partition: partition@10000 {
label = "image-0";
reg = <0x00010000 0x000F0000>;
};
slot0_s_partition: subpartition@10000 {
label = "image-0-secure";
reg = <0x00010000 0x00030000>;
};
slot0_ns_partition: partition@40000 {
slot0_ns_partition: subpartition@40000 {
label = "image-0-nonsecure";
reg = <0x00040000 0xC0000>;
};
Expand Down Expand Up @@ -160,9 +166,13 @@

slot1_partition: partition@0 {
label = "image-1";
reg = <0x00000000 0xF0000>;
};
slot1_s_partition: subpartition@0 {
label = "image-1-secure";
reg = <0x00000000 0x30000>;
};
slot1_ns_partition: partition@30000 {
slot1_ns_partition: subpartition@30000 {
label = "image-1-nonsecure";
reg = <0x00030000 0xC0000>;
};
Expand Down
15 changes: 13 additions & 2 deletions snippets/infuse/boards/thingy53_nrf5340_cpuapp_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@

/* MCUboot secondary on external flash */
/delete-node/ &slot0_partition;
/delete-node/ &slot0_s_partition;
/delete-node/ &slot0_ns_partition;
/delete-node/ &slot1_partition;
/delete-node/ &slot1_s_partition;
/delete-node/ &slot1_ns_partition;

&flash0 {
Expand All @@ -132,9 +134,13 @@
};
slot0_partition: partition@10000 {
label = "image-0";
reg = <0x00010000 0xF0000>;
};
slot0_s_partition: subpartition@10000 {
label = "image-0-secure";
reg = <0x00010000 0x30000>;
};
slot0_ns_partition: partition@40000 {
slot0_ns_partition: subpartition@40000 {
label = "image-0-nonsecure";
reg = <0x00040000 0xC0000>;
};
Expand All @@ -161,11 +167,16 @@
#address-cells = <1>;
#size-cells = <1>;


slot1_partition: partition@0 {
label = "image-1";
reg = <0x00000000 0xF0000>;
};
slot1_s_partition: subpartition@0 {
label = "image-1-secure";
reg = <0x00000000 0x30000>;
};
slot1_ns_partition: partition@30000 {
slot1_ns_partition: subpartition@30000 {
label = "image-1-nonsecure";
reg = <0x00030000 0xC0000>;
};
Expand Down
4 changes: 2 additions & 2 deletions snippets/infuse/boards/thingy53_nrf5340_cpuapp_ns.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
driver = "Driver_FLASH0";
complete = <&flash0>;
img-bl2 = <&boot_partition>;
img-primary-secure = <&slot0_partition>;
img-primary-secure = <&slot0_s_partition>;
img-primary-nonsecure = <&slot0_ns_partition>;
partition-ps = <&tfm_ps_partition>;
partition-its = <&tfm_its_partition>;
Expand All @@ -33,7 +33,7 @@
complete = <&mx25r64>;
erase-block-size = <4096>;
write-block-size = <1>;
img-secondary-secure = <&slot1_partition>;
img-secondary-secure = <&slot1_s_partition>;
img-secondary-nonsecure = <&slot1_ns_partition>;
/* Expected by Laird QSPI driver.
* Ideally driver would consume pinctrl values and
Expand Down
1 change: 1 addition & 0 deletions subsys/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ add_subdirectory_ifdef(CONFIG_MODEM_MODULES modem/backends)
add_subdirectory_ifdef(CONFIG_INFUSE_VALIDATION validation)

add_subdirectory(fs)
add_subdirectory(mgmt)
add_subdirectory(net)
1 change: 1 addition & 0 deletions subsys/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ rsource "epacket/Kconfig"
rsource "tdf/Kconfig"
rsource "fs/Kconfig"
rsource "modem/backends/Kconfig"
rsource "mgmt/Kconfig"
rsource "net/Kconfig"
rsource "rpc/Kconfig"
rsource "task_runner/Kconfig"
Expand Down
3 changes: 3 additions & 0 deletions subsys/mgmt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0

add_subdirectory_ifdef(CONFIG_MCUMGR mcumgr)
1 change: 1 addition & 0 deletions subsys/mgmt/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rsource "mcumgr/Kconfig"
3 changes: 3 additions & 0 deletions subsys/mgmt/mcumgr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0

add_subdirectory_ifdef(CONFIG_MCUMGR_GRP_OS_INFUSE os_mgmt_infuse)
11 changes: 11 additions & 0 deletions subsys/mgmt/mcumgr/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Infuse-IoT mcumgr implementations

if MCUMGR

config MCUMGR_GRP_OS_INFUSE
bool "Infuse-IoT mcumgr handlers for OS management"
select MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
depends on INFUSE_EPOCH_TIME
depends on INFUSE_REBOOT

endif # MCUMGR
4 changes: 4 additions & 0 deletions subsys/mgmt/mcumgr/os_mgmt_infuse/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: Apache-2.0

zephyr_library(mgmt_mcumgr_grp_os)
zephyr_library_sources(os_mgmt_infuse.c)
Loading
Loading