1bce88370SMarek VasutFreescale i.MX233/i.MX28 SB image generator via mkimage 2bce88370SMarek Vasut======================================================= 3bce88370SMarek Vasut 4bce88370SMarek VasutThis tool allows user to produce SB BootStream encrypted with a zero key. 5bce88370SMarek VasutSuch a BootStream is then bootable on i.MX23/i.MX28. 6bce88370SMarek Vasut 7bce88370SMarek VasutUsage -- producing image: 8bce88370SMarek Vasut========================= 9bce88370SMarek VasutThe mxsimage tool is targeted to be a simple replacement for the elftosb2 . 10bce88370SMarek VasutTo generate an image, write an image configuration file and run: 11bce88370SMarek Vasut 12bce88370SMarek Vasut mkimage -A arm -O u-boot -T mxsimage -n <path to configuration file> \ 13bce88370SMarek Vasut <output bootstream file> 14bce88370SMarek Vasut 15bce88370SMarek VasutThe output bootstream file is usually using the .sb file extension. Note 16bce88370SMarek Vasutthat the example configuration files for producing bootable BootStream with 17bce88370SMarek Vasutthe U-Boot bootloader can be found under arch/arm/boot/cpu/arm926ejs/mxs/ 18bce88370SMarek Vasutdirectory. See the following files: 19bce88370SMarek Vasut 20bce88370SMarek Vasut mxsimage.mx23.cfg -- This is an example configuration for i.MX23 21bce88370SMarek Vasut mxsimage.mx28.cfg -- This is an example configuration for i.MX28 22bce88370SMarek Vasut 23bce88370SMarek VasutEach configuration file uses very simple instruction semantics and a few 24bce88370SMarek Vasutadditional rules have to be followed so that a useful image can be produced. 25bce88370SMarek VasutThese semantics and rules will be outlined now. 26bce88370SMarek Vasut 27bce88370SMarek Vasut- Each line of the configuration file contains exactly one instruction. 28bce88370SMarek Vasut- Every numeric value must be encoded in hexadecimal and in format 0xabcdef12 . 29bce88370SMarek Vasut- The configuration file is a concatenation of blocks called "sections" and 30*7a139959SAlexey Ignatov optionally "DCD blocks" (see below), and optional flags lines. 31bce88370SMarek Vasut - Each "section" is started by the "SECTION" instruction. 32bce88370SMarek Vasut - The "SECTION" instruction has the following semantics: 33bce88370SMarek Vasut 34bce88370SMarek Vasut SECTION u32_section_number [BOOTABLE] 35bce88370SMarek Vasut - u32_section_number :: User-selected ID of the section 36bce88370SMarek Vasut - BOOTABLE :: Sets the section as bootable 37bce88370SMarek Vasut 38bce88370SMarek Vasut - A bootable section is one from which the BootROM starts executing 39bce88370SMarek Vasut subsequent instructions or code. Exactly one section must be selected 40bce88370SMarek Vasut as bootable, usually the one containing the instructions and data to 41bce88370SMarek Vasut load the bootloader. 42bce88370SMarek Vasut 43bce88370SMarek Vasut - A "SECTION" must be immediatelly followed by a "TAG" instruction. 44bce88370SMarek Vasut - The "TAG" instruction has the following semantics: 45bce88370SMarek Vasut 46bce88370SMarek Vasut TAG [LAST] 47bce88370SMarek Vasut - LAST :: Flag denoting the last section in the file 48bce88370SMarek Vasut 49bce88370SMarek Vasut - After a "TAG" unstruction, any of the following instructions may follow 50bce88370SMarek Vasut in any order and any quantity: 51bce88370SMarek Vasut 52bce88370SMarek Vasut NOOP 53bce88370SMarek Vasut - This instruction does nothing 54bce88370SMarek Vasut 55bce88370SMarek Vasut LOAD u32_address string_filename 56bce88370SMarek Vasut - Instructs the BootROM to load file pointed by "string_filename" onto 57bce88370SMarek Vasut address "u32_address". 58bce88370SMarek Vasut 59bce88370SMarek Vasut LOAD IVT u32_address u32_IVT_entry_point 60bce88370SMarek Vasut - Crafts and loads IVT onto address "u32_address" with the entry point 61bce88370SMarek Vasut of u32_IVT_entry_point. 62bce88370SMarek Vasut - i.MX28-specific instruction! 63bce88370SMarek Vasut 64bce88370SMarek Vasut LOAD DCD u32_address u32_DCD_block_ID 65bce88370SMarek Vasut - Loads the DCD block with ID "u32_DCD_block_ID" onto address 66bce88370SMarek Vasut "u32_address" and executes the contents of this DCD block 67bce88370SMarek Vasut - i.MX28-specific instruction! 68bce88370SMarek Vasut 69bce88370SMarek Vasut FILL u32_address u32_pattern u32_length 70bce88370SMarek Vasut - Starts to write memory from addres "u32_address" with a pattern 71bce88370SMarek Vasut specified by "u32_pattern". Writes exactly "u32_length" bytes of the 72bce88370SMarek Vasut pattern. 73bce88370SMarek Vasut 74bce88370SMarek Vasut JUMP [HAB] u32_address [u32_r0_arg] 75bce88370SMarek Vasut - Jumps onto memory address specified by "u32_address" by setting this 76bce88370SMarek Vasut address in PT. The BootROM will pass the "u32_r0_arg" value in ARM 77bce88370SMarek Vasut register "r0" to the executed code if this option is specified. 78bce88370SMarek Vasut Otherwise, ARM register "r0" will default to value 0x00000000. The 79bce88370SMarek Vasut optional "HAB" flag is i.MX28-specific flag turning on the HAB boot. 80bce88370SMarek Vasut 81bce88370SMarek Vasut CALL [HAB] u32_address [u32_r0_arg] 82bce88370SMarek Vasut - See JUMP instruction above, as the operation is exactly the same with 83bce88370SMarek Vasut one difference. The CALL instruction does allow returning into the 84bce88370SMarek Vasut BootROM from the executed code. U-Boot makes use of this in it's SPL 85bce88370SMarek Vasut code. 86bce88370SMarek Vasut 87bce88370SMarek Vasut MODE string_mode 88bce88370SMarek Vasut - Restart the CPU and start booting from device specified by the 89bce88370SMarek Vasut "string_mode" argument. The "string_mode" differs for each CPU 90bce88370SMarek Vasut and can be: 91bce88370SMarek Vasut i.MX23, string_mode = USB/I2C/SPI1_FLASH/SPI2_FLASH/NAND_BCH 92bce88370SMarek Vasut JTAG/SPI3_EEPROM/SD_SSP0/SD_SSP1 93bce88370SMarek Vasut i.MX28, string_mode = USB/I2C/SPI2_FLASH/SPI3_FLASH/NAND_BCH 94bce88370SMarek Vasut JTAG/SPI2_EEPROM/SD_SSP0/SD_SSP1 95bce88370SMarek Vasut 96bce88370SMarek Vasut - An optional "DCD" blocks can be added at the begining of the configuration 97bce88370SMarek Vasut file. Note that the DCD is only supported on i.MX28. 98bce88370SMarek Vasut - The DCD blocks must be inserted before the first "section" in the 99bce88370SMarek Vasut configuration file. 100bce88370SMarek Vasut - The DCD block has the following semantics: 101bce88370SMarek Vasut 102bce88370SMarek Vasut DCD u32_DCD_block_ID 103bce88370SMarek Vasut - u32_DCD_block_ID :: The ID number of the DCD block, must match 104bce88370SMarek Vasut the ID number used by "LOAD DCD" instruction. 105bce88370SMarek Vasut 106bce88370SMarek Vasut - The DCD block must be followed by one of the following instructions. All 107bce88370SMarek Vasut of the instructions operate either on 1, 2 or 4 bytes. This is selected by 108bce88370SMarek Vasut the 'n' suffix of the instruction: 109bce88370SMarek Vasut 110bce88370SMarek Vasut WRITE.n u32_address u32_value 111bce88370SMarek Vasut - Write the "u32_value" to the "u32_address" address. 112bce88370SMarek Vasut 113bce88370SMarek Vasut ORR.n u32_address u32_value 114bce88370SMarek Vasut - Read the "u32_address", perform a bitwise-OR with the "u32_value" and 115bce88370SMarek Vasut write the result back to "u32_address". 116bce88370SMarek Vasut 117bce88370SMarek Vasut ANDC.n u32_address u32_value 118bce88370SMarek Vasut - Read the "u32_address", perform a bitwise-AND with the complement of 119bce88370SMarek Vasut "u32_value" and write the result back to "u32_address". 120bce88370SMarek Vasut 121bce88370SMarek Vasut EQZ.n u32_address u32_count 122bce88370SMarek Vasut - Read the "u32_address" at most "u32_count" times and test if the value 123bce88370SMarek Vasut read is zero. If it is, break the loop earlier. 124bce88370SMarek Vasut 125bce88370SMarek Vasut NEZ.n u32_address u32_count 126bce88370SMarek Vasut - Read the "u32_address" at most "u32_count" times and test if the value 127bce88370SMarek Vasut read is non-zero. If it is, break the loop earlier. 128bce88370SMarek Vasut 129bce88370SMarek Vasut EQ.n u32_address u32_mask 130bce88370SMarek Vasut - Read the "u32_address" in a loop and test if the result masked with 131bce88370SMarek Vasut "u32_mask" equals the "u32_mask". If the values are equal, break the 132bce88370SMarek Vasut reading loop. 133bce88370SMarek Vasut 134bce88370SMarek Vasut NEQ.n u32_address u32_mask 135bce88370SMarek Vasut - Read the "u32_address" in a loop and test if the result masked with 136bce88370SMarek Vasut "u32_mask" does not equal the "u32_mask". If the values are not equal, 137bce88370SMarek Vasut break the reading loop. 138bce88370SMarek Vasut 139bce88370SMarek Vasut NOOP 140bce88370SMarek Vasut - This instruction does nothing. 141bce88370SMarek Vasut 142*7a139959SAlexey Ignatov - An optional flags lines can be one of the following: 143*7a139959SAlexey Ignatov 144*7a139959SAlexey Ignatov DISPLAYPROGRESS 145*7a139959SAlexey Ignatov - Enable boot progress output form the BootROM. 146*7a139959SAlexey Ignatov 147*7a139959SAlexey Ignatov- If the boot progress output from the BootROM is enabled, the BootROM will 148*7a139959SAlexey Ignatov produce a letter on the Debug UART for each instruction it started processing. 149*7a139959SAlexey Ignatov Here is a mapping between the above instructions and the BootROM output: 150bce88370SMarek Vasut 151bce88370SMarek Vasut H -- SB Image header loaded 152bce88370SMarek Vasut T -- TAG instruction 153bce88370SMarek Vasut N -- NOOP instruction 154bce88370SMarek Vasut L -- LOAD instruction 155bce88370SMarek Vasut F -- FILL instruction 156bce88370SMarek Vasut J -- JUMP instruction 157bce88370SMarek Vasut C -- CALL instruction 158bce88370SMarek Vasut M -- MODE instruction 159bce88370SMarek Vasut 160bce88370SMarek VasutUsage -- verifying image: 161bce88370SMarek Vasut========================= 162bce88370SMarek Vasut 163bce88370SMarek VasutThe mxsimage can also verify and dump contents of an image. Use the following 164bce88370SMarek Vasutsyntax to verify and dump contents of an image: 165bce88370SMarek Vasut 166bce88370SMarek Vasut mkimage -l <input bootstream file> 167bce88370SMarek Vasut 168bce88370SMarek VasutThis will output all the information from the SB image header and all the 169bce88370SMarek Vasutinstructions contained in the SB image. It will also check if the various 170bce88370SMarek Vasutchecksums in the SB image are correct. 171