当前位置:网站首页>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 ;
边栏推荐
- Differences between H5 architecture and native architecture
- Flexible layout (I)
- Hidden Markov model (HMM) learning notes
- 我理想的软件测试人员发展状态
- BGP experiment (1)
- ../ And/
- My ideal software tester development status
- 在线直播系统源码,使用ValueAnimator实现view放大缩小动画效果
- Why is the row of SQL_ The ranking returned by number is 1
- idea添加类注释模板和方法模板
猜你喜欢
[2022 ACTF]web题目复现
Le Service MySQL manque dans le service informatique
抽丝剥茧C语言(高阶)指针的进阶
@component(““)
Deep learning Flower Book + machine learning watermelon book electronic version I found
为什么要了解现货黄金走势?
ASEMI整流桥RS210参数,RS210规格,RS210封装
抽丝剥茧C语言(高阶)指针进阶练习
Music | cat and mouse -- classic not only plot
The annual salary of general test is 15W, and the annual salary of test and development is 30w+. What is the difference between the two?
随机推荐
外包干了三年,废了...
@component(““)
Robot technology innovation and practice old version outline
C language (high-level) data storage + Practice
考研失败,卷不进大厂,感觉没戏了
How do I get the last part of a string- How to get the last part of a string?
1、 Go knowledge check and remedy + practical course notes youth training camp notes
Several important steps to light up the display
Calculus key and difficult points record part integral + trigonometric function integral
MIPS uclibc cross compile ffmpeg, support g711a encoding and decoding
What is the difference between TCP and UDP?
四、高性能 Go 语言发行版优化与落地实践 青训营笔记
About binary cannot express decimals accurately
抽絲剝繭C語言(高階)指針的進階
Advanced practice of C language (high level) pointer
Flexible layout (I)
知识点滴 - 关于苹果认证MFI
按键精灵脚本学习-关于天猫抢红包
Outlier detection technology of time series data
[semantic segmentation] - multi-scale attention