Commit 8edcde5e4e2e7f6bc7e277011fed71e64fd9d294

Authored by Stefano Babic
Committed by Wolfgang Denk
1 parent a21fb981d5

mkimage: Add Freescale imx Boot Image support (imximage)

This patch adds support for "imximage" (MX Boot Image)
to the mkimage utility. The imximage is used on the Freescales's
MX.25, MX.35 and MX.51 processors.

Further details under doc/README.imximage.

This patch was tested on a Freescale mx51evk board.

Signed-off-by: Stefano Babic <sbabic@denx.de>

Showing 9 changed files with 628 additions and 0 deletions Side-by-side Diff

... ... @@ -324,6 +324,10 @@
324 324 sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
325 325 -d $< $@
326 326  
  327 +$(obj)u-boot.imx: $(obj)u-boot.bin
  328 + $(obj)tools/mkimage -n $(IMX_CONFIG) -T imximage \
  329 + -e $(TEXT_BASE) -d $< $@
  330 +
327 331 $(obj)u-boot.kwb: $(obj)u-boot.bin
328 332 $(obj)tools/mkimage -n $(KWD_CONFIG) -T kwbimage \
329 333 -a $(TEXT_BASE) -e $(TEXT_BASE) -d $< $@
... ... @@ -140,6 +140,7 @@
140 140 { IH_TYPE_STANDALONE, "standalone", "Standalone Program", },
141 141 { IH_TYPE_FLATDT, "flat_dt", "Flat Device Tree", },
142 142 { IH_TYPE_KWBIMAGE, "kwbimage", "Kirkwood Boot Image",},
  143 + { IH_TYPE_IMXIMAGE, "imximage", "Freescale i.MX Boot Image",},
