summaryrefslogtreecommitdiff
path: root/doc/board/ti/am65x_evm.rst
blob: 300cd3e9b9606f53c0f071716a24195cfa3c7e64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
.. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
.. sectionauthor:: Neha Francis <n-francis@ti.com>

AM65x Platforms
===============

Introduction:
-------------
The AM65x family of SoCs is the first device family from K3 Multicore
SoC architecture, targeted for broad market and industrial control with
aim to meet the complex processing needs of modern embedded products.

The device is built over three domains, each containing specific processing
cores, voltage domains and peripherals:

1. Wake-up (WKUP) domain:
        * Device Management and Security Controller (DMSC)

2. Microcontroller (MCU) domain:
        * Dual Core ARM Cortex-R5F processor

3. MAIN domain:
        * Quad core 64-bit ARM Cortex-A53

More info can be found in TRM: http://www.ti.com/lit/pdf/spruid7

Boot Flow:
----------
On AM65x family devices, ROM supports boot only via MCU(R5). This means that
bootloader has to run on R5 core. In order to meet this constraint, and for
the following reasons the boot flow is designed as mentioned:

1. Need to move away from R5 asap, so that we want to start *any*
firmware on the R5 cores for example autosar can be loaded to receive CAN
response and other safety operations to be started. This operation is
very time critical and is applicable for all automotive use cases.

2. U-Boot on A53 should start other remotecores for various
applications. This should happen before running Linux.

3. In production boot flow, we might not like to use full U-Boot,
instead use Falcon boot flow to reduce boot time.

.. code-block:: text

 +------------------------------------------------------------------------+
 |        DMSC            |         R5            |        A53            |
 +------------------------------------------------------------------------+
 |    +--------+          |                       |                       |
 |    |  Reset |          |                       |                       |
 |    +--------+          |                       |                       |
 |         :              |                       |                       |
 |    +--------+          |   +-----------+       |                       |
 |    | *ROM*  |----------|-->| Reset rls |       |                       |
 |    +--------+          |   +-----------+       |                       |
 |    |        |          |         :             |                       |
 |    |  ROM   |          |         :             |                       |
 |    |services|          |         :             |                       |
 |    |        |          |   +-------------+     |                       |
 |    |        |          |   |  *R5 ROM*   |     |                       |
 |    |        |          |   +-------------+     |                       |
 |    |        |<---------|---|Load and auth|     |                       |
 |    |        |          |   | tiboot3.bin |     |                       |
 |    |        |          |   +-------------+     |                       |
 |    |        |          |         :             |                       |
 |    |        |          |         :             |                       |
 |    |        |          |         :             |                       |
 |    |        |          |   +-------------+     |                       |
 |    |        |          |   |  *R5 SPL*   |     |                       |
 |    |        |          |   +-------------+     |                       |
 |    |        |          |   |    Load     |     |                       |
 |    |        |          |   |  sysfw.itb  |     |                       |
 |    | Start  |          |   +-------------+     |                       |
 |    | System |<---------|---|    Start    |     |                       |
 |    |Firmware|          |   |    SYSFW    |     |                       |
 |    +--------+          |   +-------------+     |                       |
 |        :               |   |             |     |                       |
 |    +---------+         |   |   Load      |     |                       |
 |    | *SYSFW* |         |   |   system    |     |                       |
 |    +---------+         |   | Config data |     |                       |
 |    |         |<--------|---|             |     |                       |
 |    |         |         |   +-------------+     |                       |
 |    |         |         |   |             |     |                       |
 |    |         |         |   |    DDR      |     |                       |
 |    |         |         |   |   config    |     |                       |
 |    |         |         |   +-------------+     |                       |
 |    |         |         |   |             |     |                       |
 |    |         |<--------|---| Start A53   |     |                       |
 |    |         |         |   |  and Reset  |     |                       |
 |    |         |         |   +-------------+     |                       |
 |    |         |         |                       |     +-----------+     |
 |    |         |---------|-----------------------|---->| Reset rls |     |
 |    |         |         |                       |     +-----------+     |
 |    |  DMSC   |         |                       |          :            |
 |    |Services |         |                       |     +------------+    |
 |    |         |<--------|-----------------------|---->|*ATF/OP-TEE*|    |
 |    |         |         |                       |     +------------+    |
 |    |         |         |                       |          :            |
 |    |         |         |                       |     +-----------+     |
 |    |         |<--------|-----------------------|---->| *A53 SPL* |     |
 |    |         |         |                       |     +-----------+     |
 |    |         |         |                       |     |   Load    |     |
 |    |         |         |                       |     | u-boot.img|     |
 |    |         |         |                       |     +-----------+     |
 |    |         |         |                       |          :            |
 |    |         |         |                       |     +-----------+     |
 |    |         |<--------|-----------------------|---->| *U-Boot*  |     |
 |    |         |         |                       |     +-----------+     |
 |    |         |         |                       |     |  prompt   |     |
 |    |         |         |                       |     +-----------+     |
 |    +---------+         |                       |                       |
 |                        |                       |                       |
 +------------------------------------------------------------------------+

