Implementation of startup guide based on ARM-μClinux Embedded System

Source: Internet
Author: User
The 32-bit ARM embedded processor features high performance and low energy consumption. It has been widely used in consumer electronics, wireless communication, network communication, and other fields. Μ Clinux is an embedded operating system designed for non-MMU processors. It supports arm, Motorola, and other micro-processors. Arm-μ Clinux is widely used as an embedded system at home and abroad. The startup and guidance technology of embedded systems is a difficult point in embedded system development. The success or failure of the system boot guide determines whether the running environment of the application can be correctly built. That is, the success of the system boot is a prerequisite for the proper running of the application.

A common embedded system startup method is to first use JTAG to import the embedded operating system kernel to flash, and then use its Bootstrap program bootloader to start and guide the embedded system. This method requires the use of expensive JTAG devices to burn and write the operating system kernel, and cannot easily update the software platform in the embedded system. This paper proposes a boot Guide Scheme Based on the arm-μ Clinux embedded system, which not only can easily update the software platform in the embedded system through a simple serial port, in addition, this architecture has successfully solved the startup, initialization, operating system kernel solidification and boot of embedded systems. This article briefly describes the hardware platform and software platform of the arm-μClinux embedded system, describes the design of the system boot program bootloader, and describes the factors and technical difficulties to be solved during the design, A set of feasible boot procedures are provided. For the boot program of the μC Linux kernel, the loading and initialization processes of the μC Linux kernel are described.

1 system composition

A typical ARM embedded system hardware platform generally includes an ARM-based Processor, memory, and necessary external interfaces and devices. In this system, Samsung uses the processor embedded with ARM7TDMI. The memory uses 2 MB flash and 16 mb sdram. In addition to the serial port used for download and communication, the external interface, an Ethernet interface is also provided to support the network functions of the network.

The software platform consists of the following components: System Boot Program, embedded operating system kernel, and file system. The system boot program, also known as bootloader, has a small amount of code but has a very large role. It is equivalent to the BIOS on the PC and is responsible for curing the operating system kernel to flash and system initialization, then, control the system to the operating system. The embedded operating system kernel is a management platform for embedded systems after power-on. It is responsible for real-time task and multi-task management. ARM7TDMI is a processor without MMU. Therefore, μClinux is used as the operating system kernel of the system. Μ Clinux is a branch of Linux. It is designed for a processor without MMU. It inherits the powerful network and multi-task management functions of Linux, and modifies memory management and process management, meets the development requirements without MMU processors. The file system is the largest part of the storage used by the embedded system software platform and the most relevant part of user development. It stores system configuration files, system programs, user applications, and necessary drivers.

The software platform is solidified in flash. Generally, the address space of Flash is partitioned based on the content of the software platform, which is divided into three zones, namely, the bootloader, the μClinux kernel, and the file system. There are two partitioning Methods: one is to allow the bootloader, kernel, and file system to have their own fixed partition and first address based on the reserved storage space of the three parts; the other is based on the actual distribution interval of the three parts. One part is stored after the other, and there is no fixed partition or first address. The first method is usually used. Although part of the flash space may be wasted, it facilitates kernel loading and file system mounting, and facilitates system debugging and development. If you make full use of the flash storage range to save costs, you can use the second method.

2 System Boot Program Design

System Boot Loader is the first program executed after the embedded system is powered on. When designing functions, consider the following:

(1) solidify the μC Linux kernel and file system in Flash

Visual μC Linux kernel and file system are solidified in flash by many means. The host can use the JTAG port to burn the kernel and file system image files to the specified flash location, or download the image files to flash through the Ethernet interface; you can also use the serial port to burn to flash. The download speed of the first two methods is much faster than that of the last method. In this system, Flash is written through serial port. This is because, on the one hand, it is convenient and cheap to configure a serial port, while JTAG is also required to configure expensive JTAG simulators and related drivers and protocol conversion programs. Ethernet support is also required for network port download; on the other hand, μClinux prints its running information through the serial port by default. The serial port not only provides the flash burning function, but also serves as the channel for debugging the μClinux kernel.

In this system, flash only stores bootloader at the beginning, and does not store the μC Linux kernel and file system. Therefore, after the system power-on completes initialization, the bootloader needs to initialize a serial channel linking the host and the target machine, and provides the serial download function.

 

(2) system initialization

Because the kernel of the operating system is not loaded when the system is powered on, the initialization of the system is completed by bootloader. It is mainly used to initialize the system, storage system, configure data stacks in various arm modes, enable frequent screen interruptions, and switch the processor mode and status as needed.

(3) μClinux kernel Loading Method

There are two operating modes for the μClinux kernel solidified in Flash: one is to directly run the boot program provided by μClinux in Flash; another method is to copy the fixed flash kernel to a specific address range of SDRAM, and then run the uClinux kernel from the first address of the address range.

The first method is to initialize the system by bootloader, jump to the first address of the kernel solidified in flash, and hand the control to μClinux, and start to execute the built-in boot program in flash one by one, the boot program loads the kernel. This method is used by many embedded systems to start the kernel, and is also the kernel loading method used by the system.

