Distributed embedded system upgrade solution based on CAN bus

Publisher:虚拟现实迷Latest update time:2013-12-31 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  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

  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

  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

  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

  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.).

Reference address:Distributed embedded system upgrade solution based on CAN bus

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

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号