A new bootloader boot guide method

Source: Internet
Author: User
A new BootLoader boot guide method
[Date:] Source: single-chip microcomputer and Embedded System Application Author: Xi'an University of Electronic Science and Technology Li Bo [Font:Large Medium Small]

 

Introduction
BootLoader is usually referred to as "System Boot Loader", which is the first program code executed after the system is powered on or reset. The main task of this program is to implement hardware device initialization and build a map of memory space, so as to bring the system's hardware and software environment to a suitable state, in order to prepare the correct environment for the final call to the operating system kernel or user applications. Generally, BootLoader includes two different loading and boot modes, namely the start loading mode and download mode.
① Boot loading mode. This Bootstrap mode is also known as the autonomous (autonomous) bootstrap mode, that is, the BootLoader loads the operating system to RAM from a solid-state storage device of the target machine and runs it as a pilot, no user intervention is involved in the entire process. This Bootstrap mode is a commonly used Bootstrap mode in normal operating mode of BootLoader. Therefore, when the embedded product is released, BootLoader generally starts and guides the kernel code in this mode.
② Download (down loading) method. In this mode, BootLoader on the target machine downloads files from the host through serial port connection or network connection, such as downloading applications, data files, and kernel images. Files downloaded from the host are usually first saved to the RAM of the target host by BootLoader, and then written to the solid state storage device of the target host. Then, the kernel is started. This Bootstrap mode of BootLoader is usually used in system development and updating. In the development phase of embedded systems, the existing BootLoader download guide methods can be divided into the following types based on different loading methods:
① Download the kernel from the host to the target board through the Ethernet port to enable the software system;
② Download the kernel from the host to the target board through the serial port to start the software system;
③ Directly extract the stored kernel from Flash to start the software system.
Summary of the above guidance methods will find that they have some common drawbacks. During system debugging, the actual connection between the hardware line between the host machine and the target board is not convenient enough, in addition, the speed of chip burning is relatively slow, and debugging efficiency is not high. In terms of hardware, large-capacity Flash support is required, which increases R & D costs. It is not flexible enough to update the kernel. Therefore, a removable storage medium is used to store the system kernel (such as SD card and CF card), so as to realize flexible debugging and guidance of the system kernel. The advantage of this mode is that you do not need to connect the host machine to the target board during debugging, which improves the debugging efficiency and makes it easier and more flexible to use; it is more flexible to update the kernel. You only need to store the updated kernel to the specified directory. In addition, its implementation is relatively simple. To improve this, you only need to do the following: in terms of hardware, add hardware circuits for specific mobile storage media, while in medium and large systems, hardware circuits related to mobile storage media (such as SD card and CF card) are ready-made, so the hardware can be ignored. Inside the BootLoader program, you only need to add instructions for storing and accessing mobile storage media (such as CF cards and SD cards) based on the file system. Based on the existing hardware platform, the original BootLoader is improved for SD cards of mobile devices. The following describes the implementation process.

1. Hardware Platform
The hardware platform for this improvement test is an I experiment platform for the hardware of the LPC2294 ARM Controller Developed by inner. Its main functional modules include:
① 2 MB Flash, 1 mb sram (expandable to 4 MB), 256B E2PROM with I2C interface and other memory;
② Two RS232 (one of which CAN be connected to Modem), RS485, CAN and other communication bus interfaces;
③ Two debugging interfaces: LPT and JTAG;
④ Mobile storage media such as CF card and SD/MMC are supported;
⑤ Supports 128x128 true color display.
Figure 1 shows the hardware function diagram.

2. Improved BOOtLoader Design
2.1 original bootloader Function

Originally: BootLoader has the following functions:
① The serial download function downloads the kernel to the specified RAM zone through the serial port;
② Flash burning and writing function, burning data from the RAM area to Flash;
③ Block migration function in the Data zone;
④ Other functions. The command encapsulation structure is as follows:


2.2 bootloader improvement Experiment
This improvement is based on the original BootLoader and added instructions for reading data from the SD card of the Mobile storage media in the FAT format. The command is encapsulated as follows:


The function is to extract the kernel files in the specified directory to the SDRAM area in the SD card to load the kernel.
Add three additional auxiliary commands, one for formatting the SD card, the other for saving the system kernel, and the last for loading the system kernel. The command is encapsulated as follows:


Among them, the function of pai_tbl_sd_format is to format the SD card. The function of pai_tbl_sd_store is to back up the kernel code in the SDRAM area to the fixed storage area of the SD card, plu_tbl_sd_ldad is used to load the kernel code in the fixed storage area of the SD card to the specified SDRAM area.
Next we will analyze the specific reading and backup methods based on the FAT file system. First, let's take a look at the basic structure of the FAT file system. The overall structure of the FAT file system consists of four parts: MBR (primary Boot Record area), DBR (DOS Boot Record area), and FAT (File Allocation Table area, FATl is the primary File Allocation Table area, and FAT2 is the backup file allocation table area) and DATA area (DATA area, including FDT area-file directory table area ). The structure of the FAT file system is as follows:

The base sector address of each region (the base sector address of the MBR region is used as O) is calculated as follows:
Base sector address of DBR area = MBR base sector address + 63
Base sector address of the FAT table = base sector address of DBR + number of reserved sectors
FDT base sector address = number of sectors in each FAT table × Number of FAT tables + (number of first clusters in the FDT area) × number of sectors in each cluster + address of base sector in the FAT table. (A cluster is the unit in which the system manages files. Each item in the FAT table corresponds to a cluster. The file is accessed by cluster. A cluster contains several sectors .)
From the organization structure of the FAT file system, it can be seen that it is easier to read the system kernel code data from the SD card to the specified RAM zone, that is, locate the data in the file system based on the system kernel file name, then the read is completed. For kernel code backup and loading, SD card formatting must be performed on the basis of in-depth analysis of the structure of the FAT file system. During formatting, you can set data in the MBR and DBR areas to avoid formatting the last 8 Mb area of the SD card storage area (which can be increased or decreased as needed, set it to the RAW area. Therefore, the implementation of system kernel backup is to fill the system kernel code with the SD card write command into the RAW area. The system kernel is loaded to directly read the backup kernel code from the RAW area.

3. Summary
The kernel loading boot guide method described in this article has been verified in practice. It completely disconnects the hardware line between the target board and the host. it facilitates system debugging and effectively improves the efficiency of system debugging. At the same time, it also facilitates online system updates. It can be said that the system boot guide design is required. This method is a good choice. At last, the improvement method of BootLoader introduced in this article is completed on the LCP2294 chip-developed LPC22EB06 I experimental platform. Because BootLoader is closely related to the processor architecture and the configuration of specific embedded board-level devices, to use the above method on other processor chips or platforms, you also need to modify the Code related to the processor architecture in BootLoader. This part is not the main content of this article, so I will not detail it here. If you want to learn more about it, please refer to the relevant papers or books.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.