blob: 7a3125d705b7879d7e63edd416148bd45d0eda1b [file] [log] [blame]
Tom Rini0b9b95a2021-09-11 08:57:31 -04001.. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
2.. sectionauthor:: Tom Rini <trini@konsulko.com>
3
Bryan Brattlof10d3f172022-12-19 14:29:49 -06004AM335x Generation
5=================
6
Tom Rini5d32dbd2013-07-08 12:15:18 -04007Summary
Bryan Brattlof10d3f172022-12-19 14:29:49 -06008-------
Tom Rini5d32dbd2013-07-08 12:15:18 -04009
Tom Rini90b24ff2021-09-11 08:57:32 -040010This document covers various features of the `am335x_evm` default
11configuration, some of the related defconfigs, and how to enable hardware
12features not present by default in the defconfigs.
Tom Rini5d32dbd2013-07-08 12:15:18 -040013
14Hardware
Tom Rini0b9b95a2021-09-11 08:57:31 -040015--------
Tom Rini5d32dbd2013-07-08 12:15:18 -040016
17The binary produced by this board supports, based on parsing of the EEPROM
18documented in TI's reference designs:
Tom Rini0b9b95a2021-09-11 08:57:31 -040019* AM335x GP EVM
20* AM335x EVM SK
Tom Rini90b24ff2021-09-11 08:57:32 -040021* The Beaglebone family of designs
Tom Rini50bbca72013-08-20 08:53:50 -040022
23Customization
Tom Rini0b9b95a2021-09-11 08:57:31 -040024-------------
Tom Rini50bbca72013-08-20 08:53:50 -040025
26Given that all of the above boards are reference platforms (and the
27Beaglebone platforms are OSHA), it is likely that this platform code and
28configuration will be used as the basis of a custom platform. It is
29worth noting that aside from things such as NAND or MMC only being
30required if a custom platform makes use of these blocks, the following
31are required, depending on design:
32
Tom Rini0b9b95a2021-09-11 08:57:31 -040033* GPIO is only required if DDR3 power is controlled in a way similar to EVM SK
34* SPI is only required for SPI flash, or exposing the SPI bus.
Tom Rini50bbca72013-08-20 08:53:50 -040035
36The following blocks are required:
Tom Rini0b9b95a2021-09-11 08:57:31 -040037
38* I2C, to talk with the PMIC and ensure that we do not run afoul of
Tom Rini50bbca72013-08-20 08:53:50 -040039 errata 1.0.24.
40
Tom Rini90b24ff2021-09-11 08:57:32 -040041When removing options as part of customization, note that you will likely need
42to look at both `include/configs/am335x_evm.h`,
43`include/configs/ti_am335x_common.h` and `include/configs/am335x_evm.h` as the
44migration to Kconfig is not yet complete.
Tom Rini50bbca72013-08-20 08:53:50 -040045
Neha Malcom Francisb61ad152023-09-08 15:06:16 +053046Secure Boot
47-----------
48
49.. secure_boot_include_start_config_ti_secure_device
50
51Secure TI devices require a boot image that is authenticated by ROM
52code to function. Without this, even JTAG remains locked and the
53device is essentially useless. In order to create a valid boot image for
54a secure device from TI, the initial public software image must be signed
55and combined with various headers, certificates, and other binary images.
56
57Information on the details on the complete boot image format can be obtained
58from Texas Instruments. The tools used to generate boot images for secure
59devices are part of a secure development package (SECDEV) that can be
60downloaded from:
61
Nishanth Menoneaa39c62023-11-01 15:56:03 -050062 https://www.ti.com/mysecuresoftware (login required)
Neha Malcom Francisb61ad152023-09-08 15:06:16 +053063
64The secure development package is access controlled due to NDA and export
65control restrictions. Access must be requested and granted by TI before the
66package is viewable and downloadable. Contact TI, either online or by way
67of a local TI representative, to request access.
68
69.. secure_boot_include_end_config_ti_secure_device
70
71.. secure_boot_include_start_spl_boot
72
731. Booting of U-Boot SPL
74^^^^^^^^^^^^^^^^^^^^^^^^
75
76When CONFIG_TI_SECURE_DEVICE is set, the U-Boot SPL build process
77requires the presence and use of these tools in order to create a
78viable boot image. The build process will look for the environment
79variable TI_SECURE_DEV_PKG, which should be the path of the installed
80SECDEV package. If the TI_SECURE_DEV_PKG variable is not defined or
81if it is defined but doesn't point to a valid SECDEV package, a
82warning is issued during the build to indicate that a final secure
83bootable image was not created.
84
85Within the SECDEV package exists an image creation script:
86
Nishanth Menon740c41c2023-11-02 23:40:25 -050087.. prompt:: bash $
Neha Malcom Francisb61ad152023-09-08 15:06:16 +053088
89 ${TI_SECURE_DEV_PKG}/scripts/create-boot-image.sh
90
91This is called as part of the SPL/u-boot build process. As the secure
92boot image formats and requirements differ between secure SOC from TI,
93the purpose of this script is to abstract these details as much as
94possible.
95
96The script is basically the only required interface to the TI SECDEV
97package for creating a bootable SPL image for secure TI devices.
98
Nishanth Menon740c41c2023-11-02 23:40:25 -050099.. prompt:: bash $
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530100
101 create-boot-image.sh \
102 <IMAGE_FLAG> <INPUT_FILE> <OUTPUT_FILE> <SPL_LOAD_ADDR>
103
104.. secure_boot_include_end_spl_boot
105
106<IMAGE_FLAG> is a value that specifies the type of the image to
107generate OR the action the image generation tool will take. Valid
108values are:
109
110.. list-table::
111 :widths: 25 25
112 :header-rows: 0
113
114 * - PI_X-LOADER
115 - Generates an image for SPI flash (byte swapped)
116 * - X-LOADER
117 - Generates an image for non-XIP flash
118 * - MLO
119 - Generates an image for SD/MMC/eMMC media
120 * - 2ND
121 - Generates an image for USB, UART and Ethernet
122 * - XIP_X-LOADER
123 - Generates a single stage u-boot for NOR/QSPI XiP
124
125<INPUT_FILE> is the full path and filename of the public world boot
126loaderbinary file (depending on the boot media, this is usually
127either u-boot-spl.bin or u-boot.bin).
128
129<OUTPUT_FILE> is the full path and filename of the final secure
130image. The output binary images should be used in place of the standard
131non-secure binary images (see the platform-specific user's guides and
132releases notes for how the non-secure images are typically used)
133
134.. list-table::
135 :widths: 25 25
136 :header-rows: 0
137
138 * - u-boot-spl_HS_SPI_X-LOADER
139 - byte swapped boot image for SPI flash
140 * - u-boot-spl_HS_X-LOADER
141 - boot image for NAND or SD/MMC/eMMC rawmode
142 * - u-boot-spl_HS_MLO
143 - boot image for SD/MMC/eMMC media
144 * - u-boot-spl_HS_2ND
145 - boot image for USB, UART and Ethernet
146 * - u-boot_HS_XIP_X-LOADER
147 - boot image for NOR or QSPI Xip flash
148
149<SPL_LOAD_ADDR> is the address at which SOC ROM should load the
150<INPUT_FILE>
151
152.. secure_boot_include_start_primary_u_boot
153
1542. Booting of Primary U-Boot (u-boot.img)
155^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
156
157The SPL image is responsible for loading the next stage boot loader,
158which is the main u-boot image. For secure TI devices, the SPL will
159be authenticated, as described above, as part of the particular
160device's ROM boot process. In order to continue the secure boot
161process, the authenticated SPL must authenticate the main u-boot
162image that it loads.
163
164The configurations for secure TI platforms are written to make the boot
165process use the FIT image format for the u-boot.img (CONFIG_SPL_FRAMEWORK
166and CONFIG_SPL_LOAD_FIT). With these configurations the binary
167components that the SPL loads include a specific DTB image and u-boot
168image. These DTB image may be one of many available to the boot
169process. In order to secure these components so that they can be
170authenticated by the SPL as they are loaded from the FIT image, the
171build procedure for secure TI devices will secure these images before
172they are integrated into the FIT image. When those images are extracted
173from the FIT image at boot time, they are post-processed to verify that
174they are still secure. The outlined security-related SPL post-processing
175is enabled through the CONFIG_SPL_FIT_IMAGE_POST_PROCESS option which
176must be enabled for the secure boot scheme to work. In order to allow
177verifying proper operation of the secure boot chain in case of successful
178authentication messages like "Authentication passed" are output by the
179SPL to the console for each blob that got extracted from the FIT image.
180
181The exact details of the how the images are secured is handled by the
182SECDEV package. Within the SECDEV package exists a script to process
183an input binary image:
184
Nishanth Menon740c41c2023-11-02 23:40:25 -0500185.. prompt:: bash $
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530186
187 ${TI_SECURE_DEV_PKG}/scripts/secure-binary-image.sh
188
189This is called as part of the u-boot build process. As the secure
190image formats and requirements can differ between the various secure
191SOCs from TI, this script in the SECDEV package abstracts these
192details. This script is essentially the only required interface to the
193TI SECDEV package for creating a u-boot.img image for secure TI
194devices.
195
196The SPL/u-boot code contains calls to dedicated secure ROM functions
197to perform the validation on the secured images. The details of the
198interface to those functions is shown in the code. The summary
199is that they are accessed by invoking an ARM secure monitor call to
200the device's secure ROM (fixed read-only-memory that is secure and
201only accessible when the ARM core is operating in the secure mode).
202
203Invoking the secure-binary-image script for Secure Devices
204^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
205
Nishanth Menon740c41c2023-11-02 23:40:25 -0500206.. prompt:: bash $
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530207
208 secure-binary-image.sh <INPUT_FILE> <OUTPUT_FILE>
209
210<INPUT_FILE> is the full path and filename of the input binary image
211
212<OUTPUT_FILE> is the full path and filename of the output secure image.
213
214.. secure_boot_include_end_primary_u_boot
215
Tom Rini9e6cff32013-07-17 12:24:30 -0400216NAND
Tom Rini0b9b95a2021-09-11 08:57:31 -0400217----
Tom Rini9e6cff32013-07-17 12:24:30 -0400218
219The AM335x GP EVM ships with a 256MiB NAND available in most profiles. In
220this example to program the NAND we assume that an SD card has been
221inserted with the files to write in the first SD slot and that mtdparts
pekon guptab7709032013-11-19 11:02:18 +0530222have been configured correctly for the board. All images are first loaded
223into memory, then written to NAND.
224
Neha Malcom Francisb61ad152023-09-08 15:06:16 +05302251. Building u-boot for NAND boot
pekon guptab7709032013-11-19 11:02:18 +0530226
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530227.. list-table:: CONFIGxx options for NAND device
228 :widths: 25 25
229 :header-rows: 1
Tom Rini0b9b95a2021-09-11 08:57:31 -0400230
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530231 * - Config
232 - Description
233 * - CONFIG_SYS_NAND_PAGE_SIZE
234 - number of main bytes in NAND page
235 * - CONFIG_SYS_NAND_OOBSIZE
236 - number of OOB bytes in NAND page
237 * - CONFIG_SYS_NAND_BLOCK_SIZE
238 - number of bytes in NAND erase-block
239 * - CFG_SYS_NAND_ECCPOS
240 - ECC map for NAND page
241 * - CONFIG_NAND_OMAP_ECCSCHEME
242 - (refer doc/README.nand)
Tom Rini0b9b95a2021-09-11 08:57:31 -0400243
Neha Malcom Francisb61ad152023-09-08 15:06:16 +05302442. Flashing NAND via MMC/SD
Tom Rini9e6cff32013-07-17 12:24:30 -0400245
Nishanth Menon740c41c2023-11-02 23:40:25 -0500246.. prompt:: bash =>
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530247
248 # select BOOTSEL to MMC/SD boot and boot from MMC/SD card
249 mmc rescan
250 # erase flash
251 nand erase.chip
252 env default -f -a
253 saveenv
254 # flash MLO. Redundant copies of MLO are kept for failsafe
255 load mmc 0 0x82000000 MLO
256 nand write 0x82000000 0x00000 0x20000
257 nand write 0x82000000 0x20000 0x20000
258 nand write 0x82000000 0x40000 0x20000
259 nand write 0x82000000 0x60000 0x20000
260 # flash u-boot.img
261 load mmc 0 0x82000000 u-boot.img
262 nand write 0x82000000 0x80000 0x60000
263 # flash kernel image
264 load mmc 0 0x82000000 uImage
265 nand write 0x82000000 ${nandsrcaddr} ${nandimgsize}
266 # flash filesystem image
267 load mmc 0 0x82000000 filesystem.img
268 nand write 0x82000000 ${loadaddress} 0x300000
269
2703. Set BOOTSEL pin to select NAND boot, and POR the device.
pekon guptab7709032013-11-19 11:02:18 +0530271 The device should boot from images flashed on NAND device.
Tom Rini5d32dbd2013-07-08 12:15:18 -0400272
Tom Rini9fe5cea2013-07-18 15:13:05 -0400273
Tom Rini5d32dbd2013-07-08 12:15:18 -0400274Falcon Mode
Tom Rini0b9b95a2021-09-11 08:57:31 -0400275-----------
Tom Rini5d32dbd2013-07-08 12:15:18 -0400276
277The default build includes "Falcon Mode" (see doc/README.falcon) via NAND,
278eMMC (or raw SD cards) and FAT SD cards. Our default behavior currently is
279to read a 'c' on the console while in SPL at any point prior to loading the
280OS payload (so as soon as possible) to opt to booting full U-Boot. Also
281note that while one can program Falcon Mode "in place" great care needs to
282be taken by the user to not 'brick' their setup. As these are all eval
283boards with multiple boot methods, recovery should not be an issue in this
284worst-case however.
285
286Falcon Mode: eMMC
Tom Rini0b9b95a2021-09-11 08:57:31 -0400287-----------------
Tom Rini5d32dbd2013-07-08 12:15:18 -0400288
289The recommended layout in this case is:
290
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530291.. list-table:: eMMC Recommended Layout
292 :widths: 25 25 50
293 :header-rows: 1
Tom Rini0b9b95a2021-09-11 08:57:31 -0400294
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530295 * - MMC Blocks
296 - Description
297 - Location in bytes
298 * - 0x0000 - 0x007F
299 - MBR or GPT table
300 - 0x000000 - 0x020000
301 * - 0x0080 - 0x00FF
302 - ARGS or FDT file
303 - 0x010000 - 0x020000
304 * - 0x0100 - 0x01FF
305 - SPL.backup1 (first copy used)
306 - 0x020000 - 0x040000
307 * - 0x0200 - 0x02FF
308 - SPL.backup2 (second copy used)
309 - 0x040000 - 0x060000
310 * - 0x0300 - 0x06FF
311 - U-Boot
312 - 0x060000 - 0x0e0000
313 * - 0x0700 - 0x08FF
314 - U-Boot Env + Redundant
315 - 0x0e0000 - 0x120000
316 * - 0x0900 - 0x28FF
317 - Kernel
318 - 0x120000 - 0x520000
Tom Rini5d32dbd2013-07-08 12:15:18 -0400319
320Note that when we run 'spl export' it will prepare to boot the kernel.
321This includes relocation of the uImage from where we loaded it to the entry
322point defined in the header. As these locations overlap by default, it
323would leave us with an image that if written to MMC will not boot, so
324instead of using the loadaddr variable we use 0x81000000 in the following
325example. In this example we are loading from the network, for simplicity,
326and assume a valid partition table already exists and 'mmc dev' has already
327been run to select the correct device. Also note that if you previously
328had a FAT partition (such as on a Beaglebone Black) it is not enough to
329write garbage into the area, you must delete it from the partition table
330first.
331
Nishanth Menon740c41c2023-11-02 23:40:25 -0500332.. prompt:: bash =>
Tom Rini0b9b95a2021-09-11 08:57:31 -0400333
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530334 # Ensure we are able to talk with this mmc device
335 mmc rescan
336 tftp 81000000 am335x/MLO
337 # Write to two of the backup locations ROM uses
338 mmc write 81000000 100 100
339 mmc write 81000000 200 100
340 # Write U-Boot to the location set in the config
341 tftp 81000000 am335x/u-boot.img
342 mmc write 81000000 300 400
343 # Load kernel and device tree into memory, perform export
344 tftp 81000000 am335x/uImage
345 run findfdt
346 tftp ${fdtaddr} am335x/${fdtfile}
347 run mmcargs
348 spl export fdt 81000000 - ${fdtaddr}
349 # Write the updated device tree to MMC
350 mmc write ${fdtaddr} 80 80
351 # Write the uImage to MMC
352 mmc write 81000000 900 2000
Tom Rini5d32dbd2013-07-08 12:15:18 -0400353
354Falcon Mode: FAT SD cards
Tom Rini0b9b95a2021-09-11 08:57:31 -0400355-------------------------
Tom Rini5d32dbd2013-07-08 12:15:18 -0400356
357In this case the additional file is written to the filesystem. In this
358example we assume that the uImage and device tree to be used are already on
359the FAT filesystem (only the uImage MUST be for this to function
360afterwards) along with a Falcon Mode aware MLO and the FAT partition has
361already been created and marked bootable:
362
Nishanth Menon740c41c2023-11-02 23:40:25 -0500363.. prompt:: bash =>
Tom Rini0b9b95a2021-09-11 08:57:31 -0400364
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530365 mmc rescan
366 # Load kernel and device tree into memory, perform export
367 load mmc 0:1 ${loadaddr} uImage
368 run findfdt
369 load mmc 0:1 ${fdtaddr} ${fdtfile}
370 run mmcargs
371 spl export fdt ${loadaddr} - ${fdtaddr}
Tom Rini5d32dbd2013-07-08 12:15:18 -0400372
373This will print a number of lines and then end with something like:
Tom Rini0b9b95a2021-09-11 08:57:31 -0400374
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530375.. code-block:: bash
Tom Rini0b9b95a2021-09-11 08:57:31 -0400376
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530377 Using Device Tree in place at 80f80000, end 80f85928
378 Using Device Tree in place at 80f80000, end 80f88928
Tom Rini0b9b95a2021-09-11 08:57:31 -0400379
Tom Rini5d32dbd2013-07-08 12:15:18 -0400380So then you:
381
Nishanth Menon740c41c2023-11-02 23:40:25 -0500382.. prompt:: bash =>
Tom Rini0b9b95a2021-09-11 08:57:31 -0400383
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530384 fatwrite mmc 0:1 0x80f80000 args 8928
Tom Rini5d32dbd2013-07-08 12:15:18 -0400385
386Falcon Mode: NAND
Tom Rini0b9b95a2021-09-11 08:57:31 -0400387-----------------
Tom Rini5d32dbd2013-07-08 12:15:18 -0400388
389In this case the additional data is written to another partition of the
390NAND. In this example we assume that the uImage and device tree to be are
Jeremiah Mahlerbec3d9d2015-01-06 16:40:28 -0800391already located on the NAND somewhere (such as filesystem or mtd partition)
Tom Rini5d32dbd2013-07-08 12:15:18 -0400392along with a Falcon Mode aware MLO written to the correct locations for
393booting and mtdparts have been configured correctly for the board:
394
Nishanth Menon740c41c2023-11-02 23:40:25 -0500395.. prompt:: bash =>
Tom Rini0b9b95a2021-09-11 08:57:31 -0400396
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530397 nand read ${loadaddr} kernel
398 load nand rootfs ${fdtaddr} /boot/am335x-evm.dtb
399 run nandargs
400 spl export fdt ${loadaddr} - ${fdtaddr}
401 nand erase.part u-boot-spl-os
402 nand write ${fdtaddr} u-boot-spl-os
Miquel Raynal1b9d2a02023-08-07 08:42:41 +0200403
404USB device
405----------
406
407The platform code for am33xx based designs is legacy in the sense that
408it is not fully compliant with the driver model in its management of the
409various resources. This is particularly true for the USB Ethernet gadget
410which will automatically be bound to the first USB Device Controller
411(UDC). This make the USB Ethernet gadget work out of the box on common
412boards like the Beagle Bone Blacks and by default will prevents other
413gadgets to be used.
414
415The output of the 'dm tree' command shows which driver is bound to which
416device, so the user can easily configure their platform differently from
417the command line:
418
Nishanth Menon740c41c2023-11-02 23:40:25 -0500419.. prompt:: bash =>
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530420
421 dm tree
422
Miquel Raynal1b9d2a02023-08-07 08:42:41 +0200423.. code-block:: text
424
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530425 Class Index Probed Driver Name
426 -----------------------------------------------------------
427 [...]
428 misc 0 [ + ] ti-musb-wrapper | |-- usb@47400000
429 usb 0 [ + ] ti-musb-peripheral | | |-- usb@47401000
430 ethernet 1 [ + ] usb_ether | | | `-- usb_ether
431 bootdev 3 [ ] eth_bootdev | | | `-- usb_ether.bootdev
432 usb 0 [ ] ti-musb-host | | `-- usb@47401800
Miquel Raynal1b9d2a02023-08-07 08:42:41 +0200433
434Typically here any network command performed using the usb_ether
435interface would work, while using other gadgets would fail:
436
Nishanth Menon740c41c2023-11-02 23:40:25 -0500437.. prompt:: bash =>
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530438
439 fastboot usb 0
440
Miquel Raynal1b9d2a02023-08-07 08:42:41 +0200441.. code-block:: text
442
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530443 All UDC in use (1 available), use the unbind command
444 g_dnl_register: failed!, error: -19
445 exit not allowed from main input shell.
Miquel Raynal1b9d2a02023-08-07 08:42:41 +0200446
447As hinted by the primary error message, the only controller available
448(usb@47401000) is currently bound to the usb_ether driver, which makes
449it impossible for the fastboot command to bind with this device (at
450least from a bootloader point of view). The solution here would be to
451use the unbind command specifying the class and index parameters (as
452shown above in the 'dm tree' output) to target the driver to unbind:
453
Nishanth Menon740c41c2023-11-02 23:40:25 -0500454.. prompt:: bash =>
Miquel Raynal1b9d2a02023-08-07 08:42:41 +0200455
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530456 unbind ethernet 1
Miquel Raynal1b9d2a02023-08-07 08:42:41 +0200457
458The output of the 'dm tree' command now shows the availability of the
459first USB device controller, the fastboot gadget will now be able to
460bind with it:
461
Nishanth Menon740c41c2023-11-02 23:40:25 -0500462.. prompt:: bash =>
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530463
464 dm tree
465
Miquel Raynal1b9d2a02023-08-07 08:42:41 +0200466.. code-block:: text
467
Neha Malcom Francisb61ad152023-09-08 15:06:16 +0530468 Class Index Probed Driver Name
469 -----------------------------------------------------------
470 [...]
471 misc 0 [ + ] ti-musb-wrapper | |-- usb@47400000
472 usb 0 [ ] ti-musb-peripheral | | |-- usb@47401000
473 usb 0 [ ] ti-musb-host | | `-- usb@47401800