The embedded linux Development uboot transplant ( Two )——uboot Project source directory analysis

     Analyzed in this paper uboot by uboot_smdkv210, It's officially released by Samsung based on S5PV210 Evaluate the development board corresponding to uboot.

One 、uboot Source directory structure analysis

1、cpu

     The sub files in this folder are processor related , Each folder represents a CPU series . Each subdirectory contains cpu.c、interrupts.c、start.S file .

    cpu.c Mainly used to initialize CPU、 Set command Cache And data Cache etc.

    interrupt.c It is mainly used to set various interrupts and exceptions of the system

    start.S yes U-boot The first file executed at startup , Mainly do the earliest system initialization , Code redirection and setting up the system stack , To enter U-boot The second stage C Procedures lay the foundation .

    S5PV210 The folder corresponding to the chip is s5pc11x.

    cpu/s5pc11x/s5pc110/cpu_init.S It is mainly used for SDRAM Memory initialization settings .

 

2、board

The sub files under this document are related to the development board , Each sub file represents a chip manufacturer , Every sub folder stored in the folder of chip manufacturer is a kind of development board , For historical reasons ,board There are still a large number of development board folders in the directory that have not been filed in the folder of the chip manufacturer , Keep compatibility , As a result, the whole is in a mess . Such as samsung Of smdk2400、smdk2410 The development board is located in samsung Out of the folder .

    S5PV210 The folder corresponding to the chip is located in board/samsung/smdkc110, In the folder lowlevel_init.S Files are mainly used for clocks 、 A serial port 、MMU、Flash Bottom drive 、 Board level initialization ,u-boot.lds Files are linked script files , It's very important for the link phase in the later stage of project compilation , Determines the assembly of the program .

 

3、common

     This folder contains general code unrelated to processor architecture ,uboot Command parsing code for /common/command.c、 The upper level code for all commands cmd_*.c、uboot Environment variable processing code env_*.c、CRC Check, etc. are located in this directory .

 

4、drivers

     All peripheral chip drivers are stored in this directory , network card 、USB、 A serial port 、LCD、Nand Flash etc. .

 

5、disk

     This directory is stored in the partition processing code of disk drive

 

6、fs

     This directory stores the code related to the file system , Each subfolder represents a file system .

 

7、net

     This directory is stored in the network protocol related code

 

8、doc

     It is stored in this catalogue uboot Description document .

 

9、api、api_examples、examples

     External extension program API And examples

 

10、include

     The header file , Includes a variety of CPU Register definition of , file system 、 Network, etc.

         configs The files in the subdirectory are the configuration header files related to the target board

 

11、lib_xxx

    lib_arm、lib_avr32、lib_blackfin、lib_generic、lib_i386、lib_m68k、lib_microblaze、lib_mips、lib_nios、lib_nios2、lib_ppc、lib_sh、lib_sparc

Each folder represents a CPU Architecture . And S5PV210 The related folders are lib_arm、lib_generic,lib_generic The directory holds all the CPU Architecture, general encryption algorithm 、 Compression algorithm 、 Character processing related codes . In each case CPU In the architecture folder board.c, yes uboot Start the second stage of code entry function and related initialization function storage place .

 

12、libfdt

     This directory is the number of devices related to the code .

 

13、tools

     compile S-Record or uboot Image and other related tools , Like making bootm Boot kernel image file tool mkimage Source code .

 

14、post

     Power on self check related codes

 

15、nand_spl、onenand_bl1、onenand_ipl

    Nand、onenand Start the relevant code .

 

16、sd_fusing

This directory is stored in the burning related tool code

 

17、 Project compilation configuration file

          Makefile、MAKEALL、config.mk、rules.mk、mkconfig

     Control the main part of the project compilation process Makefile Files and rule files

    config.mk In file TEXT_BASE Specifies the address of the code in memory .

 

18、 edition 、 Copyright documents

        CHANGELOG、CHANGELOG-before-U-Boot-1.1.5、COPYING、CREDITS、MAINTAINERS、README、Changelog_Samsung.

 

Two 、uboot Project compilation configuration

    uboot Project compilation configuration is mainly based on Makefile And sub configuration file configuration information control uboot Compilation process .

1、 Compile command analysis

    uboot The compiler commands are make xxxx_config and make

    make xxxx_config Configure commands for development board information ,make For compiling commands .make xxx_config in xxx_config The value of is determined by the specific development board , The corresponding configuration information is located in uboot Under the top directory Makefile.    

     Generally speaking , Samsung S5PV210 The corresponding value of the development board is smdkv210single_config, According to the different development board , You can also choose smdkv210vogue_config、smdkv210single_rev02_config、         smdkv210onenand_config etc. .smdkv210single_config The configuration information of the development board is as follows :

