Files

46 lines
1.7 KiB
C

#ifndef OTA_MEMORY_MAP_H
#define OTA_MEMORY_MAP_H
#include <stdint.h>
/* CYT4BFBCJE CM0+ owns the first 512 KiB of code flash. */
#define OTA_CODE_FLASH_BASE (0x10000000ul)
#define OTA_BOOTLOADER_SIZE (0x00010000ul) /* immutable 64 KiB */
#define OTA_APPLICATION_BASE (OTA_CODE_FLASH_BASE + OTA_BOOTLOADER_SIZE)
#define OTA_APPLICATION_END (0x10080000ul) /* exclusive */
#define OTA_APPLICATION_MAX_SIZE (OTA_APPLICATION_END - OTA_APPLICATION_BASE)
#define OTA_CODE_FLASH_ROW_SIZE (512ul)
#define OTA_CODE_FLASH_SECTOR_SIZE (0x00008000ul) /* 32 KiB large sector */
/* One 2 KiB work-flash sector is reserved for the committed image manifest. */
#define OTA_METADATA_ADDRESS (0x14000000ul)
#define OTA_WORK_FLASH_SECTOR_SIZE (0x00000800ul)
/* The following Work Flash sector is owned by the seat application state.
* The Bootloader never erases it, so calibration and the last known stopped
* position survive both reset and a CAN OTA application replacement. */
#define OTA_SEAT_STATE_ADDRESS (0x14000800ul)
#define OTA_SEAT_STATE_MAGIC (0x4E375354ul) /* "N7ST" */
#define OTA_SEAT_STATE_VERSION (2ul)
#define OTA_CM0_SRAM_BASE (0x28000000ul)
#define OTA_CM0_SRAM_END (0x28020000ul) /* exclusive for data, valid MSP top */
#define OTA_METADATA_MAGIC (0x4F544131ul) /* "OTA1" */
#define OTA_METADATA_VERSION (1ul)
typedef struct
{
uint32_t magic;
uint32_t formatVersion;
uint32_t imageSize;
uint32_t imageCrc32;
uint32_t imageSizeInverse;
uint32_t imageCrc32Inverse;
uint32_t applicationBase;
uint32_t applicationBaseInverse;
} ota_image_metadata_t;
#endif /* OTA_MEMORY_MAP_H */