UDS in Practice: Sessions, Services and Security Access for ECU Developers
Embed IO Private Limited is an automotive software company in Mogappair East, Chennai, Tamil Nadu, and UDS stack work is a regular part of our ECU projects. If you write ECU software, you will meet Unified Diagnostic Services sooner or later, whether for end-of-line testing, service tools or software updates. This post covers UDS the way a developer needs it: how it works, the services you will…
Unified Diagnostic Services (UDS) is a standard protocol defined in ISO 14229 that enables external testers to communicate with Electronic Control Units (ECUs) in vehicles. It allows reading data, retrieving fault codes, executing routines, changing settings, and even reprogramming software. UDS operates using a client-server model where the tester acts as the client and sends requests, while the ECU acts as the server and responds accordingly.
UDS requires a transport mechanism to carry its messages. On Controller Area Network (CAN), messages are transmitted over ISO-TP (ISO 15765-2), which segments long messages into CAN frames. On Ethernet, messages travel over DoIP (Diagnostics over IP, ISO 13400). Regardless of the transport layer, the diagnostic layer remains consistent.
In UDS, ECUs operate within different diagnostic sessions, each allowing a specific set of services. The default session is the normal state after power-up. The programming session is used for software downloads, while the extended session permits more services, such as tuning and testing. The tester switches sessions using the Diagnostic Session Control service. If the tester becomes inactive, the ECU reverts to the default session after a timeout, ensuring the tester remains connected.
Several services are commonly used, each assigned a unique Service Identifier (SID). For instance, Service Identifier 0x10 is for Diagnostic Session Control, 0x11 for ECU Reset, 0x14 for Clear Diagnostic Information, 0x19 for Read DTC Information, 0x22 for Read Data By Identifier, 0x27 for Security Access, 0x2E for Write Data By Identifier, 0x31 for Routine Control, and 0x34/0x36/0x37 for Request Download, Transfer Data, and Request Transfer Exit.
A positive response follows the request SID plus 0x40. For example, a response to service 0x22 will start with 0x62.
A practical example involves switching to the extended session and reading a vehicle identification number (VIN) using the data identifier 0xF190. The ECU responds with 0x62 followed by 0xF190, along with 17 bytes of VIN data. If an ECU cannot fulfill a request, it sends a negative response with a code starting with 0x7F, followed by the service code and an error code indicating the reason for the failure.
Some services are protected by the Security Access service (0x27), which employs a seed and key method. The tester requests a seed with service 0x27, and the ECU replies with a seed. The tester then calculates a key and sends a new request with service 0x27 and code 0x02. If the key is correct, the ECU unlocks the protected services.
Proper security measures, such as keeping the key algorithm out of the ECU's reach, limiting incorrect attempts, and introducing delays after failed attempts, are crucial to prevent security breaches.
Developers should be mindful of common mistakes when implementing UDS, such as ignoring pending responses, incorrect timing, improper session handling, missing negative responses, wrong identifiers, and weak security access. To ensure proper functionality, developers should test each service for both positive and negative cases, test in all relevant sessions, assess timeouts, pending responses, and tester loss, test over both CAN and DoIP if applicable, and log full byte-level traffic during failure cases.
In the context of Automotive Unified Diagnostic Services (AUTOSAR), UDS is managed by the Dcm (Diagnostic Communication Module) and Dem (Diagnostic Event Management) modules. Developers must configure these modules correctly and connect them to application software. Embed IO, an automotive software company in Chennai, specializes in UDS and DoIP stack development for ECUs, providing turnkey embedded hardware and software solutions for clients across India and globally.
For more information, visit their automotive UDS protocol stack development page at https://embedio.in/automotive-uds-protocol-stack-development.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to