10 uboot的配置及編譯過程分析
阿新 • • 發佈:2018-11-26
uboot的配置及編譯過程分析
uboot的配置過程(make config_uboot):
1.orangepi_sdk目錄下的Makefile:
26 PHONY += config_uboot
27 config_uboot :
28 @echo "+++++config uboot+++++"
29 @$(PWD)/script/config_uboot_source.sh
2.orangepi_sdk目錄下的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原始碼目錄
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.orangepi_sdk目錄下的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.orangepi_sdk目錄下的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.orangepi_sdk目錄下的Makefile:
63 PHONY += install_uboot
64 install_uboot :
65 @echo "Script run sudo , Please authorize :"
66 @sudo $(PWD)/script/install_uboot.sh $(sdcard)
2.orangepi_sdk目錄下的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分割槽
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個扇區開始燒寫進去