Skip to content

Development Tools MCUmgr Bootloader Management

Alex J Lennon edited this page Oct 10, 2025 · 2 revisions

MCUmgr Bootloader Management

⏱️ 15 minutes | Board: Edge EInk | Feature: Zephyr RTOS Power Controller

MCUmgr enables firmware updates and management of the MCXC143VFM power controller running Zephyr RTOS with MCUboot bootloader.


🎯 Quick Reference

Command Purpose Example
mcumgr-setup Configure connection mcumgr-setup /dev/ttyLP2 115200 pmu
mcumgr -c pmu image list Check firmware Shows current/pending images
mcumgr -c pmu image upload firmware.bin Update firmware Upload new firmware
mcumgr -c pmu reset Restart device Apply firmware update

📋 Prerequisites

Hardware Requirements

  • Board: imx93-jaguar-eink with MCXC143VFM power controller
  • Connection: UART via /dev/ttyLP2 at 115200 baud
  • Power: PMU must be running MCUboot bootloader

Software Requirements

  • MCUmgr BSP Feature: Automatically enabled on imx93-jaguar-eink
  • Serial Tools: screen, minicom (auto-installed)
  • Permissions: User must be in dialout group or use sudo

🚀 Quick Start

1. Verify MCUmgr Installation

# Check mcumgr is available
which mcumgr
mcumgr version

# Check PMU connection
ls -la /dev/ttyLP2

2. Configure Connection

# Set up connection to PMU
mcumgr-setup /dev/ttyLP2 115200 pmu

# Verify connection works
mcumgr -c pmu echo hello

3. Check Current Firmware

# List current firmware images
mcumgr -c pmu image list

# Check device info
mcumgr -c pmu taskstat

🔧 Firmware Update Workflow

Standard Update Process

# 1. Check current firmware
mcumgr -c pmu image list

# 2. Upload new firmware
mcumgr -c pmu image upload /path/to/firmware.signed.bin

# 3. Verify upload
mcumgr -c pmu image list

# 4. Test new firmware (optional - creates test slot)
mcumgr -c pmu image test <hash>

# 5. Confirm firmware (makes permanent)
mcumgr -c pmu image confirm <hash>

# 6. Reset to apply
mcumgr -c pmu reset

Emergency Recovery

# If PMU is unresponsive, try bootloader mode
# Hardware reset may be required

# Check if bootloader responds
mcumgr -c pmu echo test

# Upload recovery firmware
mcumgr -c pmu image upload recovery-firmware.signed.bin
mcumgr -c pmu reset

📊 Monitoring & Diagnostics

System Status

# Check memory usage
mcumgr -c pmu stat

# Monitor tasks
mcumgr -c pmu taskstat

# Check system uptime
mcumgr -c pmu echo uptime

Power Management Status

# Check battery level (if supported)
mcumgr -c pmu stat battery

# Monitor power states
mcumgr -c pmu stat power

🛠️ Advanced Configuration

Custom Connection Settings

# Different baud rate
mcumgr conn add pmu_fast type="serial" connstring="dev=/dev/ttyLP2,baud=921600"

# With timeout settings
mcumgr conn add pmu_slow type="serial" connstring="dev=/dev/ttyLP2,baud=115200,timeout=30"

Batch Operations

# Script multiple operations
#!/bin/bash
CONN="pmu"
mcumgr -c $CONN image list
mcumgr -c $CONN image upload "$1"
mcumgr -c $CONN image confirm
mcumgr -c $CONN reset

🔍 Troubleshooting

Connection Issues

# Check device permissions
ls -la /dev/ttyLP2
groups  # Should include 'dialout'

# Test raw serial connection
screen /dev/ttyLP2 115200

# Check for conflicts
lsof /dev/ttyLP2

Common Problems

Problem Cause Solution
Permission denied User not in dialout group sudo usermod -a -G dialout $USER
Device not found PMU not powered/connected Check hardware, power cycle
No response Wrong baud rate Try different rates: 9600, 38400, 115200
Upload fails Insufficient space Check mcumgr -c pmu stat
Bootloop Corrupted firmware Upload known-good firmware

Debug Mode

# Enable verbose logging
export MCUMGR_LOG_LEVEL=debug
mcumgr -c pmu image list

# Check serial traffic
sudo minicom -D /dev/ttyLP2 -b 115200

📚 Integration Examples

Automated Update Script

#!/bin/bash
# update-pmu-firmware.sh
set -e

FIRMWARE="$1"
CONN="pmu"

echo "Updating PMU firmware: $FIRMWARE"

# Verify connection
mcumgr -c $CONN echo test || {
    echo "PMU not responding"
    exit 1
}

# Upload and confirm
mcumgr -c $CONN image upload "$FIRMWARE"
mcumgr -c $CONN image confirm
mcumgr -c $CONN reset

echo "Update complete"

Development Workflow

# Build, sign, and update in one command
cd /path/to/zephyr/project
west build -b mcxc143vfm
west sign -t imgtool -- --key signing-key.pem
mcumgr -c pmu image upload build/zephyr/zephyr.signed.bin
mcumgr -c pmu reset

🔗 Related Documentation


📝 Technical Notes

MCUboot Configuration

  • Bootloader: MCUboot with UART serial recovery
  • Signing: ECDSA P256 signatures required
  • Slots: Dual-slot configuration for safe updates
  • Recovery: Hardware reset to bootloader mode

Security Considerations

  • Signed Images: All firmware must be properly signed
  • Secure Boot: ECDSA signature verification
  • Rollback Protection: Version-based rollback prevention
  • Debug Access: Limited in production builds

Performance Notes

  • Upload Speed: ~115200 baud (13KB/s theoretical)
  • Flash Time: ~30 seconds for typical firmware
  • Verification: Automatic CRC checking
  • Bootup Time: ~2-3 seconds after reset

💡 Pro Tip: Use mcumgr-setup for quick connection setup, and always verify firmware images with mcumgr -c pmu image list before and after updates.

Clone this wiki locally