UDS ECU Flashing Explained

Electronic Control Units (ECUs) require software updates during development, production, service and vehicle lifecycle maintenance. ECU flashing, also called ECU reprogramming, is the process of transferring a software image to an ECU and making the intended software available for execution.

The Unified Diagnostic Services (UDS) protocol, defined by the ISO 14229 series, provides diagnostic services commonly used during reprogramming. The actual flashing sequence is defined by the ECU bootloader design, OEM programming specification, transport protocol and project security requirements.

A successful data transfer alone does not prove that the new software is valid or that the ECU will boot correctly. A complete programming process also needs image validation, controlled activation, recovery planning and post-programming verification.

1. ECU reprogramming architecture

A typical ECU reprogramming setup contains:

  • Programming tool: PC application or service tool that selects and transfers the software image.
  • Communication interface: CAN, CAN FD or Ethernet interface used to communicate with the ECU.
  • Transport layer: ISO-TP for diagnostic communication over CAN, or DoIP for diagnostics over IP.
  • Bootloader: ECU software responsible for programming-mode communication, memory operations and update control.
  • Application memory: Flash memory area containing the application software and, depending on architecture, calibration or configuration data.
  • Programming metadata: Image identifiers, memory layout, compatibility information, checksums, hashes or signatures.

A simplified communication path is:

Rendering diagram...

The diagram is conceptual. A production ECU may use multiple boot stages, memory partitions, redundant images, external flash, a secure boot component or a separate update manager.

2. Bootloader and application software

The bootloader is responsible for starting or updating the application software. It may support diagnostic programming services, validate the received image and decide whether the application can be started.

Common memory arrangements include:

  • Single-bank update: the active application memory is reprogrammed. A power interruption can make recovery more difficult unless a robust bootloader recovery path exists.
  • Dual-bank or A/B update: a second image area is programmed while the current image remains available. The ECU can switch to the new image after validation.
  • Bootloader and application separation: a protected bootloader remains available to support recovery or future programming.
  • Partitioned memory: bootloader, application, calibration and data regions have separate access and programming rules.

The memory map, erase granularity, write alignment, programming voltage requirements and recovery strategy are ECU-specific. Never infer memory addresses or erase sizes from a generic example.

3. Typical UDS programming sequence

A common high-level reprogramming sequence is:

  1. Establish diagnostic communication with the intended ECU.
  2. Enter the required programming diagnostic session using DiagnosticSessionControl (0x10).
  3. Perform authorization using SecurityAccess (0x27) or the security mechanism specified by the ECU.
  4. Prepare the ECU and erase the required memory region using RoutineControl (0x31) or another OEM-defined mechanism.
  5. Request permission to download data using RequestDownload (0x34).
  6. Transfer firmware blocks using TransferData (0x36).
  7. End the transfer using RequestTransferExit (0x37).
  8. Perform the required checksum, hash, signature and compatibility checks.
  9. Activate the image and reset the ECU using the specified procedure, potentially including ECUReset (0x11).
  10. Reconnect and verify software identification, diagnostic status and application behavior.

Not every ECU uses every service in this exact order. Some projects use additional routines, dependencies, multiple download regions, file-transfer services or OEM-specific steps.

4. Entering programming session — DiagnosticSessionControl (0x10)

The tester may need to switch the ECU from its default diagnostic session into a programming session before performing reprogramming operations.

A commonly used request pattern is:

Tester -> ECU: 10 02
ECU -> Tester: 50 02 [P2Server_max] [P2*Server_max]

Here:

  • 0x10 is the DiagnosticSessionControl request SID.
  • 0x02 is commonly assigned to programmingSession.
  • 0x50 is the positive response SID.
  • Timing values are returned in the format defined by the applicable UDS edition.

The session type and sub-function support must be confirmed against the ECU diagnostic specification. Some ECUs require preconditions such as vehicle stationary, supply voltage within limits, ignition state, vehicle mode or a specific communication path.

The tester must also manage session timing. If the ECU requires TesterPresent (0x3E) to keep a non-default session active, the tester should send it according to the ECU's timing requirements without disrupting other programming operations.

5. SecurityAccess — service 0x27

Programming operations are commonly protected so that only an authorized tester can modify ECU software.

SecurityAccess (0x27) may use a seed-and-key exchange:

  1. Tester requests a seed using the configured requestSeed sub-function.
  2. ECU returns a seed.
  3. Authorized tester software calculates the corresponding key using the project-approved algorithm and credentials.
  4. Tester sends the key using the matching sendKey sub-function.
  5. ECU accepts or rejects the authorization attempt.

A schematic exchange is:

