Rust-based firmware for the MikroElektronika BigAVR2 development board featuring the ATmega128 microcontroller.
- MikroElektronika BigAVR2 board
- ATmega128 running at 16MHz
- USB-UART adapter for programming
- Debian 12 (or compatible) development system
- Rust nightly toolchain
- AVR-GCC toolchain
- AVRDUDE for flashing
- Install system dependencies:
sudo apt update
sudo apt install avr-gcc gcc-avr avr-libc avrdude
- Setup Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup default nightly
rustup target add avr-atmega128
- Build the project:
cargo build --release --target avr-atmega128.json
- Flash to board (assuming USB-UART on /dev/ttyUSB0):
avrdude -p m128 -c arduino -P /dev/ttyUSB0 -b 115200 -U flash:w:target/avr-atmega128/release/atmega128_firmware.elf
/src
/drivers → Board-specific drivers
/hal → Hardware abstraction layer
/application → Application logic
/rtos → Real-time task scheduler
/config → Build configuration
/tests → Hardware-in-loop tests
/hw → Hardware documentation
/scripts → Build and flash utilities
This project uses unsafe
Rust in the following contexts:
- Direct hardware register access in HAL layer
- Interrupt handlers
- Critical sections for atomic operations
All unsafe blocks are carefully documented and encapsulated behind safe abstractions.
The firmware implements several power-saving features:
- Sleep modes (Idle, Power-Down)
- Peripheral power control
- Clock gating
- Uses zero-cost abstractions for HAL implementation
- Implements cycle-accurate timing using direct register access
- Defensive programming with Result types for error handling
- Static memory allocation only (#![no_std])
- Connect JTAG debugger
- Use OpenOCD for debugging session:
openocd -f interface/jtagkey.cfg -f target/atmega128.cfg
MIT License - See LICENSE file for details
- ISR latency needs optimization in timer-based operations
- Power consumption in sleep mode higher than expected
- UART baud rate drift at high speeds
- Fork the repository
- Create feature branch
- Commit changes
- Open pull request
Please follow Rust style guidelines and document unsafe blocks.