uboot下载地址ftp://ftp.denx.de/pub/u-boot/
1、查看uboot文件目录结构
- Directory Hierarchy:
- ====================
- /arch Architecture specific files
- /arm Files generic to ARM architecture
- /cpu CPU specific files
- /arm720t Files specific to ARM 720 CPUs
- /arm920t Files specific to ARM 920 CPUs
- /at91 Files specific to Atmel AT91RM9200 CPU
- /imx Files specific to Freescale MC9328 i.MX CPUs
- /s3c24x0 Files specific to Samsung S3C24X0 CPUs
- /lib Architecture specific library files
- /x86 Files generic to x86 architecture
- /cpu CPU specific files
- /lib Architecture specific library files
- /mips Files generic to MIPS architecture
- /cpu CPU specific files
- /mips32 Files specific to MIPS32 CPUs
- /xburst Files specific to Ingenic XBurst CPUs
- /lib Architecture specific library files
- /powerpc Files generic to PowerPC architecture
- /cpu CPU specific files
- /74xx_7xx Files specific to Freescale MPC74xx and 7xx CPUs
- /mpc5xx Files specific to Freescale MPC5xx CPUs
- /mpc5xxx Files specific to Freescale MPC5xxx CPUs
- /lib Architecture specific library files
- /api Machine/arch independent API for external apps
- /board Board dependent files
- /common Misc architecture independent functions
- /disk Code for disk drive partition handling
- /doc Documentation (don't expect too much)
- /drivers Commonly used device drivers
- /dts Contains Makefile for building internal U-Boot fdt.
- /examples Example code for standalone applications, etc.
- /fs Filesystem code (cramfs, ext2, jffs2, etc.)
- /include Header Files
- /lib Files generic to all architectures
- /libfdt Library files to support flattened device trees
- /lzma Library files to support LZMA decompression
- /lzo Library files to support LZO decompression
- /net Networking code
- /post Power On Self Test
- /rtc Real Time Clock drivers
- /tools Tools to build S-Record or U-Boot images, etc.
uboot层次结构和调用关系
2、查看解压目录中的README文件
Software Configuration:
=======================
Configuration is usually done using C preprocessor defines; the
rationale behind that is to avoid dead code whenever possible.
There are two classes of configuration variables:
# README文件中说明了很多“CONFIG_”和“CONFIG_SYS_”的作用,在看makefile时不懂的话可以查询一下
* Configuration _OPTIONS_:
These are selectable by the user and have names beginning with
"CONFIG_".
* Configuration _SETTINGS_:
These depend on the hardware etc. and should not be meddled with if
you don't know what you're doing; they have names beginning with
"CONFIG_SYS_".
编译uboot
Selection of Processor Architecture and Board Type:
--------------------------------------------------
For all supported boards there are ready-to-use default
configurations available; just type "make <board_name>_config".
Example: For a TQM823L module type:
cd u-boot
make TQM823L_config
For the Cogent platform, you need to specify the CPU type as well;
e.g. "make cogent_mpc8xx_config". And also configure the cogent
directory according to the instructions in cogent/README.
make NAME_config
where "NAME_config" is the name of one of the existing configu-
rations; see boards.cfg for supported names.(NAME_config在uboot根目录中)
Finally, type "make all", and you should get some working U-Boot
images ready for download to / installation on your system:
- "u-boot.bin" is a raw binary image
- "u-boot" is an image in ELF binary format
- "u-boot.srec" is in Motorola S-Record format
#使用命令改变make编译输出uboot.bin的目录 etc.
By default the build is performed locally and the objects are saved
in the source directory. One of the two methods can be used to change
this behavior and build U-Boot to some external directory:
1. Add O= to the make command line invocations:
make O=/tmp/build distclean
make O=/tmp/build NAME_config
make O=/tmp/build all
2. Set environment variable BUILD_DIR to point to the desired location:
export BUILD_DIR=/tmp/build
make distclean
make NAME_config
make all
Note that the command line "O=" setting overrides the BUILD_DIR environment
variable.
#以下这段话还不知道什么时候用的上,先记录一下
Please be aware that the Makefiles assume you are using GNU make, so
for instance on NetBSD you might need to use "gmake" instead of
native "make".
#uboot命令汇总
- Monitor Commands - Overview:
- ============================
- go - start application at address 'addr'
- run - run commands in an environment variable
- bootm - boot application image from memory
- bootp - boot image via network using BootP/TFTP protocol
- bootz - boot zImage from memory
- tftpboot- boot image via network using TFTP protocol
- and env variables "ipaddr" and "serverip"
- (and eventually "gatewayip")
- tftpput - upload a file via network using TFTP protocol
- rarpboot- boot image via network using RARP/TFTP protocol
- diskboot- boot from IDE devicebootd - boot default, i.e., run 'bootcmd'
- loads - load S-Record file over serial line
- loadb - load binary file over serial line (kermit mode)
- md - memory display
- mm - memory modify (auto-incrementing)
- nm - memory modify (constant address)
- mw - memory write (fill)
- cp - memory copy
- cmp - memory compare
- crc32 - checksum calculation
- i2c - I2C sub-system
- sspi - SPI utility commands
- base - print or set address offset
- printenv- print environment variables
- setenv - set environment variables
- saveenv - save environment variables to persistent storage
- protect - enable or disable FLASH write protection
- erase - erase FLASH memory
- flinfo - print FLASH memory information
- bdinfo - print Board Info structure
- iminfo - print header information for application image
- coninfo - print console devices and informations
- ide - IDE sub-system
- loop - infinite loop on address range
- loopw - infinite write loop on address range
- mtest - simple RAM test
- icache - enable or disable instruction cache
- dcache - enable or disable data cache
- reset - Perform RESET of the CPU
- echo - echo args to console
- version - print monitor version
- help - print online help
- ? - alias for 'help'
3、uImage的64字节头信息
这里就解释了uImage比zImage多的64字节是哪些
在include/image.h中的源码为
- #define IH_NMLEN 32 /* Image Name Length */
- /*
- * Legacy format image header,
- * all data in network byte order (aka natural aka bigendian).
- */
- typedef struct image_header {
- uint32_t ih_magic; /* Image Header Magic Number */
- uint32_t ih_hcrc; /* Image Header CRC Checksum */
- uint32_t ih_time; /* Image Creation Timestamp */
- uint32_t ih_size; /* Image Data Size */
- uint32_t ih_load; /* Data Load Address */
- uint32_t ih_ep; /* Entry Point Address */
- uint32_t ih_dcrc; /* Image Data CRC Checksum */
- uint8_t ih_os; /* Operating System */
- uint8_t ih_arch; /* CPU architecture */
- uint8_t ih_type; /* Image Type */
- uint8_t ih_comp; /* Compression Type */
- uint8_t ih_name[IH_NMLEN]; /* Image Name */
- } image_header_t;
- <span style="color:#CC0000;">
- </span>
#寄存器使用情况
R0: function argument word/integer result
R1-R3: function argument word
R9: GOT pointer
R10: stack limit (used only if stack checking if enabled)
R11: argument (frame) pointer
R12: temporary workspace
R13: stack pointer
R14: link register
R15: program counter
==> U-Boot will use R8 to hold a pointer to the global data