Tester -> ECU: 27 [requestSeed sub-function]
ECU -> Tester: 67 [sub-function] [seed]
Tester -> ECU: 27 [sendKey sub-function] [key]
ECU -> Tester: 67 [sub-function]

The sub-function values, seed length, key length, algorithm and access-level mapping are ECU-specific. Do not publish real OEM algorithms, keys, credentials or seed/key examples that could enable unauthorized programming.

SecurityAccess is not equivalent to firmware authenticity. A secure update design may additionally validate a cryptographic signature, certificate chain, image version, hardware compatibility or anti-rollback counter before accepting or activating an image.

6. Memory preparation and erase — RoutineControl (0x31)

Before writing new software, the ECU may need to erase one or more flash memory regions. Some bootloaders expose erase operations through RoutineControl (0x31).

A conceptual exchange may look like:

Tester -> ECU: 31 01 [routineIdentifier] [routineParameters]
ECU -> Tester: 71 01 [routineIdentifier] [routineStatus]

The routine identifier and parameters are defined by the ECU or OEM. They may identify a memory region, address range, erase type or other programming operation.

Important engineering checks include:

  • Confirm the intended memory region and its boundaries.
  • Check erase-sector alignment and minimum erase granularity.
  • Confirm that the bootloader and recovery area are protected as intended.
  • Verify preconditions such as voltage, ignition and ECU operating state.
  • Understand whether the routine is synchronous or requires polling.
  • Check the routine result and any returned status information.

Do not use illustrative memory addresses or routine identifiers on a real ECU. An incorrect erase operation can make an ECU unusable until recovered with an approved procedure.

7. RequestDownload — service 0x34

After memory preparation, the tester can request permission to transfer a software data region using RequestDownload (0x34).

The request contains:

  • DataFormatIdentifier (DFI): identifies any compression or encryption format indicated by the request. A value of 0x00 is commonly used when no compression or encryption is indicated, but the ECU profile controls the accepted value.
  • AddressAndLengthFormatIdentifier (ALFI): describes the number of bytes used for the memory address and memory size fields.
  • Memory address: start address of the target download region.
  • Memory size: number of bytes to be transferred for that region.

A generic request layout is:

34 [DFI] [ALFI] [memoryAddress] [memorySize]

For illustration only, if the address and size are each encoded using four bytes, an ALFI value may indicate four address bytes and four size bytes. The exact ALFI nibble interpretation and permitted formats must be taken from the applicable UDS definition and ECU specification.

Illustrative request:

Tester -> ECU: 34 00 44 00 10 00 00 00 20 00 00

This example represents a request with DFI 0x00, an address/length format indicating four bytes for each field, an illustrative address 0x00100000 and an illustrative size 0x00200000. It is not a recommended address or size for any real ECU.

Positive response — 0x74

A positive response to RequestDownload uses SID 0x74. It includes a length-format indicator and a maximum number of data bytes the ECU can accept in a TransferData request, according to the response format.

Schematic response:

ECU -> Tester: 74 [lengthFormatIdentifier] [maxNumberOfBlockLength]

The tester must decode the returned maximum block length and ensure that each TransferData request fits the ECU's accepted limit. The effective application data size per block may also be constrained by transport-layer payload limits, protocol overhead, tool configuration or OEM requirements.

A positive 0x74 response means the ECU accepted the download request; it does not mean the entire image has been programmed or validated.

8. TransferData — service 0x36

The tester transfers the firmware image in blocks using TransferData (0x36). Each request contains a blockSequenceCounter followed by the transfer data and any parameters required by the ECU profile.

General request:

36 [blockSequenceCounter] [transferData]

Positive response:

76 [blockSequenceCounter] [optionalResponseParameters]

Illustrative exchange:

Tester -> ECU: 36 01 [DATA BLOCK 1]
ECU -> Tester: 76 01

Tester -> ECU: 36 02 [DATA BLOCK 2]
ECU -> Tester: 76 02

Tester -> ECU: 36 03 [DATA BLOCK 3]
ECU -> Tester: 76 03

The example omits actual firmware bytes. The ECU's accepted block length, timing, addressing and response parameters must be taken from the programming specification.

Block sequence counter

The blockSequenceCounter allows the receiver and tester to associate a transfer request with its response and detect sequence problems. The counter is one byte. In the standard TransferData sequence, it increments for subsequent blocks and wraps from 0xFF to 0x00.

For example:

... 36 FE [DATA]
... 76 FE

... 36 FF [DATA]
... 76 FF

... 36 00 [DATA]
... 76 00

The tester must follow the sequence rules defined by UDS and the ECU implementation. It must not assume that an arbitrary retry can be sent with a new counter. If a response is lost, the tester should follow the specified retry and recovery behavior and consider the ECU's handling of a repeated request.

Block size and transport constraints

