In this paper, the principle, design and implementation of bootloader based on CAN diagnostic communication are described by using the TMS320F28069 series of DSP chips of TI company. By means of remote sending, the motor controller program is sent to the motor controller ECU through the vehicle information terminal, which can update the control strategy and control parameters of the motor controller ECU in real time, improve the efficiency of product development and enhance the user experience. At present, the main way to update software programs is through local computers, SD cards, USB, or serial bus updates. Such updates are inefficient, and cost is high for the whole car factory.
The remote download through the server is adopted, and then the onboard terminal module is used to realize the forwarding and updating of each ECU. The whole remote update system is relatively large and complex. It involves many links and is vulnerable to electromagnetic interference or software failure. Therefore, the stability of Bootloader is the most important factor in the whole update process. This paper uses CAN-based communication to update the program of motor controller, uses ISO15765-based international common CAN diagnostic protocol to complete data transmission, designs and implements a lightweight bootloader based on TMS320F28069 series of DSP motor controller, and realizes remote calibration of control parameters by combining with vehicle information terminal. Real-time update of control algorithm.
The system consists of four parts: instrument, vehicle information server, vehicle information terminal and motor control system, as shown in Figure 1. Instrument is mainly a display part, responsible for the information interaction between locomotive and driver, through the instrument will download the program download progress or current conditions meet the program download prompt display, guide users to upgrade operations. Vehicle information server is mainly composed of networked communication computer and 4G mobile communication base station. It mainly realizes the storage, upload and download of data parameters of vehicle module. Vehicle information terminal is mainly composed of 4 G communication module, main control module and storage module. It mainly collects the data parameters of ECU in the vehicle through CAN bus, and uploads the collected data to the server to facilitate server download, or downloads the updated ECU program from the server, thermostatic element and burns and writes the downloaded program to each server. ECU module. The motor control system is mainly composed of the motor controller ECU and the generator, which realizes the control of the motor rotation.
Bootloader, also known as boot loader, is the first part of the program loaded when the embedded system is powered on and reset. It is used to realize the loading of embedded system applications or peripheral drivers or the downloading of applications. Bootloader can usually be divided into two modes: loading mode and downloading mode. After the embedded system is powered on, bootloader will enter the CAN communication cycle detection, usually setting up a part of the waiting time, waiting for the programming instructions from the programming instrument (usually called the host computer). If the instructions from the host computer are received during the waiting time, ECU tries to establish a connection with the host computer by shaking hands. After establishing the connection, ECU Send download confirmation request to the host computer, and start waiting for the host computer to send data frames.
Upper computer receives the download confirmation request of ECU, and starts to execute the parsing application code. One page of data and one page of data enter the CAN sending cycle. In order to let ECU receive the complete data, the upper computer sends the page header address and page data circularly to ECU. In order to ensure the accuracy of data, ECU only receives a complete page of data and completes data verification, then burns the received data into FLASH storage area in the form of pages, and sends download confirmation request to the host computer, so that the host computer can continue to send the next page of data. Until the upper computer receives the confirmation request from the ECU, it sends the download end instruction to the ECU. After the ECU receives the download end instruction from the upper computer, it copies the application program downloaded to the RAM of the ECU, starts loading the application program and completes the updating of the embedded system. When the waiting time exceeds or the loading instruction occurs on the upper computer, the application program will be downloaded to the RAM of the ECU. After that, bootloader enters the loading mode, copies the FLASH application into RAM, loads the application and exits.
The hardware part mainly realizes the block diagram as shown in Figure 2. The power part mainly completes the level conversion from the input power of the motor controller to the motor controller. The design of the CAN communication part mainly considers the impedance matching of the whole vehicle, and the design of the motor controller part mainly considers the EMC performance of the whole vehicle. The software of this scheme adopts three-tier software architecture, and the implementation block diagram is shown in Figure 3. The physical layer provides transmission media for data communication between devices, and provides a reliable environment for data transmission. As a medium between the physical layer and the application layer, the transport layer realizes data transmission, unpacking, parsing, error control, packaging and so on, and transfers data from the application layer to the physical layer. According to the service identifier of the specific diagnostic service in the diagnostic protocol and the format and content of the parameters carried thereafter, the application layer makes the corresponding processing strategy for the parsed service. TMS320F28069 supports two modes of operation, emulator mode and standalone mode. emulator mode is the simulation mode of chip, which can support real-time simulation of chip using X100DS simulator corresponding to TI. Standalone mode is the working mode of the system after it is separated from the simulator. Because the motor control system needs to be separated from the simulator, it is necessary to use standalone mode. At the same time, each mode supports four boot modes, namely RAM boot mode, SCI boot mode, USB boot mode and access mode (according to KEY). This design uses the acquired mode to start, and uses the internal Flash startup mode, which uses the internal Flash memory with the chip, without the need for external memory. The design is simple and can effectively save costs. According to the memory mapping of TMS320F28069, the system’s memory is allocated as shown in Figure 4, where the internal FLASH section A address is occupied by the application program. Because the BROM with Flash boot mode chip reads the content of 0x3F7FF6 address during power-on, it is necessary to add an instruction to jump to the main function in the address. Since bootloader can’t read internal flash instructions while running erase/write Flash, each of the corresponding Flash erase/write codes needs to be stored in a part of RAM, so part of RAM space in Figure 2 will be temporarily occupied for placing Flash erase/write codes. Bootloader coding process. Bootloader in different chips, the program code is different, because Bootloaser boot process and hardware is relatively large, so the Bootloader program is divided into two parts, so that the platform function is easy to transplant. The first part of the program is mainly decided by the hardware of the chip, and its portability is relatively poor. This part of the program is mainly completed by assembly language. Its main functions are: setting interrupt vector table, closing watchdog, setting stack, initializing system clock, initializing memory, etc. The first part completes the initialization and sets up the corresponding environment, then jumps to the entrance of the second part. In the second part, it is mainly written by C language, which mainly realizes the functions of universality and platform. Such code also has good readability and portability. The second part mainly includes MMU initialization, interrupt initialization, serial initialization, network card initialization, LCD initialization and so on. This part of code is mainly to initialize the hardware devices needed in this stage, detect the system memory mapping, load the system image of the operating system kernel image file and root file from FLASH to RAM space, set the startup parameters for the kernel, and jump to the operating system entry address to execute. As shown in Figure 5. System software flow. The execution process of the software system is shown in Figure 6. When the system is powered on, the system first determines whether there is a programming request or not. If there is no programming request, it waits for 200 ms. If there is a programming request, it enters the programming state. According to the corresponding diagnostic service received, the corresponding storage space is erased/written. After erasing/writing is completed, Bo Otloader will re-scan whether the user entry is valid or not.
If it is valid, it will enter the user program. Otherwise, the system will restart the programming command waiting for the host computer. This paper describes the design and implementation of bootloader, a motor controller based on TMS320F28069. Experiments show that the real-time diagnosis and updating of ECU control strategy of motor controller can be realized by sending diagnostic data to remote server, which greatly facilitates the updating of module in host plant. The whole process is convenient and fast, without the participation of professionals, and saves the cost of human and material resources, and improves user experience.