Problem
The Rust application currently depends on external shell scripts (xm125-control.sh and xm125-firmware-flash.sh) for GPIO control and firmware management operations. This creates several issues:
Current Dependencies
/usr/bin/xm125-control.sh - Required for bootloader mode switching and GPIO control
/usr/bin/xm125-firmware-flash.sh - Required for firmware flashing operations
stm32flash external binary - Required for actual firmware programming
Issues with Current Approach
- Deployment Complexity: Requires coordinating multiple files and ensuring correct installation paths
- Error Prone: Script availability, permissions, and path issues can cause failures
- Maintenance Overhead: Need to maintain both Rust code and shell scripts in sync
- Platform Dependency: Shell scripts may not work consistently across different embedded Linux distributions
- Security Concerns: External script execution introduces potential security vectors
- Testing Complexity: Harder to unit test functionality that depends on external scripts
Proposed Solution
Phase 1: Direct GPIO Control
- Implement native Rust GPIO control using
libgpiod or similar crate
- Replace shell script calls with direct GPIO manipulation
- Add proper error handling and validation
Phase 2: Native Firmware Management
- Implement I2C-based firmware flashing directly in Rust
- Remove dependency on
stm32flash where possible
- Add firmware verification and integrity checking
Phase 3: Cleanup
- Remove shell script dependencies from Yocto recipe
- Update documentation and deployment guides
- Add comprehensive testing for native implementations
Benefits
- Simplified Deployment: Single binary with all functionality
- Better Error Handling: Native Rust error types and messages
- Improved Testing: Unit testable GPIO and firmware operations
- Cross-Platform: Works consistently across different Linux distributions
- Security: No external script execution
- Performance: Direct system calls instead of shell process spawning
Implementation Notes
- Maintain backward compatibility during transition
- Add feature flags to switch between script-based and native implementations
- Ensure proper privilege handling for GPIO and I2C operations
- Add comprehensive documentation for GPIO pin mappings and hardware requirements
Acceptance Criteria
Priority
High - This affects deployment reliability and maintenance overhead
Problem
The Rust application currently depends on external shell scripts (
xm125-control.shandxm125-firmware-flash.sh) for GPIO control and firmware management operations. This creates several issues:Current Dependencies
/usr/bin/xm125-control.sh- Required for bootloader mode switching and GPIO control/usr/bin/xm125-firmware-flash.sh- Required for firmware flashing operationsstm32flashexternal binary - Required for actual firmware programmingIssues with Current Approach
Proposed Solution
Phase 1: Direct GPIO Control
libgpiodor similar cratePhase 2: Native Firmware Management
stm32flashwhere possiblePhase 3: Cleanup
Benefits
Implementation Notes
Acceptance Criteria
Priority
High - This affects deployment reliability and maintenance overhead