xref: /OK3568_Linux_fs/u-boot/doc/README.imx6 (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunU-Boot for Freescale i.MX6
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunThis file contains information for the port of U-Boot to the Freescale i.MX6
4*4882a593SmuzhiyunSoC.
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun1. CONVENTIONS FOR FUSE ASSIGNMENTS
7*4882a593Smuzhiyun-----------------------------------
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun1.1 MAC Address: It is stored in fuse bank 4, with the 32 lsbs in word 2 and the
10*4882a593Smuzhiyun    16 msbs in word 3[15:0].
11*4882a593Smuzhiyun    For i.MX6SX and i.MX6UL, they have two MAC addresses. The second MAC address
12*4882a593Smuzhiyun    is stored in fuse bank 4, with the 16 lsb in word 3[31:16] and the 32 msbs in
13*4882a593Smuzhiyun    word 4.
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunExample:
16*4882a593Smuzhiyun
17*4882a593SmuzhiyunFor reading the MAC address fuses on a MX6Q:
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun- The MAC address is stored in two fuse addresses (the fuse addresses are
20*4882a593Smuzhiyundescribed in the Fusemap Descriptions table from the mx6q Reference Manual):
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun0x620[31:0] - MAC_ADDR[31:0]
23*4882a593Smuzhiyun0x630[15:0] - MAC_ADDR[47:32]
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunIn order to use the fuse API, we need to pass the bank and word values, which
26*4882a593Smuzhiyunare calculated as below:
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunFuse address for the lower MAC address: 0x620
29*4882a593SmuzhiyunBase address for the fuses: 0x400
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun(0x620 - 0x400)/0x10 = 0x22 = 34 decimal
32*4882a593Smuzhiyun
33*4882a593SmuzhiyunAs the fuses are arranged in banks of 8 words:
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun34 / 8 = 4 and the remainder is 2, so in this case:
36*4882a593Smuzhiyun
37*4882a593Smuzhiyunbank = 4
38*4882a593Smuzhiyunword = 2
39*4882a593Smuzhiyun
40*4882a593SmuzhiyunAnd the U-Boot command would be:
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun=> fuse read 4 2
43*4882a593SmuzhiyunReading bank 4:
44*4882a593Smuzhiyun
45*4882a593SmuzhiyunWord 0x00000002: 9f027772
46*4882a593Smuzhiyun
47*4882a593SmuzhiyunDoing the same for the upper MAC address:
48*4882a593Smuzhiyun
49*4882a593SmuzhiyunFuse address for the upper MAC address: 0x630
50*4882a593SmuzhiyunBase address for the fuses: 0x400
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun(0x630 - 0x400)/0x10 = 0x23 = 35 decimal
53*4882a593Smuzhiyun
54*4882a593SmuzhiyunAs the fuses are arranged in banks of 8 words:
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun35 / 8 = 4 and the remainder is 3, so in this case:
57*4882a593Smuzhiyun
58*4882a593Smuzhiyunbank = 4
59*4882a593Smuzhiyunword = 3
60*4882a593Smuzhiyun
61*4882a593SmuzhiyunAnd the U-Boot command would be:
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun=> fuse read 4 3
64*4882a593SmuzhiyunReading bank 4:
65*4882a593Smuzhiyun
66*4882a593SmuzhiyunWord 0x00000003: 00000004
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun,which matches the ethaddr value:
69*4882a593Smuzhiyun=> echo ${ethaddr}
70*4882a593Smuzhiyun00:04:9f:02:77:72
71*4882a593Smuzhiyun
72*4882a593SmuzhiyunSome other useful hints:
73*4882a593Smuzhiyun
74*4882a593Smuzhiyun- The 'bank' and 'word' numbers can be easily obtained from the mx6 Reference
75*4882a593SmuzhiyunManual. For the mx6quad case, please check the "46.5 OCOTP Memory Map/Register
76*4882a593SmuzhiyunDefinition" from the "i.MX 6Dual/6Quad Applications Processor Reference Manual,
77*4882a593SmuzhiyunRev. 1, 04/2013" document. For example, for the MAC fuses we have:
78*4882a593Smuzhiyun
79*4882a593SmuzhiyunAddress:
80*4882a593Smuzhiyun21B_C620	Value of OTP Bank4 Word2 (MAC Address)(OCOTP_MAC0)
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun21B_C630	Value of OTP Bank4 Word3 (MAC Address)(OCOTP_MAC1)
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun- The command '=> fuse read 4 2 2' reads the whole MAC addresses at once:
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun=> fuse read 4 2 2
87*4882a593SmuzhiyunReading bank 4:
88*4882a593Smuzhiyun
89*4882a593SmuzhiyunWord 0x00000002: 9f027772 00000004
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun2. Using imx_usb_loader for first install with SPL
92*4882a593Smuzhiyun--------------------------------------------------
93*4882a593Smuzhiyun
94*4882a593Smuzhiyunimx_usb_loader is a very nice tool by Boundary Devices that
95*4882a593Smuzhiyunallow to install U-Boot without a JTAG debugger, using
96*4882a593Smuzhiyunthe USB boot mode as described in the manual. It is
97*4882a593Smuzhiyuna replacement for Freescale's MFGTOOLS.
98*4882a593Smuzhiyun
99*4882a593SmuzhiyunThe sources can be found here:
100*4882a593Smuzhiyun
101*4882a593Smuzhiyun	https://github.com/boundarydevices/imx_usb_loader.git
102*4882a593Smuzhiyun
103*4882a593SmuzhiyunBooting in USB mode, the i.MX6 announces itself to the Linux Host as:
104*4882a593Smuzhiyun
105*4882a593SmuzhiyunBus 001 Device 111: ID 15a2:0061 Freescale Semiconductor, Inc.
106*4882a593Smuzhiyun
107*4882a593Smuzhiyunimx_usb_loader is able to download a single file (u-boot.imx)
108*4882a593Smuzhiyunto the board. For boards without SPL support, it is enough to
109*4882a593Smuzhiyunissue the command:
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun	sudo ../imx_usb_loader/imx_usb -v u-boot.imx
112*4882a593Smuzhiyun
113*4882a593SmuzhiyunGetting U-Boot when SPL support is active, it requires
114*4882a593Smuzhiyuntwo downloads. imx_usb_loader downloads the SPL into
115*4882a593SmuzhiyunOCRAM and starts it. SPL will check for a valid u-boot.img, and
116*4882a593Smuzhiyunbecause it is not found, it will wait for it using the y-modem
117*4882a593Smuzhiyunprotocol via the console.
118*4882a593Smuzhiyun
119*4882a593SmuzhiyunA first install is then possible by combining imx_usb_loader with
120*4882a593Smuzhiyunanother tool such as kermit.
121*4882a593Smuzhiyun
122*4882a593Smuzhiyunsudo ../imx_usb_loader/imx_usb -v SPL
123*4882a593Smuzhiyunkermit kermit_uboot
124*4882a593Smuzhiyun
125*4882a593Smuzhiyunand kermit_uboot contains something like this (set line should be adjusted):
126*4882a593Smuzhiyun
127*4882a593Smuzhiyunset line /dev/ttyUSB1
128*4882a593Smuzhiyunset speed 115200
129*4882a593SmuzhiyunSET CARRIER-WATCH OFF
130*4882a593Smuzhiyunset flow-control none
131*4882a593Smuzhiyunset handshake none
132*4882a593Smuzhiyunset prefixing all
133*4882a593Smuzhiyunset file type bin
134*4882a593Smuzhiyunset protocol ymodem
135*4882a593Smuzhiyunsend u-boot.img
136*4882a593Smuzhiyunc
137*4882a593Smuzhiyun
138*4882a593SmuzhiyunThe last "c" command tells kermit (from ckermit package in most distros)
139*4882a593Smuzhiyunto switch from command line mode to communication mode, and when the
140*4882a593Smuzhiyunscript is finished, the U-Boot prompt is shown in the same shell.
141*4882a593Smuzhiyun
142*4882a593Smuzhiyun3. Using Secure Boot on i.MX6 machines with SPL support
143*4882a593Smuzhiyun-------------------------------------------------------
144*4882a593Smuzhiyun
145*4882a593SmuzhiyunThis version of U-Boot is able to build a signable version of the SPL
146*4882a593Smuzhiyunas well as a signable version of the U-Boot image. The signature can
147*4882a593Smuzhiyunbe verified through High Assurance Boot (HAB).
148*4882a593Smuzhiyun
149*4882a593SmuzhiyunCONFIG_SECURE_BOOT is needed to build those two binaries.
150*4882a593SmuzhiyunAfter building, you need to create a command sequence file and use
151*4882a593SmuzhiyunFreescales Code Signing Tool to sign both binaries. After creation,
152*4882a593Smuzhiyunthe mkimage tool outputs the required information about the HAB Blocks
153*4882a593Smuzhiyunparameter for the CSF. During the build, the information is preserved
154*4882a593Smuzhiyunin log files named as the binaries. (SPL.log and u-boot-ivt.log).
155*4882a593Smuzhiyun
156*4882a593SmuzhiyunMore information about the CSF and HAB can be found in the AN4581.
157*4882a593Smuzhiyunhttps://cache.freescale.com/files/32bit/doc/app_note/AN4581.pdf
158*4882a593Smuzhiyun
159*4882a593SmuzhiyunWe don't want to explain how to create a PKI tree or SRK table as
160*4882a593Smuzhiyunthis is well explained in the Application Note.
161*4882a593Smuzhiyun
162*4882a593SmuzhiyunExample Output of the SPL (imximage) creation:
163*4882a593Smuzhiyun Image Type:   Freescale IMX Boot Image
164*4882a593Smuzhiyun Image Ver:    2 (i.MX53/6/7 compatible)
165*4882a593Smuzhiyun Mode:         DCD
166*4882a593Smuzhiyun Data Size:    61440 Bytes = 60.00 kB = 0.06 MB
167*4882a593Smuzhiyun Load Address: 00907420
168*4882a593Smuzhiyun Entry Point:  00908000
169*4882a593Smuzhiyun HAB Blocks:   00907400 00000000 0000cc00
170*4882a593Smuzhiyun
171*4882a593SmuzhiyunExample Output of the u-boot-ivt.img (firmware_ivt) creation:
172*4882a593Smuzhiyun Image Name:   U-Boot 2016.11-rc1-31589-g2a4411
173*4882a593Smuzhiyun Created:      Sat Nov  5 21:53:28 2016
174*4882a593Smuzhiyun Image Type:   ARM U-Boot Firmware with HABv4 IVT (uncompressed)
175*4882a593Smuzhiyun Data Size:    352192 Bytes = 343.94 kB = 0.34 MB
176*4882a593Smuzhiyun Load Address: 17800000
177*4882a593Smuzhiyun Entry Point:  00000000
178*4882a593Smuzhiyun HAB Blocks:   0x177fffc0   0x0000   0x00054020
179*4882a593Smuzhiyun
180*4882a593SmuzhiyunThe CST (Code Signing Tool) can be downloaded from NXP.
181*4882a593Smuzhiyun# Compile CSF and create signature
182*4882a593Smuzhiyun./cst --o csf-u-boot.bin < command_sequence_uboot.csf
183*4882a593Smuzhiyun./cst --o csf-SPL.bin < command_sequence_spl.csf
184*4882a593Smuzhiyun# Append compiled CSF to Binary
185*4882a593Smuzhiyuncat SPL csf-SPL.bin > SPL-signed
186*4882a593Smuzhiyuncat u-boot-ivt.img csf-u-boot.bin > u-boot-signed.img
187*4882a593Smuzhiyun
188*4882a593SmuzhiyunThese two signed binaries can be used on an i.MX6 in closed
189*4882a593Smuzhiyunconfiguration when the according SRK Table Hash has been flashed.