zwischenstand

This commit is contained in:
2026-03-21 13:49:05 +01:00
parent b863b04505
commit 01448223ad
30 changed files with 1446 additions and 295 deletions

View File

@@ -0,0 +1,79 @@
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/dfu/mcuboot.h>
#include <zephyr/drivers/hwinfo.h>
#include <zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt.h>
#include <version.h>
#include <app_version.h>
#include "fw_mgmt.h"
#define SLOT1_PARTITION_SIZE DT_REG_SIZE(DT_NODELABEL(slot1_partition))
static char fw_version_string[] = APP_VERSION_STRING;
static char kernel_version_string[] = KERNEL_VERSION_STRING;
static char board_name[] = CONFIG_BOARD;
static char board_revision[] = CONFIG_BOARD_REVISION;
static char soc_name[] = CONFIG_SOC;
static uint8_t hwid[8];
LOG_MODULE_REGISTER(fw_mgmt, CONFIG_FW_MGMT_LOG_LEVEL);
const char* fw_mgmt_get_fw_version_string(void)
{
return (const char*)fw_version_string;
}
const char* fw_mgmt_get_kernel_version_string(void)
{
return (const char*)kernel_version_string;
}
const char* fw_mgmt_get_board_name(void)
{
return (const char*)board_name;
}
const char* fw_mgmt_get_board_revision(void)
{
return (const char*)board_revision;
}
const char* fw_mgmt_get_soc_name(void)
{
return (const char*)soc_name;
}
int fw_mgmt_get_id(uint8_t *buffer, size_t length)
{
int ret = hwinfo_get_device_id(hwid, length);
if (ret < 0) {
LOG_ERR("Failed to get device EUI64: %d", ret);
return ret;
}
memcpy(buffer, hwid, sizeof(hwid));
return ret;
}
fw_state_t fw_mgmt_get_fw_state(void)
{
if (!boot_is_img_confirmed()) {
return FW_STATE_TESTING;
}
int swap_type = mcuboot_swap_type();
if (swap_type == BOOT_SWAP_TYPE_NONE) {
return FW_STATE_CONFIRMED;
} else if (swap_type == BOOT_SWAP_TYPE_TEST) {
return FW_STATE_PENDING;
} else {
LOG_ERR("Unexpected swap type: %d", swap_type);
return FW_STATE_UNKNOWN; // Fallback auf bestätigten Zustand bei unerwartetem Swap-Typ
}
return FW_STATE_UNKNOWN; // Fallback, sollte nie erreicht werden
}
ssize_t fw_mgmt_get_slot1_size(void)
{
return SLOT1_PARTITION_SIZE;
}