Software Maintenance

1

A Critical Engineering Discipline

For Graduate Electrical Engineering Students

Why this matters for EEs: Modern electrical systems are increasingly software-defined. Maintenance ensures long-term reliability, safety, and adaptability of embedded systems, power electronics, and IoT devices.

What is Software Maintenance?

2

Definition: The modification of a software product after delivery to correct faults, improve performance, or adapt to a changed environment (IEEE 14764).

EE Perspective: For embedded systems, maintenance includes updating firmware, adapting to new hardware components, and ensuring real-time performance over the product lifecycle.

Key Facts:

  • Typically consumes 60-75% of total software lifecycle costs
  • More critical for long-lived systems (industrial controls, power grids, medical devices)
  • Requires understanding of both software AND hardware interactions

Software Lifecycle Cost Distribution

Maintenance: 65%

Development: 35%

Why Software Maintenance Matters

3
"The bitterness of poor quality remains long after the sweetness of meeting the schedule is forgotten." - Anonymous

Safety & Reliability

Critical for medical devices, automotive systems, aerospace, and power grid controls where failures can have catastrophic consequences.

Hardware Evolution

Components become obsolete. Software must adapt to new sensors, processors, and communication protocols.

Economic Factors

Maintenance extends product lifespan, protects investment, and reduces total cost of ownership.

Security

New vulnerabilities discovered post-deployment require patches, especially in connected IoT devices.

Four Types of Software Maintenance

4

Corrective Maintenance

Fixing defects and bugs discovered after deployment. For EEs: This could be a timing bug in a motor controller or an ADC calibration issue.

Adaptive Maintenance

Modifying software to work in a changed environment. For EEs: Porting firmware to a new microcontroller or updating communication protocols.

Perfective Maintenance

Improving performance, usability, or adding minor enhancements. For EEs: Optimizing power consumption algorithm or improving sensor fusion.

Preventive Maintenance

Making changes to prevent future problems. For EEs: Refactoring code for better testability or adding watchdog timers for reliability.

The Software Maintenance Process

5

1. Problem Identification

2. Analysis

3. Design & Implementation

4. Testing

5. Delivery

6. Feedback

EE-Specific Challenge: Hardware-Software Co-validation

In embedded systems, changes must be validated on actual hardware, not just in simulation. This requires:

  • Hardware-in-the-loop (HIL) testing
  • Checking for timing constraints and real-time requirements
  • Verifying power consumption changes
  • Ensuring EMI/EMC compliance is not affected

Unique Challenges in Embedded Systems Maintenance

6

Technical Challenges

  • Limited Resources: Memory, processing power constraints
  • Real-time Requirements: Timing constraints are critical
  • Hardware Dependency: Software tightly coupled to specific hardware
  • Legacy Systems: Decades-old code with poor documentation

Management Challenges

  • Knowledge Loss: Original developers often unavailable
  • Cost Estimation: Difficult to predict maintenance effort
  • Regulatory Compliance: Medical, automotive, aerospace standards
  • Update Distribution: Deploying updates to fielded devices

Case Example: Automotive ECU firmware update requires validation across temperature ranges (-40°C to 125°C), voltage fluctuations, and EMI conditions before deployment via OTA updates.

Software Maintenance Models

7

Quick-Fix Model

Apply patches as problems arise. Common in early-stage products or prototypes.

// Quick fix for ADC overflow issue
if (adc_value > 4095) adc_value = 4095; // Temporary fix

Iterative Enhancement Model

Treat maintenance as mini-development cycles. More structured approach.

Plan → Analyze → Design → Test → Deploy

Reuse-Oriented Model

Leverage existing components, libraries, and frameworks to reduce maintenance effort. Critical for embedded systems with hardware abstraction layers (HAL).

Benefits for EEs:

  • Consistent hardware interfaces
  • Reduced testing burden
  • Easier migration to new hardware

Examples:

  • ARM CMSIS for Cortex-M processors
  • ESP-IDF for ESP32 chips
  • Vendor-specific HALs

Reverse Engineering & Re-engineering

8

Often necessary when maintaining legacy systems with poor or no documentation.

Reverse Engineering

Understanding existing code structure and functionality.

  • Analyzing assembly/machine code
  • Creating call graphs and flowcharts
  • Documenting hardware-software interfaces
  • Using tools: IDA Pro, Ghidra, JTAG debuggers

Re-engineering

Restructuring code to improve maintainability.

  • Refactoring for clarity
  • Migrating to new language/framework
  • Adding modularity and documentation
  • Preserving external behavior

EE Example: Legacy Motor Controller

Original: Assembly code for 8-bit microcontroller with direct register manipulation

Re-engineered: C code with hardware abstraction layer, allowing migration to 32-bit ARM processor

Benefit: Future maintenance becomes easier, performance improves, new features can be added

Essential Maintenance Tools

9

Version Control

Git, SVN - Essential for tracking changes and collaboration

Debuggers

GDB, JTAG debuggers, logic analyzers for hardware-software issues

Testing Frameworks

Unity, CppUTest for embedded C/C++ code

Static Analysis

