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