Merge branch 'u-boot-imx/master' into 'u-boot-arm/master'

Conflicts:
	drivers/serial/serial.c

The conflict above was a trivial case of adding one init
function in each branch, and manually resolved in merge.
This commit is contained in:
Albert ARIBAUD
2013-09-05 11:15:26 +02:00
33 changed files with 3692 additions and 98 deletions

View File

@@ -70,31 +70,32 @@ EXT_OBJ_FILES-y += lib/md5.o
EXT_OBJ_FILES-y += lib/sha1.o
# Source files located in the tools directory
OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
NOPED_OBJ_FILES-y += default_image.o
NOPED_OBJ_FILES-y += proftool.o
OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc.o
NOPED_OBJ_FILES-y += fit_image.o
OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
OBJ_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes.o
NOPED_OBJ_FILES-y += aisimage.o
NOPED_OBJ_FILES-y += kwbimage.o
NOPED_OBJ_FILES-y += pblimage.o
NOPED_OBJ_FILES-y += imximage.o
NOPED_OBJ_FILES-y += default_image.o
NOPED_OBJ_FILES-y += fit_image.o
NOPED_OBJ_FILES-y += image-host.o
NOPED_OBJ_FILES-y += omapimage.o
NOPED_OBJ_FILES-y += imximage.o
NOPED_OBJ_FILES-y += kwbimage.o
NOPED_OBJ_FILES-y += mkenvimage.o
NOPED_OBJ_FILES-y += mkimage.o
OBJ_FILES-$(CONFIG_SMDK5250) += mkexynosspl.o
NOPED_OBJ_FILES-y += mxsimage.o
NOPED_OBJ_FILES-y += omapimage.o
NOPED_OBJ_FILES-y += os_support.o
NOPED_OBJ_FILES-y += pblimage.o
NOPED_OBJ_FILES-y += proftool.o
NOPED_OBJ_FILES-y += ublimage.o
OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc.o
OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
OBJ_FILES-$(CONFIG_KIRKWOOD) += kwboot.o
OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
OBJ_FILES-$(CONFIG_MX23) += mxsboot.o
OBJ_FILES-$(CONFIG_MX28) += mxsboot.o
OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
NOPED_OBJ_FILES-y += os_support.o
OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
NOPED_OBJ_FILES-y += ublimage.o
OBJ_FILES-$(CONFIG_KIRKWOOD) += kwboot.o
OBJ_FILES-$(CONFIG_SMDK5250) += mkexynosspl.o
OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
OBJ_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes.o
# Don't build by default
#ifeq ($(ARCH),ppc)
@@ -203,20 +204,21 @@ $(obj)mkenvimage$(SFX): $(obj)crc32.o $(obj)mkenvimage.o \
$(HOSTSTRIP) $@
$(obj)mkimage$(SFX): $(obj)aisimage.o \
$(FIT_SIG_OBJS) \
$(obj)crc32.o \
$(obj)default_image.o \
$(obj)fit_image.o \
$(obj)image-fit.o \
$(obj)image.o \
$(obj)image-host.o \
$(FIT_SIG_OBJS) \
$(obj)image.o \
$(obj)imximage.o \
$(obj)kwbimage.o \
$(obj)pblimage.o \
$(obj)md5.o \
$(obj)mkimage.o \
$(obj)os_support.o \
$(obj)mxsimage.o \
$(obj)omapimage.o \
$(obj)os_support.o \
$(obj)pblimage.o \
$(obj)sha1.o \
$(obj)ublimage.o \
$(LIBFDT_OBJS) \

View File

