Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# add headers
$ echo ‘#include “Arduino.h”’ > blink.cpp
# add sketch
$ cat blink.ino >> blink.cpp
# add int main()
$ cat /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/main.cpp >> blink.cpp
# build binary
$ avr-g++ -x c++ -MMD -c -mmcu=atmega328p -Wall -DF_CPU=16000000L -DARDUINO=160 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/ -I/Applications/Arduino.app/Contents/Java//hardware/arduino/avr/variants/standard -Wall -Os blink.cpp
# add arduino core libraries
$ avr-ar rcs libcore.a hooks.o wiring.o wiring_digital.o
# create elf
$ avr-gcc -mmcu=atmega328p -Wl,–gc-sections -Os -o blink.elf blink.o libcore.a -lc -lm
# create hex
$ avr-objcopy -O ihex -R .eeprom blink.elf blink.hex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment