uboot2015-07移植之分析make smdk2410_defconfig
2016-05-21 10:32
357 查看
1、u-boot-2015-07在jz2440上面的移植
首先尝试make一下u-boot(交叉编译工具要是4.3.2版本或以上)
make smdk2410_config(将makefile中的Q变量置1,输出命令到控制台,在顶层Makefile文件的大概74行处添加'KBUILD_VERBOSE = 1') make -f ./scripts/Makefile.build obj=scripts/basic cc -Wp,-MD,scripts/basic/.fixdep.d -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/basic/fixdep scripts/basic/fixdep.c rm -f .tmp_quiet_recordmcount make -f ./scripts/Makefile.build obj=scripts/kconfig smdk2410_defconfig cc -Wp,-MD,scripts/kconfig/.conf.o.d -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DCURSES_LOC="<ncurses.h>" -DLOCALE -c -o scripts/kconfig/conf.o scripts/kconfig/conf.c cat scripts/kconfig/zconf.tab.c_shipped > scripts/kconfig/zconf.tab.c cat scripts/kconfig/zconf.lex.c_shipped > scripts/kconfig/zconf.lex.c cat scripts/kconfig/zconf.hash.c_shipped > scripts/kconfig/zconf.hash.c cc -Wp,-MD,scripts/kconfig/.zconf.tab.o.d -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DCURSES_LOC="<ncurses.h>" -DLOCALE -Iscripts/kconfig -c -o scripts/kconfig/zconf.tab.o scripts/kconfig/zconf.tab.c cc -o scripts/kconfig/conf scripts/kconfig/conf.o scripts/kconfig/zconf.tab.o scripts/kconfig/conf --defconfig=arch/../configs/smdk2410_defconfig Kconfig # \# configuration written to .config # |
make scripts/kconfig/conf --silentoldconfig Kconfig CHK include/config.h UPD include/config.h GEN include/autoconf.mk GEN include/autoconf.mk.dep CHK include/config/uboot.release UPD include/config/uboot.release CHK include/generated/version_autogenerated.h UPD include/generated/version_autogenerated.h CHK include/generated/timestamp_autogenerated.h UPD include/generated/timestamp_autogenerated.h CC lib/asm-offsets.s lib/asm-offsets.c:1: error: bad value (armv4) for -march= switch lib/asm-offsets.c:1: error: bad value (armv4) for -mtune= switch make[1]: *** [lib/asm-offsets.s] Error 1 make: *** [prepare0] Error 2 |
出现上面的错误,原因是没有指定交叉编译工具
在顶层的Makefile中找到含有CROSS_COMPILE的一行,在底下添加CROSS_COMPILE ?= arm-linux- 再次make即可成功u-boot 2015以后的版本编译以及配置过程都已经与内核类似了,连make的时候输出的信息都是类似于内核make过程
make smdk2410_defconfig过程分析
makefile的执行过程读取工作目录下的makefile文件(按顺序查找“GNUmakefile“, ”makefile“, ”Makefile“文件进行make)
一次读取工作目录makefile文件中使用指示符“include“包含的文件
查找重建所有已读取的makefile文件的规则(如果存在一个目标是当前读取的某一个makefile文件,则执行此规则重建此makefile文件,完成以后从第一步开始重新执行)
初始化变量值并展开那些需要立即展开的变量和函数并根据预设条件确定执行分支
根据“终极目标“以及其他目标的依赖关系建立依赖关系链表
执行除“终极目标“以外的所有的目标的规则(规则中如果依赖文件中任一个文件的时间戳比目标文件新,则使用规则所定义的命令重建目标文件)
执行“终极目标“所在的规则
这里先看最顶层目录的Makefile文件,大概在第471行有以下语句
ifeq ($(config-targets),1) # =========================================================================== # *config targets only - make sure prerequisites are updated, and descend # in scripts/kconfig to make the *config target KBUILD_DEFCONFIG := sandbox_defconfig export KBUILD_DEFCONFIG KBUILD_KCONFIG config: scripts_basic outputmakefile FORCE $(Q)$(MAKE) $(build)=scripts/kconfig $@ %config: scripts_basic outputmakefile FORCE $(Q)$(MAKE) $(build)=scripts/kconfig $@
我们只关注
%config: scripts_basic outputmakefile FORCE $(Q)$(MAKE) $(build)=scripts/kconfig $@ # $(Q)中的Q在前面定义了,它的值为空或者是'@',在makefile命令前面加@符号代表在执行的时候不输出该命令到控制台,也就是静默执行;$(MAKE)就是make内建的环境变量,代表make命令 */ scripts_basic: $(Q)$(MAKE) $(build)=scripts/basic # make -f ./scripts/Makefile.build obj=scripts/basic。-f为指定makefile文件 # cc -Wp,-MD,scripts/basic/.fixdep.d -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/basic/fixdep scripts/basic/fixdep.c。此条命令是上面的make命令中产生的子命令 $(Q)rm -f .tmp_quiet_recordmcount # outputmakefile generates a Makefile in the output directory, if using a # separate output directory. This allows convenient use of make in the # output directory. outputmakefile: ifneq ($(KBUILD_SRC),) #KBUILD_SRC为空不执行 $(Q)ln -fsn $(srctree) source $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) endif FORCE: 伪目标,如果有目标的依赖项里面有此项,那么一旦make目标的时候不管文件是否为最新,每次都要对目标重新进行make %config: scripts_basic outputmakefile FORCE $(Q)$(MAKE) $(build)=scripts/kconfig $@ #make -f ./scripts/Makefile.build obj=scripts/kconfig smdk2410_defconfig #scripts/kconfig/conf --defconfig=arch/../configs/smdk2410_defconfig Kconfig // 脚本文件conf执行相应的文件写入以及配置
整体的过程应该就是:
创建scripts/basic/fixdep程序make -f ./scripts/Makefile.build obj=scripts/kconfig smdk2410_defconfig生成一系列应用程序
最后调用
scripts/kconfig/conf --defconfig=arch/../configs/smdk2410_defconfig Kconfig
根据smdk2410_defconfig文件对顶层目录下的.config文件等等进行配置。该过程会根据smdk2410_defconfig里面的信息找到对应文件夹下面的Kconfig来进行相应的配置,比如对应arm板的Kconfig在arch/arm/Kconfig,里面会有各种板级Kconfig文件的指定,例如里面有source “board/samsung/smdk2410/Kconfig”一项,然后根据此项信息找到smdk2410的Kconfig进行信息配置
最后在顶层目录下.config文件里面生成类似下面的字符(里面的CONFIG_XX在make的时候会用得到)
CONFIG_HAVE_GENERIC_BOARD=y \# CONFIG_ARC is not set CONFIG_ARM=y \# CONFIG_AVR32 is not set \# CONFIG_BLACKFIN is not set \# CONFIG_M68K is not set \# CONFIG_MICROBLAZE is not set \# CONFIG_MIPS is not set \# CONFIG_NDS32 is not set \# CONFIG_NIOS2 is not set \# CONFIG_OPENRISC is not set \# CONFIG_PPC is not set \# CONFIG_SANDBOX is not set \# CONFIG_SH is not set \# CONFIG_SPARC is not set \# CONFIG_X86 is not set CONFIG_SYS_ARCH="arm" CONFIG_SYS_CPU="arm920t" CONFIG_SYS_SOC="s3c24x0" CONFIG_SYS_VENDOR="samsung" CONFIG_SYS_BOARD="smdk2440" CONFIG_SYS_CONFIG_NAME="smdk2440" # \# ARM architecture # CONFIG_CPU_ARM920T=y |
值得一提的是,2015版的u-boot里面可以使用make menuconfig来通过菜单选项来进行配置
而2014以及之前的版本是
%_config:: unconfig @$(MKCONFIG) -A $(@:_config=) # 执行make smdk2410_config之后会执行 # mkconfig -A smdk2410 #mkconfig是一个脚本文件 // 然后该命令又会通过一系列动作根据boards.cfg板级配置文件里面对应的配置进行相应的配置
该过程就比2015版本的要简单的多了
相关文章推荐
- Meet Python: little notes
- 15 条实用 Linux/Unix 磁带管理命令
- 什么是HTTPS?听大神说https和http有何区别?
- JavaScript中对JSON对象的基本操作示例
- JAVA——Runtime对象
- 一起talk C栗子吧(第一百五十二回:C语言实例--计算机中的大小端)
- python基础
- PYTHON 基础
- Unity 3D 添加视频
- xcode git 用户名密码错误
- 用DIV+CSS做网页里要设置body和*规定内容
- uC/OS-II在STM32F103上的移植
- swich,default
- Windows分区属性信息 结构
- 在线聊天静态网页模板html Demo
- Ubuntu16.04LTS配置Mysql
- Node.js 系列01
- 解决Manjaro linux的中文输入
- iscroll碰到Select无法选择下拉刷新的解决办法
- 全面解析Linux 内核 3.10.x - 内存管理 - 伙伴系统算法(Buddy System)