stm32mp: stm32prog: add support of STM32IMAGE version 2

Add support of new header for the STM32IMAGE version V2
in command stm32prog command for STM32MP13x family.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
This commit is contained in:
Patrick Delaunay
2022-03-28 19:25:29 +02:00
committed by Patrice Chotard
parent e82ab4c890
commit 49d0ecb123
3 changed files with 120 additions and 54 deletions

View File

@@ -42,6 +42,7 @@ enum stm32prog_link_t {
enum stm32prog_header_t {
HEADER_NONE,
HEADER_STM32IMAGE,
HEADER_STM32IMAGE_V2,
HEADER_FIP,
};
@@ -49,11 +50,12 @@ struct image_header_s {
enum stm32prog_header_t type;
u32 image_checksum;
u32 image_length;
u32 length;
};
struct raw_header_s {
struct stm32_header_v1 {
u32 magic_number;
u32 image_signature[64 / 4];
u8 image_signature[64];
u32 image_checksum;
u32 header_version;
u32 image_length;
@@ -64,12 +66,30 @@ struct raw_header_s {
u32 version_number;
u32 option_flags;
u32 ecdsa_algorithm;
u32 ecdsa_public_key[64 / 4];
u32 padding[83 / 4];
u32 binary_type;
u8 ecdsa_public_key[64];
u8 padding[83];
u8 binary_type;
};
#define BL_HEADER_SIZE sizeof(struct raw_header_s)
struct stm32_header_v2 {
u32 magic_number;
u8 image_signature[64];
u32 image_checksum;
u32 header_version;
u32 image_length;
u32 image_entry_point;
u32 reserved1;
u32 load_address;
u32 reserved2;
u32 version_number;
u32 extension_flags;
u32 extension_headers_length;
u32 binary_type;
u8 padding[16];
u32 extension_header_type;
u32 extension_header_length;
u8 extension_padding[376];
};
/* partition type in flashlayout file */
enum stm32prog_part_type {
@@ -171,8 +191,7 @@ int stm32prog_pmic_read(struct stm32prog_data *data, u32 offset,
int stm32prog_pmic_start(struct stm32prog_data *data);
/* generic part*/
void stm32prog_header_check(struct raw_header_s *raw_header,
struct image_header_s *header);
void stm32prog_header_check(uintptr_t raw_header, struct image_header_s *header);
int stm32prog_dfu_init(struct stm32prog_data *data);
void stm32prog_next_phase(struct stm32prog_data *data);
void stm32prog_do_reset(struct stm32prog_data *data);