Design and implementation of remote upgrade system for embedded devices based on 4G network (study 1)

Summary

With the continuous update and development of wireless communication technology, the networking application field of embedded devices has been greatly expanded, and the remote upgrade function has become an indispensable part of product development.

This paper studies the remote upgrade of embedded devices. On the basis of not changing the hardware integration of the device, a separate upgrade remote upgrade system is designed and implemented.

The acquisition of the new program file is completed by the upgrade tool, and the terminal device realizes the download and update of the new program through the boot program developed by UART.

The upgrade tool is an intermediate adaptation layer between the wireless network and the terminal equipment. It adapts to different hardware interfaces downwards, expands the application scenarios and equipment types, and provides users with a unified application development interface upwards, which is convenient for transplantation and expansion.

research background and meaning

Embedded device program bug fixes, update iterations, program updates, and function additions all require software upgrades.
In the new application scenario, the on-site update method is far from meeting the needs of users for more convenient use, simpler operation, more stable upgrades, and safer systems.
Therefore, it is of great significance to design a remote upgrade system for embedded devices that is separated from the underlying device structure and has stable performance for embedded upgrades and the realization of device intelligence and multi-functional expansion.

Embedded upgrades generally obtain program files by connecting to a communication interface or the network. Although the interface connection is simple to implement, it requires manual operation, which is time-consuming and labor-intensive, especially for products that are difficult to install and disassemble, such as surveillance cameras, power grid power supply equipment, and astronomical observation equipment.

Most of this function is currently realized through wireless communication. The device and the wireless module perform data transmission, and obtain the upgrade program through the network, which is the simplest and most convenient for users.

Most of the recent research chooses to add remote communication function to the equipment to be upgraded, and the software and hardware of the equipment need to be redesigned, which increases the instability of the equipment. It is more suitable for embedded equipment with excellent system performance and many resource functions.

Most of the general embedded devices are front-end and back-end systems, without the powerful resource allocation and task processing capabilities of the operating system, and the hardware resources are relatively simple, with few peripheral modules and limited upgrades.

If the wireless module is directly installed on this device for remote upgrade, the boot program part needs to include the wireless module driver, the protocol analysis program for remote communication, and so on. Moreover, the chip parameters of the hardware platform are different, the product performance and the upgrade communication interface used are different, and the bootloader is mostly for a certain interface of a certain chip, and it does not have the universality of a solution corresponding to multiple devices and chips.

This paper adopts a separate two-stage upgrade method, and upgrades the bottom terminal with the help of the upgrade tool. When the bottom communication interface changes, it is not necessary to modify the program structure of the upgrade tool, just change a few parameters, and add the corresponding communication interface driver. Enter the new interface. The call interface to the application layer can be added according to the protocol function, and the corresponding parsing protocol can be added on the server. The protocol only needs to be written once, and has no impact on the bottom layer, which greatly reduces the amount of development tasks.

Research status at home and abroad

IAP in application programming refers to the technology that the MCU can obtain new codes in the system and burn them in the FLASH, and the program programs itself.
Structurally speaking, the IAP technology is divided into two parts, the boot program that executes program updates and jumps, and the application program that implements specific functions during normal operation.
The boot program is generally downloaded and burned into the on-chip FLASH through JTAG and other interfaces, and the MCU will automatically run the boot program when it is powered on and reset. Jump to the newly downloaded program to run, otherwise the program pointer jumps directly to the application program to execute, thus realizing the IAP function.

The ISP needs to connect to an external program to modify the internal data of the MCU, and cooperate with the software for manual operation.
The IAP method is more flexible. Usually, the serial port of the microcontroller can be used to connect to a PC or other communication methods, and the boot program can be used to program the internal memory to realize the upgrade.

Main research content

A remote upgrade system solution that realizes separate upgrade without changing the hardware platform of the device is proposed.
The hardware platform is modularized, and the 4G module and server remote communication are built on the upgrade tool, and the acquisition of new program files is completed by the upgrade tool.
A relatively standardized, stable and fully functional communication protocol has been formulated, and the data is packaged and encrypted according to the established communication protocol.
Propose solutions to possible errors and exceptions that may occur during wireless transmission and program operation.
The device to be upgraded realizes the download and update of the new program through the boot program developed by UART.

