如何深入分析arm9_uboot_Makefile的结构与组成?
- 内容介绍
- 文章标签
- 相关推荐
本文共计784个文字,预计阅读时间需要4分钟。
1. 解压文件:使用 `tar xjf u-boot-1.1.6.tar.bz2` 命令。
2.应用补丁:执行 `patch -p1 3.配置编译:运行 `make 100ask24x0_config`,然后在 Makefile 和 MKCONFIG 中设置:`$ (SRCTREE)/mkconfig unconfig`。
1.解压缩
tar xjf u-boot-1.1.6.tar.bz2
2.打补丁
patch -p1 < ../u-boot-1.1.6_jz2440.patch
3.配置
make 100ask24x0_config,下面为Makefile
MKCONFIG := $(SRCTREE)/mkconfig
unconfig: #清楚配置信息
@rm-f$(obj)include/config.h$(obj)include/config.mk\
$(obj)board/*/config.tmp$(obj)board/*/*/config.tmp
100ask24x0_config:unconfig
@$(MKCONFIG)$(@:_config=)armarm920t100ask24x0NULLs3c24x0
#上面这段翻译为:mkconfig 100ask24x0 armarm920t100ask24x0NULLs3c24x0
make 100ask24x0_config这个命令执行的就是mkconfig 100ask24x0 armarm920t100ask24x0NULLs3c24x0这个脚本,下面我们看下mkconfig文件
#!/bin/sh-e
#Scripttocreateheaderfilesandlinkstoconfigure
#U-Bootforaspecificboard.
#
#Parameters:TargetArchitectureCPUBoard[VENDOR][SOC]
#
#(C)2002-2006DENXSoftwareEngineering,WolfgangDenk<
[emailprotected]>
#
APPEND=no#Default:Createnewconfigfile
BOARD_NAME=""#Nametoprintinmakeoutput
#mkconfig100ask24x0armarm920t100ask24x0NULLs3c24x0
#$0$1$2$3$4$5$6
["${BOARD_NAME}"]||BOARD_NAME="$1"
[$#-lt4]&&exit1
[$#-gt6]&&exit1
echo"Configuringfor${BOARD_NAME}board..."
#
#Createlinktoarchitecturespecificheaders
#
cd./include
rm-fasm
ln-sasm-$2asm#ln-sasm-armasm创建链接文件,以指定特定架构
rm-fasm-$2/arch
ln-s${LNPREFIX}arch-$6asm-$2/arch #ln -s arch-s3c24x0 asm-arm/arch
if["$2"="arm"];then
rm-fasm-$2/proc
ln-s${LNPREFIX}proc-armvasm-$2/proc #ln -sproc-armvasm-arm/proc
fi
#
#CreateincludefileforMake
#
echo"ARCH=$2">config.mk #新建
echo"CPU=$3">>config.mk #添加
echo"BOARD=$4">>config.mk #添加
["$5"]&&["$5"!="NULL"]&&echo"VENDOR=$5">>config.mk #NULL
["$6"]&&["$6"!="NULL"]&&echo"SOC=$6">>config.mk #添加
#
#Createboardspecificheaderfile
#
if["$APPEND"="yes"]#Appendtoexistingconfigfile
then
echo>>config.h
else
>config.h#新建
fi
echo"/*Automaticallygenerated-donotedit*/">>config.h
echo"#include<configs/$1.h>">>config.h
exit0
mkconfig新建的文件打印内容如下:
4.编译
make
继续提取Makefile一些主要成分:
# load ARCH, BOARD, and CPU configuration
include $(OBJTREE)/include/config.mk
ifeq ($(ARCH),arm)
CROSS_COMPILE = arm-linux-
# U-Boot objects....order is important (i.e. start must be first)
OBJS = cpu/$(CPU)/start.o
LIBS = lib_generic/libgeneric.a
LIBS += board/$(BOARDDIR)/lib$(BOARD).a
LIBS += cpu/$(CPU)/lib$(CPU).a
ALL = $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(U_BOOT_NAND)
all: $(ALL)
$(obj)u-boot.bin:$(obj)u-boot
$(OBJCOPY)${OBJCFLAGS}-Obinary$<
[emailprotected]
$(obj)u-boot:dependversion$(SUBDIRS)$(OBJS)$(LIBS)$(LDSCRIPT)
UNDEF_SYM=`$(OBJDUMP)-x$(LIBS)|sed-n-e‘s/.*\(__u_boot_cmd_.*\)/-u\1/p‘|sort|uniq`;\
cd$(LNDIR)&&$(LD)$(LDFLAGS)$$UNDEF_SYM$(__OBJS)\
--start-group$(__LIBS)--end-group$(PLATFORM_LIBS)\
-Mapu-boot.map-ou-boot
# LDFLAGS在根目录config.mk中: LDFLAGS+=-Bstatic-T$(LDSCRIPT)-Ttext$(TEXT_BASE)$(PLATFORM_LDFLAGS) #TEXT_BASE在board/100ask24x0/config.mk中:TEXT_BASE = 0x33F80000
再看一下u-boot.lds
/* * (C) Copyright 2002 * Gary Jennejohn, DENX Software Engineering, <[emailprotected]> * * See file CREDITS for list of people who contributed to this * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") /*OUTPUT_FORMAT("elf32-arm", "elf32-arm", "elf32-arm")*/ OUTPUT_ARCH(arm) ENTRY(_start) SECTIONS { . = 0x00000000; //0x33F80000这个地址是0x30000000+64M-512Kb所在位置,当uboot大于512就要修改这个地址 . = ALIGN(4); .text : { cpu/arm920t/start.o (.text) board/100ask24x0/boot_init.o (.text) *(.text) } . = ALIGN(4); .rodata : { *(.rodata) } . = ALIGN(4); .data : { *(.data) } . = ALIGN(4); .got : { *(.got) } . = .; __u_boot_cmd_start = .; .u_boot_cmd : { *(.u_boot_cmd) } __u_boot_cmd_end = .; . = ALIGN(4); __bss_start = .; .bss : { *(.bss) } _end = .; }
本文共计784个文字,预计阅读时间需要4分钟。
1. 解压文件:使用 `tar xjf u-boot-1.1.6.tar.bz2` 命令。
2.应用补丁:执行 `patch -p1 3.配置编译:运行 `make 100ask24x0_config`,然后在 Makefile 和 MKCONFIG 中设置:`$ (SRCTREE)/mkconfig unconfig`。
1.解压缩
tar xjf u-boot-1.1.6.tar.bz2
2.打补丁
patch -p1 < ../u-boot-1.1.6_jz2440.patch
3.配置
make 100ask24x0_config,下面为Makefile
MKCONFIG := $(SRCTREE)/mkconfig
unconfig: #清楚配置信息
@rm-f$(obj)include/config.h$(obj)include/config.mk\
$(obj)board/*/config.tmp$(obj)board/*/*/config.tmp
100ask24x0_config:unconfig
@$(MKCONFIG)$(@:_config=)armarm920t100ask24x0NULLs3c24x0
#上面这段翻译为:mkconfig 100ask24x0 armarm920t100ask24x0NULLs3c24x0
make 100ask24x0_config这个命令执行的就是mkconfig 100ask24x0 armarm920t100ask24x0NULLs3c24x0这个脚本,下面我们看下mkconfig文件
#!/bin/sh-e
#Scripttocreateheaderfilesandlinkstoconfigure
#U-Bootforaspecificboard.
#
#Parameters:TargetArchitectureCPUBoard[VENDOR][SOC]
#
#(C)2002-2006DENXSoftwareEngineering,WolfgangDenk<
[emailprotected]>
#
APPEND=no#Default:Createnewconfigfile
BOARD_NAME=""#Nametoprintinmakeoutput
#mkconfig100ask24x0armarm920t100ask24x0NULLs3c24x0
#$0$1$2$3$4$5$6
["${BOARD_NAME}"]||BOARD_NAME="$1"
[$#-lt4]&&exit1
[$#-gt6]&&exit1
echo"Configuringfor${BOARD_NAME}board..."
#
#Createlinktoarchitecturespecificheaders
#
cd./include
rm-fasm
ln-sasm-$2asm#ln-sasm-armasm创建链接文件,以指定特定架构
rm-fasm-$2/arch
ln-s${LNPREFIX}arch-$6asm-$2/arch #ln -s arch-s3c24x0 asm-arm/arch
if["$2"="arm"];then
rm-fasm-$2/proc
ln-s${LNPREFIX}proc-armvasm-$2/proc #ln -sproc-armvasm-arm/proc
fi
#
#CreateincludefileforMake
#
echo"ARCH=$2">config.mk #新建
echo"CPU=$3">>config.mk #添加
echo"BOARD=$4">>config.mk #添加
["$5"]&&["$5"!="NULL"]&&echo"VENDOR=$5">>config.mk #NULL
["$6"]&&["$6"!="NULL"]&&echo"SOC=$6">>config.mk #添加
#
#Createboardspecificheaderfile
#
if["$APPEND"="yes"]#Appendtoexistingconfigfile
then
echo>>config.h
else
>config.h#新建
fi
echo"/*Automaticallygenerated-donotedit*/">>config.h
echo"#include<configs/$1.h>">>config.h
exit0
mkconfig新建的文件打印内容如下:
4.编译
make
继续提取Makefile一些主要成分:
# load ARCH, BOARD, and CPU configuration
include $(OBJTREE)/include/config.mk
ifeq ($(ARCH),arm)
CROSS_COMPILE = arm-linux-
# U-Boot objects....order is important (i.e. start must be first)
OBJS = cpu/$(CPU)/start.o
LIBS = lib_generic/libgeneric.a
LIBS += board/$(BOARDDIR)/lib$(BOARD).a
LIBS += cpu/$(CPU)/lib$(CPU).a
ALL = $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(U_BOOT_NAND)
all: $(ALL)
$(obj)u-boot.bin:$(obj)u-boot
$(OBJCOPY)${OBJCFLAGS}-Obinary$<
[emailprotected]
$(obj)u-boot:dependversion$(SUBDIRS)$(OBJS)$(LIBS)$(LDSCRIPT)
UNDEF_SYM=`$(OBJDUMP)-x$(LIBS)|sed-n-e‘s/.*\(__u_boot_cmd_.*\)/-u\1/p‘|sort|uniq`;\
cd$(LNDIR)&&$(LD)$(LDFLAGS)$$UNDEF_SYM$(__OBJS)\
--start-group$(__LIBS)--end-group$(PLATFORM_LIBS)\
-Mapu-boot.map-ou-boot
# LDFLAGS在根目录config.mk中: LDFLAGS+=-Bstatic-T$(LDSCRIPT)-Ttext$(TEXT_BASE)$(PLATFORM_LDFLAGS) #TEXT_BASE在board/100ask24x0/config.mk中:TEXT_BASE = 0x33F80000
再看一下u-boot.lds
/* * (C) Copyright 2002 * Gary Jennejohn, DENX Software Engineering, <[emailprotected]> * * See file CREDITS for list of people who contributed to this * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") /*OUTPUT_FORMAT("elf32-arm", "elf32-arm", "elf32-arm")*/ OUTPUT_ARCH(arm) ENTRY(_start) SECTIONS { . = 0x00000000; //0x33F80000这个地址是0x30000000+64M-512Kb所在位置,当uboot大于512就要修改这个地址 . = ALIGN(4); .text : { cpu/arm920t/start.o (.text) board/100ask24x0/boot_init.o (.text) *(.text) } . = ALIGN(4); .rodata : { *(.rodata) } . = ALIGN(4); .data : { *(.data) } . = ALIGN(4); .got : { *(.got) } . = .; __u_boot_cmd_start = .; .u_boot_cmd : { *(.u_boot_cmd) } __u_boot_cmd_end = .; . = ALIGN(4); __bss_start = .; .bss : { *(.bss) } _end = .; }

