Linux
Many boot loaders are available, including U-boot, Vivi, and Redboot. This course introduces U-boot version-level porting and the corresponding hardware platform is s3c2440.
Embedded
In the system, after the system is powered on or reset, the CPU usually reads the first command from the address 0x00000000 and runs the command, and the boot loader is placed with this, which is similar to the BIOS of a PC. His work is very important: initializing hardware devices, creating a memory space image, and bringing the hardware environment to a proper state.
Generally, we can divide the U-boot startup process into two phases: phase 1 and phase 2. The first stage is generally compiled in assembly, and the second stage is generally written in C, as follows:
Phase 1:
Initialize basic hardware devices (interrupt and disable processor commands and data cache)
Initialize system memory
Set Stack
Jump to the second stage of the C language program entry point.
Phase 2:
Initialize the hardware used in this phase (serial port, Ethernet port, etc)
Detect System memory ing
Read the kernel image and root file system from flash to memory.
Set startup parameters for the kernel.
Call the kernel to give control of the system to the kernel.
Next we will analyze the source code of U-boot. Ftp://ftp.denx.de/pub/u-boot/
Download U-boot 1.2.0
Compressed u-boot-1.2.0.tar.bz2
Use SSH to upload to the user's/home/21iee directory
Decompress:
Tar-jxvf u-boot-1.2.0.tar.bz2
Through SSH, we can see the U-boot source code structure,
U-boot.jpg
(62.46 KB)
The source code of U-boot is highly modular. The main directories we care about are:
-
Board: U-boot
The source code of the supported development board-related programs. Board/smdk
The 2410 directory contains the source file of Samsung's official smdk2410 Development Board.
-
Common:
Documents unrelated to the system.
-
CPU:
Contains the CPU source code supported by U-boot. S3c2440a belongs to the ARM920T family, so you only need to care about the CPU/ARM920T directory, where the start. s file will eventually become the first code of the u-boot.bin file.
-
Drivers:
General device drivers, such as serial ports, network ports, and USB
-
DOC:
Description.
-
FS:
The file system supported by U-boot.
-
Include:
Contains the header file directory. Include/configs/board_name.h defines the hardware resource configuration parameters related to the Development Board, such as the NIC address, kernel startup parameters, and physical memory ing.
-
Lib_arm:
Some common interface code related to the ARM architecture.
-
Net:
Network-related code.
-
Tools:
Compile related tools.
Compile
(I used a gcc3.3.2 environment where 3.4.1 has an error. You can modify the bashrc file according to the content of Lesson 2)
Make 2410.jpg
(7.35 KB)
Command: Make smdk2410_config
// Smdk2410_config is the target platform.
Then use make all
Command compilation. If the prompt is displayed in a few minutes
Uboot_2410_ OK .jpg
(8.6 KB)
This indicates that U-boot has been created.
Bytes -----------------------------------------------------------------------------------------------------------------------
U-boot is transplanted to the new s3c2440a platform. First, add a new Development Board directory under the board directory.
1. Create a Development Board directory named hztour2440a.
.
On the u-boot-1.2.0/board/
Create directory hztour2440a
The directory requires several basic files: config. mk, Flash. C, makefile, mensetup. S, u-boot.lds
And hztour2440a. C.
File.
CD board/
CP-ARV smdk2410 hztour2440a
// Our 2440 and 2410 are similar, so we have complicated all the files under smdk2410.
MV hztour2440a/smdk2410.c hztour2440a/hztour2440a. c
// Rename it hztour2440a. C.
|
2.
In include/configs/
Directory.
CD include/configs
CP smdk2410.h hztour2440a. h // copy the smdk2410.h header file
|
3. Modify the MAKEFILE file and add the compilation items.
|
Hztour2440a_config: unconfig
@ $ (Mkconfig) $ (@: _ Config =) arm ARM920T hztour2440a null s3c24x0 |
Here, hztour2440a is the same as the name of the target board folder in the Board/directory.
4. Check the compiling environment (optional)
This makefile
Defines the value of cross_compile, used to specify the cross compiler during cross-compilation. The default value is
Ifeq ($ (ARCH), arm)
Cross_compile = arm-Linux-// default
Prefix of the Cross-compiler name. If you use the compiler produced by crosstool, the prefix is
Arm-9tdmi-linux-gnu-
Endif // You can also directly write the path
|
5. Modify the Board/hztour2440a
Makefile
Cobjs: = hztour2440a. o
Flash. o |
6. Test Compilation
Make hztour2440a_config
// The following message is displayed: Listing ing for hztour2440a board... indicating that the configuration is successful.
Make // test compilation
|
Till now, the compiled U-boot is not
The target board can be truly applied to us, but the definition of the new target board is realized. Next we will also transplant it according to the characteristics of the new target board, follow the boot loader porting (u-boot) Section 2.
Author: Please indicate the source for hztour Reprinting