xref: /openbmc/u-boot/doc/imx/mkimage/mxsimage.txt (revision 522e035441ca04d99de2fc13b614ad896691e9c9)
175e8ca6aSBreno Matheus LimaFreescale i.MX233/i.MX28 SB image generator via mkimage
275e8ca6aSBreno Matheus Lima=======================================================
375e8ca6aSBreno Matheus Lima
475e8ca6aSBreno Matheus LimaThis tool allows user to produce SB BootStream encrypted with a zero key.
575e8ca6aSBreno Matheus LimaSuch a BootStream is then bootable on i.MX23/i.MX28.
675e8ca6aSBreno Matheus Lima
775e8ca6aSBreno Matheus LimaUsage -- producing image:
875e8ca6aSBreno Matheus Lima=========================
975e8ca6aSBreno Matheus LimaThe mxsimage tool is targeted to be a simple replacement for the elftosb2 .
1075e8ca6aSBreno Matheus LimaTo generate an image, write an image configuration file and run:
1175e8ca6aSBreno Matheus Lima
1275e8ca6aSBreno Matheus Lima mkimage -A arm -O u-boot -T mxsimage -n <path to configuration file> \
1375e8ca6aSBreno Matheus Lima	 <output bootstream file>
1475e8ca6aSBreno Matheus Lima
1575e8ca6aSBreno Matheus LimaThe output bootstream file is usually using the .sb file extension. Note
1675e8ca6aSBreno Matheus Limathat the example configuration files for producing bootable BootStream with
1775e8ca6aSBreno Matheus Limathe U-Boot bootloader can be found under arch/arm/boot/cpu/arm926ejs/mxs/
1875e8ca6aSBreno Matheus Limadirectory. See the following files:
1975e8ca6aSBreno Matheus Lima
2075e8ca6aSBreno Matheus Lima mxsimage.mx23.cfg -- This is an example configuration for i.MX23
2175e8ca6aSBreno Matheus Lima mxsimage.mx28.cfg -- This is an example configuration for i.MX28
2275e8ca6aSBreno Matheus Lima
2375e8ca6aSBreno Matheus LimaEach configuration file uses very simple instruction semantics and a few
2475e8ca6aSBreno Matheus Limaadditional rules have to be followed so that a useful image can be produced.
2575e8ca6aSBreno Matheus LimaThese semantics and rules will be outlined now.
2675e8ca6aSBreno Matheus Lima
2775e8ca6aSBreno Matheus Lima- Each line of the configuration file contains exactly one instruction.
2875e8ca6aSBreno Matheus Lima- Every numeric value must be encoded in hexadecimal and in format 0xabcdef12 .
2975e8ca6aSBreno Matheus Lima- The configuration file is a concatenation of blocks called "sections" and
3075e8ca6aSBreno Matheus Lima  optionally "DCD blocks" (see below), and optional flags lines.
3175e8ca6aSBreno Matheus Lima  - Each "section" is started by the "SECTION" instruction.
3275e8ca6aSBreno Matheus Lima  - The "SECTION" instruction has the following semantics:
3375e8ca6aSBreno Matheus Lima
3475e8ca6aSBreno Matheus Lima      SECTION u32_section_number [BOOTABLE]
3575e8ca6aSBreno Matheus Lima      - u32_section_number :: User-selected ID of the section
3675e8ca6aSBreno Matheus Lima      - BOOTABLE           :: Sets the section as bootable
3775e8ca6aSBreno Matheus Lima
3875e8ca6aSBreno Matheus Lima  - A bootable section is one from which the BootROM starts executing
3975e8ca6aSBreno Matheus Lima    subsequent instructions or code. Exactly one section must be selected
4075e8ca6aSBreno Matheus Lima    as bootable, usually the one containing the instructions and data to
4175e8ca6aSBreno Matheus Lima    load the bootloader.
4275e8ca6aSBreno Matheus Lima
4375e8ca6aSBreno Matheus Lima  - A "SECTION" must be immediatelly followed by a "TAG" instruction.
4475e8ca6aSBreno Matheus Lima  - The "TAG" instruction has the following semantics:
4575e8ca6aSBreno Matheus Lima
4675e8ca6aSBreno Matheus Lima      TAG [LAST]
4775e8ca6aSBreno Matheus Lima      - LAST               :: Flag denoting the last section in the file
4875e8ca6aSBreno Matheus Lima
49*210594a8SMichael Heimpold  - After a "TAG" instruction, any of the following instructions may follow
5075e8ca6aSBreno Matheus Lima    in any order and any quantity:
5175e8ca6aSBreno Matheus Lima
5275e8ca6aSBreno Matheus Lima      NOOP
5375e8ca6aSBreno Matheus Lima      - This instruction does nothing
5475e8ca6aSBreno Matheus Lima
5575e8ca6aSBreno Matheus Lima      LOAD     u32_address string_filename
5675e8ca6aSBreno Matheus Lima      - Instructs the BootROM to load file pointed by "string_filename" onto
5775e8ca6aSBreno Matheus Lima	address "u32_address".
5875e8ca6aSBreno Matheus Lima
5975e8ca6aSBreno Matheus Lima      LOAD IVT u32_address u32_IVT_entry_point
6075e8ca6aSBreno Matheus Lima      - Crafts and loads IVT onto address "u32_address" with the entry point
6175e8ca6aSBreno Matheus Lima	of u32_IVT_entry_point.
6275e8ca6aSBreno Matheus Lima      - i.MX28-specific instruction!
6375e8ca6aSBreno Matheus Lima
6475e8ca6aSBreno Matheus Lima      LOAD DCD u32_address u32_DCD_block_ID
6575e8ca6aSBreno Matheus Lima      - Loads the DCD block with ID "u32_DCD_block_ID" onto address
6675e8ca6aSBreno Matheus Lima	"u32_address" and executes the contents of this DCD block
6775e8ca6aSBreno Matheus Lima      - i.MX28-specific instruction!
6875e8ca6aSBreno Matheus Lima
6975e8ca6aSBreno Matheus Lima      FILL u32_address u32_pattern u32_length
7075e8ca6aSBreno Matheus Lima      - Starts to write memory from addres "u32_address" with a pattern
7175e8ca6aSBreno Matheus Lima	specified by "u32_pattern". Writes exactly "u32_length" bytes of the
7275e8ca6aSBreno Matheus Lima	pattern.
7375e8ca6aSBreno Matheus Lima
7475e8ca6aSBreno Matheus Lima      JUMP [HAB] u32_address [u32_r0_arg]
7575e8ca6aSBreno Matheus Lima      - Jumps onto memory address specified by "u32_address" by setting this
7675e8ca6aSBreno Matheus Lima	address in PT. The BootROM will pass the "u32_r0_arg" value in ARM
7775e8ca6aSBreno Matheus Lima	register "r0" to the executed code if this option is specified.
7875e8ca6aSBreno Matheus Lima	Otherwise, ARM register "r0" will default to value 0x00000000. The
7975e8ca6aSBreno Matheus Lima	optional "HAB" flag is i.MX28-specific flag turning on the HAB boot.
8075e8ca6aSBreno Matheus Lima
8175e8ca6aSBreno Matheus Lima      CALL [HAB] u32_address [u32_r0_arg]
8275e8ca6aSBreno Matheus Lima      - See JUMP instruction above, as the operation is exactly the same with
8375e8ca6aSBreno Matheus Lima	one difference. The CALL instruction does allow returning into the
8475e8ca6aSBreno Matheus Lima	BootROM from the executed code. U-Boot makes use of this in it's SPL
8575e8ca6aSBreno Matheus Lima	code.
8675e8ca6aSBreno Matheus Lima
8775e8ca6aSBreno Matheus Lima      MODE string_mode
8875e8ca6aSBreno Matheus Lima      - Restart the CPU and start booting from device specified by the
8975e8ca6aSBreno Matheus Lima	"string_mode" argument. The "string_mode" differs for each CPU
9075e8ca6aSBreno Matheus Lima	and can be:
9175e8ca6aSBreno Matheus Lima	 i.MX23, string_mode = USB/I2C/SPI1_FLASH/SPI2_FLASH/NAND_BCH
9275e8ca6aSBreno Matheus Lima			       JTAG/SPI3_EEPROM/SD_SSP0/SD_SSP1
9375e8ca6aSBreno Matheus Lima	 i.MX28, string_mode = USB/I2C/SPI2_FLASH/SPI3_FLASH/NAND_BCH
9475e8ca6aSBreno Matheus Lima			       JTAG/SPI2_EEPROM/SD_SSP0/SD_SSP1
9575e8ca6aSBreno Matheus Lima
9675e8ca6aSBreno Matheus Lima  - An optional "DCD" blocks can be added at the begining of the configuration
9775e8ca6aSBreno Matheus Lima    file. Note that the DCD is only supported on i.MX28.
9875e8ca6aSBreno Matheus Lima    - The DCD blocks must be inserted before the first "section" in the
9975e8ca6aSBreno Matheus Lima      configuration file.
10075e8ca6aSBreno Matheus Lima    - The DCD block has the following semantics:
10175e8ca6aSBreno Matheus Lima
10275e8ca6aSBreno Matheus Lima	DCD u32_DCD_block_ID
10375e8ca6aSBreno Matheus Lima	- u32_DCD_block_ID	:: The ID number of the DCD block, must match
10475e8ca6aSBreno Matheus Lima				   the ID number used by "LOAD DCD" instruction.
10575e8ca6aSBreno Matheus Lima
10675e8ca6aSBreno Matheus Lima    - The DCD block must be followed by one of the following instructions. All
10775e8ca6aSBreno Matheus Lima      of the instructions operate either on 1, 2 or 4 bytes. This is selected by
10875e8ca6aSBreno Matheus Lima      the 'n' suffix of the instruction:
10975e8ca6aSBreno Matheus Lima
11075e8ca6aSBreno Matheus Lima	WRITE.n u32_address u32_value
11175e8ca6aSBreno Matheus Lima	- Write the "u32_value" to the "u32_address" address.
11275e8ca6aSBreno Matheus Lima
11375e8ca6aSBreno Matheus Lima	ORR.n u32_address u32_value
11475e8ca6aSBreno Matheus Lima	- Read the "u32_address", perform a bitwise-OR with the "u32_value" and
11575e8ca6aSBreno Matheus Lima	  write the result back to "u32_address".
11675e8ca6aSBreno Matheus Lima
11775e8ca6aSBreno Matheus Lima	ANDC.n u32_address u32_value
11875e8ca6aSBreno Matheus Lima	- Read the "u32_address", perform a bitwise-AND with the complement of
11975e8ca6aSBreno Matheus Lima	  "u32_value" and write the result back to "u32_address".
12075e8ca6aSBreno Matheus Lima
12175e8ca6aSBreno Matheus Lima	EQZ.n u32_address u32_count
12275e8ca6aSBreno Matheus Lima	- Read the "u32_address" at most "u32_count" times and test if the value
12375e8ca6aSBreno Matheus Lima	  read is zero. If it is, break the loop earlier.
12475e8ca6aSBreno Matheus Lima
12575e8ca6aSBreno Matheus Lima	NEZ.n u32_address u32_count
12675e8ca6aSBreno Matheus Lima	- Read the "u32_address" at most "u32_count" times and test if the value
12775e8ca6aSBreno Matheus Lima	  read is non-zero. If it is, break the loop earlier.
12875e8ca6aSBreno Matheus Lima
12975e8ca6aSBreno Matheus Lima	EQ.n u32_address u32_mask
13075e8ca6aSBreno Matheus Lima	- Read the "u32_address" in a loop and test if the result masked with
13175e8ca6aSBreno Matheus Lima	  "u32_mask" equals the "u32_mask". If the values are equal, break the
13275e8ca6aSBreno Matheus Lima	  reading loop.
13375e8ca6aSBreno Matheus Lima
13475e8ca6aSBreno Matheus Lima	NEQ.n u32_address u32_mask
13575e8ca6aSBreno Matheus Lima	- Read the "u32_address" in a loop and test if the result masked with
13675e8ca6aSBreno Matheus Lima	  "u32_mask" does not equal the "u32_mask". If the values are not equal,
13775e8ca6aSBreno Matheus Lima	  break the reading loop.
13875e8ca6aSBreno Matheus Lima
13975e8ca6aSBreno Matheus Lima	NOOP
14075e8ca6aSBreno Matheus Lima	- This instruction does nothing.
14175e8ca6aSBreno Matheus Lima
14275e8ca6aSBreno Matheus Lima  - An optional flags lines can be one of the following:
14375e8ca6aSBreno Matheus Lima
14475e8ca6aSBreno Matheus Lima	DISPLAYPROGRESS
145*210594a8SMichael Heimpold	- Enable boot progress output from the BootROM.
14675e8ca6aSBreno Matheus Lima
14775e8ca6aSBreno Matheus Lima- If the boot progress output from the BootROM is enabled, the BootROM will
14875e8ca6aSBreno Matheus Lima  produce a letter on the Debug UART for each instruction it started processing.
14975e8ca6aSBreno Matheus Lima  Here is a mapping between the above instructions and the BootROM output:
15075e8ca6aSBreno Matheus Lima
15175e8ca6aSBreno Matheus Lima   H -- SB Image header loaded
15275e8ca6aSBreno Matheus Lima   T -- TAG instruction
15375e8ca6aSBreno Matheus Lima   N -- NOOP instruction
15475e8ca6aSBreno Matheus Lima   L -- LOAD instruction
15575e8ca6aSBreno Matheus Lima   F -- FILL instruction
15675e8ca6aSBreno Matheus Lima   J -- JUMP instruction
15775e8ca6aSBreno Matheus Lima   C -- CALL instruction
15875e8ca6aSBreno Matheus Lima   M -- MODE instruction
15975e8ca6aSBreno Matheus Lima
16075e8ca6aSBreno Matheus LimaUsage -- verifying image:
16175e8ca6aSBreno Matheus Lima=========================
16275e8ca6aSBreno Matheus Lima
16375e8ca6aSBreno Matheus LimaThe mxsimage can also verify and dump contents of an image. Use the following
16475e8ca6aSBreno Matheus Limasyntax to verify and dump contents of an image:
16575e8ca6aSBreno Matheus Lima
16675e8ca6aSBreno Matheus Lima mkimage -l <input bootstream file>
16775e8ca6aSBreno Matheus Lima
16875e8ca6aSBreno Matheus LimaThis will output all the information from the SB image header and all the
16975e8ca6aSBreno Matheus Limainstructions contained in the SB image. It will also check if the various
17075e8ca6aSBreno Matheus Limachecksums in the SB image are correct.
171