码迷,mamicode.com
首页 > 其他好文 > 详细

I.MX6 U-Boot mkconfig hacking

时间:2015-12-19 11:04:35      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

/****************************************************************************
 *                     I.MX6 U-Boot mkconfig hacking
 * 声明:
 *     本文主要是为了知道U-Boot中的mkconfig是如何工作的,是如何将配置
 * 中的内容进行汇总,同时又将这些内容放在了什么地方。
 *
 *                                       2015-12-19 深圳 南山区平山村 曾剑锋
 ***************************************************************************/

                    \\\\\\\\\-*- 目录 -*-//////////
                    |  一、参考文档:
                    |  二、Makefile
                    |  三、mkconfig
                    |  四、include/config.h
                    |  五、include/config.mk
                    ------------------------------

一、参考文档:
    1. $(@:_config=)什么意思?
        http://blog.csdn.net/zbffff/article/details/18991145
    2. U-BOOT Makefile注释
        http://wenku.baidu.com/view/ff14f319227916888486d7cb.html
    3. makefile中的@
        http://www.cnblogs.com/lihaiping/archive/2013/03/20/makefile.html
    4. Makefile中常用的函数
        http://linux.chinaunix.net/techdoc/develop/2009/07/09/1122854.shtml
    5. U-Boot移植(二)——U-Boot编译过程分析(2)
        http://blog.csdn.net/wafx1314/article/details/11260041
    6. 请教linux make make clean make all 的具体用法
        http://zhidao.baidu.com/question/129692720.html

二、Makefile
    ......
    SRCTREE    := $(CURDIR)    
    ......    
    MKCONFIG   := $(SRCTREE)/mkconfig    
    export MKCONFIG
    ......
    mx6solo_sabresd_config                mx6solo_sabresd_mfg_config            mx6solo_sabresd_android_config            mx6dl_sabresd_config                mx6dl_sabresd_mfg_config            mx6dl_sabresd_android_config                mx6q_sabresd_config                mx6q_sabresd_android_config                 mx6q_sabresd_mfg_config                mx6q_sabresd_iram_config    : unconfig
        @[ -z "$(findstring iram_,$@)" ] ||             { echo "TEXT_BASE = 0x00907000" >$(obj)board/freescale/mx6q_sabresd/config.tmp ;               echo "... with iram configuration" ;             }
        @$(MKCONFIG) $(@:_config=) arm arm_cortexa8 mx6q_sabresd freescale mx6
    ......

三、mkconfig
    #!/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>
    #
    
    APPEND=no    # Default: Create new config file
    # 开发板的名字
    BOARD_NAME=""    # Name to print in make output
    
    # 使用while循环和case进行命令行参数提取,很不错的处理方式
    while [ $# -gt 0 ] ; do
        case "$1" in
        --) shift ; break ;;
        -a) shift ; APPEND=yes ;;
        -n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;   # %%去除$1字符串中的_config
        *)  break ;;
        esac
    done
    
    # 如果上面的命令行参数都没有,那么$1就是开发板的名字
    [ "${BOARD_NAME}" ] || BOARD_NAME="$1"
    
    # 参数个数小于4个或者大于6个,直接退出,比较奇怪的是,为什么不放在前面进行判断呢
    [ $# -lt 4 ] && exit 1
    [ $# -gt 6 ] && exit 1
    
    # 显示提示信息
    echo "Configuring for ${BOARD_NAME} board..."
    
    #
    # Create link to architecture specific headers
    #
    # 如果编译出来的目录和源代码目录不一样,那么执行以下内容
    if [ "$SRCTREE" != "$OBJTREE" ] ; then
        mkdir -p ${OBJTREE}/include         # 创建include目录
        mkdir -p ${OBJTREE}/include2        # 创建include2目录
        cd ${OBJTREE}/include2              # 进入include2目录
        rm -f asm                           # 防止asm已经存在
        ln -s ${SRCTREE}/include/asm-$2 asm # 重新软链接到固定的位置$2(arm)平台
        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        # $2=arm
    fi
    
    # 删除include/asm-arm/arch这个软链接
    rm -f asm-$2/arch
    
    # $6等于mx6
    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
    
    #
    # Create include file for Make
    #
    echo "ARCH   = $2" >  config.mk     # $2=arm
    echo "CPU    = $3" >> config.mk     # $3=arm_cortexa8
    echo "BOARD  = $4" >> config.mk     # $4=mx6q_sabresd
    
    # $5=freescale
    [ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk
    
    # $6=mx6
    [ "$6" ] && [ "$6" != "NULL" ] && echo "SOC    = $6" >> config.mk
    
    #
    # Create board specific header file
    # APPEND=no
    if [ "$APPEND" = "yes" ]    # Append to existing config file
    then
        echo >> config.h
    else
        > config.h        # Create new config file
    fi
    # 原来我们可以在在这个文件里查看config文件
    echo "/* Automatically generated - do not edit */" >>config.h
    # $1=mx6dl_sabresd_android
    echo "#include <configs/$1.h>" >>config.h
    echo "#include <asm/config.h>" >>config.h
    
    exit 0

四、include/config.h
    /* Automatically generated - do not edit */
    #include <configs/mx6dl_sabresd_android.h>
    #include <asm/config.h>

五、include/config.mk
    ARCH   = arm
    CPU    = arm_cortexa8
    BOARD  = mx6q_sabresd
    VENDOR = freescale
    SOC    = mx6

六、总结:
    从上面的情况可知,如果要在board目录下新建一个开发板<board_name>目录,则在include/configs目录下也要建立一个对应的<board_name>文件,里面存放的就是开发板<board_name>的配置信息。这里目前没有验证。

 

I.MX6 U-Boot mkconfig hacking

标签:

原文地址:http://www.cnblogs.com/zengjfgit/p/5058754.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!