Created
December 27, 2011 17:20
-
-
Save AndrewRadev/1524438 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ARDUINO_PATH = '/usr/share/arduino/hardware/arduino/cores/arduino' | |
| VARIANTS_PATH = '/usr/share/arduino/hardware/arduino/variants/standard' | |
| MCU = 'atmega328p' | |
| F_CPU = 16000000 | |
| PORT = '/dev/ttyACM0' | |
| UPLOAD_RATE = 115200 | |
| CORE_SOURCES = %W{ | |
| #{ARDUINO_PATH}/wiring.c | |
| #{ARDUINO_PATH}/wiring_analog.c | |
| #{ARDUINO_PATH}/wiring_digital.c | |
| #{ARDUINO_PATH}/wiring_pulse.c | |
| #{ARDUINO_PATH}/wiring_shift.c | |
| #{ARDUINO_PATH}/WInterrupts.c | |
| #{ARDUINO_PATH}/HardwareSerial.cpp | |
| #{ARDUINO_PATH}/WMath.cpp | |
| #{ARDUINO_PATH}/WString.cpp | |
| #{ARDUINO_PATH}/Print.cpp | |
| }.join ' ' | |
| task :default do | |
| mkdir_p 'build' unless File.directory?('build') | |
| sh "avr-gcc -o build/main.elf -mmcu=#{MCU} -DF_CPU=#{F_CPU} #{CORE_SOURCES} main.cpp -I#{ARDUINO_PATH} -I#{VARIANTS_PATH}" | |
| sh 'avr-objcopy -O ihex -R .eeprom build/main.elf build/main.hex' | |
| # Hack for some USB 3.0 issues | |
| sh 'sudo modprobe -r xhci_hcd && sudo modprobe xhci_hcd' | |
| sleep 1 | |
| sh "avrdude -V -F -C /etc/avrdude.conf -p#{MCU} -P#{PORT} -carduino -b#{UPLOAD_RATE} -U flash:w:build/main.hex" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment