u-boot配置过程分析(ARM)
2013-06-14 23:19
495 查看
1.u-boot源码结构
源码目录下一般包含以下目录:(1) 平台相关的或者开发板相关的,比如cpu/、baord/
(2) 通用的函数,比如common/
(3)通用的设备驱动,比如drivers/
(4)u-boot工具、示例程序、文档,比如/tools/、/examples、/doc
2.u-boot生成配置文件过程
根据顶层readme,如果使用board/板名,必须先执行 make 板名_config,然后执行make all在Makefile里面有下面
smdk2410_config : unconfig @$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 NULL s3c24x0
而MKCONFIG如下
OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR)) SRCTREE := $(CURDIR) TOPDIR := $(SRCTREE) LNDIR := $(OBJTREE) export TOPDIR SRCTREE OBJTREE MKCONFIG := $(SRCTREE)/mkconfig export MKCONFIG
转换后就是./mkconfig smdk2410 arm arm920t smdk2410 NULL s3c24x0
下面着重分析这个mkconfig
(1)确定开发板名称
APPEND=no # Default: Create new config file BOARD_NAME="" # Name to print in make output while [ $# -gt 0 ] ; do case "$1" in --) shift ; break ;; -a) shift ; APPEND=yes ;; -n) shift ; BOARD_NAME="${1%%_config}" ; shift ;; *) break ;; esac done [ "${BOARD_NAME}" ] || BOARD_NAME="$1"
主要判定有没有后缀符-a、--、-n等,默认没有使用,所以结果为BOARD_NAME = smdk2410
(2)创建平台/开发板相关的头文件的链接,(包括asm_arm,asm_arm/arch,asm_arm/proc) 如下代码所示
# # Create link to architecture specific headers # if [ "$SRCTREE" != "$OBJTREE" ] ; then mkdir -p ${OBJTREE}/include mkdir -p ${OBJTREE}/include2 cd ${OBJTREE}/include2 rm -f asm ln -s ${SRCTREE}/include/asm-$2 asm LNPREFIX="../../include2/asm/" cd ../include rm -rf asm-$2 rm -f asm mkdir asm-$2 ln -s asm-$2 asm else cd ./include rm -f asm ln -s asm-$2 asm fi rm -f asm-$2/arch if [ -z "$6" -o "$6" = "NULL" ] ; then ln -s ${LNPREFIX}arch-$3 asm-$2/arch else ln -s ${LNPREFIX}arch-$6 asm-$2/arch fi if [ "$2" = "arm" ] ; then rm -f asm-$2/proc ln -s ${LNPREFIX}proc-armv asm-$2/proc fi
这里主要是删除之前的链接,然后进行重新链接,主要考虑不同平台下配置不一样
(3)创建include/config.mk
# # Create include file for Make # echo "ARCH = $2" > config.mk echo "CPU = $3" >> config.mk echo "BOARD = $4" >> config.mk [ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk [ "$6" ] && [ "$6" != "NULL" ] && echo "SOC = $6" >> config.mk
将ARCH、CPU、BOARD、VENDER、SOC,这里$5=NULL,所以只输出了四项
如下配置mini2440生成的结果
ARCH = arm CPU = arm920t BOARD = mini2440 SOC = s3c24x0
(4)创建开发板相关的头文件 include/config.h
# # Create board specific header file # if [ "$APPEND" = "yes" ] # Append to existing config file then echo >> config.h else > config.h # Create new config file fi echo "/* Automatically generated - do not edit */" >>config.h echo "#include <configs/$1.h>" >>config.h
这里APPEND=no,请看(1)处
比如mini2440生成的文件为
/* Automatically generated - do not edit */ #include <configs/mini2440.h>
从以上可以知道,移植时候可以在board目录新建一个开发板的目录,如board/mini2440/
然后会自动生成头文件,上面的include/config.h
另外还需要做一些配置,主要在include/configs/板名.h,比如smdk2410.h
包括两类宏的开启可以启用有关的配置
(1)选项 前缀为CONFIG_ 他们用于选择CPU、SOC、开发板类型、设置系统时钟、选择设备驱动、......
/* * High Level Configuration Options * (easy to change) */ #define CONFIG_ARM920T 1 /* This is an ARM920T Core */ #define CONFIG_S3C2410 1 /* in a SAMSUNG S3C2410 SoC */ #define CONFIG_SMDK2410 1 /* on a SAMSUNG SMDK2410 Board */ /* input clock of PLL */ #define CONFIG_SYS_CLK_FREQ 12000000/* the SMDK2410 has 12MHz input clock */ #define USE_920T_MMU 1 #undef CONFIG_USE_IRQ /* we don't need IRQ/FIQ stuff */
设置命令、波特率、......
/* * Command line configuration. */ #include <config_cmd_default.h> #define CONFIG_CMD_CACHE #define CONFIG_CMD_DATE #define CONFIG_CMD_ELF #define CONFIG_BOOTDELAY 3 /*#define CONFIG_BOOTARGS "root=ramfs devfs=mount console=ttySA0,9600" */ /*#define CONFIG_ETHADDR 08:00:3e:26:0a:5b */ #define CONFIG_NETMASK 255.255.255.0 #define CONFIG_IPADDR 10.0.0.110 #define CONFIG_SERVERIP 10.0.0.1 /*#define CONFIG_BOOTFILE "elinos-lart" */ /*#define CONFIG_BOOTCOMMAND "tftp; bootm" */ #if defined(CONFIG_CMD_KGDB) #define CONFIG_KGDB_BAUDRATE 115200 /* speed to run kgdb serial port */ /* what's this ? it's not used anywhere */ #define CONFIG_KGDB_SER_INDEX 1 /* which serial port to use */ #endif
注意命令中有个config_cmd_default.h 里面包含了默认的uboot命令,可以在里面增加或者删除,也可以在其下面定义有关命令
下面主要是配置启动,网络参数
(2)参数 前缀为CFG_,用于设置malloc缓冲池的大小、uboot提示符、uboot下载默认加载地址、flash起始地址、......
/* * Size of malloc() pool */ #define CFG_MALLOC_LEN (CONFIG_ENV_SIZE + 128*1024) #define CFG_GBL_DATA_SIZE 128 /* size in bytes reserved for initial data */ /* * Hardware drivers */ #define CONFIG_DRIVER_CS8900 1 /* we have a CS8900 on-board */ #define CS8900_BASE 0x19000300 #define CS8900_BUS16 1 /* the Linux driver does accesses as shorts */
命令提示符、字符缓冲区的大小、默认下载地址、.......
/* * Miscellaneous configurable options */ #define CFG_LONGHELP /* undef to save memory */ #define CFG_PROMPT "SMDK2410 # " /* Monitor Command Prompt */ #define CFG_CBSIZE 256 /* Console I/O Buffer Size */ #define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */ #define CFG_MAXARGS 16 /* max number of command args */ #define CFG_BARGSIZE CFG_CBSIZE /* Boot Argument Buffer Size */ #define CFG_MEMTEST_START 0x30000000 /* memtest works on */ #define CFG_MEMTEST_END 0x33F00000 /* 63 MB in DRAM */ #undef CFG_CLKS_IN_HZ /* everything, incl board info, in Hz */ #define CFG_LOAD_ADDR 0x33000000 /* default load address */
里面还有stack、物理内存映射、Nor Flash设置、BOOTP设置、.......
3.总结开发板配置过程:
开发板名称->头文件链接->include/config.mk->include/config.h文档:
#!/bin/sh -e # Script to create header files and links to configure # U-Boot for a specific board. # # Parameters: Target Architecture CPU Board [VENDOR] [SOC] # # (C) 2002-2006 DENX Software Engineering, Wolfgang Denk <wd@denx.de> # #./mkconfig smdk2410 arm arm920t smdk2410 NULL s3c24x0 $0 $1 $2 $3 $4 $5 $6 APPEND=no # Default: Create new config file BOARD_NAME="" # Name to print in make output [ "${BOARD_NAME}" ] || BOARD_NAME="$1" #BOARD_NAME= smdk2410 [ $# -lt 4 ] && exit 1 [ $# -gt 6 ] && exit 1 echo "Configuring for ${BOARD_NAME} board..." # # Create link to architecture specific headers # cd ./include rm -f asm ln -s asm-$2 asm # 建立链接文件 ln -s asm-arm asm rm -f asm-$2/arch # asm-arm/arch ln -s ${LNPREFIX}arch-$6 asm-$2/arch # ln -s arch-s3c24x0 asm-arm/arch if [ "$2" = "arm" ] ; then rm -f asm-$2/proc ln -s ${LNPREFIX}proc-armv asm-$2/proc # ln -s proc-armv asm-arm/proc fi # # Create include file for Make # echo "ARCH = $2" > config.mk echo "CPU = $3" >> config.mk echo "BOARD = $4" >> config.mk #ARCH = arm #CPU = arm920t #BOARD = smdk2410 [ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk [ "$6" ] && [ "$6" != "NULL" ] && echo "SOC = $6" >> config.mk #SOC = s3c24x0 # # Create board specific header file # > config.h # Create new config file echo "/* Automatically generated - do not edit */" >>config.h echo "#include <configs/$1.h>" >>config.h #/* Automatically generated - do not edit */ ##include <configs/smdk2410.h> exit 0
相关文章推荐
- GNU ARM汇编--(十九)u-boot-nand-spl启动过程分析
- U-boot分析第1章------------------Makefile(配置过程)
- U-Boot的配置过程分析
- u-boot-2016.09 make配置过程分析
- 【u-boot】u-boot-2016.09 make配置过程分析
- u-boot-1.1.6的配置编译过程分析.doc
- u-boot-2012.04.01的配置编译过程分析.doc
- 【imx6ul】U-Boot 2016.03执行过程分析-ARM Cortex-A7
- u-boot2013.01 sdmk2410 配置和编译过程分析
- 【imx6ul】U-Boot 2016.03的make xxx_defconfig配置过程分析
- 二、uboot的配置过程分析 (2011-03-10 19:41)
- arm-linux head.s 分析 基于mini2440 uboot后的解压过程
- 初学u-boot之源码配置编译过程分析
- u-boot 2014-10 Makefile 配置过程分析
- u-boot-2012.10分析一配置过程
- 【ARM-Linux开发】U-Boot启动过程--详细版的完全分析
- u-boot的配置过程分析2