Example by docs
- Install gcc, avr-gcc, avr-objcopy, avrdude
- Use updaload.sh
| #include <Arduino.h> | |
| const int delayTimeout = 100; | |
| const int pinLed = 13; | |
| void setup() { | |
| pinMode(pinLed, OUTPUT); | |
| } | |
| void loop() { | |
| digitalWrite(pinLed, HIGH); | |
| delay(delayTimeout); | |
| digitalWrite(pinLed, LOW); | |
| delay(delayTimeout); | |
| } | |
| int main(void) { | |
| init(); | |
| #if defined(USBCON) | |
| USBDEVICE.attach(); | |
| #endif | |
| setup(); | |
| for (;;) { | |
| loop(); | |
| if (serialEventRun) serialEventRun(); | |
| } | |
| return 0; | |
| } |
| #!bin/sh | |
| SOURCE=main.cpp | |
| OBJ=main.o | |
| OUTPUT=main | |
| LOAD=main.hex | |
| PORT=/dev/ttyACM0 | |
| SPEED=115200 | |
| avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o $OBJ $SOURCE | |
| avr-gcc -mmcu=atmega328p $OBJ -o $OUTPUT | |
| avr-objcopy -O ihex -R .eeprom $OUTPUT $LOAD | |
| avrdude -F -V -c arduino -p ATMEGA328P -P $PORT -b $SPEED -U flash:w:$LOAD |