u-boot-2016.05移植:(1)、建立新板并配置,使能正常编译通过

移植u-boot-2016.05到JZ2440开发板(在smdk2410基础上修改):
1、在include/configs中复制smdk2410.h拷贝为smdk2440.h。
2、在board/samsung中复制smdk2410文件夹拷贝为smdk2440,进入smdk2440文件夹,将smdk2410.c重命名为smdk2440.c,并将该文件夹下的Makefile文件中smdk2410.o改为smdk2440.o。
3、修改顶层Makefile文件,添加:

ARCH=arm
CROSS_COMPILE ?= arm-linux-

4、在configs文件夹下复制smdk2410_defconfig拷贝为smdk2440_defconfig,并将其中的2410替换为2440。
5、在arch/arm/Kconfig中添加:

config TARGET_SMDK2440
        bool "Support smdk2440"
        select CPU_ARM920T
source "board/samsung/smdk2440/Kconfig"

4、经过上面的修改,运行配置命令make smdk2440_defconfig,然后尝试make,出现下面的错误:

include/config.h:5:22: error: configs/.h: No such file or directory

错误显示:在include/config.h中出现的configs/.h并不能找到,对比编译2410生成的config.h文件,可见是config.h文件生成错误。要解决问题首先我们要找到生成config.h文件的地方,在顶层Makefile文件中找了很久都没找到生成config.h文件的地方,然后就有点无从下手了,偶然想到既然config.h是生成的文件,那么其中的注释/* Automatically generated - do not edit */应该是通过echo命令输出到config.h文件的,搜索 Automatically generated - do not edit 就应该可以找到生成config.h的地方。
搜索Automatically generated - do not edit,找到scripts/Makefile.autoconf文件,发现config.h正是在它里面生成的:

...

# include/config.h
# Prior to Kconfig, it was generated by mkconfig. Now it is created here.
define filechk_config_h
        (echo "/* Automatically generated - do not edit */";            \
        for i in $$(echo $(CONFIG_SYS_EXTRA_OPTIONS) | sed 's/,/ /g'); do \
                echo \#define CONFIG_$$i                                \
                | sed '/=/ {s/=/        /;q; } ; { s/$$/        1/; }'; \
        done;                                                           \
        echo \#define CONFIG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\
        echo \#include \;                           \
        echo \#include \;                          \
        echo \#include \;         \
        echo \#include \;                                \
        echo \#include \;)
endef

...

由此可见,之所以在config.h中出现configs/.h,是因为CONFIG_SYS_CONFIG_NAME为空的原因。
参阅doc/README.kconfig文件中建新板步骤:

Tips to add/remove boards
-------------------------

When adding a new board, the following steps are generally needed:

 [1] Add a header file include/configs/.h
 [2] Make sure to define necessary CONFIG_SYS_* in Kconfig:
       Define CONFIG_SYS_CPU="cpu" to compile arch//cpu/
       Define CONFIG_SYS_SOC="soc" to compile arch//cpu//
       Define CONFIG_SYS_VENDOR="vendor" to compile board//common/*
         and board///*
       Define CONFIG_SYS_BOARD="board" to compile board//*
         (or board///* if CONFIG_SYS_VENDOR is defined)
       Define CONFIG_SYS_CONFIG_NAME="target" to include
         include/configs/.h
 [3] Add a new entry to the board select menu in Kconfig.
     The board select menu is located in arch//Kconfig or
     arch//*/Kconfig.
 [4] Add a MAINTAINERS file
     It is generally placed at board//MAINTAINERS or
     board///MAINTAINERS
 [5] Add configs/_defconfig

When removing an obsolete board, the following steps are generally needed:

 [1] Remove configs/_defconfig
 [2] Remove include/configs/.h if it is not used by any other boards
 [3] Remove board///* or board//* if it is not used
     by any other boards
 [4] Update MAINTAINERS if necessary
 [5] Remove the unused entry from the board select menu in Kconfig
 [6] Add an entry to doc/README.scrapyard

可见,要正确生成include/config.h文件,需要配置board/samsung/smdk2440/Kconfig文件,将其中的2410改为2440。

你可能感兴趣的:(3,u-boot)