当前位置:网站首页>Detailed explanation of uboot image generation process of Hisilicon chip (hi3516dv300)
Detailed explanation of uboot image generation process of Hisilicon chip (hi3516dv300)
2022-07-07 07:39:00 【Snail taking off】
1、 Preface
(1) This paper introduces uboot The compilation process is based on the SDK In the bag uboot Source code to compile , The specific compilation parameters are based on hi3516dv300 Chip , Compile generated uboot Burning image is also used for hi3516dv300 Chip uboot Mirror image ;
(2) about Makefile If there is no special emphasis, it means uboot Top level of source code Makefile;
2、uboot Compilation process
2.1、 Configure the compilation environment
Compile command :make ARCH=arm CROSS_COMPILE=arm-himix200v002-linux- hi3516dv300_emmc_defconfig V=1
Instructions | meaning |
---|---|
ARCH=arm | Appoint CPU The architecture is arm |
CROSS_COMPILE=arm-himix200v002-linux- | Specify that the cross compilation tool chain is arm-himix200v002-linux- |
hi3516dv300_emmc_defconfig | This is the goal of compilation , On the top floor Makefile In the corresponding "%config" The goal is , What it does is it takes "./configs/hi3516dv300_emmc_defconfig" Copy to the top-level directory as ".config" The configuration file |
V=1 | It means that you will Makefile The command executed in is printed out without hiding , This is the function of debugging , If it is the learning stage, it is best to add this function |
2.2、 compile u-boot.bin
(1) Compile command :make ARCH=arm CROSS_COMPILE=arm-himix200-linux- -j 20
(2)-j 20: Specify the use of 20 Multiple threads compile at the same time , The premise is your computer CPU Yes 20 Core , If you don't know your computer CPU How many cores can it be without ;
2.3、 compile gzip Tools
(1) Provided by Hisilicon SDK There will be hi_gzip Catalog , Inside is generation gzip The source code and compilation script of the tool ,gzip It's a compression tool , And segmented uboot Image generation , Will generate a good gzip copy to uboot Under the corresponding directory of the source code ;
(2) Compile instructions :cd hi_gzip;make;cp ./bin/gzip uboot/arch/arm/cpu/armv7/hi3516dv300/hw_compressed/ -rf
Add :gzip Is in PC On board ,Makefile The compiler tool specified in is gcc, So we're compiling gzip Specify cross compilation tool chain differently ;
2.4、 Compile register configuration table file
(1) Provided by Hisilicon SDK in uboot_tools/ Open the corresponding board's Excel file , stay main Click in the tab "Generate reg bin file" Button , Generate reg_info.bin It is the table file of the corresponding platform ;
(2) Copy generated reg_info.bin To boot Top level directory of source code , Rename it to .reg;
2.5、 Generate segmented image :u-boot-z.bin
(1) Compile instructions :make ARCH=arm CROSS_COMPILE=arm-himix200-linux- u-boot-z.bin
(2) Finally, a burnable uboot Mirror image :u-boot-hi3516dv300.bin;
3、uboot Register configuration table file
3.1、 Function is introduced
(1) stay SDK There is... In the bag uboot_tools Catalog , It stores the chip register configuration xlsm Format of table file , such as hi3516dv300 The name of the table file corresponding to the chip is "Hi3516DV300-DMEB_4L_FLYBY-DDR3_1800M_512MB_16bitx2-A7_900M-SYSBUS_300M.xlsm";
(2) At the bottom is the module name , Registers are stored in modules , For example, currently in ddrc modular , The registers in the table are and configuration ddrc Function related registers ;
(3)Base Addrss: This is the base address of the module register ; When the chip allocates the register address , The addresses of related registers are continuous ;
(4)Register: This column is the name of the register , Corresponding to the data manual ;
(5)Offset Address: The offset of the register address from the base address , Access to registers is in accordance with " Base address + Offset " The way ;
(6)Value: future uboot The value here will be written into the corresponding register in the startup phase ;
3.2、 Usage method
(1) stay “main” Interface Click "Generate reg bin file" Button , Generate... In the current directory reg_info.bin It is the table file of the corresponding platform ;
(2) take reg_info.bin File copy to uboot Top level directory of source code , And rename to ".reg" file ;
(3)“.reg" Files will be used to generate u-boot-hi3516dv300.bin Image file ,uboot In the startup phase, I will read ”.reg" File to set the register ;
4、 Segmented uboot The generation process of image
4.1、 Whole uboot Composition of burning image
(1) Hisilicon built-in code starts , Will read uboot The previous part of the image goes into the film RAM address space ;
(2) Execute first .o file , This code will read .reg To set the register , Finally, initialize DDR, take uboot The image is relocated to DDR in ;
(3) decompression DDR Medium uboot Mirror image , Then execute the decompressed uboot Mirror code ;
4.2、 Lord Makefile
······
.PHONY: u-boot-z.bin
u-boot-z.bin: $(CURDIR)/u-boot.bin
make -C $(CURDIR)/arch/$(ARCH)/cpu/$(CPU)/$(SOC)/$(HW_DIR)/ \
CROSS_COMPILE=$(CROSS_COMPILE) \
BINIMAGE=$(CURDIR)/u-boot.bin TOPDIR=$(CURDIR)
# The above instructions materialize the variables
#make -C uboot/arch/arm/cpu/armv7/hi3516dv300/hw_compressed/ CROSS_COMPILE=arm-himix200-linux- BINIMAGE=uboot/u-boot.bin TOPDIR=uboot/
······
(1) On the top floor Makefile Of u-boot-z.bin On target , There is no practical function , It depends on the top-level directory u-boot.bin file , And then jump to arch/arm/cpu/armv7/hi3516dv300/hw_compressed/hw_compressed Directory execution make Instructions ;
(2) Add :CURDIR yes Makefile Built in variables for , Indicates the absolute path of the current directory ;
4.3、u-boot-hi3516dv300.bin Generation process of
4.4、hw_compressed/Makefile File source code
################################################################################
# Create By Hisilicon
################################################################################
PWD = $(shell pwd)
HW_CROSS_COMPILE = $(CROSS_COMPILE)
TOPDIR =
################################################################################
CC := $(HW_CROSS_COMPILE)gcc
AR := $(HW_CROSS_COMPILE)ar
LD := $(HW_CROSS_COMPILE)ld
OBJCOPY := $(HW_CROSS_COMPILE)objcopy
################################################################################
BOOT := u-boot-$(SOC)
TEXTBASE := 0x80700000
CFLAGS :=-g -Os -fno-builtin -ffreestanding \
-D__KERNEL__ -DTEXT_BASE=$(TEXTBASE) \
-I$(TOPDIR)/include \
-I$(TOPDIR)/drivers/ddr/hisilicon/default \
-I$(TOPDIR)/drivers/ddr/hisilicon/$(SOC) \
-I$(TOPDIR)/arch/arm/include \
-I$(TOPDIR)/lib/hw_dec \
-fno-pic -ffunction-sections \
-fdata-sections -fno-common -ffixed-r9 \
-fno-common -pipe -march=armv7-a \
-Wall -Wstrict-prototypes -fno-stack-protector \
-D__LINUX_ARM_ARCH__=7 -D__ARM__ \
-DCONFIG_MMC\
$(MKFLAGS) -fno-strict-aliasing
################################################################################
START := start.o
COBJS := lowlevel_init_v300.o \
init_registers.o \
emmc_boot.o \
uart.o \
ddr_training_impl.o \
ddr_training_ctl.o \
ddr_training_boot.o \
ddr_training_custom.o \
ddr_training_console.o \
startup.o \
image_data.o \
div0.o \
reset.o
SSRC := arch/arm/cpu/armv7/$(SOC)/start.S \
arch/arm/cpu/armv7/$(SOC)/reset.S \
arch/arm/cpu/armv7/$(SOC)/emmc_boot.c \
arch/arm/cpu/armv7/$(SOC)/uart.S \
arch/arm/cpu/armv7/$(SOC)/init_registers.c \
arch/arm/cpu/armv7/$(SOC)/lowlevel_init_v300.c \
drivers/ddr/hisilicon/default/ddr_training_impl.c \
drivers/ddr/hisilicon/default/ddr_training_ctl.c \
drivers/ddr/hisilicon/default/ddr_training_boot.c \
drivers/ddr/hisilicon/default/ddr_training_console.c \
drivers/ddr/hisilicon/$(SOC)/ddr_training_custom.c \
arch/arm/lib/div0.c \
lib/hw_dec/hw_decompress.c \
lib/hw_dec/hw_decompress_$(SOC).c \
lib/hw_dec/hw_decompress_v1.c \
lib/hw_dec/hw_decompress_v1.h
REG := $(wildcard $(TOPDIR)/*.reg $(TOPDIR)/.reg)
SRC := $(notdir $(SSRC))
################################################################################
.PHONY: $(BOOT).bin
$(BOOT).bin: $(BOOT).tmp regfile
@dd if=./$(BOOT).tmp of=./tmp1 bs=1 count=64 2>/dev/null
@dd if=$(REG) of=./tmp2 bs=8192 conv=sync 2>/dev/null
@dd if=./$(BOOT).tmp of=./tmp3 bs=1 skip=8256 2>/dev/null
@cat tmp1 tmp2 tmp3 > $(BOOT).bin
@rm -f tmp1 tmp2 tmp3
@chmod 754 $(BOOT).bin
@cp -fv [email protected] $(TOPDIR)
@echo $(BOOT).bin is Ready.
$(BOOT).tmp: $(BOOT).elf
$(OBJCOPY) -O srec $< $(BOOT).srec
$(OBJCOPY) -j .text -O binary $< $(BOOT).text
$(OBJCOPY) --gap-fill=0xff -O binary $< [email protected]
$(BOOT).elf: image_data.gzip $(SRC) $(START) $(COBJS)
$(LD) -Bstatic -T u-boot.lds -Ttext $(TEXTBASE) $(START) \
$(COBJS) -Map $(BOOT).map -o [email protected]
$(OBJDUMP) -d [email protected] > [email protected].asm
.PHONY: regfile
regfile:
@if [ "$(words $(REG))" = "0" ]; then ( \
echo '***' Need '.reg' or '*.reg' file in directory $(TOPDIR); \
exit 1; \
) fi
@if [ "$(words $(REG))" != "1" ]; then ( \
echo '***' Found multi '.reg' or '*.reg' file in directory $(TOPDIR); \
echo '***' Files: $(notdir $(REG)); \
exit 1; \
) fi
################################################################################
start.o: start.S
$(CC) -D__ASSEMBLY__ $(CFLAGS) -o [email protected] $< -c
# -1 : --fast -9 : --best
image_data.gzip: $(BINIMAGE)
./gzip -fNqc -7 $< > [email protected]
%.o: %.c
$(CC) $(CFLAGS) -Wall -Wstrict-prototypes \
-fno-stack-protector -o [email protected] $< -c
%.o: %.S
$(CC) -D__ASSEMBLY__ $(CFLAGS) -o [email protected] $< -c
image_data.o: image_data.S image_data.gzip
$(CC) -D__ASSEMBLY__ $(CFLAGS) -o [email protected] $< -c
#############################################################################
$(SRC):
ln -sf ../../../../../../$(filter %/[email protected],$(SSRC)) [email protected]
################################################################################
TMPS := $(COBJS) start.o $(SRC) \
$(BOOT).map $(BOOT).elf $(BOOT).srec $(BOOT).bin $(BOOT).text $(BOOT).tmp \
image_data.gzip
distclean: clean
clean:
-rm -f $(TMPS)
################################################################################
.PHONY: clean
################################################################################
(1)image_data.gzip: from u-boot.bin By gzip The tool is compressed to form ;
(2)u-boot-hi3516dv300.elf: from image_data.gzip and .o file , In the current directory u-boot.lds Link script files are linked into executable files under the guidance , The link address is 0x80700000; It will also generate u-boot-hi3516dv300.map Address mapping files and u-boot-hi3516dv300.asm Disassembly file ;
(3)u-boot-hi3516dv300.tmp: use objcopy Tools will elf Format generates binary format ;
(4)u-boot-hi3516dv300.bin: from u-boot-hi3516dv300.tmp and .reg File generation , Specifically, why is it divided into tmp1、tmp2、tmp3 Then combined into the final burning image , It's not clear to our engineers who use chips , It should be built-in with Hisilicon chip IROM The code in , But we don't have to care ;
边栏推荐
- 今日现货白银操作建议
- 抽丝剥茧C语言(高阶)指针的进阶
- L'externalisation a duré trois ans.
- The currently released SKU (sales specification) information contains words that are suspected to have nothing to do with baby
- resource 创建包方式
- Several important steps to light up the display
- Blue Bridge Cup Birthday candles (violence)
- Rxjs - observable doesn't complete when an error occurs - rxjs - observable doesn't complete when an error occurs
- Initial experience of teambiion network disk (Alibaba cloud network disk)
- Kuboard can't send email and nail alarm problem is solved
猜你喜欢
随机推荐
MIPS uclibc cross compile ffmpeg, support g711a encoding and decoding
Cloud backup project
Simple example of ros2 planning system plansys2
Several important steps to light up the display
抽絲剝繭C語言(高階)指針的進階
MySQL service is missing from computer service
Blue Bridge Cup Netizen age (violence)
【云原生】内存数据库如何发挥内存优势
Jenkins远程构建项目超时的问题
Six methods of flattening arrays with JS
《动手学深度学习》(四) -- 卷积神经网络 CNN
Wechat applet full stack development practice Chapter 3 Introduction and use of APIs commonly used in wechat applet development -- 3.9 introduction to network interface (IX) extending the request3 met
直播平台源码,可折叠式菜单栏
BGP experiment (1)
95后CV工程师晒出工资单,狠补了这个,真香...
聊聊异步编程的 7 种实现方式
1142_ SiCp learning notes_ Functions and processes created by functions_ Linear recursion and iteration
gatk4中的interval是什么??
按键精灵采集学习-矿药采集及跑图
[semantic segmentation] - multi-scale attention