The tester should calculate a transfer payload that respects the ECU's accepted maximum block length and the transport stack's capabilities. Do not confuse the complete UDS request length with the firmware data length: the SID, sequence counter and any additional parameters also occupy bytes.

For ISO-TP over CAN, larger UDS payloads are segmented into transport frames. Flow control, separation time, block size, bus load and timeout settings can affect throughput and reliability. DoIP has different transport behavior and configuration considerations.

9. RequestTransferExit — service 0x37

After all requested data blocks have been transferred, the tester sends RequestTransferExit (0x37) to terminate the active transfer.

Generic request and response:

Tester -> ECU: 37 [optionalRequestParameters]
ECU -> Tester: 77 [optionalResponseParameters]

The optional parameters depend on the ECU programming profile. Some implementations may return transfer-related information; others may use a simple positive response.

A positive 0x77 response indicates that the transfer-exit request was accepted. It does not, by itself, prove that the complete firmware image has passed checksum, hash, signature, compatibility or boot validation.

10. Firmware integrity, authenticity and compatibility

After data transfer, the ECU may validate the received image before activation. The validation strategy depends on the ECU architecture and security concept.

Common checks include:

  • Checksum or CRC: detects certain accidental data corruption conditions.
  • Cryptographic hash: calculates a digest of the image or defined image region.
  • Digital signature: verifies that the image was authorized by a trusted signing entity.
  • Compatibility checks: verify hardware variant, ECU identity, software dependencies and memory layout.
  • Version and anti-rollback checks: prevent installation of an unsupported or prohibited older software version.

A checksum and a cryptographic signature solve different problems. A CRC can detect many transmission or storage errors, but it does not establish who created the firmware. A signature verification process can provide authenticity when trust anchors, keys, algorithms and verification procedures are correctly designed.

The validation routine, identifiers, data formats and failure behavior are ECU-specific. Do not assume that every ECU uses the same RoutineControl sub-function or validation algorithm.

11. ECU reset and application activation

After successful transfer and validation, the ECU may need to activate the new image. Depending on the design, activation can occur immediately, after a reset, after a power cycle or through a separate boot-management mechanism.

ECUReset (0x11) is commonly used to request a reset, but the reset type and permitted conditions are defined by the ECU specification.

A successful reset response is not proof that the new application has started correctly. After the ECU restarts, the tester should:

  1. Re-establish communication.
  2. Read software identification or version information.
  3. Confirm that the expected application is active.
  4. Check relevant DTCs and programming status.
  5. Verify required communication and application functions.
  6. Confirm that the ECU is in the intended operational state.

12. Failure handling and recovery

Programming failures can occur because of communication loss, power interruption, incorrect image selection, memory errors, invalid authorization, sequence errors or validation failures.

A recovery strategy should be designed before programming begins.

Common failure scenarios

FailurePossible causeEngineering response
Programming session rejectedPreconditions not satisfied or unsupported sessionCheck ECU state, session support and diagnostic specification
SecurityAccess rejectedIncorrect access level, invalid key or delay timerStop repeated attempts; follow authorized recovery and lockout rules
Erase routine failsInvalid memory range, alignment or voltage conditionPreserve response and trace; verify memory map and preconditions
RequestDownload rejectedUnsupported DFI/ALFI, address or sizeCheck image metadata and ECU programming configuration
TransferData rejectedIncorrect sequence, block length or dataPreserve trace and follow the ECU's defined retry/recovery procedure
Transfer timeoutBus disturbance, ECU reset or timing mismatchCheck transport trace, power and configured timing
TransferExit rejectedIncomplete or inconsistent transfer stateVerify all blocks and transfer state before retrying
Image validation failsCorrupted, incompatible or unauthorized imageDo not activate; use approved image and recovery process
ECU does not bootActivation, memory or boot validation failureUse the documented bootloader or service recovery procedure

Interrupted programming

If programming is interrupted, do not assume that the ECU can restart the transfer from the last acknowledged block. The bootloader may require a new programming session, a complete erase and download, a recovery image or a dedicated service procedure.

An A/B update design can retain a previously valid image while programming a second partition. A single-bank design may depend on a protected bootloader and an external recovery tool. The recovery mechanism must be validated for the target ECU.

13. Practical programming workflow

A robust programming tool should implement the following control flow:

1. Load the approved image and its metadata.
2. Verify target ECU, hardware variant and software compatibility.
3. Establish diagnostic communication.
4. Check programming preconditions.
5. Enter the required diagnostic session.
6. Perform authorized security access.
7. Execute memory preparation or erase routine.
8. RequestDownload and decode the accepted maximum block length.
9. Transfer blocks using the required sequence counter.
10. Handle responses, timeouts and defined retry behavior.
11. RequestTransferExit.
12. Run the required image verification routine.
13. Activate the image and reset the ECU as specified.
14. Reconnect and verify software identity and application health.
15. Archive the programming result and diagnostic evidence.

