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

Linker Map Analysis: Finding ROM Consumers

Shellrom_analysis.sh
#!/bin/bash
# Identify top ROM consumers by BSW module
arm-none-eabi-nm --size-sort --print-size ECU_EPS.elf | tail -40

# Per-section breakdown
arm-none-eabi-size --format=sysv ECU_EPS.elf | sort -k2 -rn | head -30

# COM signal table is typically the #1 ROM consumer:
# _ZN3Com12signalTable_E   .rodata   0x0800A000   0x4C00  (19.2 KB)
# Com_PBcfg_SignalInit      .rodata   0x0800F000   0x3800  (14.0 KB)
# OS stack allocations:
# OsStack_Task_1ms          .bss      0x20004000   0x0800   (2.0 KB)

# Python map file parser for CI budget gate:
python3 ci_map_budget.py --elf ECU_EPS.elf \
    --budget "COM_PARTITION:65536" \
    --budget "OS_STACKS:16384" \
    --fail-on-exceed
Typical Top ROM ConsumerSize on 256KB ECUOptimization Lever
COM signal init tables18–25 KBDisable unused PDUs: ComIPduEnabled=FALSE
OS task stacks12–20 KBRight-size with paint-pattern watermark
DEM event descriptors8–12 KBRemove events for unsupported HW variants
DCM service table6–10 KBDisable unused UDS services per variant
PduR routing tables4–8 KBPost-build config moves these to PBcfg section

BSW Variant Trimming

XMLCom_Variant_Trim.arxml


  LIN_SpeedPDU
  FALSE
  




  LIN_BusOff_Event
  FALSE
  

💡 Measured Savings

On a typical body ECU with 3 CAN buses and 1 LIN bus, disabling the two unused CAN PDU groups (ComIPduEnabled=FALSE for 40 PDUs) and 15 unused DEM events saved 22 KB Flash and 1.2 KB RAM. Run a build comparison with arm-none-eabi-size before and after each change to confirm actual savings before committing to the variant config.

Post-Build Configuration for ROM Flexibility

Pre-Compile vs Post-Build ROM Split
  Flash Layout:
  ┌────────────────────────────────────┐  ← 0x08000000
  │ BSW pre-compile code + data        │  (recompile required to change)
  │ RTE, SWC code                      │
  ├────────────────────────────────────┤  ← 0x0807C000
  │ POST-BUILD CONFIG SECTION          │  (updatable without full recompile)
  │ Com_PBcfg.c  (signal tables)       │
  │ PduR_PBcfg.c (routing tables)      │
  │ NvM_PBcfg.c  (block descriptors)   │
  └────────────────────────────────────┘  ← 0x08080000

  Boot loader writes new PBcfg.bin to post-build section
  → BSW calls Xxx_Init(ConfigPtr) pointing to new PBcfg
  → No BSW recompile needed for COM signal or PduR route changes
Config PhaseExample ContentCan Flash Without Recompile?
Pre-compile (Xxx_Cfg.h)#define COM_SIGNAL_COUNT 120No — header change triggers full recompile
Link-time (Xxx_Lcfg.c)Function pointer callback tablesNo — symbol references resolved at link time
Post-build (Xxx_PBcfg.c)COM signal byte positions, PduR routing tableYes — PBcfg.bin is a self-contained binary

Stack Right-Sizing with Paint-Pattern Watermark

TRACE32stack_watermark.cmm
/* TRACE32 stack watermark check after 30-minute soak test */
TASK.ORTI "output/OsOrti_Core0.orti"

/* Check all tasks on Core 0 */
TASK.STACK.LIST

/* Expected output:
   Task Name              | Stack Size | Used | Watermark | Margin
   Task_SafetyCtrl_10ms   |   2048 B   |  920 | 45%       | 55%
   Task_BSW_100ms         |   1024 B   |  380 | 37%       | 63%
   Task_Init              |   4096 B   | 1840 | 45%       | 55%

   Optimization: Task_BSW_100ms used 380/1024 = 37%
   Safe new size: 380 * 1.20 = 456 → round up to 512 bytes
   Saving: 512 bytes per task */

/* After resizing: rebuild + rerun soak test to reconfirm 

Summary

ROM/RAM optimization is a four-step process: map file analysis identifies the biggest consumers, BSW variant trimming removes unused features, post-build config separation enables field updates without full reflash, and stack watermark right-sizing reclaims over-allocated stack. Document all savings with before/after map file comparisons — undocumented optimizations are routinely reverted by the next developer who sees the tight memory budget and assumes it is a mistake.

🔬 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: ASIL-D ECU ConfigurationNext →Startup Time Optimization