PC-lint, Coverity, SonarQube for code quality metrics

Documentation

Doxygen for automatic documentation generation

CI/CD

Jenkins, GitLab CI for automated builds and tests

EE-Specific Tool: Hardware-in-the-Loop (HIL) simulators allow testing firmware changes against simulated hardware, reducing risk before deploying to physical devices.

Case Study: Power Management System

10

System Overview

Function: Battery management system for electric vehicle

Hardware: ARM Cortex-M4, voltage/current sensors, temperature sensors

Age: 5 years in production

Issue: Need to update battery charging algorithm based on new research

Maintenance Challenges

  • Safety-critical system (risk of fire/explosion)
  • Limited flash memory for new algorithm
  • Real-time constraints for cell balancing
  • Regulatory certification required for changes

Maintenance Approach

Analysis Phase

Study existing code, identify memory constraints

Implementation

Optimize algorithm for memory, maintain safety margins

Validation

HIL testing, thermal chamber testing, certification

Key Takeaway: Maintenance of safety-critical embedded systems requires rigorous process, extensive testing, and often regulatory re-certification.

Measuring Maintenance Effectiveness

11

Metrics help quantify maintenance effort and quality:

Mean Time To Repair (MTTR)

Average time to fix a reported defect

Target: < 4 hours for critical defects

Code Churn

Percentage of code modified during maintenance

High churn indicates instability

Defect Density

Defects per thousand lines of code (KLOC)

Industry avg: 0.5-2 defects/KLOC

Customer Satisfaction

User feedback on maintenance responsiveness

CSAT Score > 4.0/5.0

EE-Specific Metric: Mean Time Between Failures (MTBF)

For embedded hardware-software systems, MTBF considers both software stability and hardware reliability. Maintenance activities should improve or maintain MTBF.

Formula: MTBF = Total operating time / Number of failures

Best Practices in Software Maintenance

12

During Development

  • Write maintainable code: Follow coding standards, add comments
  • Design for change: Use modular architecture, hardware abstraction
  • Create thorough documentation: APIs, hardware interfaces, design decisions
  • Implement automated testing: Unit tests, integration tests, HIL tests

During Maintenance

  • Prioritize changes: Safety-critical fixes first
  • Maintain backward compatibility: When possible
  • Update documentation: Keep it synchronized with code
  • Use version control: For all changes, with meaningful commit messages

EE-Specific Recommendations

Hardware Abstraction Layer (HAL): Isolate hardware-specific code to ease migration to new components.

// HAL function for ADC reading
uint16_t hal_read_adc(adc_channel_t channel) {
  // Implementation for specific MCU
}

Configuration Management: Track hardware versions alongside software versions.

Safe Update Mechanisms: Implement bootloaders with rollback capability for field updates.

Factors Affecting Maintenance Cost

13
Maintenance Cost Drivers
Application Type
Safety-critical > Business > Personal
Staff Experience
Domain knowledge reduces cost
Code Quality
Well-structured code is cheaper to maintain
Hardware Dependencies
Tight coupling increases maintenance cost
Documentation
Good docs reduce onboarding time

Cost Reduction Strategies for Embedded Systems

Modular Design

Isolate hardware-dependent code to minimize impact of hardware changes.

Comprehensive Testing

Invest in automated test suites to catch regressions early.

Knowledge Management

Maintain institutional knowledge through documentation and mentoring.

Tool Investment

Use static analysis, debuggers, and simulators to improve efficiency.

Future Trends in Software Maintenance

14

AI-Assisted Maintenance

Machine learning algorithms can predict defect-prone code, suggest fixes, and automate code refactoring.

EE Impact: AI could analyze hardware-software interaction patterns to predict failures.

OTA Updates

Over-the-air updates becoming standard for IoT and automotive systems, changing maintenance delivery.

EE Impact: Requires secure bootloaders, delta updates, and rollback capabilities.

Containerization

Embedded Linux systems using containers for isolated, reproducible software deployments.

EE Impact: Easier dependency management and safer updates on edge devices.

Digital Twins for Maintenance

Virtual replicas of physical systems allow testing maintenance changes in simulation before deploying to hardware.

Benefits:

  • Test firmware updates against simulated hardware
  • Predict system behavior under various conditions
  • Reduce physical testing costs
  • Enable predictive maintenance

Physical System ↔ Digital Twin

Key Takeaways

15
Software maintenance consumes the majority of software lifecycle costs
For EEs, maintenance involves both software AND hardware considerations
Design for maintainability from the start reduces long-term costs
Tools, processes, and documentation are critical for effective maintenance

Maintenance is not an afterthought
It's a core engineering discipline

Conclusion & Further Resources

16

Thank You!

Questions & Discussion

Further Reading & Resources

Books

  • Software Maintenance: Concepts and Practice
  • Embedded Software Development for Safety-Critical Systems
  • The Art of Software Maintenance

Standards

  • IEEE 14764: Software Maintenance
  • IEC 61508: Functional Safety
  • ISO/IEC 12207: Software lifecycle processes

Contact

For further questions: software.maintenance@eeuniversity.edu