@@ -13,6 +13,8 @@
#include <image.h>
#include "imximage.h"
#define UNDEFINED 0xFFFFFFFF
/*
* Supported commands for configuration file
*/
@@ -20,6 +22,7 @@ static table_entry_t imximage_cmds[] = {
{CMD_BOOT_FROM, "BOOT_FROM", "boot command", },
{CMD_BOOT_OFFSET, "BOOT_OFFSET", "Boot offset", },
{CMD_DATA, "DATA", "Reg Write Data", },
{CMD_CSF, "CSF", "Command Sequence File", },
{CMD_IMAGE_VERSION, "IMAGE_VERSION", "image version", },
{-1, "", "", },
};
@@ -28,7 +31,7 @@ static table_entry_t imximage_cmds[] = {
* Supported Boot options for configuration file
* this is needed to set the correct flash offset
*/
static table_entry_t imximage_bootops[] = {
static table_entry_t imximage_boot_offset[] = {
{FLASH_OFFSET_ONENAND, "onenand", "OneNAND Flash",},
{FLASH_OFFSET_NAND, "nand", "NAND Flash", },
{FLASH_OFFSET_NOR, "nor", "NOR Flash", },
@@ -38,6 +41,20 @@ static table_entry_t imximage_bootops[] = {
{-1, "", "Invalid", },
};
/*
* Supported Boot options for configuration file
* this is needed to determine the initial load size
*/
static table_entry_t imximage_boot_loadsize[] = {
{FLASH_LOADSIZE_ONENAND, "onenand", "OneNAND Flash",},
{FLASH_LOADSIZE_NAND, "nand", "NAND Flash", },
{FLASH_LOADSIZE_NOR, "nor", "NOR Flash", },
{FLASH_LOADSIZE_SATA, "sata", "SATA Disk", },
{FLASH_LOADSIZE_SD, "sd", "SD Card", },
{FLASH_LOADSIZE_SPI, "spi", "SPI Flash", },
{-1, "", "Invalid", },
};
/*
* IMXIMAGE version definition for i.MX chips
*/
@@ -49,12 +66,22 @@ static table_entry_t imximage_versions[] = {
static struct imx_header imximage_header;
static uint32_t imximage_version;
/*
* Image Vector Table Offset
* Initialized to a wrong not 4-bytes aligned address to
* check if it is was set by the cfg file.
*/
static uint32_t imximage_ivt_offset = UNDEFINED;
static uint32_t imximage_csf_size = UNDEFINED;
/* Initial Load Region Size */
static uint32_t imximage_init_loadsize;
static set_dcd_val_t set_dcd_val;
static set_dcd_rst_t set_dcd_rst;
static set_imx_hdr_t set_imx_hdr;
static uint32_t max_dcd_entries;
static uint32_t *header_size_ptr;
static uint32_t *csf_ptr;
static uint32_t get_cfg_value(char *token, char *name, int linenr)
{
@@ -190,7 +217,8 @@ static void set_imx_hdr_v1(struct imx_header *imxhdr, uint32_t dcd_len,
/* Set magic number */
fhdr_v1->app_code_barker = APP_CODE_BARKER;
hdr_base = entry_point - sizeof(struct imx_header);
/* TODO: check i.MX image V1 handling, for now use 'old' style */
hdr_base = entry_point - 4096;
fhdr_v1->app_dest_ptr = hdr_base - flash_offset;
fhdr_v1->app_code_jump_vector = entry_point;
@@ -217,16 +245,18 @@ static void set_imx_hdr_v2(struct imx_header *imxhdr, uint32_t dcd_len,
fhdr_v2->entry = entry_point;
fhdr_v2->reserved1 = fhdr_v2->reserved2 = 0;
fhdr_v2->self = hdr_base = entry_point - sizeof(struct imx_header);
hdr_base = entry_point - imximage_init_loadsize +
flash_offset;
fhdr_v2->self = hdr_base;
fhdr_v2->dcd_ptr = hdr_base + offsetof(imx_header_v2_t, dcd_table);
fhdr_v2->boot_data_ptr = hdr_base
+ offsetof(imx_header_v2_t, boot_data);
hdr_v2->boot_data.start = hdr_base - flash_offset;
hdr_v2->boot_data.start = entry_point - imximage_init_loadsize;
/* Security feature are not supported */
fhdr_v2->csf = 0;
header_size_ptr = &hdr_v2->boot_data.size;
csf_ptr = &fhdr_v2->csf;
}
static void set_hdr_func(struct imx_header *imxhdr)
@@ -303,6 +333,13 @@ static void print_hdr_v2(struct imx_header *imx_hdr)
genimg_print_size(hdr_v2->boot_data.size);
printf("Load Address: %08x\n", (uint32_t)fhdr_v2->boot_data_ptr);
printf("Entry Point: %08x\n", (uint32_t)fhdr_v2->entry);
if (fhdr_v2->csf && (imximage_ivt_offset != UNDEFINED) &&
(imximage_csf_size != UNDEFINED)) {
printf("HAB Blocks: %08x %08x %08x\n",
(uint32_t)fhdr_v2->self, 0,
hdr_v2->boot_data.size - imximage_ivt_offset -
imximage_csf_size);
}
}
static void parse_cfg_cmd(struct imx_header *imxhdr, int32_t cmd, char *token,
@@ -324,18 +361,36 @@ static void parse_cfg_cmd(struct imx_header *imxhdr, int32_t cmd, char *token,
set_hdr_func(imxhdr);
break;
case CMD_BOOT_FROM:
imxhdr->flash_offset = get_table_entry_id(imximage_bootops,
imximage_ivt_offset = get_table_entry_id(imximage_boot_offset,
"imximage boot option", token);
if (imxhdr->flash_offset == -1) {
if (imximage_ivt_offset == -1) {
fprintf(stderr, "Error: %s[%d] -Invalid boot device"
"(%s)\n", name, lineno, token);
exit(EXIT_FAILURE);
}
imximage_init_loadsize =
get_table_entry_id(imximage_boot_loadsize,
"imximage boot option", token);
if (imximage_init_loadsize == -1) {
fprintf(stderr,
"Error: %s[%d] -Invalid boot device(%s)\n",
name, lineno, token);
exit(EXIT_FAILURE);
}
/*
* The SOC loads from the storage starting at address 0
* then ensures that the load size contains the offset
*/
if (imximage_init_loadsize < imximage_ivt_offset)
imximage_init_loadsize = imximage_ivt_offset;
if (unlikely(cmd_ver_first != 1))
cmd_ver_first = 0;
break;
case CMD_BOOT_OFFSET:
imxhdr->flash_offset = get_cfg_value(token, name, lineno);
imximage_ivt_offset = get_cfg_value(token, name, lineno);
if (unlikely(cmd_ver_first != 1))
cmd_ver_first = 0;
break;
@@ -345,6 +400,17 @@ static void parse_cfg_cmd(struct imx_header *imxhdr, int32_t cmd, char *token,
if (unlikely(cmd_ver_first != 1))
cmd_ver_first = 0;
break;
case CMD_CSF:
if (imximage_version != 2) {
fprintf(stderr,
"Error: %s[%d] - CSF only supported for VERSION 2(%s)\n",
name, lineno, token);
exit(EXIT_FAILURE);
}
imximage_csf_size = get_cfg_value(token, name, lineno);
if (unlikely(cmd_ver_first != 1))
cmd_ver_first = 0;
break;
}
}
@@ -405,7 +471,8 @@ static uint32_t parse_cfg_file(struct imx_header *imxhdr, char *name)
exit(EXIT_FAILURE);
}
/* Very simple parsing, line starting with # are comments
/*
* Very simple parsing, line starting with # are comments
* and are dropped
*/
while ((getline(&line, &len, fd)) > 0) {
@@ -436,7 +503,7 @@ static uint32_t parse_cfg_file(struct imx_header *imxhdr, char *name)
fclose(fd);
/* Exit if there is no BOOT_FROM field specifying the flash_offset */
if (imxhdr->flash_offset == FLASH_OFFSET_UNDEFINED) {
if (imximage_ivt_offset == FLASH_OFFSET_UNDEFINED) {
fprintf(stderr, "Error: No BOOT_FROM tag in %s\n", name);
exit(EXIT_FAILURE);
}
@@ -494,14 +561,15 @@ static void imximage_set_header(void *ptr, struct stat *sbuf, int ifd,
*/
imximage_version = IMXIMAGE_V1;
/* Be able to detect if the cfg file has no BOOT_FROM tag */
imxhdr->flash_offset = FLASH_OFFSET_UNDEFINED;
imximage_ivt_offset = FLASH_OFFSET_UNDEFINED;
imximage_csf_size = 0;
set_hdr_func(imxhdr);
/* Parse dcd configuration file */
dcd_len = parse_cfg_file(imxhdr, params->imagename);
/* Set the imx header */
(*set_imx_hdr)(imxhdr, dcd_len, params->ep, imxhdr->flash_offset);
(*set_imx_hdr)(imxhdr, dcd_len, params->ep, imximage_ivt_offset);
/*
* ROM bug alert
@@ -512,7 +580,13 @@ static void imximage_set_header(void *ptr, struct stat *sbuf, int ifd,
*
* The remaining fraction of a block bytes would not be loaded!
*/
*header_size_ptr = ROUND(sbuf->st_size + imxhdr->flash_offset, 4096);
*header_size_ptr = ROUND(sbuf->st_size, 4096);
if (csf_ptr && imximage_csf_size) {
*csf_ptr = params->ep - imximage_init_loadsize +
*header_size_ptr;
*header_size_ptr += imximage_csf_size;
}
}
int imximage_check_params(struct mkimage_params *params)
@@ -537,18 +611,92 @@ int imximage_check_params(struct mkimage_params *params)
(params->xflag) || !(strlen(params->imagename));
}
static int imximage_generate(struct mkimage_params *params,
struct image_type_params *tparams)
{
struct imx_header *imxhdr;
size_t alloc_len;
struct stat sbuf;
char *datafile = params->datafile;
uint32_t pad_len;
memset(&imximage_header, 0, sizeof(imximage_header));
/*
* In order to not change the old imx cfg file
* by adding VERSION command into it, here need
* set up function ptr group to V1 by default.
*/
imximage_version = IMXIMAGE_V1;
/* Be able to detect if the cfg file has no BOOT_FROM tag */
imximage_ivt_offset = FLASH_OFFSET_UNDEFINED;
imximage_csf_size = 0;
set_hdr_func(imxhdr);
/* Parse dcd configuration file */
parse_cfg_file(&imximage_header, params->imagename);
/* TODO: check i.MX image V1 handling, for now use 'old' style */
if (imximage_version == IMXIMAGE_V1) {
alloc_len = 4096;
} else {
if (imximage_init_loadsize < imximage_ivt_offset +
sizeof(imx_header_v2_t))
imximage_init_loadsize = imximage_ivt_offset +
sizeof(imx_header_v2_t);
alloc_len = imximage_init_loadsize - imximage_ivt_offset;
}
if (alloc_len < sizeof(struct imx_header)) {
fprintf(stderr, "%s: header error\n",
params->cmdname);
exit(EXIT_FAILURE);
}
imxhdr = malloc(alloc_len);
if (!imxhdr) {
fprintf(stderr, "%s: malloc return failure: %s\n",
params->cmdname, strerror(errno));
exit(EXIT_FAILURE);
}
memset(imxhdr, 0, alloc_len);
tparams->header_size = alloc_len;
tparams->hdr = imxhdr;
/* determine data image file length */
if (stat(datafile, &sbuf) < 0) {
fprintf(stderr, "%s: Can't stat %s: %s\n",
params->cmdname, datafile, strerror(errno));
exit(EXIT_FAILURE);
}
pad_len = ROUND(sbuf.st_size, 4096) - sbuf.st_size;
/* TODO: check i.MX image V1 handling, for now use 'old' style */
if (imximage_version == IMXIMAGE_V1)
return 0;
else
return pad_len;
}
/*
* imximage parameters
*/
static struct image_type_params imximage_params = {
.name = "Freescale i.MX Boot Image support",
.header_size = sizeof(struct imx_header),
.hdr = (void *)&imximage_header,
.header_size = 0,
.hdr = NULL,
.check_image_type = imximage_check_image_types,
.verify_header = imximage_verify_header,
.print_header = imximage_print_header,
.set_header = imximage_set_header,
.check_params = imximage_check_params,
.vrec_header = imximage_generate,
};
void init_imx_image_type(void)

View File

@@ -13,14 +13,14 @@
#define APP_CODE_BARKER 0xB1
#define DCD_BARKER 0xB17219E9
#define HEADER_OFFSET 0x400
/*
* NOTE: This file must be kept in sync with arch/arm/include/asm/\
* imx-common/imximage.cfg because tools/imximage.c can not
* cross-include headers from arch/arm/ and vice-versa.
*/
#define CMD_DATA_STR "DATA"
/* Initial Vector Table Offset */
#define FLASH_OFFSET_UNDEFINED 0xFFFFFFFF
#define FLASH_OFFSET_STANDARD 0x400
#define FLASH_OFFSET_NAND FLASH_OFFSET_STANDARD
@@ -30,6 +30,16 @@
#define FLASH_OFFSET_NOR 0x1000
#define FLASH_OFFSET_SATA FLASH_OFFSET_STANDARD
/* Initial Load Region Size */
#define FLASH_LOADSIZE_UNDEFINED 0xFFFFFFFF
#define FLASH_LOADSIZE_STANDARD 0x1000
#define FLASH_LOADSIZE_NAND FLASH_LOADSIZE_STANDARD
#define FLASH_LOADSIZE_SD FLASH_LOADSIZE_STANDARD
#define FLASH_LOADSIZE_SPI FLASH_LOADSIZE_STANDARD
#define FLASH_LOADSIZE_ONENAND 0x400
#define FLASH_LOADSIZE_NOR 0x0 /* entire image */
#define FLASH_LOADSIZE_SATA FLASH_LOADSIZE_STANDARD
#define IVT_HEADER_TAG 0xD1
#define IVT_VERSION 0x40
#define DCD_HEADER_TAG 0xD2
@@ -42,7 +52,8 @@ enum imximage_cmd {
CMD_IMAGE_VERSION,
CMD_BOOT_FROM,
CMD_BOOT_OFFSET,
CMD_DATA
CMD_DATA,
CMD_CSF,
};
enum imximage_fld_types {
@@ -147,8 +158,7 @@ struct imx_header {
imx_header_v1_t hdr_v1;
imx_header_v2_t hdr_v2;
} header;
uint32_t flash_offset;
} __attribute__((aligned(4096)));
};
typedef void (*set_dcd_val_t)(struct imx_header *imxhdr,
char *name, int lineno,

View File

@@ -137,6 +137,7 @@ main (int argc, char **argv)
char *ptr;
int retval = 0;
struct image_type_params *tparams = NULL;
int pad_len = 0;
/* Init Freescale PBL Boot image generation/list support */
init_pbl_image_type();
@@ -144,6 +145,8 @@ main (int argc, char **argv)
init_kwb_image_type ();
/* Init Freescale imx Boot image generation/list support */
init_imx_image_type ();
/* Init Freescale mxs Boot image generation/list support */
init_mxs_image_type();
/* Init FIT image generation/list support */
init_fit_image_type ();
/* Init TI OMAP Boot image generation/list support */
@@ -391,7 +394,7 @@ NXTARG: ;
* allocate memory for the header itself.
*/
if (tparams->vrec_header)
tparams->vrec_header(&params, tparams);
pad_len = tparams->vrec_header(&params, tparams);
else
memset(tparams->hdr, 0, tparams->header_size);
@@ -463,7 +466,7 @@ NXTARG: ;
/* PBL has special Image format, implements its' own */
pbl_load_uboot(ifd, &params);
} else {
copy_file (ifd, params.datafile, 0);
copy_file(ifd, params.datafile, pad_len);
}
}
@@ -537,10 +540,19 @@ copy_file (int ifd, const char *datafile, int pad)
unsigned char *ptr;
int tail;
int zero = 0;
uint8_t zeros[4096];
int offset = 0;
int size;
struct image_type_params *tparams = mkimage_get_type (params.type);
if (pad >= sizeof(zeros)) {
fprintf(stderr, "%s: Can't pad to %d\n",
params.cmdname, pad);
exit(EXIT_FAILURE);
}
memset(zeros, 0, sizeof(zeros));
if (params.vflag) {
fprintf (stderr, "Adding Image %s\n", datafile);
}
@@ -598,7 +610,8 @@ copy_file (int ifd, const char *datafile, int pad)
exit (EXIT_FAILURE);
}
if (pad && ((tail = size % 4) != 0)) {
tail = size % 4;
if ((pad == 1) && (tail != 0)) {
if (write(ifd, (char *)&zero, 4-tail) != 4-tail) {
fprintf (stderr, "%s: Write error on %s: %s\n",
@@ -606,6 +619,13 @@ copy_file (int ifd, const char *datafile, int pad)
strerror(errno));
exit (EXIT_FAILURE);
}
} else if (pad > 1) {
if (write(ifd, (char *)&zeros, pad) != pad) {
fprintf(stderr, "%s: Write error on %s: %s\n",
params.cmdname, params.imagefile,
strerror(errno));
exit(EXIT_FAILURE);
}
}
(void) munmap((void *)ptr, sbuf.st_size);

View File

@@ -132,7 +132,10 @@ struct image_type_params {
/*
* This callback function will be executed for variable size record
* It is expected to build this header in memory and return its length
* and a pointer to it
* and a pointer to it by using image_type_params.header_size and
* image_type_params.hdr. The return value shall indicate if an
* additional padding should be used when copying the data image
* by returning the padding length.
*/
int (*vrec_header) (struct mkimage_params *,
struct image_type_params *);
@@ -158,6 +161,7 @@ void init_pbl_image_type(void);
void init_ais_image_type(void);
void init_kwb_image_type (void);
void init_imx_image_type (void);
void init_mxs_image_type(void);
void init_default_image_type (void);
void init_fit_image_type (void);
void init_ubl_image_type(void);

View File

@@ -28,14 +28,14 @@
*
* TWEAK this if you have different kind of NAND chip.
*/
uint32_t nand_writesize = 2048;
uint32_t nand_oobsize = 64;
uint32_t nand_erasesize = 128 * 1024;
static uint32_t nand_writesize = 2048;
static uint32_t nand_oobsize = 64;
static uint32_t nand_erasesize = 128 * 1024;
/*
* Sector on which the SigmaTel boot partition (0x53) starts.
*/
uint32_t sd_sector = 2048;
static uint32_t sd_sector = 2048;
/*
* Each of the U-Boot bootstreams is at maximum 1MB big.
@@ -434,7 +434,7 @@ static int mx28_nand_write_firmware(struct mx28_nand_fcb *fcb, int infd,
return 0;
}
void usage(void)
static void usage(void)
{
printf(
"Usage: mxsboot [ops] <type> <infile> <outfile>\n"
@@ -575,7 +575,7 @@ err0:
return ret;
}
int parse_ops(int argc, char **argv)
static int parse_ops(int argc, char **argv)
{
int i;
int tmp;

2347
tools/mxsimage.c Normal file

File diff suppressed because it is too large Load Diff

230
tools/mxsimage.h Normal file
View File

@@ -0,0 +1,230 @@
/*
* Freescale i.MX28 SB image generator
*
* Copyright (C) 2012 Marek Vasut <marex@denx.de>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __MXSSB_H__
#define __MXSSB_H__
#include <stdint.h>
#include <arpa/inet.h>
#define SB_BLOCK_SIZE 16
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
struct sb_boot_image_version {
uint16_t major;
uint16_t pad0;
uint16_t minor;
uint16_t pad1;
uint16_t revision;
uint16_t pad2;
};
struct sb_boot_image_header {
union {
/* SHA1 of the header. */
uint8_t digest[20];
struct {
/* CBC-MAC initialization vector. */
uint8_t iv[16];
uint8_t extra[4];
};
};
/* 'STMP' */
uint8_t signature1[4];
/* Major version of the image format. */
uint8_t major_version;
/* Minor version of the image format. */
uint8_t minor_version;
/* Flags associated with the image. */
uint16_t flags;
/* Size of the image in 16b blocks. */
uint32_t image_blocks;
/* Offset of the first tag in 16b blocks. */
uint32_t first_boot_tag_block;
/* ID of the section to boot from. */
uint32_t first_boot_section_id;
/* Amount of crypto keys. */
uint16_t key_count;
/* Offset to the key dictionary in 16b blocks. */
uint16_t key_dictionary_block;
/* Size of this header in 16b blocks. */
uint16_t header_blocks;
/* Amount of section headers. */
uint16_t section_count;
/* Section header size in 16b blocks. */
uint16_t section_header_size;
/* Padding to align timestamp to uint64_t. */
uint8_t padding0[2];
/* 'sgtl' (since v1.1) */
uint8_t signature2[4];
/* Image generation date, in microseconds since 1.1.2000 . */
uint64_t timestamp_us;
/* Product version. */
struct sb_boot_image_version
product_version;
/* Component version. */
struct sb_boot_image_version
component_version;
/* Drive tag for the system drive. (since v1.1) */
uint16_t drive_tag;
/* Padding. */
uint8_t padding1[6];
};
#define SB_VERSION_MAJOR 1
#define SB_VERSION_MINOR 1
/* Enable to HTLLC verbose boot report. */
#define SB_IMAGE_FLAG_VERBOSE (1 << 0)
struct sb_key_dictionary_key {
/* The CBC-MAC of image and sections header. */
uint8_t cbc_mac[SB_BLOCK_SIZE];
/* The AES key encrypted by image key (zero). */
uint8_t key[SB_BLOCK_SIZE];
};
struct sb_ivt_header {
uint32_t header;
uint32_t entry;
uint32_t reserved1;
uint32_t dcd;
uint32_t boot_data;
uint32_t self;
uint32_t csf;
uint32_t reserved2;
};
#define SB_HAB_IVT_TAG 0xd1UL
#define SB_HAB_DCD_TAG 0xd2UL
#define SB_HAB_VERSION 0x40UL
/*
* The "size" field in the IVT header is not naturally aligned,
* use this macro to fill first 4 bytes of the IVT header without
* causing issues on some systems (esp. M68k, PPC, MIPS-BE, ARM-BE).
*/
static inline uint32_t sb_hab_ivt_header(void)
{
uint32_t ret = 0;
ret |= SB_HAB_IVT_TAG << 24;
ret |= sizeof(struct sb_ivt_header) << 16;
ret |= SB_HAB_VERSION;
return htonl(ret);
}
struct sb_sections_header {
/* Section number. */
uint32_t section_number;
/* Offset of this sections first instruction after "TAG". */
uint32_t section_offset;
/* Size of the section in 16b blocks. */
uint32_t section_size;
/* Section flags. */
uint32_t section_flags;
};
#define SB_SECTION_FLAG_BOOTABLE (1 << 0)
struct sb_command {
struct {
uint8_t checksum;
uint8_t tag;
uint16_t flags;
#define ROM_TAG_CMD_FLAG_ROM_LAST_TAG 0x1
#define ROM_LOAD_CMD_FLAG_DCD_LOAD 0x1 /* MX28 only */
#define ROM_JUMP_CMD_FLAG_HAB 0x1 /* MX28 only */
#define ROM_CALL_CMD_FLAG_HAB 0x1 /* MX28 only */
} header;
union {
struct {
uint32_t reserved[3];
} nop;
struct {
uint32_t section_number;
uint32_t section_length;
uint32_t section_flags;
} tag;
struct {
uint32_t address;
uint32_t count;
uint32_t crc32;
} load;
struct {
uint32_t address;
uint32_t count;
uint32_t pattern;
} fill;
struct {
uint32_t address;
uint32_t reserved;
/* Passed in register r0 before JUMP */
uint32_t argument;
} jump;
struct {
uint32_t address;
uint32_t reserved;
/* Passed in register r0 before CALL */
uint32_t argument;
} call;
struct {
uint32_t reserved1;
uint32_t reserved2;
uint32_t mode;
} mode;
};
};
/*
* Most of the mode names are same or at least similar
* on i.MX23 and i.MX28, but some of the mode names
* differ. The "name" field represents the mode name
* on i.MX28 as seen in Table 12-2 of the datasheet.
* The "altname" field represents the differently named
* fields on i.MX23 as seen in Table 35-3 of the
* datasheet.
*/
static const struct {
const char *name;
const char *altname;
const uint8_t mode;
} modetable[] = {
{ "USB", NULL, 0x00 },
{ "I2C", NULL, 0x01 },
{ "SPI2_FLASH", "SPI1_FLASH", 0x02 },
{ "SPI3_FLASH", "SPI2_FLASH", 0x03 },
{ "NAND_BCH", NULL, 0x04 },
{ "JTAG", NULL, 0x06 },
{ "SPI3_EEPROM", "SPI2_EEPROM", 0x08 },
{ "SD_SSP0", NULL, 0x09 },
{ "SD_SSP1", NULL, 0x0A }
};
enum sb_tag {
ROM_NOP_CMD = 0x00,
ROM_TAG_CMD = 0x01,
ROM_LOAD_CMD = 0x02,
ROM_FILL_CMD = 0x03,
ROM_JUMP_CMD = 0x04,
ROM_CALL_CMD = 0x05,
ROM_MODE_CMD = 0x06
};
struct sb_source_entry {
uint8_t tag;
uint32_t address;
uint32_t flags;
char *filename;
};
#endif /* __MXSSB_H__ */