Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -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>;
};
5 changes: 5 additions & 0 deletions samples/subsys/mgmt/mcumgr/smp_svr/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 23 additions & 0 deletions samples/subsys/mgmt/mcumgr/smp_svr/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

#include "common.h"

#include <zephyr/retention/blinfo.h>
#include <bootutil/image.h>

#define STORAGE_PARTITION_LABEL storage_partition
#define STORAGE_PARTITION_ID FIXED_PARTITION_ID(STORAGE_PARTITION_LABEL)

Expand All @@ -50,6 +53,24 @@
};
#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));

Check notice on line 62 in samples/subsys/mgmt/mcumgr/smp_svr/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

samples/subsys/mgmt/mcumgr/smp_svr/src/main.c:62 - int ret = blinfo_lookup(BLINFO_BOOTLOADER_VERSION, - (char *)&version, + int ret = blinfo_lookup(BLINFO_BOOTLOADER_VERSION, (char *)&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,
Expand Down Expand Up @@ -85,6 +106,8 @@
*/
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.
*/
Expand Down
8 changes: 8 additions & 0 deletions samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/mcuboot.conf
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/mcuboot.overlay
Original file line number Diff line number Diff line change
@@ -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>;
};
Loading