| NRC | Hex | Service Context | Recovery Action |
|---|---|---|---|
| serviceNotSupported | 0x11 | Service not implemented in this session | Check session; retry in correct session |
| subFunctionNotSupported | 0x12 | Unknown session ID / routine ID | Verify sub-function value |
| incorrectMessageLengthOrInvalidFormat | 0x13 | Request too short or malformed | Check request format against spec |
| conditionsNotCorrect | 0x22 | Pre-condition failed (voltage, speed, session) | Resolve pre-condition; retry |
| requestSequenceError | 0x24 | Wrong service order (e.g., 0x36 before 0x34) | Re-start from RequestDownload |
| requestOutOfRange | 0x31 | Address not in programmable region | Verify address in RequestDownload |
| securityAccessDenied | 0x33 | Service requires higher security level | Perform SecurityAccess first |
| invalidKey | 0x35 | Wrong key in SecurityAccess | Recompute key; check tester algorithm |
| exceededNumberOfAttempts | 0x36 | 5 wrong keys | Wait 10 minutes; restart session |
| requiredTimeDelayNotExpired | 0x37 | In lockout period | Wait for lockout to expire |
| uploadDownloadNotAccepted | 0x72 | Flash write/erase error | Check flash health; retry erase |
| wrongBlockSequenceCounter | 0x73 | Block counter mismatch | Re-start from RequestDownload |
| responsePending | 0x78 | Long operation in progress | Wait; ECU will respond when done |
NRC Reference for Bootloader Services
Power Loss During Programming: Recovery
Scenario 1: Power loss during ERASE (before download starts) State: Application region partially erased Boot: App_IsValid() = FALSE (magic/CRC invalid after partial erase) PBL: Enters reprogramming mode automatically (no valid app) Recovery: Tester reconnects → erase again → download → check → reset Result: Full recovery — PBL is always present Scenario 2: Power loss during DOWNLOAD (mid-transfer) State: Some blocks written; rest unprogrammed (0xFF or partial) Boot: App_IsValid() = FALSE (CRC check fails) PBL: Enters reprogramming mode Recovery: Tester: erase → full download → check → reset Result: Full recovery Scenario 3: Power loss during CHECKSUM VERIFY (after download, before flag) State: All blocks written; boot flag NOT yet set; CRC stored in header Boot: App_IsValid() = MAY PASS (if header was written before power loss) PBL: May jump to app (if valid) or reprog mode (if not) Recovery: If app valid: boots normally. If not: tester re-downloads. Result: Full recovery in both cases KEY: PBL hardware protection ensures recovery is ALWAYS possible The only unrecoverable scenario: PBL flash sector damaged (hardware fault)
DEM Integration for Programming Events
/* DEM events for programming failures: required for field diagnostics */
/* OEM can read DTCs after failed OTA update to determine root cause */
#include "Dem.h"
/* Programming failure DTC table */
#define DEM_EVENT_PROG_VOLTAGE_LOW 0x0001u /* battery < 11.5V during flash */
#define DEM_EVENT_PROG_ERASE_FAILED 0x0002u /* flash erase returned error */
#define DEM_EVENT_PROG_WRITE_FAILED 0x0003u /* flash write returned error */
#define DEM_EVENT_PROG_CRC_MISMATCH 0x0004u /* CRC verification failed */
#define DEM_EVENT_PROG_SIG_INVALID 0x0005u /* signature verification failed */
#define DEM_EVENT_PROG_ROLLBACK_BLOCK 0x0006u /* anti-rollback blocked update */
#define DEM_EVENT_PROG_SUCCESS 0x0007u /* programming completed successfully */
void Programming_ReportResult(Std_ReturnType result, uint8_t failure_code)
{
if (result == E_OK) {
Dem_ReportErrorStatus(DEM_EVENT_PROG_SUCCESS, DEM_EVENT_STATUS_PASSED);
/* Store programming fingerprint: timestamp, tester serial, SW version */
Programming_StoreFingerprint();
} else {
Dem_ReportErrorStatus(DEM_EVENT_PROG_SUCCESS, DEM_EVENT_STATUS_FAILED);
switch (failure_code) {
case 0x01u: Dem_ReportErrorStatus(DEM_EVENT_PROG_ERASE_FAILED, DEM_EVENT_STATUS_FAILED); break;
case 0x02u: Dem_ReportErrorStatus(DEM_EVENT_PROG_WRITE_FAILED, DEM_EVENT_STATUS_FAILED); break;
case 0x03u: Dem_ReportErrorStatus(DEM_EVENT_PROG_CRC_MISMATCH, DEM_EVENT_STATUS_FAILED); break;
case 0x04u: Dem_ReportErrorStatus(DEM_EVENT_PROG_SIG_INVALID, DEM_EVENT_STATUS_FAILED); break;
}
}
}Summary
NRC error codes are the diagnostic language of UDS — a tester that receives NRC 0x72 (uploadDownloadNotAccepted) during TransferData knows that the flash hardware reported an error, which might indicate a bad flash sector requiring ECU replacement. Power loss during programming is handled by the PBL's always-present fallback: since the PBL can never be erased, there is always a recovery path to re-enter reprogramming mode. DEM integration for programming events is essential for production quality monitoring — OEM quality teams track programming failure rates by DTC to identify systemic issues with OTA delivery, voltage management, or flash component quality.
🔬 Deep Dive — Core Concepts Expanded
This section builds on the foundational concepts covered above with additional technical depth, edge cases, and configuration nuances that separate competent engineers from experts. When working on production ECU projects, the details covered here are the ones most commonly responsible for integration delays and late-phase defects.
Key principles to reinforce:
- Configuration over coding: In AUTOSAR and automotive middleware environments, correctness is largely determined by ARXML configuration, not application code. A correctly implemented algorithm can produce wrong results due to a single misconfigured parameter.
- Traceability as a first-class concern: Every configuration decision should be traceable to a requirement, safety goal, or architecture decision. Undocumented configuration choices are a common source of regression defects when ECUs are updated.
- Cross-module dependencies: In tightly integrated automotive software stacks, changing one module's configuration often requires corresponding updates in dependent modules. Always perform a dependency impact analysis before submitting configuration changes.
🏭 How This Topic Appears in Production Projects
- Project integration phase: The concepts covered in this lesson are most commonly encountered during ECU integration testing — when multiple software components from different teams are combined for the first time. Issues that were invisible in unit tests frequently surface at this stage.
- Supplier/OEM interface: This is a topic that frequently appears in technical discussions between Tier-1 ECU suppliers and OEM system integrators. Engineers who can speak fluently about these details earn credibility and are often brought into critical design review meetings.
- Automotive tool ecosystem: Vector CANoe/CANalyzer, dSPACE tools, and ETAS INCA are the standard tools used to validate and measure the correct behaviour of the systems described in this lesson. Familiarity with these tools alongside the conceptual knowledge dramatically accelerates debugging in real projects.
⚠️ Common Mistakes and How to Avoid Them
- Assuming default configuration is correct: Automotive software tools ship with default configurations that are designed to compile and link, not to meet project-specific requirements. Every configuration parameter needs to be consciously set. 'It compiled' is not the same as 'it is correctly configured'.
- Skipping documentation of configuration rationale: In a 3-year ECU project with team turnover, undocumented configuration choices become tribal knowledge that disappears when engineers leave. Document why a parameter is set to a specific value, not just what it is set to.
- Testing only the happy path: Automotive ECUs must behave correctly under fault conditions, voltage variations, and communication errors. Always test the error handling paths as rigorously as the nominal operation. Many production escapes originate in untested error branches.
- Version mismatches between teams: In a multi-team project, the BSW team, SWC team, and system integration team may use different versions of the same ARXML file. Version management of all ARXML files in a shared repository is mandatory, not optional.
📊 Industry Note
Engineers who master both the theoretical concepts and the practical toolchain skills covered in this course are among the most sought-after professionals in the automotive software industry. The combination of AUTOSAR standards knowledge, safety engineering understanding, and hands-on configuration experience commands premium salaries at OEMs and Tier-1 suppliers globally.