Arduino Uno
dependencies
pkgsCross.avr.stdenv.mkDerivation {
# ...
nativeBuildInputs = []; # packages executed by host
buildInputs = []; # packages built into target
# ...
}
CC=avr-gcc
, using in a Makefile
:
%.elf: %.c
$(CC) -DF_CPU=16000000UL -mmcu=atmega328p $^ -o $@
avr-objcopy
,
%.hex: %.elf
$(OBJCOPY) -O ihex -R .eeprom $^ $@
flashing
a hex file withavrdude
$ avrdude -F -V -c arduino -p ATMEGA328P -P $TTY -b $BAUD -U flash:w:$FILE.hex
TTY=/dev/ttyACM0
, BAUD=115200
.
code sample
#include <avr/io.h>
#include <util/delay.h>
int main (void) {
DDRB |= _BV(DDB5);
while (1) {
PORTB |= _BV(PORTB5);
_delay_ms(1000);
PORTB &= ~_BV(PORTB5);
_delay_ms(1000);
}
}
emulation
withsimavr
$ simavr --mcu atmega328p --freq 16000000 $FILE.elf