UDS in CAN Flash Programming
UDS in CAN Flash Programming
UDS in CAN Flash Programming
To cite this article: Li Du et al 2019 IOP Conf. Ser.: Mater. Sci. Eng. 490 072060 - Servo control system based on optical
fiber CAN communication
Li Yahui
Li Du1,*, Peng Xie2 ,Bing Zhou3 ,Yongyan Yu4 ,Juan Wan5 ,Haixia Hu6 and
Lianghao Cui 7
1-7
Dongfeng Motor Technology Center,WuHan,China;
Abstract. Flash bootloader is the most important part in the ECU platform software. It
is the base function of the product in developing and after-sale, supporting self-flash.
CAN bus is the main network in vehicle, which connect the whole network together.
Thus, flash programming through CAN bus, bring us convenient in whole vehicle
flashing.
1. Introduction
With the development of CAN bus technology, ISO organization issued relevant international
standards, such as ISO 15765, ISO 14229, ISO 15031, etc. At present, vehicle factories have gradually
begun to develop flashing based on CAN bus for meeting vehicle ECU program upgrade requirements,
through the connection of vehicle OBD port[1][2].
This paper briefly introduced the technical usage in flashing and takes Freescale S12 series chip for
an example that the use of UDS in BootLoader .
Content from this work may be used under the terms of the Creative Commons Attribution 3.0 licence. Any further distribution
of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI.
Published under licence by IOP Publishing Ltd 1
SAMSE 2018 IOP Publishing
IOP Conf. Series: Materials Science and Engineering 490 (2019) 072060 doi:10.1088/1757-899X/490/7/072060
In the software architecture,the first layer was CAN driver, which obtained message content
(including physical layer and data link layer) from CAN bus according to ISO 11898.
The second layer was the network layer, which is responsible for sending and receiving network
data, and its key content was to process the decomposition and assembly of large data packets
according ISO 15765-2[4].
The third layer was the Diagnostic Layer (UDS), which defined the commands and service of
diagnosing communication standards between the diagnostic instrument and the controller.
The fourth level was the application layer, which pass data to each other's nodes through various
services of UDS.
2
SAMSE 2018 IOP Publishing
IOP Conf. Series: Materials Science and Engineering 490 (2019) 072060 doi:10.1088/1757-899X/490/7/072060
The STmin parameter is the minimum interval, which represents the time interval between the two
frames. The BS parameter is the frequency of persistent transmission, which indicates the maximum
times of frames sent in an interaction.
By framing, UDS service can achieve the interaction among long messages to provide a basic data
channel for large data transmission in the process of flashing.
3
SAMSE 2018 IOP Publishing
IOP Conf. Series: Materials Science and Engineering 490 (2019) 072060 doi:10.1088/1757-899X/490/7/072060
Judge flag
As shown in Figure 4, the software program works in the model of ASW. When there is flashing
requirement according to the order of UDS on CAN bus, the ASW will set the refresh flag and restart.
After the program restarted, it will enter the bootloader programming mode according to the refresh
flag. When running bootloader software, program will maintain the communication with the host
device, while receiving the data sent by the host device and updating the ASW part.
4
SAMSE 2018 IOP Publishing
IOP Conf. Series: Materials Science and Engineering 490 (2019) 072060 doi:10.1088/1757-899X/490/7/072060
4. Project development
MC9S12XET256 has two different erase Flash modes, one is erase command by block and the other
is erase command by sector. Block erase command could erase the entire block at one time, i.e. 128K.
Sector erase command erase only one sector at a time, i.e. 1K. As shown in table3, the time parameters
of block erase command and sector erase command are described.
Table 3. The time parameters of block erase command and sector erase command
XER256 flash erasing time
flash action time detect by MCU ticks time detect by oscilloscope
erase all block(E0-E7) 870*0.128ms =111.36ms 111ms
erase one sector 177*0.128ms =22.656ms 22.8ms
flash module working frequence:181.8KHZ
In software designing, the bootloader section is only in the last section of Blcok0, that is the address
0xC000-0xFFFF (the purple section in Figure 5). As shown in Table 3, it takes 111ms to erase block1
with block erase commands. However, it would take 22.8ms*16*8=2918.4ms with block erase
commands, which is 26 times with block erase commands. Therefore, block erase commands are
chosen to erase Block1 flash while sector erase commands are used to erase Block0 flash. According
to the above time parameters, the total erasing time was 111 + 22.8 * 15 = 453 ms. In the flash erasing
strategy, program uses the background task for erase job, that is, after receiving the erase command,
the communication layer of ECU will start an erase task at background. When the erase task finished,
the communication layer will send an positive response to the host device.
5
SAMSE 2018 IOP Publishing
IOP Conf. Series: Materials Science and Engineering 490 (2019) 072060 doi:10.1088/1757-899X/490/7/072060
After the flash erased, the ECU can update the ASW program section with the data sent by the host
gradually. The strategy is as followed:
1) Firstly, the ECU receives the request from the host and determines whether the address and data
length are valid. If the address and data length meet the expectation, the ECU will inform the host the
maximum number of bytes which can send each time according to its own conditions.
2) The host transfers data according to the maximum number of bytes specified by ECU.
3) The host sent all the data in this round and requested the end of this round. Then the ECU
checked the data, and judged the validity of the data in the process of communication. If the checksum
passed, the next round of transmission will begin.
4) Repeat the strategy above until all data updated.
6
SAMSE 2018 IOP Publishing
IOP Conf. Series: Materials Science and Engineering 490 (2019) 072060 doi:10.1088/1757-899X/490/7/072060
6. Conclusion
This paper described the use of UDS in flash and introduced complete design and completion of
the ECU flash through the S12 chip. In the future, There will be consistent growth in ECU flashing ,
and UDS usage in bootloader will become more and more popular .
References
[1] WANG Chun-hua, ZHANG Yu-wen, HU Ji-kang. Design and Implementation of Fault Diagnosis
System for BCM Based on UDS [J]. Auto Electric Parts,2017(08):41-45.
[2] CHEN Zi-lin, SONG Lei-feng, ZHANG Long-gang, DONG Hai. Vehicle Diagnosis and Design
Method Based On UDS [J]. Auto Electric Parts,2017(04):14-17.
[3] ISO 14229-1: 2013, Road vehicles - Unified diagnostic services ( UDS ) --Part 1 : Specification
and requirements [S].
[4] ISO 15765-2: 2004, Road vehicles - Diagnostics on Controller Area Networks ( CAN ) -Part2 :
Network layer services [S]
[5] You Changneng . Development of CAN bus UDS diagnostic tool based on Lab VIEW [J].
Electronic Test, 2016 (10): 59-60.
[6] LYYing, SUNYun-xi, LIUDe-li, GUYuan-ye, SUN Yun. ECU Bootloader Refresh Function Test
Method [J]. Auto Electric Parts, 2017 (11): 63-66.