Transplantation and analysis of u-boot on B0 time: 13:14:14 Source: modern electronic technology Author: Li Xiangyang, Dai Xuefeng, Lin Qiqihar University
Abstract
Abstract: Bootloader is the first step in software development for embedded systems. It is used to initialize the target board hardware and provide hardware resources for Embedded operating systems.
Source Information, and further load and boot embedded system firmware, its performance directly affects the system stability. To guide the embedded operating system
Specific hardware information on the Development Board, without changing the Bootloader architecture, for hardware-related code, especially the FLASH chip Intel 28F320C3B
The Code was added and modified, and U-bOOt was successfully transplanted to the Development Board, and used well in the Intelligent Robot Obstacle Avoidance System Based on μClinux.
Key words: Bootloader; U-boot; s3c2444bo; transplantation
O Yan
Bootloader is a small program executed before the operating system starts and runs. It is implemented based on a specific hardware platform. It can be used to initialize hardware devices, create a memory space ing table, and then create
Appropriate system software and hardware environment to prepare for the final call of the operating system kernel. The hardware part of the embedded system cannot be completely consistent. Because the embedded system must work properly with the hardware and software
Design the boot program for the hardware system. For an embedded system, the boot program is complicated. Generally, it is modified based on the existing boot program that basically meets the requirements of the hardware system.
Design the Bootstrap program through the application method. This is the transplantation of the Bootstrap program.
1 U-boot Introduction
U-boot (Universal
Boot loadei) originated from Wolfgang Denk in the denx Software Engineering Center. Based on the 8xxrom source code, the ppcboot project is an open source project that complies with the GPL terms and can support PowerPC, arm, x86, there are hundreds of development boards in the mips architecture. U-
Boot provides two operation modes: boot loading and down loading. With
All functions of large bootloader are available. Main features include: scc/FEC Ethernet support; Bootp/TFTP boot -- IP, Mac
Preset functions; online flash, Doc, IDE, I2C, e2rom,
RTC; supports downloading code through kermit and S-record; Recognizes binary, elf32, and pimage images; provides special support for Linux boot;
Minitor command set, with read/write I/O, memory, registers, peripheral testing and other functions.
U-boot also supports multiple file systems, such as cramfs, ext2,
Fat, reiserfs, and jffs2; supports multiple embedded operating system kernels, such as Linux, NetBSD, VxWorks, QNX, RTEMS, and Artos.
And lynxos, and has special support for Linux boot. In addition,
U-boot also provides a single-task software running environment that can dynamically load and run independent applications without an operating system, these independent applications can use U-boot to provide the Console
I/O functions, memory application, and service interruption.
2 U-boot Startup Process
For the ARM7 processor, U-boot. the startup process is mainly reflected in three files, namely start. s, lib ARM/board. C and U-boot/common/main. c. The following describes the startup process in detail.
2.1 start. s file
The start. s file is mainly used for CPU initialization and compiled in assembly language. The main code process is as follows:
(1) define the entry. An executable Image must have one entry point and only one global entry. Generally, this entry is placed at the Ox0 address of the ROM (FLASH). The following statement is available in the start. s file:
. Globl_start
_ Start:
Therefore, the compiler must be notified of this entry. This can be done by modifying the connector script file U-boot.1ds.
(2) set the Exception vector (Exception
Vector ). The abnormal interrupt vector table is one of the key links between U-boot and the operating system kernel. Even if the operating system kernel has gained control of the processor, once the operation is interrupted
Or automatically jump to a location in the abnormal interrupt vector table starting from the OxO address (based on the interrupt type) to read the command.
(3) set the CPU speed, clock frequency, and interrupt control register. Turn off the watchdog timer, block all interrupts, and configure the clock (including PLLCON, CLKCON, and LOCK-TIME ).
(4) initialize the memory controller. Memory Controller Initialization is mainly accomplished by setting 13 special function Registers starting from 1c80000, including the external data bus width, access period, and timed control signals.
(5) copy the program in the ROM to RAM. First, the start address of BootLoader in FIASH is obtained using PC, and then the code size of the program is calculated based on the difference of the number. Through registers (r3 ~ R10) copy the code to RAM as an intermediate medium for replication.
(6) initialize the stack. Go to various modes to set the stack of the corresponding mode.
(7) Go to ram for execution. This task can be completed using commands 1 dr pc, namely idr pc and start armboot.
2.2 lib_arm/board. c file ()
U-b00t/lib ARM/board. c In the start armboot is the C language to start the function, is also the main function of C language in the whole startup code, the function is mainly to call a series of initialization functions. Perform Various initialization settings. The operation completed by this function is:
(1) call a series of initialization functions, including: CPU Init (CPU-related settings ),
Init (board-related settings), in-terrupt_init (Interrupt settings), env_init (environment variable settings), init _
Baudrate (baud parameter settings), serial
Init (Serial Port initialization), lele_inh_f (console setting), display_banner (display title), DRAM Init (available memory configuration );
(2) initialize the flash device;
(3) initialize the system memory allocation function;
(4) If the target system has a NAND device, the NAND device is initialized;
(5) If the target system has a display device, initialize the device;
(6) initialize related network devices, and fill in IP addresses and MAC addresses.
2.3 U-boot/common/Main. c file
After completing the above initialization, enter the command loop (that is, the operating cycle of the entire boot). The Code is:
For (;;)
{
Main_loop ();
}
3. porting process
Here we use the EB44BO Development Board of skyworth. the system configuration is as follows:
Processor: SamslJng box, working frequency 60 MHz;
Two serial ports. Four programmable LEDs and 14-pin JTAG interfaces.
To reduce the difficulty of porting, we usually choose a version closest to the target processor and Target Board during the porting process. Therefore, select B2 for transplantation. From the official website of U-bo () t
Download the latest source code. The current maximum version is 1.3.3. Transplant main modified files
Including: cptl/jx44b0/start. s, board/dave/b2/lowlevel
Init. s, board/dave/b2/b2.c, board/dave/corn.
Mon/FLASH. c, include/configs/b2.h, board/dave/b2/config. mk.
3.1 cpu/B0/start. s file
Start. s is a U-boot program written in assembly language. It mainly includes the initialization of various registers in the processor and the code moving. The main task is to set the processor status and initialize it.
Break, stack, memory controller, and so on, and determine whether to relocate the entire U-boot code, and finally jump from FLASH to the location of the specified memory for execution. Some of the code below are targeted
Analysis.
(1) set WTCON = 0x0. Disable the watchdog timer to avoid force reset of the processor;
(2) Set INTMSK = Ox7ffffff to disable all interrupts. During the execution of Bootloader, it is unnecessary to respond to any interruptions;
(3) modify the macro CON-FIG 83C4480 clcick speed = 60 MHz Based on the operating frequency of the embedded microprocessor, so that the processor can work properly;
(4) set PLLCON = 0x34031. PLLCON control registers store parameters related to the computing system clock. In order to generate the correct system clock, the frequency doubling factor must be determined based on the external crystal oscillator frequency and processor clock speed.
3.2 board/dave/b2/lowlevel init. S file
This file is completed by the assembly code, mainly including the setting of the parameters for the SDRAM operation and the initialization of the processor memory controller. The parameters need to be set according to the data of the SDRAM chip.
3.3 board/dave/b2/b2.c File
The code in this file is mainly the SDRAM driver, and the initialization of each I/O port of the processor is completed. Modify it according to the specific target board.
3.4 board/dave/common/FLASH. C
This file is the Flash Driver. Flash Memory burning, writing, and erasure are generally not universal. You can modify them based on different types of memory. The eb4480 Development Board uses
Intel28f320c3b, 71 in total, 1 ~ 8. The size of each block is 8 KB, 9 ~ 71 the size of each block is 64 KB, and its particularity determines the need
3.5 include/configs/b2.h File
This file contains some macro definitions of B2 target board configurations, including the system operating frequency, Environment Variable Buffer length, serial port baud rate, flash start address and capacity, DRAM start address and capacity
Volume, environment variable storage location, flash read/write command word, network chip base address, target board IP address, hardware address MAC, Host IP address, kernel Mount address, Interactive Operation Command, etc.
3.6 board/Dave/b2/config. mk File
U-boot copies its code from flash to the location of SDRAM at 0x0c700000 and modifies text_base = 0x0c700000.
U-boot is developed in Linux. Therefore, you need to compile it in Linux. The operating system used is Fedora Core.
7. Download from http://opensrc.see.samsung.corn/download/arm-elf-tools-20040427.sh.
Arm-elf = tools = 20040427.sh. the compiler used is arm-elf-GCC, And the MAKEFILE file in the root directory of U-boot is used.
Then, run the following command in the command line:
After the connection is compiled, u_boot, u_boot.bin, and u_boot are generated.
SREC,
The u_boot.bin is a binary binfile that executes the code in the pure u_boot binary file without saving the ELF format and debugging information. This file is used to download to your Development Board. Connect
The Flash burning and writing tools provided by the integrated development environment of chuangvitt run in the SDRAM, And the startup information of U-boot is displayed from the Super Terminal.
Erase, CP, Printenv, saveenv, and other commands, and detect flash operations. Use the TFTP Command to detect the download function of the network port, and then load the operating system kernel,
The above task is successfully transplanted. After the above steps, the transplanted U-boot has successfully guided the μClinux operating system on its own arm board.
4 knots
Bootloader is a bridge between the system hardware and the operating system. Based on the operating mechanism of U-boot, if the hardware resources are fixed and the bootloader framework is not changed
Code related to the target board hardware, especially the flash chip intel
The Code of 28f320c3b is modified and transplanted to the eb4480 Development Board. Combined with the startup process and running mechanism of U-boot and μClinux
Guide the embedded operating system on the-box target board. During the porting process, you should be familiar with the organization structure and workflow of U-boot, have a certain understanding of the relevant hardware resources, and enter
Line Cutting, flexible selection of functional modules. At present, the transplanted U-boot can run stably on the embedded target board and guide the embedded μ cinux system smoothly. It has been successfully applied to intelligent robots.
In the obstacle avoidance system.