Embedded systems have many advantages such as high intelligence, small size, high reliability, and strong real-time performance. They have been increasingly used in various industries such as consumer electronics, industrial control, and automotive electronics. Often a large system is composed of many small embedded systems, which communicate with each other to complete various detection and control tasks, forming a distributed embedded system. The on-board GPS, reversing radar, engine control, instrument panel system, etc. in automotive electronic systems, the keyboard display system, motor control system, etc. in CNC machine tools, etc., are all specific applications of embedded systems.
The application of many embedded systems also brings many difficulties to software upgrades, mainly the following points:
① These systems are located in different parts of the large system, and it is difficult to upgrade each system separately;
② In order to meet the requirements of confidentiality and reliability, some systems are permanently sealed, with only communication and power ports reserved, which makes it even more impossible to upgrade them independently.
To address these issues, this paper proposes a distributed embedded system upgrade solution using the CAN bus, which realizes multi-point, single-point or even full-system upgrades. Other types of communication ports are similar.
1 System Architecture
The system structure block diagram is shown in Figure 1.
Figure 1 System structure diagram
The entire system consists of multiple independent embedded modules that perform certain functions, a CAN bus, and a control module for upgrading the entire system. The control module can also be one of the functional modules. An independent boot program is installed on each functional module, which can be regarded as the Bootloader of the module. The boot program is permanently fixed in the module and is not upgraded with the program upgrade. The CAN bus communication program is embedded in the boot program. Under normal working conditions, each functional module works alone or in conjunction with other modules through the CAN bus. When a software upgrade is required for a module, an upgrade command is sent to the module through the system upgrade control module. After receiving the command, the module jumps to the boot program and waits for the system upgrade module to send the upgrade data. After the upgrade is completed, it jumps back to the application.
2 System Implementation
2.1 Implementation Principle of Online Upgrade
The 32-bit embedded processor STM32F103VC based on the ARM Cortex-M3 core of ST Company is used. Its on-chip Flash is the main storage area. The application code is stored in the Flash (0x08000000~0x0807FFFF), and the Flash is managed by Page, so the Flash can be divided into several areas for use.
Figure 2 Flash partition
In this system, Flash is divided into two areas, one of which is the boot program area mentioned above, and the other is the application program area. The Flash partition is shown in Figure 2.
After the chip is powered on, STM32F103VC will automatically jump to the address 0x08000000 to execute the following program. The starting position of a project (that is, the address of the main function) can be set to the address of the Flash. In the design of this system, two main functions are placed in the Flash. The boot program is used to upgrade the application and jump to the application after power-on, and the application completes the corresponding module function. These two areas can jump to each other through specific instructions, and thus realize online upgrades.
2.2 Hardware System
The STM32F103VC processor has the characteristics of high performance, low cost, and low power consumption. The processor has rich on-chip peripherals, including multiple system timers, CAN communication interface, USART communication interface, DMA and other rich resources. With the help of the firmware library provided by ST, it is easy to operate the system resources. The processor integrates 256 KB on-chip Flash and 64 KB on-chip SRAM, which is enough to handle most tasks. To realize CAN bus communication, you only need to add a CAN driver chip to the STM32F103VC for level conversion.
The system hardware structure block diagram is shown in Figure 3.
Figure 3 System hardware structure diagram [page]
2.3 Software System
To realize the online upgrade function, you first need to write a boot program and then burn it into the Flash boot area. To prevent the application upgrade from failing, the boot program needs to determine whether there is a program integrity flag in the Flash specified location. This flag is written by the complete application after each power-on. The application can be written into the corresponding program area by burning and upgrading. To realize the mutual jump between the boot program and the application, a function pointer is used to achieve it. The boot program and the application in the Flash can be regarded as two ordinary functions, and the entry positions of these two functions are 0x08000000 and 0x08004000 respectively. Then set a pointer to the function in the boot program, and its pointer value is 0x08004000; similarly, set a function pointer in the application, and its value is 0x08000000. In this way, the program jump can be realized when the function pointer is called in the corresponding program.
The CAN bus adopts a multi-master competition working mode and non-destructive bus arbitration technology. Any node on the bus can actively send information to other nodes on the network at any time without distinguishing between the primary and the secondary, and the nodes can communicate freely. When multiple nodes send information to the bus at the same time, the nodes with lower priority will actively quit sending, while the nodes with higher priority will not be affected, which greatly saves the bus conflict arbitration time. Even when the network load is heavy, the network will not be paralyzed. Therefore, it is suitable for data communication in distributed monitoring systems. Since the CAN bus protocol specification only defines the physical layer and the data link layer, in actual applications, a suitable application layer protocol must be formulated according to the actual system. In this system, several application layer commands are customized according to the data transmission requirements, namely upgrade-related commands and data transmission and reception verification-related commands. Due to space limitations, they will not be described in detail here.
3 Software Upgrade Process
Software upgrade includes upgrading the control module part and the module part to be upgraded.
The working process of the upgrade control module is as follows: send an upgrade command to the module to be upgraded, and after receiving the confirmation mark returned by the module, send the upgrade data to the module to be upgraded through the CAN application layer protocol, and send a completion command to the module to be upgraded after the upgrade is completed.
The workflow of the module to be upgraded is shown in Figure 4. It is divided into the boot program part and the application program part, which are completed as two independent engineering projects during development.
Figure 4 Workflow of the module to be upgraded
To ensure the security of online upgrades, a program integrity flag is set at the specified location of the Flash. Since the Flash is erased and written according to the page, this flag needs to occupy the size of a page even if it is only one bit. In this system, the flag is set at the last page of the Flash. If there is no free page in the application area to write the flag, it is necessary to consider switching to a product with a larger Flash capacity or external expansion memory. The program integrity flag is written when the application enters and erased when the upgrade command is received. If the flag is detected as illegal in the boot program, it will remain in the upgrade state until the upgrade success command is finally received.
The program jump example jump code is as follows:
typedef void (*pFunc) (void); //Custom function pointer data type
pFunc Jump_To_App; //Define a pointer to the application
Jump_To_App=(pFunc)0x08004000;
Jump_To_App();
It should be noted that before the program executes the jump code, the interrupt response needs to be turned off to avoid unpredictable exceptions. At the same time, before the program jumps, the stack pointer needs to be set to the corresponding program area.
Conclusion
Online upgrade of distributed embedded systems through CAN bus is very representative. As more and more chips integrate a variety of on-chip communication peripherals (such as Ethernet ports, I2C bus, etc.), embedded system upgrades have more styles and can even be remotely upgraded through public networks (such as the Internet, GPRS, etc.).
Previous article:Design of Intelligent Vehicle Instrument Based on S3C2440 Processor and WinCE
Next article:Data Acquisition System Based on S3C2410A and Multiple AD7656-1 Daisy Chain
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- W5500 server program problem
- 【ST NUCLEO-G071RB Review】AM2302_PDC401
- EEWORLD University Hall ---- Embedded Systems and Applications Luo Lei, University of Electronic Science and Technology of China
- STM32 Motor Control Application Lecture Series
- Chat with Vicor engineers about efficient power supply
- msp430f5529-clock configuration, routine analysis
- Codecs - Optimized for C55x devices C55XCODECS
- Spectrum of the phase-locked loop output waveform
- 【nRF52840 DK Review】Bluetooth Mesh Test
- Live broadcast has ended [Microchip uses dsPIC33/PIC24 and ATECC608 devices to simplify security application design]