This article uses the 32-bit microprocessor LPC2378 of Philips Company to develop the distribution transformer monitoring terminal, and uses the IAP function of the chip to realize the remote update of the terminal program. In order to reduce communication traffic and terminal storage space, this article also applies the LZW compression algorithm to program updates.
1 LPC2378 chip introduction
LPC2378 is a 32-bit processor based on ARM7TDMI-S. It has 512 KB of on-chip Flash program memory, 32 KB of static RAM (SRAM), and in-system programming (In-System Programming, ISP) and in-application programming (In-Application Program-ming, IAP) functions. Since the program has relatively large memory requirements, a 64 KB SRAM was expanded.
Generally, program downloading can be achieved in three ways:
① Using an embedded real-time operating system. This method increases the system's requirements for storage capacity and increases hardware and software costs.
②Adopt the method of adding external control burning system. This method also increases the complexity and cost of the system, and reduces the reliability of the system itself.
③Adopt IAP technology. This method makes full use of the functions of the chip itself without adding peripheral devices, and is the best implementation solution.
1.1 The FIash sector
IAP command of LPC2378 operates in "sector" units, and the sector number needs to be specified during operation. The sector distribution of LPC2378 is listed in Table 1. The IAP, ISP and RealMonitor programs are all located in the Boot area, and the Boot area is located at addresses 0x000TE000~0x0007FFFF. The IAP command does not allow write/erase/run operations on the Boot sector.
1.2 IAP function of LPC2378
The IAP program is Thumb code located at address 0x7ffffff1. The IAP function can be called with the following C code.
Define the entry address of the IAP program:
# define IAP_ENTER_ADR 0x7ffffff1
Define the function type pointer:
Typedef void(* IAP)(uint32[ ], uint32[ ])
IAP iap_entry;
set the function pointer:
Iap_entry=(IAP) IAP_ENTER_ADR;
use the following statement to Call IAP:
Iap_entry(command, result);
The IAP function is mainly implemented by calling the iap_entry() function. IAP commands and defined functions are listed in Table 2.
When modifying the on-chip Flash, you first need to read the device ID and Boot code command version; after confirming that they are correct, select the sector to be programmed; then erase the sector and perform a sector blank check to copy the RAM content to the Flash Medium; Finally, compare the RAM content with Flash to check whether the copy is successful.
2 Implementation of remote update
2.1 Program partition
software development adopts ADS1.2 integrated open environment. The full name of ADS is ARM Developer Suite, which is an ARM integrated development tool launched by ARM Company. After selecting the Scattered mode in the ADS link option ARM Linker, modify the . The scf file can compile the program into two parts: application program and update program. Among them, the application program occupies sectors 0 to 21 and is used to implement the functions of the terminal; the update program occupies sectors 22 to 27 and will not be modified after the terminal leaves the factory. When the program is updated, the IAP function is used to erase and rewrite the application part to realize the update of the terminal application. For links. The scf file is defined as follows:
in. In the scf file, RO represents the program code data content, RW and ZI represent the general data variables defined in the program part and the data variables that require zero initialization. The ROM_MAIN part mainly includes the application part and its defined data. ROM_EXEC is the code area of the application program, located in the on-chip Flash, and the address starts from 0. IRAM is the stack where the program runs, located in the on-chip RAM. ERAM is an application-defined data variable located in off-chip RAM. The LOADER part is the code area of the update program, located in the on-chip Flash, and the address starts from 0x78000. After the program is compiled and linked, ADS will generate two hexadecimal files named ROM_MAIN and LOADER. When a program update is required, the master station will send the ROM_MAIN file that has completed binary extraction to the terminal through wired or wireless means. After receiving all the files, the terminal calls the update program to update the program. However, since the extracted binary file is still relatively large, it needs to be compressed to reduce communication costs.
2.2 Implementation method of program update
The program running process is shown in Figure 1. When the program starts, the terminal first checks whether the program needs to be updated. If not, it enters the main() function to run normally. During the operation, when encountering the compressed program package sent by the main station, the compressed program package needs to be checked first. If it is correct, it will be stored in the external Flash at the corresponding location. When receiving the program update command from the master station, the terminal needs to check all the compressed program packages received, set the program update flag after confirmation, save the current data and reset. When the terminal program is started again and a program update flag is found, the update program is called. In the update program, first remove the compressed program package from the external Flash, then decompress it, and copy the compressed program to the corresponding internal Flash sector. When all compressed program packages are decompressed and copied, clear the program update flag and then reset it. After the terminal is started again, the updated application will be running.
2.3 Implementation of the decompression algorithm in the update program
After the program is compiled and linked, the ROM_MAIN. generated by the application program is processed. hex file for binary extraction. While this can make the file size significantly smaller, the resulting file is still large and requires further compression. This article uses the LZW compression algorithm to compress it. The LZW (Lempel-Ziv-Welch) compression algorithm is a string table-type lossless compression technology that supports streaming decompression and can select the appropriate maximum dictionary string length according to the memory size. Table 3 shows the results for ROM_MAIN. hex file (940 KB) for binary extraction, and the file size of each stage of LZW compression after extraction.
When a program update is required, the compressed file is sent to the terminal. After the terminal receives all the program compressed packages and confirms that they are correct, it resets and calls the update program. In the update program, due to memory limitations, 1,024 bytes are read from the external Flash each time for decompression. When the number of decompressed bytes reaches 512, the IAP function is called and these 512 bytes are copied to the internal Flash to continue decompression. After the previously read 1024 bytes are decompressed, read and decompress them from the external Flash again until the application is completely decompressed and copied.
Conclusion
This article introduces the method of remote update of distribution transformer monitoring terminal program based on the IAP function of LPC2378, and applies the LZW compression algorithm to the program update. This product has been put into operation for more than a year and has achieved good operating results. This technology has certain universality and can be applied to other similar products with slight modifications.
Previous article:Design of intelligent communication card system using LPC2294 four-way CAN controller
Next article:ARM LPC2103 timer interrupt mode register setting
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- Breaking through the intelligent competition, Changan Automobile opens the "God's perspective"
- The world's first fully digital chassis, looking forward to the debut of the U7 PHEV and EV versions
- Design of automotive LIN communication simulator based on Renesas MCU
- When will solid-state batteries become popular?
- Adding solid-state batteries, CATL wants to continue to be the "King of Ning"
- The agency predicts that my country's public electric vehicle charging piles will reach 3.6 million this year, accounting for nearly 70% of the world
- U.S. senators urge NHTSA to issue new vehicle safety rules
- Giants step up investment, accelerating the application of solid-state batteries
- Guangzhou Auto Show: End-to-end competition accelerates, autonomous driving fully impacts luxury...
- Lotus launches ultra-900V hybrid technology "Luyao" to accelerate the "Win26" plan
- High performance and low cost scale reference design
- Research on high power photovoltaic inverter system
- Exposed business---Beijing Aitai United Technology Co., Ltd.
- Recruitment position: MCU engineer (urgent) 1 person
- STM32 virtual serial port (USB driver)
- New Tang 8051 (1T) Quickly build the entry keil environment
- A python comic
- A display solution for APF system information——Based on Topmicro intelligent display module
- Why does CCS need to install a driver?
- The age of gadgets freeing your hands