当前位置:网站首页>[UDS unified diagnostic service] (Supplement) v. detailed explanation of ECU bootloader development points (1)

[UDS unified diagnostic service] (Supplement) v. detailed explanation of ECU bootloader development points (1)

2022-04-23 17:58:00 Tomorrow is like noon

introduction

  1. bootloader The function of

  2. How to establish reliable bus communication ?

  3. Parsing programming files (S19/HEX/BIN)

  4. NVM Driver development

  5. bootloader Other points of development
    a. bootloader Relationship with Applications
    b.bootloader Jump method to application
    c. Development bootloader Need to master the knowledge and debugging methods and skills
    d. In mass production bootloader And how to download the application

————————————————————

introduction

One side , With the development of semiconductor technology ( According to Moore's law ),MCU There are more and more logic function peripherals integrated internally , Memory is getting bigger and bigger ;

On the other hand , Consumers are interested in car energy saving ( Economic and regulatory requirements for emissions ) type 、 comfort 、 Interconnection 、 Security ( Functional security and information security ) The demand is higher and higher , Especially in recent years, new energy electric vehicles 、 The rise of Internet of vehicles and automatic driving technology , It has greatly accelerated the development of automotive electronic technology . Automotive electronics ECU(Electronic Control Unit– Electronic control unit ) The functions of integration are becoming more and more complex , In response Software remote ( On-line ) Function upgrade ( Add new features ) and bug Need for repair 、 Yes **bootLoader( Start the loader )** There is a growing demand for .

This paper will introduce automotive electronics in detail ECU BootLoader Key points of development , For everyone to learn .
 Insert picture description here

1. bootloader The function of

BootLoader, seeing the name of a thing one thinks of its function , Is to reside in ECU A piece of program loading code in nonvolatile memory , Every time ECU After reset , Will run bootloader.

It checks whether there is a remote program load request from the communication bus ,

If there is , entering bootloader Pattern , Establish and download the program ( Usually it is PC Upper computer ) And receive the application downloaded from the communication bus 、 Parse its address and data code , function NVM(None Valitale Momory– Nonvolatile memory ) The driver , Program it to NVM in , And verify its integrity , To complete the application update .

without Remote program loading request from communication bus , be Jump directly to the application reset entry function ( Reset interrupt ISR, Also known as Entry_Point()– Use Processor Expert Of CodeWarrior Engineering or Startup() function – Ordinary CodeWarrior engineering ), Running the application .

Based on this , automobile ECU Of bootloader The three main concepts are as follows :

  • And remote program download terminal (PC Upper computer ) Establish reliable bus communication to Get the application to update ;

  • Parsing application programming files (S19/HEX/BIN) Get it in NVM Medium Address ( Address ) and Program code and data ( data )( The actual is : Address + Corresponding data );

  • function NVM The code and data that drive the application Program to NVM And verify ;

2. How to establish reliable bus communication ?

automobile ECU Common data buses are CAN and LIN, So usually cars ECU Of bootloader It's all through CAN perhaps LIN How to download data .

Of course , It can also be based on other buses , For example, based on SPI Bus perhaps I2C Bus ( Typical examples are some safety functions with safety monitoring ECU, Through the master MCU Functional safety monitoring MCU Upgrade your program ) as well as Ethernet ( be based on Enternet Central control of communication or full LCD instrument ECU And the next generation of high-speed gateways and ADAS ECU).

Important note :

  • Different ECU The communication bus is different , The specific need for a communication bus depends on the actual application ;

  • The communication bus consists of ECU Of MCU Peripheral implementation , So in bootloader Must develop corresponding Communication bus peripheral driver (Flash Driver), Realize the basic data sending and receiving functions ;

  • In order to ensure the reliability of communication , Must develop a Perfect communication protocol based on communication bus , Application download side and bootloader A request command needs to be established between (request command)、 confirm (acknowledge)、 wait for (block wait)、 Error retransmission (error re-send) Equal mechanism ,bootloader Complete different tasks according to different request commands and confirm whether the operation is completed (ACK), And whether the data is transmitted correctly and completely , If there is a data error ( By checksum or ECC Realization ), Automatic retransmission is required ;

  • The application download side usually needs to be in PC Based on VC perhaps C#、QT、Labview Etc GUI Software , Bus communication protocol to realize the above requirements , Usually in its The bottom layer is through calling the corresponding bus device , Such as USB turn CAN/LIN Dynamic library of repeater equipment (DLL) Of API Interface to realize data sending and receiving , Corresponding bus USB The forwarding device will provide the corresponding driver library (DLL). therefore bootloader Developers generally need to have a certain PC PC software development ability ;

  • In order to realize the reliable transmission of data , Generally, add... To the bus communication protocol Source code . That is, when the upper computer sends , Check and sum the valid data or ECC Calculate and send the result together with the valid data in the communication data frame ,bootloader As the receiver , After receiving the data frame, the effective data field is checked and summed the same as the sender ECC Calculation , The result is consistent with the received checksum or ECC The calculated results are compared to determine the integrity of the data .
    Application programming files (S19/HEX/BIN) All have corresponding checksum mechanism , Therefore, we can directly transfer the lines of program programming files ; otherwise , The user needs to analyze the programming file in the upper computer software first , Then the address, data and code are encapsulated and packaged into a customized communication protocol , stay bootloader They have to be unpacked in the process , thus , A little trouble , But some OEMs (Car OEM) For the protection of intellectual property , Have their own bootloader agreement , In this case ,bootloader Developers must develop according to the requirements of the host factory ;

  • Some regular large mainframe factories require them to ECU Supplier developed ECU bootloader must be based on UDS Wait for bus diagnostic protocol , stay UDS The corresponding CAN ID to bootloader Use , Then it must be in this class ECU Medium bootloader Add corresponding... In the project UDS Protocol stack ;

3. Parsing programming files (S19/HEX/BIN)

  • Different MCU software development IDE The format of programming files generated by compiling links may be different , but S19、HEX and BIN Files can be transformed into each other , So all you need to do is bootloader Just open a parsing program for programming files , Others can use the corresponding conversion tools (convert tool) Carry out conversion on the upper computer ;

  • Parsing of programming files , The purpose is to get the of the application Program code and data And in NVM Medium Storage address ;

  • To parse programming files , You must first understand the coding format and principle , Please refer to the following links :
    S19 File format details (1):https://star-302.blog.csdn.net/article/details/119564818
    S19 File format details (2):https://star-302.blog.csdn.net/article/details/119565232
    HEX File format details :https://star-302.blog.csdn.net/article/details/119563635

版权声明
本文为[Tomorrow is like noon]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230546376462.html