The tool should log timestamps, ECU identity, image identity, software versions, request/response payloads, block counters, transfer progress, negative responses and final verification results. Protect credentials and avoid logging secret key material.

14. Verification and failure-injection test strategy

A programming test plan should cover the nominal sequence and abnormal conditions. Test only on an approved bench, development ECU or controlled vehicle setup with a defined recovery method.

Test caseStimulusExpected verification
Programming sessionRequest supported programming sessionCorrect positive/negative response and timing
Security accessAuthorized and unauthorized test credentialsCorrect access decision and lockout behavior
Erase routineValid and invalid configured regionCorrect routine status and memory protection
RequestDownloadSupported and unsupported DFI/ALFI and address/sizeCorrect acceptance or rejection
Maximum block lengthTransfer at the accepted limitNo overflow; correct response handling
Sequence counterNormal increment and rollover boundaryCorrect sequence behavior
Transfer retryRepeat according to defined retry procedureECU and tester remain synchronized
Interrupted transferControlled communication interruptionDefined timeout and recovery behavior
Transfer exitComplete and incomplete transfer statesCorrect acceptance or rejection
Image integrityValid and deliberately corrupted test imageCorrect validation result
CompatibilityImage for a different approved test variantImage rejected before activation
Power interruptionControlled interruption at approved test stageRecovery behavior matches design
Post-reset checkECU reset after successful validationExpected software identity and application startup
RegressionRepeat programming on supported configurationRepeatable result and complete evidence

A test should have measurable acceptance criteria linked to requirements. Record the ECU hardware and software baseline, bootloader version, image hash, diagnostic configuration, test tool version and transport settings.

15. Common mistakes in ECU flashing

  • Using an image for the wrong ECU hardware or software variant.
  • Assuming a positive 0x74 response means programming is complete.
  • Ignoring the maximum block length returned by the ECU.
  • Incorrectly handling block sequence counter rollover.
  • Retrying a TransferData request without following the ECU's defined retry rules.
  • Treating TransferExit as proof of image authenticity.
  • Resetting the ECU before required verification has completed.
  • Erasing memory without confirming the target range and recovery plan.
  • Performing programming with unstable power or an unapproved communication setup.
  • Failing to archive the original diagnostic trace and image metadata.

16. Engineering checklist

Before programming:

  • Confirm ECU identity, hardware variant and software compatibility.
  • Confirm the approved firmware image and its integrity metadata.
  • Confirm the programming specification and applicable UDS edition.
  • Confirm stable power and communication setup.
  • Confirm memory layout, erase region and recovery method.
  • Confirm authorized security access and required credentials.
  • Confirm transfer timing and maximum block length handling.

During programming:

  • Record all diagnostic requests and responses.
  • Check each service response and negative response.
  • Respect the maximum accepted block length.
  • Track block sequence counters and transfer progress.
  • Follow the defined retry and timeout behavior.
  • Do not interrupt programming outside an approved test case.

After programming:

  • Confirm TransferExit response.
  • Complete checksum/hash/signature and compatibility checks.
  • Activate and reset the ECU according to the programming procedure.
  • Verify software identification and application startup.
  • Check DTCs and required ECU functions.
  • Archive logs, image hash, software versions and test evidence.

17. Check your understanding

  1. What is the purpose of RequestDownload (0x34)?
  2. What information does the ECU return in a positive 0x74 response?
  3. Why does TransferData (0x36) use a block sequence counter?
  4. What is the purpose of RequestTransferExit (0x37)?
  5. Why is a successful transfer not sufficient to prove firmware authenticity?
  6. What should a programming tool do after an interrupted transfer?
  7. Why must ECU software identity be checked after reset?

Answers

  1. It requests permission to download a defined data region to the ECU.
  2. It returns a length-format indicator and the maximum number of data bytes accepted in a TransferData request, according to the response format.
  3. It identifies the transfer block sequence and helps detect sequence inconsistencies.
  4. It terminates the active data transfer.
  5. Transfer completion does not establish that the image was signed by a trusted authority or is compatible with the target ECU.
  6. It should follow the ECU's documented recovery procedure rather than assuming it can resume from the last block.
  7. To confirm that the intended software image was activated and the ECU started the expected application.

Related UDS articles

References and further reading

Standards note: Confirm the ISO 14229 edition and project-specific programming profile applicable to the ECU under test. Existing ECU programs may be contractually based on earlier editions. The OEM/ECU programming specification determines supported services, memory regions, security mechanisms, timing and recovery behavior.