- Here DMSC acts as master and provides all the critical services. R5/A53
  requests DMSC to get these services done as shown in the above diagram.

Sources:
--------
1. Trusted Firmware-A:
        Tree: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/
        Branch: master

2. OP-TEE:
        Tree: https://github.com/OP-TEE/optee_os.git
        Branch: master

3. U-Boot:
        Tree: https://source.denx.de/u-boot/u-boot
        Branch: master

4. TI Linux Firmware:
        Tree: git://git.ti.com/processor-firmware/ti-linux-firmware.git
        Branch: ti-linux-firmware

Build procedure:
----------------
1. Trusted Firmware-A:

.. code-block:: bash

 $ make CROSS_COMPILE=aarch64-linux-gnu- ARCH=aarch64 PLAT=k3 \
        TARGET_BOARD=generic SPD=opteed

2. OP-TEE:

.. code-block:: bash

 $ make PLATFORM=k3-am65x CFG_ARM64_core=y

3. U-Boot:

* 4.1 R5:

.. code-block:: bash

 $ make am65x_evm_r5_defconfig
 $ make CROSS_COMPILE=arm-linux-gnueabihf- \
        BINMAN_INDIRS=<path/to/ti-linux-firmware>

* 4.2 A53:

.. code-block:: bash

 $ make am65x_evm_a53_defconfig
 $ make CROSS_COMPILE=aarch64-linux-gnu- \
        BL31=<path/to/trusted-firmware-a/dir>/build/k3/generic/release/bl31.bin \
        TEE=<path/to/optee_os/dir>/out/arm-plat-k3/core/tee-raw.bin \
        BINMAN_INDIRS=<path/to/ti-linux-firmware>

Target Images
--------------
Copy the below images to an SD card and boot:

- GP

        * tiboot3-am65x_sr2-gp-evm.bin, sysfw-am65x_sr2-gp-evm.itb from step 4.1
        * tispl.bin_unsigned, u-boot.img_unsigned from step 4.2

- HS

        * tiboot3-am65x_sr2-hs-evm.bin, sysfw-am65x_sr2-hs-evm.itb from step 4.1
        * tispl.bin, u-boot.img from step 4.2

Image formats:
--------------

- tiboot3.bin:

.. code-block:: text

                +-----------------------+
                |        X.509          |
                |      Certificate      |
                | +-------------------+ |
                | |                   | |
                | |        R5         | |
                | |   u-boot-spl.bin  | |
                | |                   | |
                | +-------------------+ |
                | |                   | |
                | |     FIT header    | |
                | | +---------------+ | |
                | | |               | | |
                | | |   DTB 1...N   | | |
                | | +---------------+ | |
                | +-------------------+ |
                +-----------------------+

- tispl.bin

.. code-block:: text

                +-----------------------+
                |                       |
                |       FIT HEADER      |
                | +-------------------+ |
                | |                   | |
                | |      A53 ATF      | |
                | +-------------------+ |
                | |                   | |
                | |     A53 OP-TEE    | |
                | +-------------------+ |
                | |                   | |
                | |      A53 SPL      | |
                | +-------------------+ |
                | |                   | |
                | |   SPL DTB 1...N   | |
                | +-------------------+ |
                +-----------------------+

- sysfw.itb

.. code-block:: text

                +-----------------------+
                |                       |
                |       FIT HEADER      |
                | +-------------------+ |
                | |                   | |
                | |     sysfw.bin     | |
                | +-------------------+ |
                | |                   | |
                | |    board config   | |
                | +-------------------+ |
                | |                   | |
                | |     PM config     | |
                | +-------------------+ |
                | |                   | |
                | |     RM config     | |
                | +-------------------+ |
                | |                   | |
                | |    Secure config  | |
                | +-------------------+ |
                +-----------------------+

eMMC:
-----
ROM supports booting from eMMC from boot0 partition offset 0x0

Flashing images to eMMC:

The following commands can be used to download tiboot3.bin, tispl.bin,
u-boot.img, and sysfw.itb from an SD card and write them to the eMMC boot0
partition at respective addresses.

.. code-block:: text

 => mmc dev 0 1
 => fatload mmc 1 ${loadaddr} tiboot3.bin
 => mmc write ${loadaddr} 0x0 0x400
 => fatload mmc 1 ${loadaddr} tispl.bin
 => mmc write ${loadaddr} 0x400 0x1000
 => fatload mmc 1 ${loadaddr} u-boot.img
 => mmc write ${loadaddr} 0x1400 0x2000
 => fatload mmc 1 ${loadaddr} sysfw.itb
 => mmc write ${loadaddr} 0x3600 0x800

To give the ROM access to the boot partition, the following commands must be
used for the first time:

