bootloader: Move chip specific things under chip specific folders

- move systick.c under chip specific sources
- move do_jump into chip specific main.c as arch_do_jump
- wrap flash writes to "arch_flash_write" and implement in chip specific main.c
- add bootloader TOC check
- sync image_toc.h with the version currently in use with old bootloader

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
Jukka Laitinen
2021-05-18 13:19:10 +03:00
committed by David Sidrane
parent 3e18fa12d6
commit 64d264b49a
20 changed files with 462 additions and 33 deletions

View File

@@ -34,6 +34,11 @@
#ifndef _IMAGE_TOC_H
#define _IMAGE_TOC_H
#include <stdbool.h>
/* Max number of TOC entries */
#define MAX_TOC_ENTRIES 32
/* Table of contents entry flags, describing what to
do with the image
*/
@@ -41,6 +46,7 @@
#define TOC_FLAG1_VTORS 0x2
#define TOC_FLAG1_CHECK_SIGNATURE 0x4
#define TOC_FLAG1_DECRYPT 0x8
#define TOC_FLAG1_COPY 0x10
#define TOC_FLAG1_RDCT 0x80
@@ -54,7 +60,6 @@
#define TOC_VERSION BOARD_IMAGE_TOC_VERSION
#endif
/* Markers for TOC start and end in the image */
typedef const struct __attribute__((__packed__)) image_toc_start {
@@ -68,7 +73,7 @@ typedef struct __attribute__((__packed__)) image_toc_entry {
unsigned char name[4]; /* Name of the section */
const void *start; /* Start address of the section in flash */
const void *end; /* End of the section */
const void *target; /* Copy target address of the section */
void *target; /* Copy target address of the section */
uint8_t signature_idx; /* Index to the signature in the TOC */
uint8_t signature_key; /* Key index for the signature */
uint8_t encryption_key; /* Key index for encryption */
@@ -102,4 +107,15 @@ typedef struct __attribute__((__packed__))
uint8_t signature[];
} image_cert_t;
extern bool find_toc(const image_toc_entry_t **toc_entries, uint8_t *len);
/* If decrypt or copy flags are defined, this returns the target address.
* Otherwise, return the start address.
*/
inline static const void *get_base_addr(const image_toc_entry_t *e)
{
return (e->flags1 & TOC_FLAG1_DECRYPT) || (e->flags1 & TOC_FLAG1_COPY) ?
e->target : e->start;
}
#endif