blob: 82bae7c633ab719dfb0a58e66874a0daa61af79e [file] [log] [blame]
Neha Malcom Francis507be122023-07-22 00:14:43 +05301.. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
2.. sectionauthor:: Neha Francis <n-francis@ti.com>
3
4AM65x Platforms
5===============
6
7Introduction:
8-------------
9The AM65x family of SoCs is the first device family from K3 Multicore
10SoC architecture, targeted for broad market and industrial control with
11aim to meet the complex processing needs of modern embedded products.
12
13The device is built over three domains, each containing specific processing
14cores, voltage domains and peripherals:
15
161. Wake-up (WKUP) domain:
17 * Device Management and Security Controller (DMSC)
18
192. Microcontroller (MCU) domain:
20 * Dual Core ARM Cortex-R5F processor
21
223. MAIN domain:
23 * Quad core 64-bit ARM Cortex-A53
24
25More info can be found in TRM: http://www.ti.com/lit/pdf/spruid7
26
27Boot Flow:
28----------
29On AM65x family devices, ROM supports boot only via MCU(R5). This means that
30bootloader has to run on R5 core. In order to meet this constraint, and for
31the following reasons the boot flow is designed as mentioned:
32
331. Need to move away from R5 asap, so that we want to start *any*
34firmware on the R5 cores for example autosar can be loaded to receive CAN
35response and other safety operations to be started. This operation is
36very time critical and is applicable for all automotive use cases.
37
382. U-Boot on A53 should start other remotecores for various
39applications. This should happen before running Linux.
40
413. In production boot flow, we might not like to use full U-Boot,
42instead use Falcon boot flow to reduce boot time.
43
44.. code-block:: text
45
46 +------------------------------------------------------------------------+
47 | DMSC | R5 | A53 |
48 +------------------------------------------------------------------------+
49 | +--------+ | | |
50 | | Reset | | | |
51 | +--------+ | | |
52 | : | | |
53 | +--------+ | +-----------+ | |
54 | | *ROM* |----------|-->| Reset rls | | |
55 | +--------+ | +-----------+ | |
56 | | | | : | |
57 | | ROM | | : | |
58 | |services| | : | |
59 | | | | +-------------+ | |
60 | | | | | *R5 ROM* | | |
61 | | | | +-------------+ | |
62 | | |<---------|---|Load and auth| | |
63 | | | | | tiboot3.bin | | |
64 | | | | +-------------+ | |
65 | | | | : | |
66 | | | | : | |
67 | | | | : | |
68 | | | | +-------------+ | |
69 | | | | | *R5 SPL* | | |
70 | | | | +-------------+ | |
71 | | | | | Load | | |
72 | | | | | sysfw.itb | | |
73 | | Start | | +-------------+ | |
74 | | System |<---------|---| Start | | |
75 | |Firmware| | | SYSFW | | |
76 | +--------+ | +-------------+ | |
77 | : | | | | |
78 | +---------+ | | Load | | |
79 | | *SYSFW* | | | system | | |
80 | +---------+ | | Config data | | |
81 | | |<--------|---| | | |
82 | | | | +-------------+ | |
83 | | | | | | | |
84 | | | | | DDR | | |
85 | | | | | config | | |
86 | | | | +-------------+ | |
87 | | | | | | | |
88 | | |<--------|---| Start A53 | | |
89 | | | | | and Reset | | |
90 | | | | +-------------+ | |
91 | | | | | +-----------+ |
92 | | |---------|-----------------------|---->| Reset rls | |
93 | | | | | +-----------+ |
94 | | DMSC | | | : |
95 | |Services | | | +------------+ |
96 | | |<--------|-----------------------|---->|*ATF/OP-TEE*| |
97 | | | | | +------------+ |
98 | | | | | : |
99 | | | | | +-----------+ |
100 | | |<--------|-----------------------|---->| *A53 SPL* | |
101 | | | | | +-----------+ |
102 | | | | | | Load | |
103 | | | | | | u-boot.img| |
104 | | | | | +-----------+ |
105 | | | | | : |
106 | | | | | +-----------+ |
107 | | |<--------|-----------------------|---->| *U-Boot* | |
108 | | | | | +-----------+ |
109 | | | | | | prompt | |
110 | | | | | +-----------+ |
111 | +---------+ | | |
112 | | | |
113 +------------------------------------------------------------------------+
114
115- Here DMSC acts as master and provides all the critical services. R5/A53
116 requests DMSC to get these services done as shown in the above diagram.
117
118Sources:
119--------
1201. Trusted Firmware-A:
121 Tree: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/
122 Branch: master
123
1242. OP-TEE:
125 Tree: https://github.com/OP-TEE/optee_os.git
126 Branch: master
127
1283. U-Boot:
129 Tree: https://source.denx.de/u-boot/u-boot
130 Branch: master
131
1324. TI Linux Firmware:
133 Tree: git://git.ti.com/processor-firmware/ti-linux-firmware.git
134 Branch: ti-linux-firmware
135
136Build procedure:
137----------------
1381. Trusted Firmware-A:
139
140.. code-block:: bash
141
142 $ make CROSS_COMPILE=aarch64-linux-gnu- ARCH=aarch64 PLAT=k3 \
143 TARGET_BOARD=generic SPD=opteed
144
1452. OP-TEE:
146
147.. code-block:: bash
148
149 $ make PLATFORM=k3-am65x CFG_ARM64_core=y
150
1513. U-Boot:
152
153* 4.1 R5:
154
155.. code-block:: bash
156
157 $ make am65x_evm_r5_defconfig
158 $ make CROSS_COMPILE=arm-linux-gnueabihf- \
159 BINMAN_INDIRS=<path/to/ti-linux-firmware>
160
161* 4.2 A53:
162
163.. code-block:: bash
164
165 $ make am65x_evm_a53_defconfig
166 $ make CROSS_COMPILE=aarch64-linux-gnu- \
167 BL31=<path/to/trusted-firmware-a/dir>/build/k3/generic/release/bl31.bin \
168 TEE=<path/to/optee_os/dir>/out/arm-plat-k3/core/tee-raw.bin \
169 BINMAN_INDIRS=<path/to/ti-linux-firmware>
170
171Target Images
172--------------
Tom Rinifdf45032023-07-25 12:44:16 -0400173In order to boot we need tiboot3.bin, sysfw.itb, tispl.bin and u-boot.img.
174Each SoC variant (GP and HS) requires a different source for these files.
Neha Malcom Francis507be122023-07-22 00:14:43 +0530175
176- GP
177
178 * tiboot3-am65x_sr2-gp-evm.bin, sysfw-am65x_sr2-gp-evm.itb from step 4.1
179 * tispl.bin_unsigned, u-boot.img_unsigned from step 4.2
180
181- HS
182
183 * tiboot3-am65x_sr2-hs-evm.bin, sysfw-am65x_sr2-hs-evm.itb from step 4.1
184 * tispl.bin, u-boot.img from step 4.2
185
186Image formats:
187--------------
188
189- tiboot3.bin:
190
191.. code-block:: text
192
193 +-----------------------+
194 | X.509 |
195 | Certificate |
196 | +-------------------+ |
197 | | | |
198 | | R5 | |
199 | | u-boot-spl.bin | |
200 | | | |
201 | +-------------------+ |
202 | | | |
203 | | FIT header | |
204 | | +---------------+ | |
205 | | | | | |
206 | | | DTB 1...N | | |
207 | | +---------------+ | |
208 | +-------------------+ |
209 +-----------------------+
210
211- tispl.bin
212
213.. code-block:: text
214
215 +-----------------------+
216 | |
217 | FIT HEADER |
218 | +-------------------+ |
219 | | | |
220 | | A53 ATF | |
221 | +-------------------+ |
222 | | | |
223 | | A53 OP-TEE | |
224 | +-------------------+ |
225 | | | |
226 | | A53 SPL | |
227 | +-------------------+ |
228 | | | |
229 | | SPL DTB 1...N | |
230 | +-------------------+ |
231 +-----------------------+
232
233- sysfw.itb
234
235.. code-block:: text
236
237 +-----------------------+
238 | |
239 | FIT HEADER |
240 | +-------------------+ |
241 | | | |
242 | | sysfw.bin | |
243 | +-------------------+ |
244 | | | |
245 | | board config | |
246 | +-------------------+ |
247 | | | |
248 | | PM config | |
249 | +-------------------+ |
250 | | | |
251 | | RM config | |
252 | +-------------------+ |
253 | | | |
254 | | Secure config | |
255 | +-------------------+ |
256 +-----------------------+
257
258eMMC:
259-----
260ROM supports booting from eMMC from boot0 partition offset 0x0
261
262Flashing images to eMMC:
263
264The following commands can be used to download tiboot3.bin, tispl.bin,
265u-boot.img, and sysfw.itb from an SD card and write them to the eMMC boot0
266partition at respective addresses.
267
268.. code-block:: text
269
270 => mmc dev 0 1
271 => fatload mmc 1 ${loadaddr} tiboot3.bin
272 => mmc write ${loadaddr} 0x0 0x400
273 => fatload mmc 1 ${loadaddr} tispl.bin
274 => mmc write ${loadaddr} 0x400 0x1000
275 => fatload mmc 1 ${loadaddr} u-boot.img
276 => mmc write ${loadaddr} 0x1400 0x2000
277 => fatload mmc 1 ${loadaddr} sysfw.itb
278 => mmc write ${loadaddr} 0x3600 0x800
279
280To give the ROM access to the boot partition, the following commands must be
281used for the first time:
282
283.. code-block:: text
284
285 => mmc partconf 0 1 1 1
286 => mmc bootbus 0 1 0 0
287
288To create a software partition for the rootfs, the following command can be
289used:
290
291.. code-block:: text
292
293 => gpt write mmc 0 ${partitions}
294
295eMMC layout:
296
297.. code-block:: text
298
299 boot0 partition (8 MB) user partition
300 0x0+----------------------------------+ 0x0+-------------------------+
301 | tiboot3.bin (512 KB) | | |
302 0x400+----------------------------------+ | |
303 | tispl.bin (2 MB) | | |
304 0x1400+----------------------------------+ | rootfs |
305 | u-boot.img (4 MB) | | |
306 0x3400+----------------------------------+ | |
307 | environment (128 KB) | | |
308 0x3500+----------------------------------+ | |
309 | backup environment (128 KB) | | |
310 0x3600+----------------------------------+ | |
311 | sysfw (1 MB) | | |
312 0x3E00+----------------------------------+ +-------------------------+
313
314Kernel image and DT are expected to be present in the /boot folder of rootfs.
315To boot kernel from eMMC, use the following commands:
316
317.. code-block:: text
318
319 => setenv mmcdev 0
320 => setenv bootpart 0
321 => boot
322
323OSPI:
324-----
325ROM supports booting from OSPI from offset 0x0.
326
327Flashing images to OSPI:
328
329Below commands can be used to download tiboot3.bin, tispl.bin, u-boot.img,
330and sysfw.itb over tftp and then flash those to OSPI at their respective
331addresses.
332
333.. code-block:: text
334
335 => sf probe
336 => tftp ${loadaddr} tiboot3.bin
337 => sf update $loadaddr 0x0 $filesize
338 => tftp ${loadaddr} tispl.bin
339 => sf update $loadaddr 0x80000 $filesize
340 => tftp ${loadaddr} u-boot.img
341 => sf update $loadaddr 0x280000 $filesize
342 => tftp ${loadaddr} sysfw.itb
343 => sf update $loadaddr 0x6C0000 $filesize
344
345Flash layout for OSPI:
346
347.. code-block:: text
348
349 0x0 +----------------------------+
350 | ospi.tiboot3(512K) |
351 | |
352 0x80000 +----------------------------+
353 | ospi.tispl(2M) |
354 | |
355 0x280000 +----------------------------+
356 | ospi.u-boot(4M) |
357 | |
358 0x680000 +----------------------------+
359 | ospi.env(128K) |
360 | |
361 0x6A0000 +----------------------------+
362 | ospi.env.backup (128K) |
363 | |
364 0x6C0000 +----------------------------+
365 | ospi.sysfw(1M) |
366 | |
367 0x7C0000 +----------------------------+
368 | padding (256k) |
369 0x800000 +----------------------------+
370 | ospi.rootfs(UBIFS) |
371 | |
372 +----------------------------+
373
374Kernel Image and DT are expected to be present in the /boot folder of UBIFS
375ospi.rootfs just like in SD card case. U-Boot looks for UBI volume named
376"rootfs" for rootfs.
377
378To boot kernel from OSPI, at the U-Boot prompt:
379
380.. code-block:: text
381
382 => setenv boot ubi
383 => boot
384
385UART:
386-----
387ROM supports booting from MCU_UART0 via X-Modem protocol. The entire UART-based
388boot process up to U-Boot (proper) prompt goes through different stages and uses
389different UART peripherals as follows:
390
391.. code-block:: text
392
393 +---------+---------------+-------------+------------+
394 | WHO | Loading WHAT | HW Module | Protocol |
395 +---------+---------------+-------------+------------+
396 |Boot ROM | tiboot3.bin | MCU_UART0 | X-Modem(*)|
397 |R5 SPL | sysfw.itb | MCU_UART0 | Y-Modem(*)|
398 |R5 SPL | tispl.bin | MAIN_UART0 | Y-Modem |
399 |A53 SPL | u-boot.img | MAIN_UART0 | Y-Modem |
400 +---------+---------------+-------------+------------+
401
402Note that in addition to X/Y-Modem related protocol timeouts the DMSC
403watchdog timeout of 3min (typ.) needs to be observed until System Firmware
404is fully loaded (from sysfw.itb) and started.
405
406Example bash script sequence for running on a Linux host PC feeding all boot
407artifacts needed to the device:
408
409.. code-block:: text
410
411 MCU_DEV=/dev/ttyUSB1
412 MAIN_DEV=/dev/ttyUSB0
413
414 stty -F $MCU_DEV 115200 cs8 -cstopb -parenb
415 stty -F $MAIN_DEV 115200 cs8 -cstopb -parenb
416
417 sb --xmodem tiboot3.bin > $MCU_DEV < $MCU_DEV
418 sb --ymodem sysfw.itb > $MCU_DEV < $MCU_DEV
419 sb --ymodem tispl.bin > $MAIN_DEV < $MAIN_DEV
420 sleep 1
421 sb --xmodem u-boot.img > $MAIN_DEV < $MAIN_DEV