09 uboot的配置编译主过程分析

在orangepi_sdk目录下:

//////////////////////////////////////
uboot的配置过程
make config_uboot  //配置uboot

1). //当前目录的Makefile
    26 PHONY += config_uboot
    27 config_uboot :
    28     @echo "+++++config uboot+++++" 
    29     @$(PWD)/script/config_uboot_source.sh 

2). //当前目录下的script/config_uboot_source.sh
  2 source $PWD/script/orangepi.conf   //让orangepi.conf里的环境变量生效。如交叉编译器,uboot, kernel目录路径
  3 source $PWD/script/common.sh  //提供功能函数

  11 message "entry u-boot source dir " && cd ${OPI_U_source} //进入uboot源码目录
  12 
  13 if [ ! -f .config ] //判断uboot源码根目录下是否存在".config", ".config"用于指定uboot的编译配置 
  14 then  //如没有.config文件
  15     message "clear   u-boot " && make distclean //清作编译生成的文件及配置文件
  16     message "config  u-boot " && make ${OPI_U_config} // make orangepi_linux_defconfig 
  17 fi

  20 message "config u-boot" && make menuconfig   //弹出一个配置界面

////////////////
 总结下uboot的配置过程:
    1). script/orangepi.conf里的环境变量生效, 及进入uboot源码目录
        2). make distclean
    3). make orangepi_linux_defconfig
    4). make menuconfig

uboot编译是通过命令:

make uboot
1). 当前目录下的Makefile
 42 PHONY += uboot
 43 PHONY += bootloader
 44 uboot bootloader :
 45     @echo "+++++build u-boot+++++" | tee  $(OPI_OUTPUT_DIR)/build_uboot.log
 46     @$(PWD)/script/make_uboot.sh 2>&1 | tee -a $(OPI_OUTPUT_DIR)/build_uboot.log

2). script/make_uboot.sh里的主要内容:
 2 source $OPI_WORK_DIR/script/common.sh

 10 message "entry u-boot source dir " && cd $OPI_U_source

 20 message "build u-boot , Please wait some time." && make -j8

 22 if [ -f u-boot-sunxi-with-spl.bin  ]; then
 23     # Copy u-boot-sunxi-with-spl.bin to output
 24     cp u-boot-sunxi-with-spl.bin  $OPI_UBOOT_OUTPUT_DIR
 25     cp arch/arm/dts/*sun8i-h3*  $OPI_DTB_OUTPUT_DIR
 26 fi

 // boot.scr文件的生成, boot.scr是uboot的环境变量存放文件         
 30 message "build u-boot boot.scr" && rm $OPI_UBOOT_OUTPUT_DIR/boot.scr
 31 mkimage -C none -A arm -T script -d $OPI_source/u-boot-script/orangepi.cmd $OPI_UBOOT_O    UTPUT_DIR/boot.scr

 //由orangepi.fex生成script.bin, 文件里用于描述硬件相关的资源
 34 message "build sunxi script.bin" && rm $OPI_UBOOT_OUTPUT_DIR/script.bin
 35 fex2bin $OPI_source/sunxi-script/orangepi.fex  $OPI_UBOOT_OUTPUT_DIR/script.bin

 总结下编译主要过程:
  1).进入uboot源码目录
  2). make -j8
  3). 生成boot.src环境变量文件 
  4). 生成script.bin文件
////////////////////////////////////////////////////
最后我们是用"make install_uboot sdcard=/dev/sdb"烧写到sd卡里

1). 当前目录里的Makefile:
 63 PHONY += install_uboot
 64 install_uboot :
 65     @echo "Script run sudo , Please authorize :"
 66     @sudo $(PWD)/script/install_uboot.sh $(sdcard)


2). script/install_uboot.sh的主要内容:
  2 source $PWD/script/orangepi.conf
  3 source $PWD/script/common.sh
  4 sdcard=$1                       // sdcard=/dev/sdb

 18 echo "mount -t vfat $sdcard"1" $OPI_SDCARD_BOOT"
 19 mount -t vfat $sdcard"1" $OPI_SDCARD_BOOT  //挂载/dev/sdb1到目录里, sdb1是fat分区
 20 
 21 cd ${OPI_UBOOT_OUTPUT_DIR}
 23 cp boot.scr ${OPI_SDCARD_BOOT}/      //复制到挂载目录里,也就是存放到sd卡的fat分区
 25 cp script.bin ${OPI_SDCARD_BOOT}/    //复制script.bin到sd卡的fat分区

 27 cp u-boot-sunxi-with-spl.bin ${OPI_SDCARD_BOOT}/  //也复制uboot.bin到分区里

 29 dd if=/dev/zero of=$sdcard bs=1k seek=8 count=1015 //从sd卡的第8个扇区(每个扇区512字节)开始,清零1015K字节空间
 30 dd if=u-boot-sunxi-with-spl.bin of=$sdcard bs=1k seek=8  //把uboot.bin从sd卡的第8个扇区开始烧写进去
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值