Home Learning Paths ECU Lab Assessments Interview Preparation Arena Pricing Log In Sign Up

XCP Master/Slave Model

XCP (Universal Measurement and Calibration Protocol) is a strictly master/slave protocol. The calibration tool (INCA, CANape) is always the master and initiates every transaction. The ECU is the slave and responds — it never sends data unsolicited, except for pre-configured DAQ packets which the master has set up and armed.

XCP Master/Slave Communication
  CANape / INCA (Master)           ECU (Slave)
  ──────────────────────────────────────────────
  CMD: CONNECT (0xFE) ──────────► RESPONSE: 0xFF (positive)
  CMD: GET_STATUS (0xFB) ────────► RESPONSE: session_status bytes
  CMD: SET_MTA (0xF1) ───────────► RESPONSE: 0xFF
  CMD: UPLOAD (0xF5) ────────────► RESPONSE: 0xFF + data bytes
  CMD: DOWNLOAD (0xF6) ──────────► RESPONSE: 0xFF
  CMD: SET_CAL_PAGE (0xEB) ──────► RESPONSE: 0xFF
  CMD: START_STOP_DAQ (0xDE) ────► RESPONSE: 0xFF
       (ECU begins streaming DAQ packets)
  DAQ packet ◄──────────────────── ECU sends at configured rate
  DAQ packet ◄──────────────────── (unsolicited after START_STOP)
  CMD: DISCONNECT (0xFC) ────────► RESPONSE: 0xFF

Packet Structure: CMD, Response, Error

Byte PositionCMD PacketPositive ResponseError Response (0xFE)
Byte 0CMD code (e.g., 0xF6=DOWNLOAD)0xFF (positive acknowledgement)0xFE (error indicator)
Byte 1Counter (optional, transport-specific)Counter echoError code (e.g., 0x29=ACCESS_LOCKED)
Bytes 2-7Command parametersResponse dataAdditional error info
XCP Error CodeHexMeaning
ERR_CMD_SYNCH0x00Command not synchronised — resend
ERR_CMD_BUSY0x10Slave is busy processing previous command
ERR_DAQ_ACTIVE0x11DAQ running — cannot execute this command during DAQ
ERR_MEMORY_OVERFLOW0x12Memory allocation failed for DAQ
ERR_ACCESS_LOCKED0x29Seed/key authentication required — unlock first
ERR_PAGE_NOT_VALID0x26Requested page does not exist in segment
ERR_OUT_OF_RANGE0x22Parameter value outside valid range

Core Command Sequence: Full Calibration Session

Hexfull_session_trace.txt
/* Complete XCP calibration session command flow */

/* 1. Connect */
Tx: FE 00 00 00 00 00 00 00  /* CONNECT mode=normal */
Rx: FF 00 00 00 01 01 08 08  /* OK: MAX_CTO=8, MAX_DTO=8 */

/* 2. Get comm mode (check block transfer support) */
Tx: FB 00 00 00 00 00 00 00  /* GET_COMM_MODE_INFO */
Rx: FF 00 00 00 00 00 00 00  /* session=ready */

/* 3. Set address for UPLOAD read */
Tx: F1 00 00 00 00 10 00 20  /* SET_MTA: ext=0, addr=0x20001000 */
Rx: FF 00 00 00 00 00 00 00

/* 4. Upload 2 bytes (read IDLE_RPM_TARGET) */
Tx: F5 02 00 00 00 00 00 00  /* UPLOAD 2 bytes */
Rx: FF 20 03 00 00 00 00 00  /* data = 0x0320 = 800 rpm */

/* 5. Set MTA for DOWNLOAD */
Tx: F1 00 00 00 00 10 00 20  /* SET_MTA: addr=0x20001000 */
Rx: FF 00 00 00 00 00 00 00

/* 6. Download new value = 850 (0x0352) */
Tx: F6 02 52 03 00 00 00 00  /* DOWNLOAD 2 bytes: 0x0352 */
Rx: FF 00 00 00 00 00 00 00

/* 7. Switch active page to working (RAM) */
Tx: EB 00 00 00 00 00 00 00  /* SET_CAL_PAGE: seg=0, page=0(working), mode=ECU+XCP */
Rx: FF 00 00 00 00 00 00 00

/* 8. Copy working to reference (Flash write) */
Tx: EC 00 00 01 00 00 00 00  /* COPY_CAL_PAGE: src=0(working), dst=1(reference) */
Rx: FF 00 00 00 00 00 00 00  /* (ECU flash write: ~100ms) */

/* 9. Disconnect */
Tx: FC 00 00 00 00 00 00 00
Rx: FF 00 00 00 00 00 00 00

Address Extension: Memory Space Mapping

Address Extension ValueMemory SpaceTypical Use
0x00Flash (program memory)Read calibration reference page from Flash
0x01SRAM (data memory)Read/write working page in RAM — most common
0x02Peripheral registersDirect peripheral access (rarely used)
0x03External flash (SPI)External calibration data store on ECU board

💡 ECU-Specific Extension Values

Address extension values and their memory space mapping are ECU-specific and defined in the A2L IF_DATA section. There is no universal standard for which extension maps to which space — always consult the A2L and the ECU software integration spec. A wrong extension value causes writes to go to the wrong memory space, producing no immediate error but having no effect on the parameter being targeted.

Summary

XCP is a command/response protocol where every transaction is tool-initiated. The six essential commands are CONNECT, SET_MTA, UPLOAD, DOWNLOAD, SET_CAL_PAGE, and COPY_CAL_PAGE. Error code 0x29 (ACCESS_LOCKED) is the most common production ECU issue — it requires a seed/key unlock sequence before calibration access is granted. Trace the XCP packet stream in INCA or CANape's XCP monitor window to diagnose any connection issue.

🔬 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

  1. 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'.
  2. 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.
  3. 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.
  4. 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.

← PreviousHands-On: First Calibration SessionNext →XCP on CAN, Ethernet & SPI