143 144 { -1, "", "", },
144 145 };
145 146  
  1 +---------------------------------------------
  2 +Imximage Boot Image generation using mkimage
  3 +---------------------------------------------
  4 +
  5 +This document describes how to set up a U-Boot image
  6 +that can be booted by Freescale MX25, MX35 and MX51
  7 +processors via internal boot mode.
  8 +
  9 +These processors can boot directly from NAND, SPI flash and SD card flash
  10 +using its internal boot ROM support. They can boot from an internal
  11 +UART, if booting from device media fails.
  12 +Booting from NOR flash does not require to use this image type.
  13 +
  14 +For more details refer Chapter 2 - System Boot and section 2.14
  15 +(flash header description) of the processor's manual.
  16 +
  17 +This implementation does not use at the moment the secure boot feature
  18 +of the processor. The image is generated disabling all security fields.
  19 +
  20 +Command syntax:
  21 +--------------
  22 +./tools/mkimage -l <mx u-boot_file>
  23 + to list the imx image file details
  24 +
  25 +./tools/mkimage -T imximage \
  26 + -n <board specific configuration file> \
  27 + -e <execution address> -d <u-boot binary> <output image file>
  28 +
  29 +For example, for the mx51evk board:
  30 +./tools/mkimage -n ./board/freescale/mx51evk/imximage.cfg \
  31 + -T imximage -e 0x97800000 \
  32 + -d u-boot.bin u-boot.imx
  33 +
  34 +You can generate directly the image when you compile u-boot with:
  35 +
  36 +$ make u-boot.imx
  37 +
  38 +The output image can be flashed on the board SPI flash or on a SD card.
  39 +In both cases, you have to copy the image at the offset required for the
  40 +chosen media devices (0x400 for both SPI flash or SD card).
  41 +
  42 +Please check Freescale documentation for further details.
  43 +
  44 +Board specific configuration file specifications:
  45 +-------------------------------------------------
  46 +1. This file must present in the $(BOARDDIR) and the name should be
  47 + imximage.cfg (since this is used in Makefile).
  48 +2. This file can have empty lines and lines starting with "#" as first
  49 + character to put comments.
  50 +3. This file can have configuration command lines as mentioned below,
  51 + any other information in this file is treated as invalid.
  52 +
  53 +Configuration command line syntax:
  54 +---------------------------------
  55 +1. Each command line is must have two strings, first one command or address
  56 + and second one data string
  57 +2. Following are the valid command strings and associated data strings:-
  58 + Command string data string
  59 + -------------- -----------
  60 + BOOT_FROM nand/spi/sd/onenand
  61 + Example:
  62 + BOOT_FROM spi
  63 + DATA type address value
  64 +
  65 + type: word=4, halfword=2, byte=1
  66 + address: physycal register address
  67 + value: value to be set in register
  68 + All values are in in hexadecimal.
  69 + Example (write to IOMUXC):
  70 + DATA 4 0x73FA88a0 0x200
  71 +
  72 +The processor support up to 60 register programming commands. An error
  73 +is generated if more commands are found in the configuration file.
  74 +
  75 +3. All commands are optional to program.
  76 +
  77 +Setup a SD Card for booting
  78 +--------------------------------
  79 +
  80 +The following example prepare a SD card with u-boot and a FAT partition
  81 +to be used to stored the kernel to be booted.
  82 +I will set the SD in the most compatible mode, setting it with
  83 +255 heads and 63 sectors, as suggested from several documentation and
  84 +howto on line (I took as reference the preparation of a SD Card for the
  85 +Beagleboard, running u-boot as bootloader).
  86 +
  87 +You should start clearing the partitions table on the SD card. Because
  88 +the u-boot image must be stored at the offset 0x400, it must be assured
  89 +that there is no partition at that address. A new SD card is already
  90 +formatted with FAT filesystem and the partition starts from the first
  91 +cylinder, so we need to change it.
  92 +
  93 +You can do all steps with fdisk. If the device for the SD card is
  94 +/dev/mmcblk0, the following commands make the job:
  95 +
  96 +1. Start the fdisk utility (as superuser)
  97 + fdisk /dev/mmcblk0
  98 +
  99 +2. Clear the actual partition
  100 +
  101 +Command (m for help): o
  102 +
  103 +3. Print card info:
  104 +
  105 +Command (m for help): p
  106 +Disk /dev/mmcblk0: 1981 MB, 1981284352 bytes
  107 +
  108 +In my case, I have a 2 GB card. I need the size to set later the correct value
  109 +for the cylinders.
  110 +
  111 +4. Go to expert mode:
  112 +
  113 +Command (m for help): x
  114 +
  115 +5. Set card geometry
  116 +
  117 +Expert command (m for help): h
  118 +Number of heads (1-256, default 4): 255
  119 +
  120 +Expert command (m for help): s
  121 +Number of sectors (1-63, default 16): 63
  122 +Warning: setting sector offset for DOS compatiblity
  123 +
  124 +We have set 255 heads, 63 sector. We have to set the cylinder.
  125 +The value to be set can be calculated with:
  126 +
  127 + cilynder = <total size> / <heads> / <sectors> / <blocksize>
  128 +
  129 +in this example,
  130 + 1981284352 / 255 / 63 / 512 = 239.x = 239
  131 +
  132 +
  133 +Expert command (m for help): c
  134 +Number of cylinders (1-1048576, default 60032): 239
  135 +
  136 +6. Leave the expert mode
  137 +Expert command (m for help): r
  138 +
  139 +7. Set up a partition
  140 +
  141 +Now set a partition table to store the kernel or whatever you want. Of course,
  142 +you can set additional partitions to store rootfs, data, etc.
  143 +In my example I want to set a single partition. I must take care
  144 +to not overwrite the space where I will put u-boot.
  145 +
  146 +Command (m for help): n
  147 +Command action
  148 + e extended
  149 + p primary partition (1-4)
  150 +p
  151 +Partition number (1-4): 1
  152 +First cylinder (1-239, default 1): 3
  153 +Last cylinder, +cylinders or +size{K,M,G} (3-239, default 239): +100M
  154 +
  155 +Command (m for help): p
  156 +
  157 +Disk /dev/mmcblk0: 1967 MB, 1967128576 bytes
  158 +255 heads, 63 sectors/track, 239 cylinders
  159 +Units = cylinders of 16065 * 512 = 8225280 bytes
  160 +Disk identifier: 0xb712a870
  161 +
  162 + Device Boot Start End Blocks Id System
  163 +/dev/mmcblk0p1 3 16 112455 83 Linux
  164 +
  165 +I have set 100MB, leaving the first 2 sectors free. I will copy u-boot
  166 +there.
  167 +
  168 +8. Write the partition table and exit.
  169 +
  170 +Command (m for help): w
  171 +The partition table has been altered!
  172 +
  173 +Calling ioctl() to re-read partition table.
  174 +
  175 +9. Copy u-boot.imx on the SD card
  176 +
  177 +I use dd:
  178 +
  179 +dd if=u-boot.imx of=/dev/mmcblk0 bs=512 seek=2
  180 +
  181 +This command copies the u-boot image at the address 0x400, as required
  182 +by the processor.
  183 +
  184 +Now remove your card from the PC and go to the target. If evrything went right,
  185 +the u-boot prompt should come after power on.
  186 +
  187 +------------------------------------------------
  188 +Author: Stefano babic <sbabic@denx.de>
