As modern vehicles continue to promote intelligence and electrification,the traditional emission diagnosis protocol OBD(On-Board Diagnostic)can no longer meet the diagnostic needs of various types of automotive ECUs.Nowadays,the UDS(Unified Diagnostic Services)protocol formulated by ISO 14229 is rapidly spreading in the automotive industry because of its universality beyond OBD.In addition,the Over-the-Air(OTA)technology that emerged in recent years requires the Bootloader of ECU to support standard communication protocols,so UDS protocol becomes an option.And due to the large number of ECUs and the large amount of software,OTA is time-consuming and easily disturbed.So,OTA requires the Bootloader to design fault tolerance mechanism.This thesis designs and implements a set of CAN(Controller Area Network)bus-based UDS software on a Vehicle Control Unit of pure electric logistics vehicle,which is based on NXP MC9S12XEQ512 microcontroller,to realize the common diagnostic services.Firstly,the software is written according to MISRA-C specification to ensure software reliability.Secondly,layered and modular processing are adopted to improve software portability.Finally,the state machine model is used to realize the discrete operation of time-consuming processes to ensure software real-time.This thesis designs and implements the Bootloader software for automotive ECU,and uses UDS protocol as the standard communication protocol relied on for software upgrade.Further more,this thesis also proposes to implement functions of resuming from breakpoint and software rollback on the Bootloader software to meet the needs of OTA scenarios.The former enables the OTA process to continue even if it is interrupted by unexpected circumstances;the latter enables the ECU software to roll back to the previous stable version in time when adaptation problems occur after the upgrade.The introduction of these two new features improves the fault tolerance of the software upgrade system and ensures vehicle safety.This thesis also implements a WinForm-based UDS diagnostic upper computer on the PC(Personal Computer)side,which supports sending UDS diagnostic service requests,parsing and displaying the response information of diagnostic service,and downloading software packages for testing and applying the UDS software and Bootloader software.Finally,this thesis verifies the functions and performance of UDS software and Bootloader software through laboratory test and real vehicle test,and proves that the software implemented in this thesis has met the design requirements. |