“ARM embedded processors have been widely used in consumer electronics, wireless communications, network communications, industrial control and other fields. Among them, ARM9 chips occupy an important market in handheld devices because of their low price, low power consumption, and high performance. Among the embedded operating systems, Linux, Vxworks, and WinCE stand together, among which Linux is even more independent due to its open source, stability, security, and scalability. In the embedded system, how to realize the boot work of the Linux operating system under the ARM9 platform is an important link in the development of embedded technology.
ARM embedded processors have been widely used in consumer electronics, wireless communications, network communications, industrial control and other fields. Among them, ARM9 chips occupy an important market in handheld devices because of their low price, low power consumption, and high performance. Among the embedded operating systems, Linux, Vxworks, and WinCE stand together, among which Linux is even more independent due to its open source, stability, security, and scalability. In the embedded system, how to realize the boot work of the Linux operating system under the ARM9 platform is an important link in the development of embedded technology.
1 The software composition of the embedded system
1.1 The software composition of the system
The embedded software system is mainly composed of Bootloader, operating system, file system, application program and so on. Among them, Bootloader is a layer between the hardware and the operating system, and its function is like the BIOS in the PC. After the system is powered up and running, it is automatically loaded by the system. Through this program, hardware devices can be initialized and a map of the memory space can be established to bring the hardware environment of the system to an appropriate state so as to prepare the environment for the final call of the operating system kernel. For an embedded system, BootLoader is usually implemented depending on the hardware. For different types of embedded chips, different operating systems and peripheral interfaces, it is necessary to re-port, modify and compile the Bootloader.
1.2 U-Boot analysis
Bootloader boot programs commonly used in embedded Linux systems include U-Boot, redboot, blob and vivi, etc. Among them, U-Boot is an open source project that follows GPL terms and has the most powerful functions; U-Boot supports the most abundant PowerPC series processors. At the same time, it also supports MIPS, x86, ARM, Nios, XScale and many other common series of processors; U-Boot boot program is divided into two parts, Stage 1 and Stage 2. Stage 1 mainly includes device initialization, interrupt settings, clock settings and Memory initialization and other tasks are implemented in assembly language, while some common functions are mostly implemented in C language and placed in Stage 2.
2 U-Boot startup analysis
The code of Stage 1 is in CPU/arm920t/start. Defined in s, it includes the part that starts to execute at address 0x00000000 after the system is powered on. After the system is started, this part of the code is automatically loaded from NAND FLASH to SDRAM. It includes the initialization of registers in S3C2410A and the copy of U-Boot Stage 2 code from FLASH to SDRAM. The starting address of Stage 2 is specified in the Stage1 code. After being copied to SDRAM, jump to this entry address from the first stage, and start executing the remaining part of the code. The second stage is mainly the allocation of memory, the initialization of NAND FLASH and the peripheral equipment, the code is in lib-arm/board. C. The start-up process analysis is shown in Figure 1.
(1) After jumping to the C language program, first define the initialization function table, the program is in lib-arm/board. In e, it is as follows:
(2) Initialize FLASH device and Display FLASH device information;
(3) Initialize the system memory allocation function;
(4) If the target system has a NAND device, initialize the NAND device;
(5) Initialize the Display device;
(6) Initialize the network equipment, fill in the IP address, MAC address and other information;
(7) Turn on interrupt processing;
(8) Enter the command loop and receive the user’s command input from the serial port.
3 U-Boot transplantation method
This article chooses the cross-compilation environment arm-linux-gcc-2. 95.3, chooses U-Boot-1.1.4 version as the transplant platform. In order to make U-Boot support the new development board, a simple way is to choose a development board close to the target board among the development boards already supported by U-Boot, and modify it on the basis of it. Here is the configuration of smdk2410.
3.1 Modify cpu/arm920t/start. S file
Start. s is the U-Boot program entry code written in assembly language to complete the initialization of the underlying hardware. One of the important functions is to copy the stage 2 code from the NAND FLASH to the SDRAM. At this stage, the read operation of NANDFLASH is involved. In U-Boot, there is no drive for the read operation of NANDFLASH. The following methods are used to achieve:
By calling board/smdk2410/nand_read. The nand_read_11 function in C copies the code of Stage 2 to ram.
3.2 Modify the files in the board/smdk2410 directory
(1) Increase the read drive nand_read for NANDFLASH. c
(2) In smdk2410. Add a program to initialize NANDFLASH in the C file
This is mainly to set some GPIO of the motherboard, and add the initialization program for NANDFLASH.
(3) Add nand_read in the Makefile under this directory. C file compilation
OBJS: = smdk24 10. o FLASH. o nand_read. o
3.3 Set the NAND FLASH hardware parameters in the include file
In /linux/mtd/nand_ids. Set parameters in h:
3.4 Compile and run
After configuration, enter the U-Boot main directory, recompile the U-Boot code, and run the command:
(1) View the version number of the cross compiler
(2) Clear the generated connection
(3) Compile make smdk2410_config
(4) After make CROSS-COMPILE=arm-linux- is compiled successfully, three files will be generated:
u-boot: A file in ELF format that can be recognized by most Debug programs.
u-boot. bin: Binary bin file, purely fragmented U-Boot binary execution code, without saving ELF format and debugging information. This file is used to burn into the user’s development board.
u-boot. srec: Motorola S-Record format, which can be downloaded to the development board through the serial port.
The u-boot will be obtained. After the bin file is downloaded to the target board through the JTAG port with the help of the FLASH chip programming tool, check whether the U-Boot can work normally. If the correct startup information can be output from the serial port, it indicates that the transplantation is basically successful.
The U-Boot transplanted by the author has been able to run stably on the development board. U-Boot boot program is an important link in the software development of embedded Linux system. Here, by analyzing the code structure and startup process of U-Boot, and aiming at the hardware resources of the development board system, through analysis and debugging, the transplantation of U-Boot has been realized, and the embedded Linux kernel and file system can be guided, which is for further development in the future. The development has laid a solid foundation.