Embedded systems consist of two parts: hardware and software. The software part mainly includes Bootloader, kernel and file system. Bootloader is the first piece of software code that runs when the hardware system is powered on. However, there is generally no firmware like BIOS in PC in embedded systems, so the entire system loading process is completed by Bootloader. When the system is powered on or reset, it usually starts to execute from address 0x00000000, and the address at which the system's Bootloader is usually arranged is the Bootloader of the system. The main tasks of Bootloader include: initializing the most basic hardware; copying the Bootloader itself to RAM for execution; copying the kernel to RAM and calling the kernel, etc.
In embedded systems, Bootloader is usually burned into the Flash of the target board through the JTAG interface first, and then in Bootloader, the kernel image file and file system image file are downloaded and burned into Flash through the serial port and network. If the kernel or file system needs to be upgraded, the new image file is re-burned according to the above method, directly overwriting the original image file.
In the above method, on the one hand, the target board and the host must be connected through a serial cable and a network cable, and on the other hand, the image file is downloaded through the serial port or the network, which is very slow. This experiment expands the Bootloader function and realizes the automatic upgrade of the kernel or file system image file through the CF memory card. For embedded systems that need to frequently upgrade the kernel or file system, it overcomes the limitations of traditional upgrade methods, simplifies the upgrade method, and improves the upgrade speed.
1 Basic Principles
This experiment expands the functions of the traditional Bootloader and adds the function of upgrading the system. For example, if the user needs to upgrade the kernel or file system on the target board, he only needs to name the new image file as the specified name and copy it to the CF memory card. Then, insert the CF memory card into the CF memory card slot of the target board, and restart the target board to complete the upgrade process. When restarting, the system first runs the Bootloader, and the Bootloader will detect whether there is an image file of the kernel or file system in the CF memory card. If so, the image file is read and burned into the F1ash of the target board to achieve the upgrade; if not, the system in the target board is directly started, as shown in Figure 1.
The development board used in the experiment is based on the Intel XScale processor PXA255. PXA255 has a 16-bit CF memory card controller for connecting to the CF memory card. There are 32 MB of Flash and 64 MB of SDRAM on the development board, and the starting address of Flash is mapped to Ox00000000, and the starting address of SDRAM is mapped to OxA0000000.
The InteI Strata Flash on the experimental board has a capacity of 32 MB and is divided into four areas: Bootloader, reserved, kernel, and root filesystem. Among them, the Bootloader partition is used to burn the Bootloader, and its starting address is Ox00000000. When the system is powered on or reset, the CPU jumps to this location to start executing instructions; the reserved partition is a reserved partition, which is mainly used to pass kernel startup parameters and other system settings; the kernel partition and the root filesystem partition are used to burn the kernel and the file system respectively. The starting address and size of each partition are shown in Figure 2.
2 Implementation
The implementation method discussed in this paper is mainly to expand the function of Bootloader and add support for CF memory card, so that Bootloader can read files from CF memory card when the system starts. First, the CF memory card should be formatted into a specific file system format (this experiment mainly supports three file systems: FAT32, FATl6 and EXT2). Then, the image file to be upgraded (kernel image file, file system image file or Bootloader's own image file) is copied to the CF memory card through the host. Therefore, Bootloader can detect the image file to be upgraded and update the corresponding part on the target board.
2.1 Bootloader framework and workflow
The Bootloader written in this experiment only implements the most basic hardware initialization function, system boot function and system upgrade function. The size of the statically compiled binary file is 38 KB. Bootloader is implemented in assembly language and C language. The assembly language only does simple work such as shielding all interrupts, initializing related GPIO (General Purpose IO), initializing SDRAM, copying Bootloader and kernel to SDRAM, and then jumps to the C program, in which the subsequent initialization work and system upgrade are implemented. The detailed process is shown in Figure 3. [page]
2.2 Support for CF memory card and data reading process
Since the new image file is read from the CF memory card and the system is updated, the CF card must be supported in the bootloader first. The CF card itself provides two detection pins (i.e., Card Detect Pins) to determine whether the CF card exists. These two pins are called CD1 and CD2, and are directly connected to the ground by hardware design inside the CF card. When the CF card is inserted, CD1 and CD2 should all be low level. Therefore, in the bootloader, by detecting the level of CD1 and CD2, it can be determined whether the CF card exists.
The CF card mainly consists of three parts: controller, memory array and buffer. Among them, the built-in intelligent memory can greatly simplify the peripheral circuit design and fully comply with the PCMCIA (Personal Computer Memory Card Interemational Association) and AIA (AdvanccdTechnology Attachment) interface specifications of the memory card. Therefore, the access to the CF card includes the Memory Map mode based on the PCMCIA specification, the I/O mode, and the True IDE mode based on the ATA specification. In the Bootloader implemented here, the CF card works in the Truc IDE mode, and the 0E (Output Enable) pin of the CF card is set to a low level (conversely, if it is a high level, the CF card will work in the Memory Map mode or I/O mode of the PCMCIA specification).
After the True IDE working mode of the CF card is set, the control and reading and writing of the CF card are realized by writing the necessary information to the register of the CF card. The CF card mainly includes the following registers:
◆Data register (R/W), used for the read/write operation of the sector. The host writes the data of the sector buffer to the CF card controller or reads the data from the CF card control register through this register;
◆Error register (R), the cause of the error of the control register in the diagnostic mode or the operation mode;
◆Sector number register (R/W). Record the number of sectors of the read and write commands;
◆ Sector number register (R/W), record the starting sector number specified by the read, write and verify commands;
◆ Cylinder number register (R/W), record the cylinder number specified by the read, write, verify and addressing commands;
◆ Drive/register (R/W), record the drive number, head number and addressing mode specified by the read, write, verify and seek commands;
◆ Status register (R), reflect the status of the CF card drive after executing the command, the read register must clear the interrupt request signal;
◆ Command register (W), the command register receives the control command of the CF card sent by the host.
The process of reading data from the CF card is shown in Figure 4.
2.3 File System Support
To access files on the CF card, the CF card must be formatted into a certain file system. The Bootloader written in this experiment mainly supports three file systems: FATl6, FAT32 and EXT2. When it is necessary to upgrade the kernel image (image file name zlmage) or the root file system image (image file name tootfs.img) of the embedded system, copy the image file to be updated to the CF memory card according to the specified file name. When the system starts, the Bootloader first detects the file system type of the CF memory card, and then queries all files in the CF card according to the corresponding file system format. If the image file to be updated is found, the CF card underlying operation (see Section 2.2 for details) is called to read the image file into SDRAM, and then burn it from SDRAM to the Flash of the embedded development board to achieve the upgrade. For details on the implementation of the file system, see the references.
3 Conclusion
Automatically upgrading embedded systems through CF memory cards can simplify the upgrade process. Instead of connecting the target board to the host through a serial port or network to download and upgrade files, you only need to insert the CF card and start the system to complete the upgrade process. On the other hand, the upgrade speed is greatly improved because the system's access speed to the CF card is much higher than that of the serial port or network. However, to achieve system upgrades through CF cards, the embedded board must have a CF card interface, so it is not suitable for all embedded systems.
Previous article:Comparative Study of Linux 2.4 and Linux 2.6 Kernel Schedulers
Next article:Some suggestions on embedded software development
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- How to choose the most suitable network cable for POE power supply?
- [Silicon Labs Development Kit Review] +EFM32PG22_EVB Key Control Example
- [Zhongke Bluexun AB32VG1 RISC-V board "runs into" RTT evaluation] Watchdog
- Voltage sampling is inaccurate
- About initialization problem
- Cost a few cents to DIY a charger
- EV2400 WIN7 64 BQ20Z45
- Help
- EEWORLD University ---- QA7: The most important component of the analog world - signal chain and power supply: gate driver
- title