System Requirements Analysis

The system scheme design requires that the upgrade tool can establish a communication connection with the remote server, and transmit data remotely and in real time with the equipment to be upgraded. The functional requirements are as follows:

  1. Reliability of the communication protocol
    The upgrade tool communicates frequently with the server and the device to be upgraded. The communication protocol must have complete functions and a standardized format to facilitate analysis and processing. For the error state during the software operation, different error messages should be formulated in the protocol according to the working state.
  2. Correct performance of data storage and transmission
    Long-term storage of data files for upgrading of equipment to be upgraded. During the program upgrade process, the transmission of program files and version numbers must avoid data errors, and data verification and encryption algorithms are required.
  3. Scalability of hardware design
    The hardware platform is not easy to disassemble and change, so the hardware design must be scalable, and it can be connected with various industrial communication interfaces and upgraded according to the requirements of the project. The hardware design of the system needs to be stable and reliable, and the interface connecting the equipment to be upgraded needs to be designed in isolation.
  4. The display of device status
    can provide users with a visual view of the running status and error status of the upgrade tool.

Network communication protocol selection

This paper adopts UART interface on the physical layer, the data link layer sets the format of the UART protocol, the network layer uses the IP protocol, and the transport layer protocols include TCP and UDP.

TCP is Transmission Control Protocol, which is a connection-oriented transport layer protocol. Before data transmission, there will be a three-way handshake between the client and the server to establish a connection, and there will be confirmation and windows during data transmission. Retransmission. Congestion control mechanism. Four waves are also performed on disconnect, greatly increasing reliability but increasing latency.
TCP provides full-duplex communication and corresponding data cache to ensure that data is error-free, loss-free, and non-duplicate.

UDP, the User Datagram Protocol, is a connectionless transport layer protocol. After the connection is established, the transmission starts without waiting for a response. Therefore, after the message is sent, it cannot be guaranteed that the data is safe and complete. The transmission speed is faster than TCP, but there will be some security risks when the network quality is not good.

Therefore, the UDP protocol considers time rather than reliability. Compared with the UDP protocol, the TCP transmission speed is relatively slow, but the reliability is high. In this paper, the remote communication mainly transmits program files and protocol instructions, which has high requirements on the accuracy and reliability of the communication protocol, so the TCP protocol is adopted.

Wireless Communication Solution Selection

GPRS (General Packet Radio Service) data transmission technology is between 2G and 3G, also known as 2.5G. GPRS technology is constantly updated and mature, and the transmission rate of GPRS is about 100kbps. It has the characteristics of short access time, fast connection establishment, and real-time online.

The biggest difference between the above schemes is the network speed, service type and transmission delay.
In this article, the upgrade tool is mainly for transferring program files, without transferring image or audio data, and the size of the program is variable, and it is set as sub-packet transmission, which does not require high transfer rate. However, reliable transmission, wide network coverage, high real-time performance and long-time online are required.

overall architecture design

insert image description here
The system mainly includes: equipment to be upgraded, upgrading tool, wireless communication network, remote server and PC.

On the one hand, the upgrade tool uses the wireless module to form the data into a TCP/IP protocol packet and sends it to the server through the wireless network
. The BootLoader protocol is used for program upgrades, which is applicable to various devices to be upgraded with serial communication interfaces.

MCU selection

MCU is the core of the embedded system and plays the role of central scheduling. A wide range of MCUs include STMicroelectronics, etc. Most of the chip cores are ARM series, and different versions are used according to specific products, such as ARM7, ARM9, ARM Cortex-M, etc.

insert image description here
Select the STM32F405 chip as the MCU, and connect it to the 4G module through the hardware data flow mode of the UART.
The MCU loads the data into a message according to the custom data communication protocol, and the 4G module sends the message to the server through the network, and the server sends a response message to the upgrade tool after parsing and processing.

Guess you like

Origin blog.csdn.net/Caramel_biscuit/article/details/131909700