diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/boards/nrf54h20dk_nrf54h20_cpuapp_iron.overlay b/samples/subsys/mgmt/mcumgr/smp_svr/boards/nrf54h20dk_nrf54h20_cpuapp_iron.overlay new file mode 100644 index 00000000000..183ae27f104 --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/boards/nrf54h20dk_nrf54h20_cpuapp_iron.overlay @@ -0,0 +1,29 @@ +/ { + sram@22007FC0 { + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x22007FC0 0x40>; + zephyr,memory-region = "RetainedMem"; + status = "okay"; + + retainedmem { + compatible = "zephyr,retained-ram"; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; + + boot_info0: boot_info@0 { + compatible = "zephyr,retention"; + status = "okay"; + reg = <0x0 0x40>; + }; + }; + }; + + chosen { + zephyr,bootloader-info = &boot_info0; + }; +}; + +&cpuapp_ram0 { + reg = <0x22000000 0x7FC0>; +}; diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/prj.conf b/samples/subsys/mgmt/mcumgr/smp_svr/prj.conf index 925ac0c93a2..ef14692d5f4 100644 --- a/samples/subsys/mgmt/mcumgr/smp_svr/prj.conf +++ b/samples/subsys/mgmt/mcumgr/smp_svr/prj.conf @@ -39,3 +39,8 @@ CONFIG_MCUBOOT_UTIL_LOG_LEVEL_WRN=y # Disable debug logging CONFIG_LOG_MAX_LEVEL=3 + +CONFIG_RETAINED_MEM=y +CONFIG_RETENTION=y +CONFIG_RETENTION_BOOTLOADER_INFO=y +CONFIG_RETENTION_BOOTLOADER_INFO_TYPE_MCUBOOT=y diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/src/main.c b/samples/subsys/mgmt/mcumgr/smp_svr/src/main.c index 8b0c0b44a88..611c6fa86fd 100644 --- a/samples/subsys/mgmt/mcumgr/smp_svr/src/main.c +++ b/samples/subsys/mgmt/mcumgr/smp_svr/src/main.c @@ -24,6 +24,9 @@ LOG_MODULE_REGISTER(smp_sample); #include "common.h" +#include +#include + #define STORAGE_PARTITION_LABEL storage_partition #define STORAGE_PARTITION_ID FIXED_PARTITION_ID(STORAGE_PARTITION_LABEL) @@ -50,6 +53,24 @@ static struct fs_mount_t littlefs_mnt = { }; #endif +static void blinfo_bootloader_version(void) +{ + struct image_version version = {0x00}; + + int ret = blinfo_lookup(BLINFO_BOOTLOADER_VERSION, + (char *)&version, + sizeof(struct image_version)); + + if (ret < 0) { + printf("blinfo_lookup error: %d\n", ret); + } else { + printf("bl iv_major: %d\n", version.iv_major); + printf("bl iv_minor: %d\n", version.iv_minor); + printf("bl iv_revision: %d\n", version.iv_revision); + printf("bl iv_build_num: %d\n", version.iv_build_num); + } +} + int main(void) { int rc = STATS_INIT_AND_REG(smp_svr_stats, STATS_SIZE_32, @@ -85,6 +106,8 @@ int main(void) */ LOG_INF("build time: " __DATE__ " " __TIME__); + blinfo_bootloader_version(); + /* The system work queue handles all incoming mcumgr requests. Let the * main thread idle while the mcumgr server runs. */ diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/mcuboot.conf b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/mcuboot.conf new file mode 100644 index 00000000000..37b33471163 --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/mcuboot.conf @@ -0,0 +1,8 @@ +CONFIG_LOG=y +CONFIG_MCUBOOT_LOG_LEVEL_INF=y + +CONFIG_RETAINED_MEM=y +CONFIG_RETENTION=y +CONFIG_BOOT_SHARE_DATA=y +CONFIG_BOOT_SHARE_DATA_BOOTINFO=y +CONFIG_BOOT_SHARE_BACKEND_RETENTION=y diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/mcuboot.overlay b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/mcuboot.overlay new file mode 100644 index 00000000000..76d4c0c34a1 --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/mcuboot.overlay @@ -0,0 +1,30 @@ +/ { + sram@22007FC0 { + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x22007FC0 0x40>; + zephyr,memory-region = "RetainedMem"; + status = "okay"; + + retainedmem { + compatible = "zephyr,retained-ram"; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; + + boot_info0: boot_info@0 { + compatible = "zephyr,retention"; + status = "okay"; + reg = <0x0 0x40>; + }; + }; + }; + + chosen { + zephyr,bootloader-info = &boot_info0; + zephyr,code-partition = &boot_partition; + }; +}; + +&cpuapp_ram0 { + reg = <0x22000000 0x7FC0>; +};