Zynq U-boot

Introduction

The purpose of this page is to describe the Xilinx Zynq U-boot solution. The u-boot source is based on is the source code from git://git.denx.de. The exact version will vary with each Xilinx release. In general, the Xilinx Linux kernel for Zynq follows normal ARM Linux processes for building and running.

General

Xilinx Zynq Linux Support

Xilinx Zynq u-boot is based on open source software. Xilinx provides support for Xilinx specific parts of u-boot (drivers and BSP). Xilinx also supports u-boot thru the Embedded Linux forum on http://forums.xilinx.com. As with many open source projects, Xilinx also expects customers to also use the open source mailing lists for Linux in areas that are not specific to Xilinx Zynq.

Assumptions

Building u-boot is only supported from a Linux based host. It is not supported from Windows.

GNU Tools

GNU tools are required to build u-boot. The same GNU tools are used for Linux. See the wiki page Zynq Tools for more GNU tools details. Note: the latest version of the tools, 2011.09, is required as u-boot will not build with the older tools.

The Details of Building Linux

Downloading the Source Tree

The source can be downloaded from the Xilinx GIT repository using the command as illustated below.

bash> git clone git://git.xilinx.com/u-boot-xlnx.git
bash> cd u-boot-xlnx

Note that this repository is seperate from the MicroBlaze and PowerPC support (u-boot-xlnx) for u-boot from Xilinx.

Configuring U-boot

U-boot must be configured to build the Xilinx BSP and drivers.

For 14.1 and 14.2 releases, configure the kernel for the ZC702 hardware using the command line as shown below.

bash> make zynq_zc702_config

Starting in the 14.3 release configure the kernel for the ZC702 or ZC706 using the command line as shown below.

bash> make zynq_zc70x_config

Note: u-boot does not require the environment variable ARCH to be set, but it can cause build issues if it is set to something other than arm.

Building U-boot

Building u-boot causes u-boot (an elf file), to be created in the root directory of the u-boot source code. A binary file, u-boot.bin, and an s-record file, u-boot.srec, are also created.

Build u-boot as shown below.

bash> make

U-boot 14.3 (and newer releases) Specific Details

U-boot is now by default expecting a uImage Linux kernel image and a ramdisk that is also wrapped with the mkimage utility. It is using the bootm command by default now which also passes the address of the device tree to the Linux kernel. The Linux build process will build a uImage when the uImage target is specified on the make command line.

For users wanting to avoid the new features temporarily, checkout the last 14.2 TRD release branch as shown in the following command.

git checkout -b xilinx-14.2-build1-trd xilinx-14.2-build1-trd

Mkimage Utility

The mkimage utility is part of u-boot and is located in the u-boot/tools directory. It prepends a header onto the specified image such that u-boot can verify an image was loaded into memory correctly.

Bootm Command Details

The bootm command has the following format:

bootm <Linux uImage address> <mkimage wrapped ramdisk address> <device tree (dtb) address>

The following u-boot commands illustrate loading the Linux kernel uImage, a mkimage wrapped ramdisk, and a device tree into memory from the SD card and then booting the Linux kernel.

u-boot> fatload mmc 0 0x3000000 uImage
u-boot> fatload mmc 0 0x2A00000 devicetree.dtb
u-boot> fatload mmc 0 0x2000000 uramdisk.image.gz
u-boot> bootm 0x3000000 0x2000000 0x2A00000

With the bootm command, u-boot is relocating the images before it boots Linux such that the addresses above may not be what the kernel sees. U-boot also alters the device tree to tell the kernel where the ramdisk image is located in memory (initrd-start and initrd-end). The bootm command sets the R2 register to the address of the device tree in memory which is not done by the go command.

U-boot commands

The list of U-boot commands can be accessed while in the U-Boot prompt. Type "help" or "?" for a complete listing of available commands.

Following is a reference of U-boot commands.

?       - alias for 'help'
base    - print or set address offset
bdinfo  - print Board Info structure
boot    - boot default, i.e., run 'bootcmd'
bootd   - boot default, i.e., run 'bootcmd'
bootm   - boot application image from memory
bootp   - boot image via network using BOOTP/TFTP protocol
cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
date    - get/set/reset date & time
echo    - echo args to console
editenv - edit environment variable
erase   - erase FLASH memory
ext2load- load binary file from a Ext2 filesystem
ext2ls  - list files in a directory (default /)
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
fdt     - flattened device tree utility commands
flinfo  - print FLASH memory information
go      - start application at address 'addr'
help    - print command description/usage
iminfo  - print header information for application image
imls    - list all images found in flash
imxtract- extract a part of a multi-image
itest   - return true/false on integer compare
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loady   - load binary file over serial line (ymodem mode)
loop    - infinite loop on address range
md      - memory display
mm      - memory modify (auto-incrementing address)
mmc     - MMC sub system
mmcinfo - display MMC info
mtest   - simple RAM read/write test
mw      - memory write (fill)
nfs     - boot image via network using NFS protocol
nm      - memory modify (constant address)
ping    - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
rarpboot- boot image via network using RARP/TFTP protocol
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
setenv  - set environment variables
sf      - SPI flash sub-system
sleep   - delay execution for some time
source  - run script from memory
sspi    - SPI utility commands
tftpboot- boot image via network using TFTP protocol
version - print monitor version

Programming QSPI flash

U-boot provides the SF command to program serial flash devices. On the ZC702 board you can use the SF command to program a QSPI device. Here is an example of loading an image file to QSPI device.

zynq-boot> sf probe 0 0 0
SF: Detected N25Q128 with page size 256, total 16 MiB
16384 KiB N25Q128 at 0:0 is now current device
zynq-boot> sf erase 0 0x200000
zynq-boot> sf read 0x08000000 0 100

//you can use any location in DDR as destination. make sure it doesnt overwrite u-boot code/data area. u-boot is at 0x04000000.

zynq-boot> md 08000000
08000000: ffffffff ffffffff ffffffff ffffffff    ................

zynq-boot> loadb 0x08000000

//load the boot image through KERMIT protocol after this step
it is assumed that you should have a boot image generated using the bootgen utility

## Ready for binary (kermit) download to 0x08000000 at 115200 bps...
## Total Size      = 0x0003e444 = 255044 Bytes
## Start Addr      = 0x08000000
zynq-boot> md 08000000 100
zynq-boot> sf write
Usage: sf write addr offset len
zynq-boot> sf write 0x08000000 0 0x3E444

U-boot read command can be used to see what is programmed in to QSPI memory.
Following is the syntax of the "sf read" command.

zynq-boot> sf read  <destination address in RAM> <source address in QSPI> <length of data to read>

NOTE: The "destination address" should not be ZERO.

Example:

zynq-boot> sf read 0x800 0x0 0x2000
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License