... ... @@ -156,6 +156,7 @@
156 156 #define IH_TYPE_FILESYSTEM 7 /* Filesystem Image (any type) */
157 157 #define IH_TYPE_FLATDT 8 /* Binary Flat Device Tree Blob */
158 158 #define IH_TYPE_KWBIMAGE 9 /* Kirkwood Boot Image */
  159 +#define IH_TYPE_IMXIMAGE 10 /* Freescale IMXBoot Image */
159 160  
160 161 /*
161 162 * Compression Types
... ... @@ -82,6 +82,7 @@
82 82 OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
83 83 OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
84 84 NOPED_OBJ_FILES-y += kwbimage.o
  85 +NOPED_OBJ_FILES-y += imximage.o
85 86 NOPED_OBJ_FILES-y += mkimage.o
86 87 OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
87 88 NOPED_OBJ_FILES-y += os_support.o
... ... @@ -167,6 +168,7 @@
167 168 $(obj)default_image.o \
168 169 $(obj)fit_image.o \
169 170 $(obj)image.o \
  171 + $(obj)imximage.o \
170 172 $(obj)kwbimage.o \
171 173 $(obj)md5.o \
172 174 $(obj)mkimage.o \
  1 +/*
  2 + * (C) Copyright 2009
  3 + * Stefano Babic, DENX Software Engineering, sbabic@denx.de.
  4 + *
  5 + * (C) Copyright 2008
  6 + * Marvell Semiconductor <www.marvell.com>
  7 + * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  8 + *
  9 + * See file CREDITS for list of people who contributed to this
  10 + * project.
  11 + *
  12 + * This program is free software; you can redistribute it and/or
  13 + * modify it under the terms of the GNU General Public License as
  14 + * published by the Free Software Foundation; either version 2 of
  15 + * the License, or (at your option) any later version.
  16 + *
  17 + * This program is distributed in the hope that it will be useful,
  18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20 + * GNU General Public License for more details.
  21 + *
  22 + * You should have received a copy of the GNU General Public License
  23 + * along with this program; if not, write to the Free Software
  24 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25 + * MA 02111-1307 USA
  26 + */
  27 +
  28 +#include "mkimage.h"
  29 +#include <image.h>
  30 +#include "imximage.h"
  31 +
  32 +/*
  33 + * Supported commands for configuration file
  34 + */
  35 +static table_entry_t imximage_cmds[] = {
  36 + {CMD_BOOT_FROM, "BOOT_FROM", "boot comand", },
  37 + {CMD_DATA, "DATA", "Reg Write Data", },
  38 + {-1, "", "", },
  39 +};
  40 +
  41 +/*
  42 + * Supported Boot options for configuration file
  43 + * this is needed to set the correct flash offset
  44 + */
  45 +static table_entry_t imximage_bootops[] = {
  46 + {FLASH_OFFSET_SPI, "spi", "SPI Flash", },
  47 + {FLASH_OFFSET_NAND, "nand", "NAND Flash", },
  48 + {FLASH_OFFSET_SD, "sd", "SD Card", },
  49 + {FLASH_OFFSET_ONENAND, "onenand", "OneNAND Flash",},
  50 + {-1, "", "Invalid", },
  51 +};
  52 +
  53 +
  54 +static struct imx_header imximage_header;
  55 +
  56 +static uint32_t get_cfg_value(char *token, char *name, int linenr)
  57 +{
  58 + char *endptr;
  59 + uint32_t value;
  60 +
  61 + errno = 0;
  62 + value = strtoul(token, &endptr, 16);
  63 + if (errno || (token == endptr)) {
  64 + fprintf(stderr, "Error: %s[%d] - Invalid hex data(%s)\n",
  65 + name, linenr, token);
  66 + exit(EXIT_FAILURE);
  67 + }
  68 + return value;
  69 +}
  70 +
  71 +static int imximage_check_image_types(uint8_t type)
  72 +{
  73 + if (type == IH_TYPE_IMXIMAGE)
  74 + return EXIT_SUCCESS;
  75 + else
  76 + return EXIT_FAILURE;
  77 +}
  78 +
  79 +static int imximage_verify_header(unsigned char *ptr, int image_size,
  80 + struct mkimage_params *params)
  81 +{
  82 +
  83 + struct imx_header *imx_hdr = (struct imx_header *) ptr;
  84 + flash_header_t *hdr = &imx_hdr->fhdr;
  85 +
  86 + /* Only a few checks can be done: search for magic numbers */
  87 + if (hdr->app_code_barker != APP_CODE_BARKER)
  88 + return -FDT_ERR_BADSTRUCTURE;
  89 +
  90 + if (imx_hdr->dcd_table.preamble.barker != DCD_BARKER)
  91 + return -FDT_ERR_BADSTRUCTURE;
  92 +
  93 + return 0;
  94 +}
  95 +
  96 +static void imximage_print_header(const void *ptr)
  97 +{
  98 + struct imx_header *imx_hdr = (struct imx_header *) ptr;
  99 + flash_header_t *hdr = &imx_hdr->fhdr;
  100 + uint32_t size;
  101 + flash_cfg_parms_t *ext_header;
  102 +
  103 + size = imx_hdr->dcd_table.preamble.length;
  104 + if (size > (MAX_HW_CFG_SIZE * sizeof(dcd_type_addr_data_t))) {
  105 + fprintf(stderr,
  106 + "Error: Image corrupt DCD size %d exceed maximum %d\n",
  107 + size / sizeof(dcd_type_addr_data_t), MAX_HW_CFG_SIZE);
  108 + exit(EXIT_FAILURE);
  109 + }
  110 +
  111 + ext_header = (flash_cfg_parms_t *) ((uint32_t)&imx_hdr->dcd_table +
  112 + sizeof(dcd_preamble_t) + size);
  113 +
  114 + printf("Image Type: Freescale IMX Boot Image\n");
  115 + printf("Data Size: ");
  116 + genimg_print_size(ext_header->length);
  117 + printf("Load Address: %08x\n", (unsigned int)hdr->app_dest_ptr);
  118 + printf("Entry Point: %08x\n", (unsigned int)hdr->app_code_jump_vector);
  119 +}
  120 +
  121 +static uint32_t imximage_parse_cfg_file(struct imx_header *imxhdr, char *name)
  122 +{
  123 + FILE *fd = NULL;
  124 + char *line = NULL;
  125 + char *token, *saveptr1, *saveptr2;
  126 + int lineno = 0;
  127 + int fld, value;
  128 + uint32_t len;
  129 + int dcd_len = 0;
  130 + dcd_t *dcd = &imxhdr->dcd_table;
  131 + int32_t cmd;
  132 +
  133 + fd = fopen(name, "r");
  134 + if (fd == 0) {
  135 + fprintf(stderr, "Error: %s - Can't open DCD file\n", name);
  136 + exit(EXIT_FAILURE);
  137 + }
  138 +
  139 + /* Very simple parsing, line starting with # are comments
  140 + * and are dropped
  141 + */
  142 + while ((getline(&line, &len, fd)) > 0) {
  143 + lineno++;
  144 +
  145 + token = strtok_r(line, "\r\n", &saveptr1);
  146 + if (token == NULL)
  147 + continue;
  148 +
  149 + /* Check inside the single line */
  150 + for (fld = CFG_COMMAND, cmd = CMD_INVALID,
  151 + line = token; ; line = NULL, fld++) {
  152 + token = strtok_r(line, " \t", &saveptr2);
  153 + if (token == NULL)
  154 + break;
  155 +
  156 + /* Drop all text starting with '#' as comments */
  157 + if (token[0] == '#')
  158 + break;
  159 +
  160 + /* parse all fields in a single line */
  161 + switch (fld) {
  162 + case CFG_COMMAND:
  163 + cmd = get_table_entry_id(imximage_cmds,
  164 + "imximage commands", token);
  165 + if (cmd < 0) {
  166 + fprintf(stderr,
  167 + "Error: %s[%d] - "
  168 + "Invalid command (%s)\n",
  169 + name, lineno, token);
  170 + exit(EXIT_FAILURE);
  171 + }
  172 + break;
  173 + case CFG_REG_SIZE:
  174 + switch (cmd) {
  175 + case CMD_BOOT_FROM:
  176 + /* Get flash header offset */
  177 + imxhdr->flash_offset =
  178 + get_table_entry_id(
  179 + imximage_bootops,
  180 + "imximage boot option",
  181 + token);
  182 + if (imxhdr->flash_offset == -1) {
  183 + fprintf(stderr,
  184 + "Error: %s[%d] -"
  185 + "Invalid boot device"
  186 + "(%s)\n",
  187 + name, lineno, token);
  188 + exit(EXIT_FAILURE);
  189 + }
  190 + break;
  191 + case CMD_DATA:
  192 + value = get_cfg_value(token,
  193 + name, lineno);
  194 +
  195 + /* Byte, halfword, word */
  196 + if ((value != 1) &&
  197 + (value != 2) && (value != 4)) {
  198 + fprintf(stderr,
  199 + "Error: %s[%d] - "
  200 + "Invalid register size "
  201 + "(%d)\n",
  202 + name, lineno, value);
  203 + exit(EXIT_FAILURE);
  204 + }
  205 + dcd->addr_data[dcd_len].type = value;
  206 + break;
  207 + }
  208 +
  209 + case CFG_REG_ADDRESS:
  210 + if (cmd == CMD_DATA)
  211 + dcd->addr_data[dcd_len].addr =
  212 + get_cfg_value(token,
  213 + name, lineno);
  214 + break;
  215 + case CFG_REG_VALUE:
  216 + if (cmd == CMD_DATA) {
  217 + dcd->addr_data[dcd_len].value =
  218 + get_cfg_value(token,
  219 + name, lineno);
  220 + dcd_len++;
  221 + }
  222 + break;
  223 + }
  224 + }
  225 +
  226 + if (dcd_len > MAX_HW_CFG_SIZE) {
  227 + fprintf(stderr,
  228 + "Error: %s[%d] -"
  229 + "DCD table exceeds maximum size(%d)\n",
  230 + name, lineno, MAX_HW_CFG_SIZE);
  231 + }
  232 + }
  233 + dcd->preamble.barker = DCD_BARKER;
  234 + dcd->preamble.length = dcd_len * sizeof(dcd_type_addr_data_t);
  235 + fclose(fd);
  236 +
  237 + return dcd->preamble.length;
  238 +}
  239 +
  240 +static void imximage_set_header(void *ptr, struct stat *sbuf, int ifd,
  241 + struct mkimage_params *params)
  242 +{
  243 + struct imx_header *hdr = (struct imx_header *)ptr;
  244 + flash_header_t *fhdr = &hdr->fhdr;
  245 + int dcd_len;
  246 + flash_cfg_parms_t *ext_header;
  247 + uint32_t base_offset;
  248 +
  249 + /* Set default offset */
  250 + hdr->flash_offset = FLASH_OFFSET_STANDARD;
  251 +
  252 + /* Set magic number */
  253 + fhdr->app_code_barker = APP_CODE_BARKER;
  254 +
  255 + /* Parse dcd configuration file */
  256 + dcd_len = imximage_parse_cfg_file(hdr, params->imagename);
  257 +
  258 + fhdr->app_dest_ptr = params->addr;
  259 + fhdr->app_dest_ptr = params->ep - hdr->flash_offset -
  260 + sizeof(struct imx_header);
  261 + fhdr->app_code_jump_vector = params->ep;
  262 +
  263 + base_offset = fhdr->app_dest_ptr + hdr->flash_offset ;
  264 + fhdr->dcd_ptr_ptr = (uint32_t) ((uint32_t)&fhdr->dcd_ptr -
  265 + (uint32_t)&fhdr->app_code_jump_vector) + base_offset ;
  266 +
  267 + fhdr->dcd_ptr = base_offset +
  268 + ((uint32_t)&hdr->dcd_table -
  269 + (uint32_t)&hdr->fhdr);
  270 +
  271 + /* The external flash header must be at the end of the DCD table */
  272 + ext_header = (flash_cfg_parms_t *) ((uint32_t)&hdr->dcd_table +
  273 + dcd_len +
  274 + sizeof(dcd_preamble_t));
  275 + ext_header->length = sbuf->st_size +
  276 + hdr->flash_offset +
  277 + sizeof(struct imx_header);
  278 +
  279 + /* Security feature are not supported */
  280 + fhdr->app_code_csf = 0;
  281 + fhdr->super_root_key = NULL;
  282 +
  283 +}
  284 +
  285 +int imximage_check_params(struct mkimage_params *params)
  286 +{
  287 + if (!params)
  288 + return CFG_INVALID;
  289 + if (!strlen(params->imagename)) {
  290 + fprintf(stderr, "Error: %s - Configuration file not specified, "
  291 + "it is needed for imximage generation\n",
  292 + params->cmdname);
  293 + return CFG_INVALID;
  294 + }
  295 + /*
  296 + * Check parameters:
  297 + * XIP is not allowed and verify that incompatible
  298 + * parameters are not sent at the same time
  299 + * For example, if list is required a data image must not be provided
  300 + */
  301 + return (params->dflag && (params->fflag || params->lflag)) ||
  302 + (params->fflag && (params->dflag || params->lflag)) ||
  303 + (params->lflag && (params->dflag || params->fflag)) ||
  304 + (params->xflag) || !(strlen(params->imagename));
  305 +}
  306 +
  307 +/*
  308 + * imximage parameters
  309 + */
  310 +static struct image_type_params imximage_params = {
  311 + .name = "Freescale i.MX 51 Boot Image support",
  312 + .header_size = sizeof(struct imx_header),
  313 + .hdr = (void *)&imximage_header,
  314 + .check_image_type = imximage_check_image_types,
  315 + .verify_header = imximage_verify_header,
  316 + .print_header = imximage_print_header,
  317 + .set_header = imximage_set_header,
  318 + .check_params = imximage_check_params,
  319 +};
  320 +
  321 +void init_imx_image_type(void)
  322 +{
  323 + mkimage_register(&imximage_params);
  324 +}
  1 +/*
  2 + * (C) Copyright 2009
  3 + * Stefano Babic, DENX Software Engineering, sbabic@denx.de.
  4 + *
  5 + * See file CREDITS for list of people who contributed to this
  6 + * project.
  7 + *
  8 + * This program is free software; you can redistribute it and/or
  9 + * modify it under the terms of the GNU General Public License as
  10 + * published by the Free Software Foundation; either version 2 of
  11 + * the License, or (at your option) any later version.
  12 + *
  13 + * This program is distributed in the hope that it will be useful,
  14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16 + * GNU General Public License for more details.
  17 + *
  18 + * You should have received a copy of the GNU General Public License
  19 + * along with this program; if not, write to the Free Software
  20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21 + * MA 02111-1307 USA
  22 + */
  23 +
  24 +#ifndef _IMXIMAGE_H_
  25 +#define _IMXIMAGE_H_
  26 +
  27 +#define MAX_HW_CFG_SIZE 60 /* Max number of registers imx can set */
  28 +#define MAX_EXP_SIZE 4
  29 +#define APP_CODE_BARKER 0xB1
  30 +#define DCD_BARKER 0xB17219E9
  31 +#define HEADER_OFFSET 0x400
  32 +
  33 +
  34 +#define CMD_DATA_STR "DATA"
  35 +#define FLASH_OFFSET_STANDARD 0x400
  36 +#define FLASH_OFFSET_NAND FLASH_OFFSET_STANDARD
  37 +#define FLASH_OFFSET_SD FLASH_OFFSET_STANDARD
  38 +#define FLASH_OFFSET_SPI FLASH_OFFSET_STANDARD
  39 +#define FLASH_OFFSET_ONENAND 0x100
  40 +
  41 +enum imximage_cmd {
  42 + CMD_INVALID,
  43 + CMD_BOOT_FROM,
  44 + CMD_DATA
  45 +};
  46 +
  47 +enum imximage_fld_types {
  48 + CFG_INVALID = -1,
  49 + CFG_COMMAND,
  50 + CFG_REG_SIZE,
  51 + CFG_REG_ADDRESS,
  52 + CFG_REG_VALUE
  53 +};
  54 +
  55 +typedef struct {
  56 + uint8_t rsa_exponent[MAX_EXP_SIZE]; /* RSA public exponent */
  57 + uint8_t *rsa_modulus; /* RSA modulus pointer */
  58 + uint16_t exponent_size; /* Exponent size (bytes) */
  59 + uint16_t modulus_size; /* Modulus size (bytes) */
  60 + uint8_t init_flag; /* key initialized */
  61 +} hab_rsa_public_key;
  62 +
  63 +typedef struct {
  64 + uint32_t type; /* Type of pointer (byte, halfword, word, wait/read) */
  65 + uint32_t addr; /* Address to write to */
  66 + uint32_t value; /* Data to write */
  67 +} dcd_type_addr_data_t;
  68 +
  69 +typedef struct {
  70 + uint32_t barker; /* Barker for sanity check */
  71 + uint32_t length; /* Device configuration length (without preamble) */
  72 +} dcd_preamble_t;
  73 +
  74 +typedef struct {
  75 + dcd_preamble_t preamble;
  76 + dcd_type_addr_data_t addr_data[MAX_HW_CFG_SIZE];
  77 +} dcd_t;
  78 +
  79 +typedef struct {
  80 + uint32_t app_code_jump_vector;
  81 + uint32_t app_code_barker;
  82 + uint32_t app_code_csf;
  83 + uint32_t dcd_ptr_ptr;
  84 + hab_rsa_public_key *super_root_key;
  85 + uint32_t dcd_ptr;
  86 + uint32_t app_dest_ptr;
  87 +} flash_header_t;
  88 +
  89 +typedef struct {
  90 + uint32_t length; /* Length of data to be read from flash */
  91 +} flash_cfg_parms_t;
  92 +
  93 +struct imx_header {
  94 + flash_header_t fhdr;
  95 + dcd_t dcd_table;
  96 + flash_cfg_parms_t ext_header;
  97 + uint32_t flash_offset;
  98 +};
  99 +
  100 +struct reg_config {
  101 + uint32_t raddr;
  102 + uint32_t rdata;
  103 +};
  104 +
  105 +#endif /* _IMXIMAGE_H_ */
... ... @@ -150,6 +150,8 @@
150 150  
151 151 /* Init Kirkwood Boot image generation/list support */
152 152 init_kwb_image_type ();
  153 + /* Init Freescale imx Boot image generation/list support */
  154 + init_imx_image_type ();
153 155 /* Init FIT image generation/list support */
154 156 init_fit_image_type ();
155 157 /* Init Default image generation/list support */
... ... @@ -140,6 +140,7 @@
140 140 * Supported image types init functions
141 141 */
142 142 void init_kwb_image_type (void);
  143 +void init_imx_image_type (void);
143 144 void init_default_image_type (void);
144 145 void init_fit_image_type (void);
145 146