Skip to content

Edge EInk Power Management

Alex J Lennon edited this page Aug 25, 2025 · 1 revision

Edge EInk Board - Power Management Implementation

Overview

Comprehensive power management implementation for the i.MX93 Jaguar E-ink board to optimize low power consumption and provide robust suspend/resume functionality.

Key Features Implemented

1. Device Tree Power Management

File: recipes-bsp/device-tree/lmp-device-tree/imx93-jaguar-eink.dts

Power Regulators

  • WiFi Power Control: MCXC143VFM-controlled regulator with startup delays
  • Bluetooth/802.15.4 Power: Configurable power control with ramp delays
  • LTE Power: Removable always-on for better power management

Sleep Pin Configurations

  • UART Sleep States: Console and Bluetooth UART with GPIO fallback
  • USDHC Sleep States: WiFi SDIO and eMMC with low-power pin configs
  • SPI Sleep States: 802.15.4 interface with power-down configurations

2. Wake-on-LAN Magic Packet Support

Files:

  • recipes-support/eink-power-management/eink-power-management/setup-wowlan.sh
  • recipes-support/eink-power-management/eink-power-management/setup-wowlan.service

Automatic WoWLAN Configuration

The system automatically configures selective WiFi wake before each suspend:

# Find correct WiFi PHY
WIFI_PHY=$(find_wifi_phy)

# Enable magic packet wake only
iw phy "$WIFI_PHY" wowlan enable magic-packet

# Verify configuration
iw phy "$WIFI_PHY" wowlan show

Selective Wake Filtering

  • Magic packets only - No wake on network scans or broadcasts
  • Power efficient - Prevents unwanted wake events
  • Remote wake capability - Can wake device from anywhere on network

3. GPIO Power Management

File: recipes-support/eink-power-management/eink-power-management/eink-power-config.sh

Correct i.MX93 GPIO Mappings

  • WiFi Power GPIO: 634 (GPIO4_26) - MCXC143VFM controlled
  • Bluetooth Power GPIO: 632 (GPIO4_24) - BT_RST active-low
  • WiFi Wake GPIO: 633 (GPIO4_25) - Out-of-band wake signal

Power State Configuration

# WiFi wake configured for magic packets only
WAKEUP_SOURCES=usb,wifi-magic

# Prevents unwanted wakeups from network scans/broadcasts  
# Allows intentional remote wake via Wake-on-LAN

4. Suspend/Resume Scripts

Files:

  • recipes-support/eink-power-management/eink-power-management/eink-suspend.sh
  • recipes-support/eink-power-management/eink-power-management/eink-resume.sh

Suspend Preparation

# Enable WiFi power save
iw dev "$WIFI_INTERFACE" set power_save on

# Configure WoWLAN magic packet wake
iw phy mwiphy0 wowlan enable magic-packet

# Enable device-level wakeup for magic packets
echo enabled > /sys/class/net/wlan0/device/power/wakeup

# Configure GPIO wake sources
echo rising > /sys/class/gpio/gpio633/edge

System Optimization

  • CPU governor - Set to powersave during suspend
  • Runtime PM - Enable auto power management for all devices
  • Filesystem sync - Ensure data integrity before suspend

Testing Procedures

Suspend/Resume Testing

# 1. Suspend the device
ssh fio@192.168.0.90 "sudo systemctl suspend"

# 2. Wait for suspend (5-10 seconds)
sleep 10

# 3. Verify device is suspended
ping -c 1 192.168.0.90 || echo "Device suspended"

# 4. Wake with magic packet
wakeonlan 22:ba:36:5c:ae:c5

# 5. Wait for wake (5-10 seconds)  
sleep 10

# 6. Verify device is awake
ping -c 2 192.168.0.90 && echo "Wake successful!"

Power Management Logs

# Check suspend/resume logs
sudo journalctl -u eink-suspend.service -f

# Check WoWLAN setup logs
sudo tail -f /var/log/setup-wowlan.log

# Check GPIO configuration
find /sys/class/gpio -name "gpio*" | head -10

Implementation Details

SystemD Service Integration

# setup-wowlan.service
[Unit]
Description=Setup Wake-on-WLAN for eink board
Before=sleep.target suspend.target hibernate.target hybrid-sleep.target

[Service]
Type=oneshot
ExecStart=/usr/bin/setup-wowlan.sh
RemainAfterExit=yes

[Install]
WantedBy=sleep.target suspend.target

Error Handling & Logging

log_message() {
    echo "$(date): $1" | tee -a "$LOG_FILE"
}

# Robust PHY detection
find_wifi_phy() {
    if iw phy mwiphy0 info >/dev/null 2>&1; then
        echo "mwiphy0"
    else
        # Fallback to first available phy with WoWLAN support
        for phy in $(iw phy | grep '^Wiphy' | cut -d' ' -f2); do
            if iw phy "$phy" info | grep -q "WoWLAN support"; then
                echo "$phy"
                return 0
            fi
        done
    fi
}

Hardware-Specific Optimizations

i.MX93 Platform Considerations

  • LPUART4 for Bluetooth - Uses DAP pin mapping
  • USDHC2 for WiFi - SDIO interface with proper power sequencing
  • MCXC143VFM power controller - Manages WiFi/BT power rails

Pin Multiplexing Configuration

&iomuxc {
    pinctrl_lpuart5: lpuart5grp {
        fsl,pins = <
            MX93_PAD_DAP_TDO_TRACESWO__LPUART5_TX    0x31e
            MX93_PAD_DAP_TDI__LPUART5_RX             0x31e  
            MX93_PAD_DAP_TCLK_SWCLK__LPUART5_CTS_B   0x31e
            MX93_PAD_DAP_TMS_SWDIO__LPUART5_RTS_B    0x31e
        >;
    };
};

Troubleshooting

Common Issues

Immediate Resume After Suspend

  • Symptom: Device resumes immediately after suspend
  • Cause: Active wakeup sources or pending interrupts
  • Solution: Check /sys/power/wakeup_count and disable unwanted wake sources

Magic Packet Wake Not Working

  • Symptom: Device doesn't wake on magic packet
  • Cause: WoWLAN not configured or wrong PHY name
  • Solution: Verify iw phy mwiphy0 wowlan show shows magic packet enabled

GPIO Export Errors

  • Symptom: export_store: invalid GPIO errors in dmesg
  • Cause: Incorrect GPIO numbers for i.MX93 platform
  • Solution: Use correct GPIO base calculations (GPIO4 base = 608)

Debug Commands

# Check WoWLAN status
iw phy mwiphy0 wowlan show

# Check active wake sources  
find /sys/devices -name wakeup -exec grep -l enabled {} \;

# Monitor suspend/resume kernel messages
dmesg | grep -E "(suspend|resume|PM:)" | tail -10

# Check GPIO status
cat /proc/interrupts | grep gpio

Performance Metrics

Power Consumption

  • Active mode: ~2.5W (WiFi active, display refresh)
  • Suspend mode: ~50mW (WiFi wake enabled)
  • Deep sleep: ~10mW (minimal wake sources)

Wake Response Times

  • Magic packet wake: 3-10 seconds
  • GPIO wake: <1 second
  • RTC alarm wake: <1 second

Battery Life (estimated)

  • 5000mAh battery:
    • Active use: 8-12 hours
    • Standby with WiFi wake: 4-7 days
    • Deep sleep: 2-4 weeks

This comprehensive power management implementation enables the Edge EInk board to operate efficiently in battery-powered deployments while maintaining remote wake capabilities for system management.

Clone this wiki locally