Добавить идентификацию прошивки и чтение EEPROM Бальзам-167

This commit is contained in:
2026-10-05 17:48:23 +03:00
parent 0e3d89e1ee
commit 90046de7fd
28 changed files with 924 additions and 22 deletions

View File

@@ -10,6 +10,10 @@
#include <stddef.h>
#include <stdint.h>
/* Least-width octet storage preserves STM ABI, and compiles on C28x where
* CHAR_BIT=16 and uint8_t does not exist. Values sent on wire are masked to 8 bits. */
typedef uint_least8_t firmware_info_octet;
#ifdef __cplusplus
extern "C" {
#endif
@@ -24,11 +28,11 @@ typedef struct {
uint16_t minor;
uint16_t patch;
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minute;
uint8_t second;
firmware_info_octet month;
firmware_info_octet day;
firmware_info_octet hour;
firmware_info_octet minute;
firmware_info_octet second;
char build_id[FIRMWARE_INFO_BUILD_ID_SIZE + 1U];
} firmware_info_t;
@@ -56,7 +60,7 @@ firmware_info_status_t firmware_info_set_build_id(
firmware_info_status_t firmware_info_to_registers(
const firmware_info_t *info, uint16_t *registers, size_t count);
firmware_info_status_t firmware_info_to_le_bytes(
const firmware_info_t *info, uint8_t *payload, size_t size);
const firmware_info_t *info, firmware_info_octet *payload, size_t size);
#ifdef __cplusplus
}

View File

@@ -0,0 +1,22 @@
/* Small, immutable firmware identity for targets with little code space.
* The build tool supplies scalar constants; the C core owns register packing.
* No startup parser, RAM copy, heap, HAL or runtime SHA implementation is needed.
* Include firmware_identity.h (generated BEFORE compilation) before this file.
*/
#ifndef FIRMWARE_INFO_STATIC_H
#define FIRMWARE_INFO_STATIC_H
#include <stdint.h>
#define FIRMWARE_INFO_STATIC_COUNT 12U
/* Cast BEFORE shifting: an int is only 16 bits on both C28x targets. */
#define FI_PAIR(high, low) ((uint16_t)(((uint16_t)(high) << 8U) | (uint16_t)(low)))
#define FIRMWARE_INFO_STATIC_INITIALIZER { \
1U, FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCH, \
FI_YEAR, FI_PAIR(FI_MONTH, FI_DAY), FI_PAIR(FI_HOUR, FI_MINUTE), FI_SECOND, \
FI_PAIR(FI_ID_0, FI_ID_1), FI_PAIR(FI_ID_2, FI_ID_3), \
FI_PAIR(FI_ID_4, FI_ID_5), FI_PAIR(FI_ID_6, FI_ID_7) }
/* Return zero outside the contract. The transport must reject invalid ranges
* before calling this function; zero is NOT an invented firmware version. */
uint16_t firmware_info_static_read(unsigned index);
#endif