The second method is to copy the image file of the kernel from flash to the SDRAM after the bootloader completes system initialization. Then, execute the boot program of the μClinux kernel from the SDRAM and load the μClinux kernel.

The second method is to run the program in the SDRAM, so the execution speed is faster than the first method, and this method can be implemented through the ram Quick Guide technology. Mainly for NAND Flash. The biggest difference with nor flash is that nor flash uses the random memory reading technology. Like SDRAM, it can directly execute programs stored in flash. Like nand, the random read technology can be used to read a whole block of memory at a time. Therefore, programs stored in NAND Flash cannot be directly executed. Programs in NAND flash must be copied to SDRAM first, execute the program in SDRAM. However, NAND Flash is cheaper than nor flash, so many embedded systems still adopt the nor flash (several hundred KB) + NAND Flash (several megabytes) storage mode. Among them, the nor flash stores executable bootloader with a small amount of code and some necessary data, while the NAND Flash stores large volumes of kernel and file systems.

In this system, because the nor flash is used to store bootloader, kernel, and file systems, you can directly access the first address in the address range of the kernel and execute its own boot program, in addition, the boot program provided by the kernel has powerful functions, allowing you to easily load the kernel and transmit relevant hardware parameters to the kernel. The system adopts the first loading method. (4) switching between the auto-lifting mode and the kernel Startup Mode

Bootloader generally needs to implement two boot modes: The bootstrap mode and the kernel startup mode. The bootstrap mode is also called the bootstrap mode. The main function of this mode is that the target machine communicates with the host through a serial port and can receive the image files sent from the host, such as the kernel, file system, and applications, it can also be solidified in flash, and the image files in flash can be uploaded to the host. The kernel startup mode allows the embedded system to load the μClinux kernel after power-on, and hand over the system to the μClinux operating system for management.

In this system, a single switch is used to extract the two modes. When only bootloader is available in the system flash, first unplug the switch and prompt the system to enter the auto-lift mode. After the boot starts, the bootloader enters the auto-boot mode according to the switch status, receives the kernel and file system image files sent from the host. Next, unplug the switch and prompt the system to enter the kernel startup mode. Then, press the chain. bootloader enters the kernel Startup Mode Based on the switch status, loads the kernel and the file system, and the operating system takes over the system. You can also set the status of the switch as needed to prompt the system to enter different startup modes.

(5) configure and remap the address ing table

The address ing table is configured to set the flash Address Space, SDRAM address space, external I/O address range, and Processor register address range. The ARM processor executes the code at address 0x0 after power-on. Therefore, when power-on is enabled, the flash Address Space of the bootlader is set to 0x0-0x200000, and the address space of the SDRAM is set to 0x000000-0x2000000, after the kernel boot program copies the kernel to the SDRAM, set the address space of the SDRAM to 0x00x1000000, and the address space of flash to 0x1800000-0x1a00000. This requires the address space of flash and SDRAM to be remapped in the kernel boot program.

Flowchart 1 of the System Boot guide solution used in this article.

3μclinux kernel loading and initialization

In this startup scheme, the boot program of μClinux is used to load the kernel. The bootstrap code is in the Linux/ARCH/armnommu/boot/compressed directory, where head. s plays the most important role. It completes most of the work of loading the kernel; Misc. C provides the subprograms required to load the kernel. the subprogram for extracting the kernel is head. important program called by S. In addition, kernel loading must also know the necessary hardware information of the system. The hardware information is stored in hardware. h. s.

When bootloader gives control to the kernel boot program, the first program to be executed is head. S. The following describes the main process of loading the kernel in head. s based on this system. Head. s first configures the system registers of the; then initializes the control registers of the RoM, ram, and bus, and sets the address ranges of flash and SDRAM to 0x0-0x200000 and 0x000000-0x2000000 respectively; next, copy the kernel image file from flash to SDRAM, and re-map the address ranges of flash and SDRAM to 0x1800000-0x1a00000 and 0x0-0x000000, and then call Misc. in C, extract the kernel function (decompress_kernel), decompress the kernel image file copied to the SDRAM, and run the call kernel function (call_kernel) to grant the control to the decompressed μClinux system.

Executing the call_kernel function is actually to execute the start_kernel function in Linux/init/Main. C, including initialization of the processor structure, initialization of interruptions, initialization of processes, and memory initialization.

The boot guide solution implements the auto-boot mode, kernel boot mode, and two switching modes, enabling developers to use the auto-Boot Mode to easily write flash, update the software platform in the embedded system and switch to the kernel startup mode to automatically and securely start the system. Secondly, this solution uses a simple serial port channel to communicate with the target system, you can easily download the operating system kernel, file system, and other applications to the target system, and use it as the channel for debugging the μClinux kernel and application programs. In addition, the MMU-free feature for ARM7TDMI is provided, the modified μC Linux kernel boot program is used to load the operating system and initialize the operating system environment, solving the address re ing problem of kernel loading and the memory management problem of the operating system.

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.