.. code-block:: text

 => mmc partconf 0 1 1 1
 => mmc bootbus 0 1 0 0

To create a software partition for the rootfs, the following command can be
used:

.. code-block:: text

 => gpt write mmc 0 ${partitions}

eMMC layout:

.. code-block:: text

            boot0 partition (8 MB)                        user partition
    0x0+----------------------------------+      0x0+-------------------------+
       |     tiboot3.bin (512 KB)         |         |                         |
  0x400+----------------------------------+         |                         |
       |       tispl.bin (2 MB)           |         |                         |
 0x1400+----------------------------------+         |        rootfs           |
       |       u-boot.img (4 MB)          |         |                         |
 0x3400+----------------------------------+         |                         |
       |      environment (128 KB)        |         |                         |
 0x3500+----------------------------------+         |                         |
       |   backup environment (128 KB)    |         |                         |
 0x3600+----------------------------------+         |                         |
       |          sysfw (1 MB)            |         |                         |
 0x3E00+----------------------------------+         +-------------------------+

Kernel image and DT are expected to be present in the /boot folder of rootfs.
To boot kernel from eMMC, use the following commands:

.. code-block:: text

 => setenv mmcdev 0
 => setenv bootpart 0
 => boot

OSPI:
-----
ROM supports booting from OSPI from offset 0x0.

Flashing images to OSPI:

Below commands can be used to download tiboot3.bin, tispl.bin, u-boot.img,
and sysfw.itb over tftp and then flash those to OSPI at their respective
addresses.

.. code-block:: text

 => sf probe
 => tftp ${loadaddr} tiboot3.bin
 => sf update $loadaddr 0x0 $filesize
 => tftp ${loadaddr} tispl.bin
 => sf update $loadaddr 0x80000 $filesize
 => tftp ${loadaddr} u-boot.img
 => sf update $loadaddr 0x280000 $filesize
 => tftp ${loadaddr} sysfw.itb
 => sf update $loadaddr 0x6C0000 $filesize

Flash layout for OSPI:

.. code-block:: text

         0x0 +----------------------------+
             |     ospi.tiboot3(512K)     |
             |                            |
     0x80000 +----------------------------+
             |     ospi.tispl(2M)         |
             |                            |
    0x280000 +----------------------------+
             |     ospi.u-boot(4M)        |
             |                            |
    0x680000 +----------------------------+
             |     ospi.env(128K)         |
             |                            |
    0x6A0000 +----------------------------+
             |   ospi.env.backup (128K)   |
             |                            |
    0x6C0000 +----------------------------+
             |      ospi.sysfw(1M)        |
             |                            |
    0x7C0000 +----------------------------+
             |      padding (256k)        |
    0x800000 +----------------------------+
             |     ospi.rootfs(UBIFS)     |
             |                            |
             +----------------------------+

Kernel Image and DT are expected to be present in the /boot folder of UBIFS
ospi.rootfs just like in SD card case. U-Boot looks for UBI volume named
"rootfs" for rootfs.

To boot kernel from OSPI, at the U-Boot prompt:

.. code-block:: text

 => setenv boot ubi
 => boot

UART:
-----
ROM supports booting from MCU_UART0 via X-Modem protocol. The entire UART-based
boot process up to U-Boot (proper) prompt goes through different stages and uses
different UART peripherals as follows:

.. code-block:: text

 +---------+---------------+-------------+------------+
 | WHO     | Loading WHAT  |  HW Module  |  Protocol  |
 +---------+---------------+-------------+------------+
 |Boot ROM |  tiboot3.bin  |  MCU_UART0  |  X-Modem(*)|
 |R5 SPL   |  sysfw.itb    |  MCU_UART0  |  Y-Modem(*)|
 |R5 SPL   |  tispl.bin    |  MAIN_UART0 |  Y-Modem   |
 |A53 SPL  |  u-boot.img   |  MAIN_UART0 |  Y-Modem   |
 +---------+---------------+-------------+------------+

Note that in addition to X/Y-Modem related protocol timeouts the DMSC
watchdog timeout of 3min (typ.) needs to be observed until System Firmware
is fully loaded (from sysfw.itb) and started.

Example bash script sequence for running on a Linux host PC feeding all boot
artifacts needed to the device:

.. code-block:: text

 MCU_DEV=/dev/ttyUSB1
 MAIN_DEV=/dev/ttyUSB0

 stty -F $MCU_DEV 115200 cs8 -cstopb -parenb
 stty -F $MAIN_DEV 115200 cs8 -cstopb -parenb

 sb --xmodem tiboot3.bin > $MCU_DEV < $MCU_DEV
 sb --ymodem sysfw.itb > $MCU_DEV < $MCU_DEV
 sb --ymodem tispl.bin > $MAIN_DEV < $MAIN_DEV
 sleep 1
 sb --xmodem u-boot.img > $MAIN_DEV < $MAIN_DEV