smdkv210single_config :unconfig

    @$(MKCONFIG) $(@:_config=) arm s5pc11x smdkc110 samsung s5pc110

    @echo "TEXT_BASE = 0xc3e00000" > $(obj)board/samsung/smdkc110/config.mk

    @$(MKCONFIG) $(@:_config=) arm s5pc11x smdkc110 samsung s5pc110 The corresponding execution statement of the statement is mkconfig smdkv210single arm s5pc11x smdkc110 samsung s5pc110, According to the input arm s5pc11x smdkc110 samsung s5pc110 Parameters use the mkconfig Script generation include/config.mk Configuration file for .

    @echo "TEXT_BASE = 0xc3e00000" > $(obj)board/samsung/smdkc110/config.mk Statement is used to create board/samsung/smdkc110/config.mk file , write in TEXT_BASE = 0xc3e00000 Content .

2、mkconfig Script analysis

mkconfig Scripts are used to configure... For a development board uboot Create header files and link files .mkconfig The main parameters of the script are Target  Architecture  CPU  Board [VENDOR] [SOC].S5PV210 The development board execution script is :mkconfig smdkv210single arm s5pc11x smdkc110 samsung s5pc110

    mkconfig The main functions of the script are as follows :

A、 establish CPU Architecture related link files

By default ,make The command does not specify the output directory , At the top level of the catalog include Create link file under Directory /include/asm Point to /include/asm_arm Catalog

B、 Create link files related to the development board

At the top level of the catalog include Create link file under Directory /include/regs.h Point to the development board include Directory development board header file /include/s5pv110.h

At the top level of the catalog include Under the asm-arm Create link file under Directory arch, Point to include In the catalog arch-s5pc11x Catalog .

C、 Generate include/config.mk file

     According to the selected development board , The configuration information of the development board smdkv210single arm s5pc11x smdkc110 samsung s5pc110 As mkconfig Input parameters , And write these parameters as the values of the variables to the created include/config.mk In file ,config.mk The contents of the document are listed below :

ARCH   = arm

CPU    = s5pc11x

BOARD  = smdkc110

VENDOR = samsung

SOC    = s5pc110

D、 Create the header file of the development board configuration

     At the top level of the catalog include Create under directory config.h file , Write file contents :

/* Automatically generated - do not edit */

#include <configs/smdkv210single_config.h>

3、 Development board configuration header file analysis

     The development board configuration header file is include/configs/smdkv210single_config.h

    smdkv210single_config.h The header file mainly defines two kinds of variables with macro , One is options , use CONFIG_ Make prefixes , Used to select the processor 、 Device interface 、 command 、 Properties, etc . Such as :

#define CONFIG_S5PC1101

#define CONFIG_S5PC11X1

     One is parameters , use CFG_ Make prefixes , Used to define the bus frequency 、 Serial port baud rate 、Flash Address and other parameters . Such as : The main configuration information in the file is : Memory base address 、 Machine code 、 Starting mode 、 A serial port 、I2C、 Internet Information 、 The system clock 、 Memory parameters, etc .

4、Makefile File analysis

Makefile The main function is to control uboot Compilation process ,Makefile The configuration information in includes the configuration of version information , call mkconfig Script generation configuration information , Cross compile toolchain settings ( Generally, you need to set CROSS_COMPILE = arm-linux-)、 Configure the header file according to the development board information include/configs/smdkv210single.h call config.mk Script generation /include/autoconf.mk Control the compilation process . The codes of the main functions are as follows :

uboot Version setting options :

VERSION = 1

PATCHLEVEL = 3

SUBLEVEL = 4

EXTRAVERSION =

U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)

VERSION_FILE = $(obj)include/version_autogenerated.h// Generate automatic files based on configuration options

Cross compiler tool settings :

ifeq ($(ARCH),arm)

# modify CROSS_COMPILE = arm-linux-

CROSS_COMPILE = arm-linux-

#CROSS_COMPILE = /usr/local/arm/4.4.1-eabi-cortex-a8/usr/bin/arm-linux-

#CROSS_COMPILE = /usr/local/arm/4.2.2-eabi/usr/bin/arm-linux-

#CROSS_COMPILE = /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-

endif

     Cross compile toolchain configuration 、 After the development board is configured, it can be compiled

 

This article mainly refers to Samsung smdkv210 The official development board uboot Source code .