AM335x U-Boot User's Guide
AM335x U-Boot User's Guide
U-Boot
In AM335x the ROM code serves as the bootstrap loader, sometimes referred to as the Initial Program Loader (IPL)
or the Primary Program Loader (PPL). The booting is completed in two consecutive stages by U-Boot [1] binaries.
The binary for the 1st U-Boot stage is referred to as the Secondary Program Loader (SPL) or the MLO. The binary
for the 2nd U-Boot stage is simply referred to as U-Boot. SPL is a non-interactive loader and is a specially built
version of U-Boot. It is built concurrently when building U-Boot.
The ROM code can load the SPL image from any of the following devices
• Memory devices non XIP (NAND/SDMMC)
The image should have the Image header. The image header is of length 8 byte which has the load address(Entry
point) and the size of the image to be copied. RBL would copy the image, whose size is given by the length field in
the image header, from the device and loads into the internal memory address specified in the load address field of
Image header.
• Peripheral devices (UART)
RBL loads the image to the internal memory address 0x402f0400 and executes it. No Image Header present.
Updated Toolchain
Starting with Sitara Linux SDK 6.0 the location of the toolchain has changed and for non ARM 9 devices a new
Linaro based toolchain will be used. Details about the change in toolchain location can be found here [2]. Also details
about the switch to Linaro can be found here [3].
AM18x users are not affected by the switch to Linaro. Therefore, any references to the Linaro toolchain prefix
"arm-linux-gnueabihf-" should be replaced with "arm-arago-linux-gnueabi-".
Building U-Boot
Prerequisite
GNU toolchain for ARM processors from Arago is recommended. Arago Toolchain can be found in the linux-devkit
directory of the SDK here [4]
NOTE
Below steps assumes that the release package is extracted inside directory represented as $AM335x-PSP-DIR
Change to the base of the U-Boot directory.
$ cd ./AM335x-LINUX-PSP-MM.mm.pp.bb/src/u-boot/u-boot-MM.mm.pp.bb
Building into a separate object directory with the "O=" parameter to make is strongly recommended.
Commands
$ [ -d ./am335x ] && rm -rf ./am335x
$ make O=am335x CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm am335x_evm
This will generate two binaries in the am335x directory, MLO and u-boot.img along with other intermediate binaries
that may be needed in some cases (see below).
Host configuration
NOTE
If Teraterm is being used, ensure that the latest version (4.67 is the latest version as of writing this user guide) of
Teraterm is installed. The implementation of the Kermit protocol in Teraterm is not reliable in older versions. The
latest version of Teraterm 4.67 can be downloaded from here [5]. Recent Teraterm updates causes slow Binary
transfer over UART. In such cases, use Windows in-built HyperTerminal application.
AM335x U-Boot User's Guide 3
Target configuration
• Make sure that the EVM boot switch settings are set to required boot mode and then power on the board.
NAND
In order to boot from the NAND flash, set the SW3 switch as follows:
Dip switch # 1 2 3 4 5
SPI
In order to boot from the SPI flash, set the SW3 switch as follows:
Dip switch # 1 2 3 4 5
USB
In order to boot from the USBmode, set the SW3 switch as follows:
Dip switch # 1 2 3 4 5
UART
In order to boot from the UART mode, set the SW3 switch as follows:
Dip switch # 1 2 3 4 5
SD
In order to boot from the SD card, set the SW3 switch as follows:
Dip switch # 1 2 3 4 5
Position ON ON ON OFF ON
CPSW Ethernet
In order to boot from the CPSW ethernet mode, set the SW3 switch as follows:
Dip switch # 1 2 3 4 5 6 7 8
NOTE
The setting of switch SW3:[7:6] is because the EVM uses RGMII mode. For more details please refer to the TRM.
NOTE
Due to heavy pin-muxing, boot device is selectively available on selected AM335x EVMs & profiles. Details about
the availability of the peripherals on different Profiles can be found from the EVM reference manual [6].
Boot Modes
NAND
NOTE
*The following sub-sections illustrate the usage of NAND specific commands on AM335X EVM.
• Refer to EVM Switch Settings section for more info on enabling/disabling different boot devices.
This section gives an overview of the NAND support in U-Boot. It also describe how to store the kernel image,
RAMDISK or the UBIFS filesystem to NAND so as to have a network-free boot right from powering on the board to
getting the kernel up and running.
Overview
Micron NAND parts (page size 2KB, block size 128KB) are supported on AM335XEVM platforms.
NAND Layout
The NAND part on the EVM has been configured in the following manner. The addresses mentioned here are used
in the subsequent NAND related commands.
| |
| |
| |
| |
| |
| |
| |
| |
| |
+------------+-->0x10000000-> NAND end (Free end)
Writing to NAND
To write len bytes of data from a memory buffer located at addr to the NAND block offset:
NOTE
*Offset & len fields should be in align with 0x800 (2048) bytes. On writing 3000 (0xbb8) bytes, len field can be
aligned to 0x1000 ie 4096 bytes. Offset field should be aligned to page start address, multiple of 2048 bytes.
If a bad block is encountered during the write operation, it is skipped and the write operation continues from next
'good' block.
For example, to write 0x40000 bytes from memory buffer at address 0x80000000 to NAND - starting at block 32
(offset 0x400000):
If a bad block is encountered during the read operation, it is skipped and the read operation continues from next
'good' block.
For example, to read 0x40000 bytes from NAND - starting at block 32 (offset 0x400000) to memory buffer at
address 0x80000000:
For example, to mark block 32 (assuming erase block size of 128Kbytes) as bad block - offset = blocknum * 128 *
1024:
NOTE
*The user marked bad blocks can be viewed by using this command only after a reset.
Erasing NAND
To erase NAND blocks in a particular the address range or using block numbers:
NOTE
*start offset addr & len fields should align to 0x20000 (64*2048) bytes, i.e.to block size 128KB.
This commands skips bad blocks (both factory and user marked) encountered within the specified range.
For example, to erase blocks 32 through 34:
H/W ECC - Hamming Code Should use this scheme only for flashing the U-Boot ENV variables.
H/W ECC – BCH8 Should use this scheme while flashing any image/binary other than the U-Boot ENV variables.
Usage:
sw - Set software ECC for NAND hw <hw_type> - Set hardware ECC for NAND <hw_type> - 0 for Hamming code
1 for bch4 2 for bch8 3 for bch16 Currently we support only Software, Hamming Code and BCH8. We do not
support BCH4 and BCH16
Environment NA Hamming NA
variables
Flashing Kernel
TFTP the kernel uImage to DDR.
Now flash the kernel image to NAND at the appropriate offset (refer to NAND layout section for the offsets)
NOTE
*Image_size should be aligned to page size of 2048 (0x800) bytes
AM335x U-Boot User's Guide 9
UART
This section describes how to use UART boot mode using TeraTerm.
• From TeraTerm Menu click “File -> Transfer -> Kermit -> Send”.
• Select the 1st stage u-boot image “MLO” and click “OPEN” button
• Wait for download to complete and then run following commands in u-boot prompt
If no error messages are displayed the SPL of NAND boot has been successfully transferred to NAND.
AM335x U-Boot User's Guide 10
• From TeraTerm Menu click “File -> Transfer -> Kermit -> Send”.
• Select the 2nd stage u-boot image “u-boot.img” and click “OPEN” button
• Wait for download to complete and then run following commands in U-Boot prompt
If no error messages are displayed the U-boot of NAND boot has been successfully transferred to NAND.
• Connect the SD memory card using Memory Card reader to the Linux Host
• Note the name allotted for this device. Type "dmesg". The SD/MMC card name should show up near the end,
usually something like "SDC" (/dev/sdc) or "SDD" (/dev/sdd).
• Navigate to the /home/am335x directory where all the mentioned files are copied
• Ensure that the script mksd-am335x.sh has executable permissions
• This scripts expects arguments in the following format
./mksd-am335x.sh <sd-device-name> <sd-1st-stage-bootloader> <sd-2nd-stage-bootloader> <kernel-uImage>
<filesystem>
NOTE
that the user will require root/sudo permissions
• In our example, we run the following command
sudo ./mksd-am335x.sh /dev/sdd MLO u-boot.img uImage nfs.tar.gz
• You will be asked about data getting overwritten, confirm it and the files along with filesystem will be copied to
SD card
• Note that this script will create two primary partitions:
• 1st partition is formatted as FAT32 containing MLO, u-boot.img, uImage files
• 2nd partition is formatted as ext3 where the filesystem is extracted in root
If no error messages are displayed the SPL of NAND boot has been successfully transferred to NAND.
If no error messages are displayed the U-boot of NAND boot has been successfully transferred to NAND.
AM335x U-Boot User's Guide 12
The file uEnv.txt is automatically loaded from SD if the bootcmd is run. It can be loaded and put into the
environment manually.
SPI
Note
• This feature is not supported prior to PSP 04.06.00.08 (and AMSDK 05.05.00.00).
• This feature changed kernel location and filenames with PSP 04.06.00.09 (and AMSDK 05.06.00.00).
• The release package does not contain the binary for SPI boot. Please follow the steps mentioned here for
compiling u-boot and use the MLO.spi and u-boot.bin files that are produced.
• Following those same instructions but building for am335x_evm_spiboot rather than am335x_evm will result in
binaries that will use the SPI flash for environment rather than NAND.
In this example we initially boot from an SD card and use that to transfer the files to write to SPI flash. If loading via
other methods, modify the commands below.
1. Switch ON EVM with switch settings such that SPI is present and boot via non-SPI. See SPI boot for more
information.
2. Write it to SPI memory by executing the following commands:
U-Boot# sf probe 0
U-Boot# sf erase 0 +E0000
U-Boot# mmc rescan
U-Boot# fatload mmc 0 ${loadaddr} MLO.byteswap
U-Boot# sf write ${loadaddr} 0 ${filesize}
U-Boot# fatload mmc 0 ${loadaddr} u-boot.img
U-Boot# sf write ${loadaddr} 0x80000 ${filesize}
AM335x U-Boot User's Guide 13
CPSW Ethernet
Note
• This feature is not supported prior to PSP 04.06.00.08 (and AMSDK 05.05.00.00).
• The release package does not contain the binary for CPSW ethernet boot. Please follow the steps mentioned here
for compiling u-boot and use the spl/u-boot-spl.bin and u-boot.img files that are produced.
host am335x_evm {
hardware ethernet de:ad:be:ee:ee:ef;
if substring (option vendor-class-identifier, 0, 10) = "DM814x ROM" {
filename "u-boot-spl.bin";
} elsif substring (option vendor-class-identifier, 0, 17) = "AM335x U-Boot SPL" {
filename "u-boot.img";
} else {
filename "uImage-am335x";
}
}
• Copy the u-boot-spl.bin and u-boot.img files you have build to the directory tftpd serves files from.
• Switch ON EVM with switch settings for CPSW ethernet boot.
• Hit enter and get to u-boot prompt “U-Boot# ”
and copy the resulting debrick.scr file to the location tftpd serves files out of. For more information please see the
doc/am335x.net-spl/README file in the source tree.
AM335x U-Boot User's Guide 14
NOTE
*When setting a MAC address please ensure that the LSB of the 1st byte if not 1 i.e. when setting the MAC address:
y in xy:ab:cd:ef:gh:jk has to be an even number. For more info this refer to the wiki page http:/ / en. wikipedia. org/
wiki/MAC_address
In case a static ip is not available run the dhcp command to obtain the ip address from the DHCP server on the
network to which the EVM is connected.
U-Boot# saveenv
In all cases we make use of optargs to control passing in of additional arguments and ip_method to determine how
the kernel will deal with networking PRIOR to userspace spawning init. This does not control for example if a dhcp
client will be started as part of the userspace init sequence.
AM335x U-Boot User's Guide 15
NOTE
*The sizes of images mentioned in the above commands have to be modified based on the actual image size. Also, it
should be aligned to sector size of the flash device used.
The value of PARTITION_ID depends on MTD device which holds the rootfs, YYYY depends on the page size of
the partition and VOLUME NAME depends on the volume name given in ubinize.cfg file while creating
UBIFS image as described here . In cases where you have multiple UBI volumes, ubi0 would change to the volume
with the root partition.
Once nand_root is set:
U-Boot# print ethaddr <-- Check if MAC address is assigned and is unique
U-Boot# setenv ethaddr <unique-MAC-address> <-- Set only if not present already, format uv:yy:zz:aa:bb:cc
U-Boot# boot
Archived
Sitara Linux SDK 05.07 [8]
References
[1] http:/ / www. denx. de/ wiki/ U-Boot/ WebHome
[2] http:/ / processors. wiki. ti. com/ index. php/ Sitara_Linux_SDK_GCC_Toolchain#Updated. C2. A0Linux-Devkit_Structure
[3] http:/ / processors. wiki. ti. com/ index. php/ Sitara_Linux_SDK_GCC_Toolchain#Switch_to_Linaro
[4] http:/ / software-dl. ti. com/ dsps/ dsps_public_sw/ am_bu/ sdk/ AM335xSDK/ latest/ index_FDS. html
[5] http:/ / logmett. com/ index. php?/ products/ teraterm. html
[6] http:/ / www. ti. com/ tool/ tmdxevm3358
[7] http:/ / processors. wiki. ti. com/ index. php/ AM335x_JFFS2_Support_Guide
[8] http:/ / processors. wiki. ti. com/ index. php?title=AM335x_U-Boot_User%27s_Guide& oldid=151545
Article Sources and Contributors 17