Uboot学习笔记①---(文件目录结构、README摘要、uImage的64字节头信息)

来源:互联网 发布:周末可以做的兼职知乎 编辑:程序博客网 时间:2024/06/05 20:33

uboot下载地址ftp://ftp.denx.de/pub/u-boot/

1、查看uboot文件目录结构

Directory Hierarchy:====================/archArchitecture specific files  /armFiles generic to ARM architecture    /cpuCPU specific files      /arm720tFiles specific to ARM 720 CPUs      /arm920tFiles specific to ARM 920 CPUs  /at91Files specific to Atmel AT91RM9200 CPU  /imxFiles specific to Freescale MC9328 i.MX CPUs  /s3c24x0Files specific to Samsung S3C24X0 CPUs    /libArchitecture specific library files  /x86Files generic to x86 architecture    /cpuCPU specific files    /libArchitecture specific library files  /mipsFiles generic to MIPS architecture    /cpuCPU specific files      /mips32Files specific to MIPS32 CPUs      /xburstFiles specific to Ingenic XBurst CPUs    /libArchitecture specific library files  /powerpcFiles generic to PowerPC architecture    /cpuCPU specific files      /74xx_7xxFiles specific to Freescale MPC74xx and 7xx CPUs      /mpc5xxFiles specific to Freescale MPC5xx CPUs      /mpc5xxxFiles specific to Freescale MPC5xxx CPUs    /libArchitecture specific library files/apiMachine/arch independent API for external apps/boardBoard dependent files/commonMisc architecture independent functions/diskCode for disk drive partition handling/docDocumentation (don't expect too much)/driversCommonly used device drivers/dts                    Contains Makefile for building internal U-Boot fdt./examplesExample code for standalone applications, etc./fs    Filesystem code (cramfs, ext2, jffs2, etc.)/includeHeader Files/libFiles generic to all architectures  /libfdtLibrary files to support flattened device trees  /lzmaLibrary files to support LZMA decompression  /lzoLibrary files to support LZO decompression/netNetworking code/postPower On Self Test/rtcReal Time Clock drivers/toolsTools 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 variablebootm    - boot application image from memorybootp    - boot image via network using BootP/TFTP protocolbootz   - boot zImage from memorytftpboot- boot image via network using TFTP protocol           and env variables "ipaddr" and "serverip"           (and eventually "gatewayip")tftpput - upload a file via network using TFTP protocolrarpboot- boot image via network using RARP/TFTP protocoldiskboot- boot from IDE devicebootd   - boot default, i.e., run 'bootcmd'loads    - load S-Record file over serial lineloadb    - load binary file over serial line (kermit mode)md    - memory displaymm    - memory modify (auto-incrementing)nm    - memory modify (constant address)mw    - memory write (fill)cp    - memory copycmp    - memory comparecrc32    - checksum calculationi2c    - I2C sub-systemsspi    - SPI utility commandsbase    - print or set address offsetprintenv- print environment variablessetenv    - set environment variablessaveenv - save environment variables to persistent storageprotect - enable or disable FLASH write protectionerase    - erase FLASH memoryflinfo    - print FLASH memory informationbdinfo    - print Board Info structureiminfo    - print header information for application imageconinfo - print console devices and informationside    - IDE sub-systemloop    - infinite loop on address rangeloopw    - infinite write loop on address rangemtest    - simple RAM testicache    - enable or disable instruction cachedcache    - enable or disable data cachereset    - Perform RESET of the CPUecho    - echo args to consoleversion - print monitor versionhelp    - print online help?    - alias for 'help'

3、uImage的64字节头信息

Image uImage与zImage的区别

这里就解释了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>

#寄存器使用情况

On ARM, the following registers are used:

    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

0 0