├── crouse-of-the-hedospace ├── licence.txt ├── examples │ ├── Blink │ │ ├── Makefile │ │ └── Blink.ino │ ├── Fade │ │ ├── Makefile │ │ └── Fade.ino │ ├── toneMelody │ │ ├── Makefile │ │ ├── toneMelody.ino │ │ └── pitches.h │ ├── AnalogInOutSerial │ │ ├── Makefile │ │ └── AnalogInOutSerial.ino │ ├── BlinkTeensy │ │ ├── Makefile │ │ └── Blink.ino │ ├── BlinkWithoutDelay │ │ ├── Makefile │ │ └── BlinkWithoutDelay.ino │ ├── BlinkChipKIT │ │ ├── Makefile │ │ └── BlinkChipKIT.pde │ ├── HelloWorld │ │ ├── Makefile │ │ └── HelloWorld.ino │ ├── BlinkOpenCR │ │ ├── Makefile │ │ └── BlinkOpenCR.ino │ ├── SerialPrint │ │ ├── Makefile │ │ └── SerialPrint.ino │ ├── BlinkOpenCM │ │ ├── Makefile │ │ └── Blink.ino │ ├── WebServer │ │ ├── Makefile │ │ └── WebServer.ino │ ├── master_reader │ │ ├── Makefile │ │ └── master_reader.ino │ ├── TinySoftWareSerial │ │ ├── TinySoftwareSerial.ino │ │ └── Makefile │ ├── Blink3rdPartyLib │ │ ├── board.mk │ │ ├── Toggle │ │ │ ├── TogglePin.h │ │ │ ├── Makefile │ │ │ └── TogglePin.cpp │ │ ├── Blink3rdPartyLib.cpp │ │ └── Makefile │ ├── README.md │ ├── BlinkInAVRC │ │ ├── Makefile │ │ └── blink.c │ ├── DueBlink │ │ ├── DueBlink.ino │ │ └── Makefile │ ├── MZeroBlink │ │ ├── MZeroBlink.ino │ │ └── Makefile │ ├── ZeroBlink │ │ ├── ZeroBlink.ino │ │ └── Makefile │ ├── BlinkNetworkRPi │ │ ├── ATtinyBlink.ino │ │ └── Makefile │ ├── ATtinyBlink │ │ ├── ATtinyBlink.ino │ │ └── Makefile │ └── MakefileExample │ │ ├── Makefile-3rd_party-board.mk │ │ └── Makefile-example.mk ├── tests │ └── script │ │ ├── bootstrap │ │ ├── pip-requirements.txt │ │ ├── arduino.sh │ │ ├── samd.sh │ │ ├── chipkit.sh │ │ └── common.sh │ │ ├── bootstrap.sh │ │ └── runtests.sh ├── robotis-loader.1 ├── packaging │ ├── debian │ │ └── README.md │ └── fedora │ │ ├── README.md │ │ └── arduino-mk.spec ├── ardmk-init.1 ├── ard-reset-arduino.1 ├── bin │ ├── robotis-loader │ ├── ard-reset-arduino │ └── ardmk-init ├── chipKIT.mk ├── Teensy.mk ├── OpenCM.mk ├── Common.mk ├── OpenCR.mk ├── Sam.mk └── Arduino.mk └── README.md /crouse-of-the-hedospace/licence.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/Blink/Makefile: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/tests/script/bootstrap/pip-requirements.txt: -------------------------------------------------------------------------------- 1 | pyserial==3.4 2 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/Fade/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = uno 2 | ARDUINO_LIBS = 3 | 4 | include $(ARDMK_DIR)/Arduino.mk 5 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/toneMelody/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = uno 2 | ARDUINO_LIBS = 3 | 4 | include $(ARDMK_DIR)/Arduino.mk 5 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/AnalogInOutSerial/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = uno 2 | ARDUINO_LIBS = 3 | 4 | include $(ARDMK_DIR)/Arduino.mk 5 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/BlinkTeensy/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = teensy31 2 | ARDUINO_LIBS = 3 | 4 | include $(ARDMK_DIR)/Teensy.mk 5 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/BlinkWithoutDelay/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = uno 2 | ARDUINO_LIBS = 3 | 4 | include $(ARDMK_DIR)/Arduino.mk 5 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/BlinkChipKIT/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = mega_pic32 2 | ARDUINO_LIBS = 3 | 4 | include $(ARDMK_DIR)/chipKIT.mk 5 | 6 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/HelloWorld/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = uno 2 | ARDUINO_LIBS = LiquidCrystal 3 | 4 | include $(ARDMK_DIR)/Arduino.mk 5 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/BlinkOpenCR/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = OpenCR 2 | 3 | 4 | ARDUINO_LIBS = 5 | 6 | #MONITOR_PORT = /dev/ttyACM0 7 | 8 | include ../../OpenCR.mk 9 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/SerialPrint/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile 2 | 3 | BOARD_TAG = uno 4 | 5 | include $(ARDMK_DIR)/Arduino.mk 6 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/BlinkOpenCM/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = cm904 2 | ARDUINO_LIBS = 3 | 4 | #MONITOR_PORT = /dev/ttyACM0 5 | #OPENCMIDE_DIR = /where/you/installed/robotis_opencm 6 | 7 | include ../../OpenCM.mk 8 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/WebServer/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile 2 | 3 | BOARD_TAG = uno 4 | ARDUINO_LIBS = Ethernet SPI 5 | 6 | include $(ARDMK_DIR)/Arduino.mk 7 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/master_reader/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile 2 | 3 | BOARD_TAG = uno 4 | ARDUINO_LIBS = Wire 5 | 6 | include $(ARDMK_DIR)/Arduino.mk 7 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/SerialPrint/SerialPrint.ino: -------------------------------------------------------------------------------- 1 | void setup() { 2 | Serial.begin(9600); 3 | Serial.print("Press any key: "); 4 | } 5 | 6 | void loop() { 7 | if (Serial.available()) { 8 | Serial.println(Serial.read()); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/TinySoftWareSerial/TinySoftwareSerial.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | SoftwareSerial mySerial(3, 4); // RX, TX 4 | 5 | void setup() { 6 | mySerial.begin(9600); 7 | } 8 | 9 | void loop() { 10 | mySerial.println(millis()); 11 | delay(1000); 12 | } 13 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/tests/script/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 6 | pushd $SCRIPTS_DIR/.. 7 | 8 | source $SCRIPTS_DIR/bootstrap/chipkit.sh 9 | source $SCRIPTS_DIR/bootstrap/arduino.sh 10 | source $SCRIPTS_DIR/bootstrap/samd.sh 11 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/Blink3rdPartyLib/board.mk: -------------------------------------------------------------------------------- 1 | # This program is free software and is licensed under the same conditions as 2 | # describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt 3 | 4 | # The following can be overridden at make-time, by setting an environment 5 | # variable with the same name. eg. BOARD_TAG=pro5v328 make 6 | 7 | BOARD_TAG ?= uno 8 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/README.md: -------------------------------------------------------------------------------- 1 | This folder contains the list of example Arduino sketches and makefile showing 2 | the different usage patterns 3 | 4 | - BlinkInAVRC - Shows how to use plain AVR C code 5 | - ATtinyBlink - Shows how to use different cores like ATtiny 6 | - Blink - Shows normal usage 7 | - HelloWorld - Shows how to include Arduino libraries 8 | - SerialPrint - Shows how serial monitor can be used 9 | - BlinkChipKIT - Shows how to use ChipKIT 10 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/Blink3rdPartyLib/Toggle/TogglePin.h: -------------------------------------------------------------------------------- 1 | // This program is free software and is licensed under the same conditions as 2 | // describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt 3 | 4 | #ifndef TOGGLEPIN_H_ 5 | #define TOGGLEPIN_H_ 6 | 7 | class TogglePin 8 | { 9 | public: 10 | TogglePin(int pinNumber, bool state); 11 | 12 | bool toggle(); 13 | 14 | private: 15 | const int _pinNumber; 16 | bool _state; 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/BlinkInAVRC/Makefile: -------------------------------------------------------------------------------- 1 | # This sample Makefile, explains how you can compile plain AVR C file. 2 | # 3 | # Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile 4 | 5 | NO_CORE = Yes 6 | 7 | BOARD_TAG = atmega16 8 | MCU = atmega16 9 | F_CPU = 8000000L 10 | 11 | ISP_PROG = stk500v1 12 | AVRDUDE_ISP_BAUDRATE = 19200 13 | 14 | include $(ARDMK_DIR)/Arduino.mk 15 | 16 | # !!! Important. You have to use make ispload to upload when using ISP programmer 17 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/Blink3rdPartyLib/Blink3rdPartyLib.cpp: -------------------------------------------------------------------------------- 1 | // A derived Blink, that uses an example 3rd party library. 2 | // Turns on an LED on for one second, then off for one second, repeatedly. 3 | // This example code is in the public domain. 4 | 5 | #include 6 | 7 | #ifdef ARDUINO 8 | #if ARDUINO >= 100 9 | #include "Arduino.h" 10 | #else 11 | #include "WProgram.h" 12 | #endif 13 | #endif // ARDUINO 14 | 15 | int main() 16 | { 17 | init(); 18 | TogglePin led(13, false); 19 | while (true) { 20 | delay(1000); 21 | led.toggle(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/BlinkOpenCM/Blink.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Blink 3 | Turns an LED on for one second, then off for one second, repeatedly. 4 | 5 | This example code is in the public domain. 6 | */ 7 | 8 | void setup() { 9 | // initialize the led pin as an output. 10 | pinMode(BOARD_LED_PIN, OUTPUT); 11 | } 12 | 13 | void loop() { 14 | digitalWrite(BOARD_LED_PIN, HIGH); // set the LED on 15 | delay(1000); // wait for a second 16 | digitalWrite(BOARD_LED_PIN, LOW); // set the LED off 17 | delay(1000); // wait for a second 18 | } 19 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/BlinkTeensy/Blink.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Blink 3 | Turns on an LED on for one second, then off for one second, repeatedly. 4 | 5 | This example code is in the public domain. 6 | */ 7 | 8 | void setup() { 9 | // initialize the digital pin as an output. 10 | // Pin 13 has an LED connected on most Arduino boards: 11 | pinMode(13, OUTPUT); 12 | } 13 | 14 | void loop() { 15 | digitalWrite(13, HIGH); // set the LED on 16 | delay(1000); // wait for a second 17 | digitalWrite(13, LOW); // set the LED off 18 | delay(1000); // wait for a second 19 | } 20 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/DueBlink/DueBlink.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Blink 3 | Turns on an LED on for one second, then off for one second, repeatedly. 4 | 5 | This example code is in the public domain. 6 | */ 7 | 8 | void setup() { 9 | // initialize the digital pin as an output. 10 | // Pin 13 has an LED connected on most Arduino boards: 11 | pinMode(13, OUTPUT); 12 | } 13 | 14 | void loop() { 15 | digitalWrite(13, HIGH); // set the LED on 16 | delay(1000); // wait for a second 17 | digitalWrite(13, LOW); // set the LED off 18 | delay(1000); // wait for a second 19 | } 20 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/Blink/Blink.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Blink 3 | Turns on an LED on for one second, then off for one second, repeatedly. 4 | This example code is in the public domain. 5 | */ 6 | 7 | void setup() { 8 | // initialize the digital pin as an output. 9 | // Pin 13 has an LED connected on most Arduino boards: 10 | pinMode(13, OUTPUT); 11 | } 12 | 13 | void loop() { 14 | digitalWrite(13, HIGH); // set the LED on 15 | delay(1000); // wait for a second 16 | digitalWrite(13, LOW); // set the LED off 17 | delay(1000); // wait for a second 18 | } 19 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/MZeroBlink/MZeroBlink.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Blink 3 | Turns on an LED on for one second, then off for one second, repeatedly. 4 | 5 | This example code is in the public domain. 6 | */ 7 | 8 | void setup() { 9 | // initialize the digital pin as an output. 10 | // Pin 13 has an LED connected on most Arduino boards: 11 | pinMode(13, OUTPUT); 12 | } 13 | 14 | void loop() { 15 | digitalWrite(13, HIGH); // set the LED on 16 | delay(1000); // wait for a second 17 | digitalWrite(13, LOW); // set the LED off 18 | delay(1000); // wait for a second 19 | } 20 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/ZeroBlink/ZeroBlink.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Blink 3 | Turns on an LED on for one second, then off for one second, repeatedly. 4 | 5 | This example code is in the public domain. 6 | */ 7 | 8 | void setup() { 9 | // initialize the digital pin as an output. 10 | // Pin 13 has an LED connected on most Arduino boards: 11 | pinMode(13, OUTPUT); 12 | } 13 | 14 | void loop() { 15 | digitalWrite(13, HIGH); // set the LED on 16 | delay(1000); // wait for a second 17 | digitalWrite(13, LOW); // set the LED off 18 | delay(1000); // wait for a second 19 | } 20 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/Blink3rdPartyLib/Toggle/Makefile: -------------------------------------------------------------------------------- 1 | # This program is free software and is licensed under the same conditions as 2 | # describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt 3 | 4 | # This is an example Makefile, that is being used to build an archive 5 | # from locally compiled objects. 6 | # 7 | # All source files in this directory will automatically get compiled 8 | # and archived into the build-$(BOARD_TAG)/libtoggle.a target. 9 | 10 | include ../board.mk 11 | include $(ARDMK_DIR)/Arduino.mk 12 | 13 | build-$(BOARD_TAG)/libtoggle.a: $(LOCAL_OBJS) 14 | $(AR) rcs $@ $(LOCAL_OBJS) 15 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/BlinkChipKIT/BlinkChipKIT.pde: -------------------------------------------------------------------------------- 1 | /* 2 | Blink 3 | Turns on an LED on for one second, then off for one second, repeatedly. 4 | 5 | This example code is in the public domain. 6 | */ 7 | 8 | void setup() { 9 | // initialize the digital pin as an output. 10 | // Pin 13 has an LED connected on most Arduino boards: 11 | pinMode(13, OUTPUT); 12 | } 13 | 14 | void loop() { 15 | digitalWrite(13, HIGH); // set the LED on 16 | delay(1000); // wait for a second 17 | digitalWrite(13, LOW); // set the LED off 18 | delay(1000); // wait for a second 19 | } 20 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/robotis-loader.1: -------------------------------------------------------------------------------- 1 | .TH ROBOTIS-LOADER "1" "July 2017" "robotis-loader" "Robotis CLI Uploader" 2 | 3 | .SH NAME 4 | robotis-loader - Flash Robotis boards 5 | 6 | .SH SYNOPSIS 7 | .B robotis-loader 8 | PORT BINARY 9 | 10 | .SH DESCRIPTION 11 | Sends a program on a Robotis board (OpenCM9.04 or CM900) using the 12 | Robotis bootloader (used in OpenCM IDE). 13 | 14 | .SH EXAMPLE 15 | robotis-loader /dev/ttyACM0 firmware.bin 16 | 17 | .SH BUGS 18 | Problems may reported on the github project page at: 19 | .PP 20 | https://github.com/Gregwar/robotis-loader 21 | 22 | .SH AUTHOR 23 | Grégoire Passault, g.passault@gmail.com 24 | 25 | .SH LICENSE 26 | This is under MIT license. 27 | 28 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/DueBlink/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Due uses SAM3X8E SAM chip 2 | BOARD_TAG = arduino_due_x 3 | ARCHITECTURE = sam 4 | 5 | # Define ARM toolchain dir if not using Arduino supplied 6 | #ARM_TOOLS_DIR = /usr 7 | 8 | # Define AVR toolchain dir if not using Arduino supplied and using native port 9 | #AVR_TOOLS_DIR = /usr 10 | 11 | # Define Arduino support package installation path where SAM device support has been installed 12 | # Linux 13 | #ARDUINO_PACKAGE_DIR := $(HOME)/.arduino15/packages 14 | # macOS 15 | #ARDUINO_PACKAGE_DIR := $(HOME)/Library/Arduino15/packages 16 | # Windows 17 | #ARDUINO_PACKAGE_DIR := "C:/Users/$(USER)/AppData/Local/Arduino15/packages" 18 | 19 | include ../../Sam.mk 20 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/Blink3rdPartyLib/Toggle/TogglePin.cpp: -------------------------------------------------------------------------------- 1 | // This program is free software and is licensed under the same conditions as 2 | // describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt 3 | 4 | #include "TogglePin.h" 5 | 6 | #ifdef ARDUINO 7 | #if ARDUINO >= 100 8 | #include "Arduino.h" 9 | #else 10 | #include "WProgram.h" 11 | #endif 12 | #endif // ARDUINO 13 | 14 | TogglePin::TogglePin(int pinNumber, bool state) 15 | : _pinNumber(pinNumber), _state(state) 16 | { 17 | pinMode(_pinNumber, OUTPUT); 18 | digitalWrite(_pinNumber, _state ? HIGH : LOW); 19 | } 20 | 21 | bool 22 | TogglePin::toggle() 23 | { 24 | _state = !_state; 25 | digitalWrite(_pinNumber, _state ? HIGH : LOW); 26 | return _state; 27 | } 28 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/TinySoftWareSerial/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile 2 | 3 | # if you have placed the alternate core in your sketchbook directory, then you can just mention the core name alone. 4 | ALTERNATE_CORE = attiny 5 | # If not, you might have to include the full path. 6 | #ALTERNATE_CORE_PATH = /home/sudar/Dropbox/code/arduino-sketches/hardware/attiny/ 7 | 8 | # !!! Important. You have to use "make ispload" to upload when using ISP programmer 9 | ISP_PROG = usbasp 10 | 11 | # 1.5+ example of submenu cpu 12 | BOARD_TAG = attiny 13 | BOARD_SUB = attiny85 14 | 15 | # clock is a submenu too 16 | F_CPU = 16000000L 17 | 18 | ARDUINO_LIBS = SoftwareSerial 19 | 20 | include $(ARDMK_DIR)/Arduino.mk 21 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/BlinkInAVRC/blink.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Anil Kumar Pugalia, 2010. Email: email@sarika-pugs.com 3 | * 4 | * ATmega48/88/168, ATmega16/32 5 | * 6 | * Example Blink. Toggles all IO pins at 1Hz 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | void init_io(void) 13 | { 14 | // 1 = output, 0 = input 15 | DDRB = 0b11111111; // All outputs 16 | DDRC = 0b11111111; // All outputs 17 | DDRD = 0b11111110; // PORTD (RX on PD0). Just for demo 18 | } 19 | 20 | int main(void) 21 | { 22 | init_io(); 23 | 24 | while (1) 25 | { 26 | PORTC = 0xFF; 27 | PORTB = 0xFF; 28 | PORTD = 0xFF; 29 | _delay_ms(500); 30 | 31 | PORTC = 0x00; 32 | PORTB = 0x00; 33 | PORTD = 0x00; 34 | _delay_ms(500); 35 | } 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/packaging/debian/README.md: -------------------------------------------------------------------------------- 1 | # How to compile a Deb package 2 | 3 | Use these instructions to build your own Deb package from your local sources. 4 | For the latest official packages go to [Debian](http://packages.debian.org/arduino-mk) 5 | or [Ubuntu](https://launchpad.net/ubuntu/+source/arduino-mk) or use apt. 6 | 7 | First install the dependencies as root: 8 | 9 | apt-get build-dep arduino-mk 10 | apt-get install arduino-core build-essential dpkg-dev fakeroot devscripts 11 | 12 | Fetch the Debian source: 13 | 14 | apt-get source arduino-mk 15 | 16 | Make any local changes to want within the arduino-mk-* directory and update the package version: 17 | 18 | cd arduino-mk-* 19 | dch -i 20 | 21 | Then compile. This will create a binary Deb: 22 | 23 | dpkg-buildpackage -b 24 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/BlinkNetworkRPi/ATtinyBlink.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Blink 3 | Turns on an LED on for one second, then off for one second, repeatedly. 4 | 5 | This example code is in the public domain. 6 | */ 7 | 8 | // Connect a LED to Pin 3. It might be different in different ATtiny micro controllers 9 | int led = 3; 10 | 11 | // the setup routine runs once when you press reset: 12 | void setup() { 13 | // initialize the digital pin as an output. 14 | pinMode(led, OUTPUT); 15 | } 16 | 17 | // the loop routine runs over and over again forever: 18 | void loop() { 19 | digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) 20 | delay(1000); // wait for a second 21 | digitalWrite(led, LOW); // turn the LED off by making the voltage LOW 22 | delay(1000); // wait for a second 23 | } 24 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/ATtinyBlink/ATtinyBlink.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Blink 3 | Turns on an LED on for one second, then off for one second, repeatedly. 4 | 5 | This example code is in the public domain. 6 | */ 7 | 8 | // Connect a LED to Pin 3. It might be different in different ATtiny micro controllers 9 | int led = 3; 10 | 11 | // the setup routine runs once when you press reset: 12 | void setup() { 13 | // initialize the digital pin as an output. 14 | pinMode(led, OUTPUT); 15 | } 16 | 17 | // the loop routine runs over and over again forever: 18 | void loop() { 19 | digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) 20 | delay(1000); // wait for a second 21 | digitalWrite(led, LOW); // turn the LED off by making the voltage LOW 22 | delay(1000); // wait for a second 23 | } 24 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/MZeroBlink/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino M0 Pro Programming Port 2 | BOARD_TAG = mzero_pro_bl_dbg 3 | 4 | # Define debug if you want to use gdb 5 | #DEBUG = 1 6 | 7 | # Define port if using Black Magic Probe rather than default localhost:3333 8 | #GDB_PORT = /dev/ttyACM0 9 | 10 | # Define ARM toolchain dir if not using Arduino supplied 11 | #ARM_TOOLS_DIR = /usr 12 | 13 | # Define AVR toolchain dir if not using Arduino supplied and using native port 14 | #AVR_TOOLS_DIR = /usr 15 | 16 | # Define Arduino support package installation path where SAM device support has been installed 17 | # Linux 18 | # ARDUINO_PACKAGE_DIR := $(HOME)/.arduino15/packages 19 | # macOS 20 | # ARDUINO_PACKAGE_DIR := $(HOME)/Library/Arduino15/packages 21 | # Windows 22 | # ARDUINO_PACKAGE_DIR := "C:/Users/$(USER)/AppData/Local/Arduino15/packages" 23 | 24 | include ../../Sam.mk 25 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/master_reader/master_reader.ino: -------------------------------------------------------------------------------- 1 | // Wire Master Reader 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Reads data from an I2C/TWI slave device 6 | // Refer to the "Wire Slave Sender" example for use with this 7 | 8 | // Created 29 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() 16 | { 17 | Wire.begin(); // join i2c bus (address optional for master) 18 | Serial.begin(9600); // start serial for output 19 | } 20 | 21 | void loop() 22 | { 23 | Wire.requestFrom(2, 6); // request 6 bytes from slave device #2 24 | 25 | while(Wire.available()) // slave may send less than requested 26 | { 27 | char c = Wire.read(); // receive a byte as character 28 | Serial.print(c); // print the character 29 | } 30 | 31 | delay(500); 32 | } 33 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/Fade/Fade.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Fade 3 | 4 | This example shows how to fade an LED on pin 9 5 | using the analogWrite() function. 6 | 7 | This example code is in the public domain. 8 | 9 | */ 10 | int brightness = 0; // how bright the LED is 11 | int fadeAmount = 5; // how many points to fade the LED by 12 | 13 | void setup() { 14 | // declare pin 9 to be an output: 15 | pinMode(9, OUTPUT); 16 | } 17 | 18 | void loop() { 19 | // set the brightness of pin 9: 20 | analogWrite(9, brightness); 21 | 22 | // change the brightness for next time through the loop: 23 | brightness = brightness + fadeAmount; 24 | 25 | // reverse the direction of the fading at the ends of the fade: 26 | if (brightness == 0 || brightness == 255) { 27 | fadeAmount = -fadeAmount ; 28 | } 29 | // wait for 30 milliseconds to see the dimming effect 30 | delay(30); 31 | } 32 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/Blink3rdPartyLib/Makefile: -------------------------------------------------------------------------------- 1 | # This program is free software and is licensed under the same conditions as 2 | # describe in https://github.com/sudar/Arduino-Makefile/blob/master/licence.txt 3 | 4 | # This is an example Makefile, that demonstrates the linking of a third party 5 | # library. In this case the third party library resides in the ./Toggle 6 | # sub-directory. Note that the archive TOGGLE_ARCHIVE _only_ contains the 7 | # compiled Toggle.c.o object. The TOGGLE_ARCHIVE is thus very lean, but it 8 | # requires the Arduino libraries, which are being build in this directory, 9 | # together with Blink, the 'main' program. 10 | 11 | include board.mk 12 | 13 | TOGGLE_ARCHIVE = build-$(BOARD_TAG)/libtoggle.a 14 | 15 | CXXFLAGS += -IToggle 16 | OTHER_OBJS = Toggle/$(TOGGLE_ARCHIVE) 17 | 18 | include $(ARDMK_DIR)/Arduino.mk 19 | 20 | Toggle/$(TOGGLE_ARCHIVE): 21 | $(MAKE) -C Toggle $(TOGGLE_ARCHIVE) 22 | 23 | clean:: 24 | $(MAKE) -C Toggle clean 25 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/BlinkOpenCR/BlinkOpenCR.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Blink(LED) 3 | */ 4 | 5 | 6 | #define BDPIN_LED_USER_1 22 7 | #define BDPIN_LED_USER_2 23 8 | #define BDPIN_LED_USER_3 24 9 | #define BDPIN_LED_USER_4 25 10 | 11 | 12 | int led_pin = 13; 13 | int led_pin_user[4] = { BDPIN_LED_USER_1, BDPIN_LED_USER_2, BDPIN_LED_USER_3, BDPIN_LED_USER_4 }; 14 | 15 | void setup() { 16 | // Set up the built-in LED pin as an output: 17 | pinMode(led_pin, OUTPUT); 18 | pinMode(led_pin_user[0], OUTPUT); 19 | pinMode(led_pin_user[1], OUTPUT); 20 | pinMode(led_pin_user[2], OUTPUT); 21 | pinMode(led_pin_user[3], OUTPUT); 22 | 23 | Serial.begin(115200); 24 | 25 | } 26 | 27 | void loop() { 28 | int i; 29 | 30 | digitalWrite(led_pin, HIGH); // set to as HIGH LED is turn-off 31 | delay(100); // Wait for 0.1 second 32 | digitalWrite(led_pin, LOW); // set to as LOW LED is turn-on 33 | delay(100); // Wait for 0.1 second 34 | 35 | 36 | for( i=0; i<4; i++ ) 37 | { 38 | digitalWrite(led_pin_user[i], HIGH); 39 | delay(100); 40 | } 41 | for( i=0; i<4; i++ ) 42 | { 43 | digitalWrite(led_pin_user[i], LOW); 44 | delay(100); 45 | } 46 | 47 | Serial.println( String(10) ); 48 | } 49 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/ZeroBlink/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Zero Native Port (should work with Feather, MKR1000 etc.) 2 | # BOOTLOADER: The bootloader on these devices loaded when reset is pressed twice 3 | # or the port is opened/closed at 1200 BAUD. If there is no program on the device, 4 | # you may have to manually enter bootloader by toggling reset twice. 5 | # see http://www.avdweb.nl/arduino/samd21/virus.html 6 | BOARD_TAG = arduino_zero_native 7 | 8 | # Define alternative core path if using another board supplier 9 | #ALTERNATE_CORE_PATH = $(HOME)/Arduino/hardware/sparkfun/samd 10 | 11 | # Define monitor port and isp port (bootloader port). 12 | # Will automatically detect if Linux/macOS but MUST be defined on Windows 13 | #MONITOR_PORT = com40 # CDC serial 14 | #ISP_PORT = com39 # bootloader 15 | 16 | # Define ARM toolchain dir if not using Arduino supplied 17 | #ARM_TOOLS_DIR = /usr 18 | 19 | # Define AVR toolchain dir if not using Arduino supplied and using native port 20 | #AVR_TOOLS_DIR = /usr 21 | 22 | # Define Arduino support package installation path where SAM device support has been installed 23 | # Linux 24 | #ARDUINO_PACKAGE_DIR := $(HOME)/.arduino15/packages 25 | # macOS 26 | #ARDUINO_PACKAGE_DIR := $(HOME)/Library/Arduino15/packages 27 | # Windows 28 | #ARDUINO_PACKAGE_DIR := "C:/Users/$(USER)/AppData/Local/Arduino15/packages" 29 | 30 | include ../../Sam.mk 31 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/toneMelody/toneMelody.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Melody 3 | 4 | Plays a melody 5 | 6 | circuit: 7 | * 8-ohm speaker on digital pin 8 8 | 9 | created 21 Jan 2010 10 | modified 30 Aug 2011 11 | by Tom Igoe 12 | 13 | This example code is in the public domain. 14 | 15 | http://arduino.cc/en/Tutorial/Tone 16 | 17 | */ 18 | #include "pitches.h" 19 | 20 | // notes in the melody: 21 | int melody[] = { 22 | NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4}; 23 | 24 | // note durations: 4 = quarter note, 8 = eighth note, etc.: 25 | int noteDurations[] = { 26 | 4, 8, 8, 4,4,4,4,4 }; 27 | 28 | void setup() { 29 | // iterate over the notes of the melody: 30 | for (int thisNote = 0; thisNote < 8; thisNote++) { 31 | 32 | // to calculate the note duration, take one second 33 | // divided by the note type. 34 | //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. 35 | int noteDuration = 1000/noteDurations[thisNote]; 36 | tone(8, melody[thisNote],noteDuration); 37 | 38 | // to distinguish the notes, set a minimum time between them. 39 | // the note's duration + 30% seems to work well: 40 | int pauseBetweenNotes = noteDuration * 1.30; 41 | delay(pauseBetweenNotes); 42 | // stop the tone playing: 43 | noTone(8); 44 | } 45 | } 46 | 47 | void loop() { 48 | // no need to repeat the melody. 49 | } 50 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/tests/script/bootstrap/arduino.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 3 | source $BOOTSTRAP_DIR/common.sh 4 | 5 | echo "Installing dependencies for building for the Arduino" 6 | 7 | if [ -z "$ARDUINO_DIR" ] || ! test -e $ARDUINO_DIR || [ $OS == "cygwin" ]; then 8 | 9 | echo "Installing Arduino..." 10 | 11 | ARDUINO_BASENAME="arduino-1.8.11" 12 | 13 | if [ $OS == "cygwin" ]; then 14 | ARDUINO_FILE="$ARDUINO_BASENAME-windows".zip 15 | EXTRACT_COMMAND="unzip -q" 16 | elif [ $OS == "mac" ]; then 17 | ARDUINO_FILE="$ARDUINO_BASENAME-macosx".zip 18 | EXTRACT_COMMAND="unzip -q" 19 | else 20 | ARDUINO_FILE="$ARDUINO_BASENAME-linux64".tar.xz 21 | EXTRACT_COMMAND="tar -xf" 22 | fi 23 | 24 | ARDUINO_URL=http://arduino.cc/download.php?f=/$ARDUINO_FILE 25 | 26 | _pushd $DEPENDENCIES_FOLDER 27 | if ! test -e $ARDUINO_FILE 28 | then 29 | echo "Downloading Arduino IDE..." 30 | download $ARDUINO_URL $ARDUINO_FILE 31 | fi 32 | 33 | if ! test -d $ARDUINO_BASENAME 34 | then 35 | echo "Installing Arduino to local folder..." 36 | $EXTRACT_COMMAND $ARDUINO_FILE 37 | mv $ARDUINO_BASENAME arduino 38 | echo "Arduino installed" 39 | fi 40 | 41 | _popd 42 | 43 | fi 44 | 45 | echo 46 | echo "${bldgreen}Arduino dependencies installed.$txtrst" 47 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/ardmk-init.1: -------------------------------------------------------------------------------- 1 | .TH ARDMK-INIT "1" "Nov 2017" "ardmk-init" "Arduino Makefile Generator" 2 | 3 | .SH NAME 4 | ardmk-init - Generate Arduino Makefile environments 5 | 6 | .SH SYNOPSIS 7 | .B ardmk-init 8 | [OPTION]... 9 | 10 | .SH OPTIONS 11 | .B \-v, \-\-verbose 12 | Print file contents during creation. 13 | 14 | .B \-d, \-\-directory 15 | Directory to run generator. 16 | 17 | .B \-b, \-\-board 18 | Board tag. 19 | 20 | .B \-u, \-\-micro 21 | Microcontroller on board. 22 | 23 | .B \-f, \-\-freq 24 | Clock frequency. 25 | 26 | .B \-p, \-\-port 27 | Monitor port. 28 | 29 | .B \-n, \-\-name 30 | Project name. 31 | 32 | .B \-\-cli 33 | Run with user prompts rather than arguments. 34 | 35 | .B \-p, \-\-project 36 | Create boilerplate project with src, lib and bin folder structure. 37 | 38 | .B \-t, \-\-template 39 | Create bare minimum Arduino source file. 40 | 41 | .SH DESCRIPTION 42 | Creates a Makefile and project tree structure from templates. 43 | 44 | .SH EXAMPLE 45 | ardmk-init -b uno # create Arduino uno Makefile 46 | .PP 47 | ardmk-init --cli # run with user prompts 48 | .PP 49 | ardmk-init --board uno --project --template --name my-project # create Arduino uno project and template with name "my-project" 50 | 51 | .SH BUGS 52 | Problems may reported on the github project page at: 53 | .PP 54 | https://github.com/sudar/Arduino-Makefile 55 | 56 | .SH AUTHOR 57 | John Whittington, git@jbrengineering.co.uk 58 | 59 | .SH LICENSE 60 | This is under MIT license. 61 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/ard-reset-arduino.1: -------------------------------------------------------------------------------- 1 | .TH ARD-RESET-ARDUINO "1" "January 2017" "ard-reset-arduino 1.6.0" "Arduino CLI Reset" 2 | 3 | .SH NAME 4 | ard-reset-arduino - Reset Arduino board 5 | 6 | .SH SYNOPSIS 7 | .B ard-reset-arduino 8 | [OPTION]... [PORT] 9 | 10 | .SH DESCRIPTION 11 | To reset Arduinos, we either pulse the DTR line or open the USB port 12 | at 1200 baud and close it again. 13 | 14 | .SH OPTIONS 15 | .B \-\-verbose 16 | Watch what's going on on STDERR. 17 | 18 | .B \-\-period 19 | Specify the DTR pulse width in seconds. 20 | 21 | .B \-\-caterina 22 | Reset a Leonardo, Micro, Robot, LilyPadUSB or similar 32u4-based device. 23 | 24 | .SH EXAMPLES 25 | ard-reset-arduino /dev/ttyACM0 26 | .PP 27 | ard-reset-arduino \-\-verbose \-\-period=0.1 /dev/cu.usb* 28 | .PP 29 | ard-reset-arduino \-\-verbose \-\-caterina /dev/ttyUSB0 30 | 31 | .SH BUGS 32 | There are no known bugs in this application. Please report problems 33 | to the author. Patches are welcome. 34 | 35 | .SH AUTHOR 36 | Simon John, git@the-jedi.co.uk 37 | 38 | .SH LICENSE 39 | Copyright (c) 2014, Simon John. All rights reserved. 40 | .PP 41 | This file is free software; you can redistribute it and/or modify it 42 | under the terms of the GNU Lesser General Public License as published 43 | by the Free Software Foundation; either version 2.1 of the License, or 44 | (at your option) any later version. 45 | .PP 46 | This program is distributed in the hope that it will be useful, but 47 | WITHOUT ANY WARRANTY; without even the implied warranty of 48 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 49 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/tests/script/bootstrap/samd.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 3 | source $BOOTSTRAP_DIR/common.sh 4 | 5 | echo "Installing dependencies for building for the SAMD boards" 6 | 7 | # these extract to dirs without versions... 8 | SAMD_PACKAGE="samd-1.8.6" 9 | CMSIS_PACKAGE="CMSIS-4.5.0" 10 | CMSIS_ATMEL_PACKAGE="CMSIS-Atmel-1.2.0" 11 | 12 | if [ $OS == "mac" ]; then 13 | TOOLCHAIN_PACKAGE="gcc-arm-none-eabi-7-2017-q4-major-mac" 14 | else 15 | TOOLCHAIN_PACKAGE="gcc-arm-none-eabi-7-2017-q4-major-linux" 16 | fi 17 | 18 | ARDUINO_URL=https://downloads.arduino.cc 19 | TOOLCHAIN_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2017q4 20 | 21 | EXTRACT_COMMAND="tar -xjf" 22 | 23 | _pushd $DEPENDENCIES_FOLDER 24 | if ! test -e $SAMD_PACKAGE 25 | then 26 | echo "Downloading SAMD packages..." 27 | download $ARDUINO_URL/cores/$SAMD_PACKAGE.tar.bz2 $SAMD_PACKAGE.tar.bz2 28 | download $ARDUINO_URL/$CMSIS_PACKAGE.tar.bz2 $CMSIS_PACKAGE.tar.bz2 29 | download $ARDUINO_URL/$CMSIS_ATMEL_PACKAGE.tar.bz2 $CMSIS_ATMEL_PACKAGE.tar.bz2 30 | download $TOOLCHAIN_URL/$TOOLCHAIN_PACKAGE.tar.bz2 $TOOLCHAIN_PACKAGE.tar.bz2 31 | fi 32 | 33 | if ! test -d $SAMD_PACKAGE 34 | then 35 | echo "Installing packages to local folder..." 36 | $EXTRACT_COMMAND $SAMD_PACKAGE.tar.bz2 37 | $EXTRACT_COMMAND $CMSIS_PACKAGE.tar.bz2 38 | $EXTRACT_COMMAND $CMSIS_ATMEL_PACKAGE.tar.bz2 39 | $EXTRACT_COMMAND $TOOLCHAIN_PACKAGE.tar.bz2 40 | echo "SAMD support installed" 41 | fi 42 | 43 | _popd 44 | 45 | echo 46 | echo "${bldgreen}SAMD dependencies installed.$txtrst" 47 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/BlinkNetworkRPi/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile 2 | 3 | # Tested and working with a linuxspi programmer on a remote Raspberry Pi 4 | # Refer to https://github.com/kcuzner/avrdude for linuxspi. 5 | # Should work with ISP as well if you replace $(AVRDUDE_ARD_OPTS) with 6 | # $(AVRDUDE_ISP_OPTS) in the net_set_fuses rule. 7 | 8 | # Alternate core from https://code.google.com/p/arduino-tiny 9 | ALTERNATE_CORE = tiny 10 | BOARD_TAG = attiny85at8 11 | 12 | # Avrdude config path on the remote Raspberry Pi 13 | AVRDUDE_CONF=/usr/local/etc/avrdude.conf 14 | 15 | # Skip the monitor port existance check since it's not on our machine. 16 | FORCE_MONITOR_PORT=true 17 | MONITOR_PORT=/dev/spidev0.0 18 | 19 | include $(ARDMK_DIR)/Arduino.mk 20 | 21 | 22 | # Additional rules to use a remote Raspberry Pi programmer 23 | 24 | # Note that it's recommended not to use root for this task, 25 | # but to setup spidev access on a normal user instead. 26 | HOST = root@alarmpi 27 | SSH_AVRDUDE = ssh $(HOST) /usr/local/bin/avrdude 28 | 29 | CAT_HEX = cat $(TARGET_HEX) 30 | AVRDUDE_UPLOAD_PIPE = -U flash:w:-:i 31 | 32 | .PHONY: net_upload net_set_fuses 33 | 34 | net_upload: $(TARGET_HEX) verify_size 35 | $(CAT_HEX) | $(SSH_AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ 36 | $(AVRDUDE_UPLOAD_PIPE) 37 | 38 | net_set_fuses: 39 | ifneq ($(strip $(AVRDUDE_ISP_FUSES_PRE)),) 40 | $(SSH_AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) -e \ 41 | $(AVRDUDE_ISP_FUSES_PRE) 42 | endif 43 | ifneq ($(strip $(AVRDUDE_ISP_FUSES_POST)),) 44 | $(SSH_AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ 45 | $(AVRDUDE_ISP_FUSES_POST) 46 | endif 47 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/packaging/fedora/README.md: -------------------------------------------------------------------------------- 1 | # How to compile an RPM 2 | 3 | First install the dependencies as root: 4 | 5 | ```sh 6 | yum install arduino-core rpm-build 7 | 8 | # or on Fedora 22+ 9 | 10 | dnf install arduino-core rpmdevtools 11 | ``` 12 | 13 | From the top-level Arduino-Makefile directory you've checked out of github, run the following (as unprivileged user) to create a compressed tarball using the naming conventions required by rpmbuild: 14 | 15 | git archive HEAD --prefix=arduino-mk-1.5/ -o ../arduino-mk-1.5.tar.gz 16 | 17 | If you don't already have a rpmbuild setup (e.g. you've not installed the SRPM) you will need to create the directories: 18 | 19 | mkdir -p ~/rpmbuild/{SOURCES,SPECS} 20 | 21 | Then copy the tarball and specfile into those directories: 22 | 23 | cp ../arduino-mk-1.5.tar.gz ~/rpmbuild/SOURCES/ 24 | cp packaging/fedora/arduino-mk.spec ~/rpmbuild/SPECS/ 25 | 26 | Then compile. This will create a binary and source RPM: 27 | 28 | cd ~/rpmbuild/SPECS/ 29 | rpmbuild -ba arduino-mk.spec 30 | 31 | Fedora's AVR compilers use ccache, so you may have to override some of the paths to the AVR tools in your sketch's Makefile, for example: 32 | 33 | ```Makefile 34 | OVERRIDE_EXECUTABLES = 1 35 | CC = /usr/lib64/ccache/$(CC_NAME) 36 | CXX = /usr/lib64/ccache/$(CXX_NAME) 37 | AS = /usr/bin/$(AS_NAME) 38 | OBJCOPY = /usr/bin/$(OBJCOPY_NAME) 39 | OBJDUMP = /usr/bin/$(OBJDUMP_NAME) 40 | AR = /usr/bin/$(AR_NAME) 41 | SIZE = /usr/bin/$(SIZE_NAME) 42 | NM = /usr/bin/$(NM_NAME) 43 | ``` 44 | 45 | Or if you don't want to use ccache, then just set ```AVR_TOOLS_PATH=/usr``` and none of the above will be necessary. 46 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/HelloWorld/HelloWorld.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Hello World 3 | 4 | Demonstrates the use a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "Hello World!" to the LCD 10 | and shows the time. 11 | 12 | The circuit: 13 | * LCD RS pin to digital pin 12 14 | * LCD Enable pin to digital pin 11 15 | * LCD D4 pin to digital pin 5 16 | * LCD D5 pin to digital pin 4 17 | * LCD D6 pin to digital pin 3 18 | * LCD D7 pin to digital pin 2 19 | * LCD R/W pin to ground 20 | * 10K resistor: 21 | * ends to +5V and ground 22 | * wiper to LCD VO pin (pin 3) 23 | 24 | Library originally added 18 Apr 2008 25 | by David A. Mellis 26 | library modified 5 Jul 2009 27 | by Limor Fried (http://www.ladyada.net) 28 | example added 9 Jul 2009 29 | by Tom Igoe 30 | modified 22 Nov 2010 31 | by Tom Igoe 32 | 33 | This example code is in the public domain. 34 | 35 | http://www.arduino.cc/en/Tutorial/LiquidCrystal 36 | */ 37 | 38 | // include the library code: 39 | #include 40 | 41 | // initialize the library with the numbers of the interface pins 42 | LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 43 | 44 | void setup() { 45 | // set up the LCD's number of columns and rows: 46 | lcd.begin(16, 2); 47 | // Print a message to the LCD. 48 | lcd.print("hello, world!"); 49 | } 50 | 51 | void loop() { 52 | // set the cursor to column 0, line 1 53 | // (note: line 1 is the second row, since counting begins with 0): 54 | lcd.setCursor(0, 1); 55 | // print the number of seconds since reset: 56 | lcd.print(millis()/1000); 57 | } 58 | 59 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/ATtinyBlink/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile 2 | 3 | # Set this if the IDE is not in your $PATH or you want to use a specific version: 4 | ARDUINO_DIR = $(HOME)/arduino-1.8.5 5 | 6 | # Programmer type: 7 | ISP_PROG = usbasp 8 | 9 | # Examples - obviously pick only one and comment/delete the rest: 10 | 11 | # ------------------------------------------------------------------ # 12 | 13 | # https://github.com/SpenceKonde/ATTinyCore (1.5+) 14 | ALTERNATE_CORE = ATTinyCore 15 | BOARD_TAG = attinyx4 16 | BOARD_SUB = 84 17 | VARIANT = tinyX4 18 | F_CPU = 8000000L 19 | #BOARD_TAG = attinyx313 20 | #BOARD_SUB = 4313 21 | #BOARD_TAG = attinyx61 22 | #BOARD_SUB = 861 23 | #F_CPU = 8000000L 24 | 25 | # ------------------------------------------------------------------ # 26 | 27 | # https://github.com/Coding-Badly/TinyCore1 (1.5+) 28 | ALTERNATE_CORE = tiny 29 | BOARD_TAG = attiny85at8 30 | #BOARD_TAG = attiny2313at1 31 | 32 | # https://github.com/Coding-Badly/arduino-tiny (1.0) 33 | ALTERNATE_CORE = tiny 34 | BOARD_TAG = attiny85at8 35 | #BOARD_TAG = attiny44at8 36 | #BOARD_TAG = attiny84at8 37 | ARDUINO_VAR_PATH = $(HOME)/arduino/hardware/tiny/cores/tiny 38 | ARDUINO_CORE_PATH = $(HOME)/arduino/hardware/tiny/cores/tiny 39 | 40 | # ------------------------------------------------------------------ # 41 | 42 | # https://github.com/damellis/attiny (1.5+) 43 | ALTERNATE_CORE = attiny-master 44 | BOARD_TAG = attiny 45 | BOARD_SUB = attiny85 46 | F_CPU = 16000000L 47 | 48 | # https://github.com/damellis/attiny (1.0) 49 | ALTERNATE_CORE = attiny-master 50 | BOARD_TAG = attiny85 51 | #BOARD_TAG = attiny44-8 52 | #BOARD_TAG = attiny84-20 53 | 54 | # ------------------------------------------------------------------ # 55 | 56 | # Path to the Arduino Makefile 57 | include $(ARDMK_DIR)/Arduino.mk 58 | 59 | # !!! Important. You have to use 'make ispload' when using an ISP. 60 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/AnalogInOutSerial/AnalogInOutSerial.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Analog input, analog output, serial output 3 | 4 | Reads an analog input pin, maps the result to a range from 0 to 255 5 | and uses the result to set the pulsewidth modulation (PWM) of an output pin. 6 | Also prints the results to the serial monitor. 7 | 8 | The circuit: 9 | * potentiometer connected to analog pin 0. 10 | Center pin of the potentiometer goes to the analog pin. 11 | side pins of the potentiometer go to +5V and ground 12 | * LED connected from digital pin 9 to ground 13 | 14 | created 29 Dec. 2008 15 | modified 30 Aug 2011 16 | by Tom Igoe 17 | 18 | This example code is in the public domain. 19 | 20 | */ 21 | 22 | // These constants won't change. They're used to give names 23 | // to the pins used: 24 | const int analogInPin = A0; // Analog input pin that the potentiometer is attached to 25 | const int analogOutPin = 9; // Analog output pin that the LED is attached to 26 | 27 | int sensorValue = 0; // value read from the pot 28 | int outputValue = 0; // value output to the PWM (analog out) 29 | 30 | void setup() { 31 | // initialize serial communications at 9600 bps: 32 | Serial.begin(9600); 33 | } 34 | 35 | void loop() { 36 | // read the analog in value: 37 | sensorValue = analogRead(analogInPin); 38 | // map it to the range of the analog out: 39 | outputValue = map(sensorValue, 0, 1023, 0, 255); 40 | // change the analog out value: 41 | analogWrite(analogOutPin, outputValue); 42 | 43 | // print the results to the serial monitor: 44 | Serial.print("sensor = " ); 45 | Serial.print(sensorValue); 46 | Serial.print("\t output = "); 47 | Serial.println(outputValue); 48 | 49 | // wait 10 milliseconds before the next loop 50 | // for the analog-to-digital converter to settle 51 | // after the last reading: 52 | delay(10); 53 | } 54 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/tests/script/bootstrap/chipkit.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 3 | source $BOOTSTRAP_DIR/common.sh 4 | 5 | echo "Installing dependencies for building for the chipKIT" 6 | 7 | 8 | if [ -z "$MPIDE_DIR" ] || ! test -e $MPIDE_DIR || [ $OS == "cygwin" ]; then 9 | 10 | echo "Installing MPIDE..." 11 | 12 | if [ $OS == "cygwin" ]; then 13 | MPIDE_BASENAME="mpide-0023-windows-20130715" 14 | MPIDE_FILE="$MPIDE_BASENAME".zip 15 | EXTRACT_COMMAND="unzip -q" 16 | if ! command -v unzip >/dev/null 2>&1; then 17 | _cygwin_error "unzip" 18 | fi 19 | elif [ $OS == "mac" ]; then 20 | MPIDE_BASENAME=mpide-0023-macosx-20130715 21 | MPIDE_FILE="$MPIDE_BASENAME".dmg 22 | else 23 | MPIDE_BASENAME=mpide-0023-linux64-20130817-test 24 | MPIDE_FILE="$MPIDE_BASENAME".tgz 25 | EXTRACT_COMMAND="tar -xzf" 26 | fi 27 | 28 | MPIDE_URL=http://chipkit.s3.amazonaws.com/builds/$MPIDE_FILE 29 | 30 | _pushd $DEPENDENCIES_FOLDER 31 | if ! test -e $MPIDE_FILE 32 | then 33 | echo "Downloading MPIDE..." 34 | download $MPIDE_URL $MPIDE_FILE 35 | fi 36 | 37 | if ! test -d $MPIDE_BASENAME 38 | then 39 | echo "Installing MPIDE to local folder..." 40 | if [ $OS == "mac" ]; then 41 | hdiutil attach $MPIDE_FILE 42 | cp -R /Volumes/Mpide/Mpide.app/Contents/Resources/Java $MPIDE_BASENAME 43 | hdiutil detach /Volumes/Mpide 44 | else 45 | $EXTRACT_COMMAND $MPIDE_FILE 46 | fi 47 | echo "MPIDE installed" 48 | fi 49 | 50 | if [ $OS == "cygwin" ]; then 51 | chmod a+x mpide/hardware/pic32/compiler/pic32-tools/bin/* 52 | chmod a+x -R mpide/hardware/pic32/compiler/pic32-tools/pic32mx/ 53 | chmod a+x mpide/*.dll 54 | chmod a+x mpide/hardware/tools/avr/bin/* 55 | fi 56 | _popd 57 | 58 | fi 59 | 60 | echo 61 | echo "${bldgreen}chipKIT dependencies installed.$txtrst" 62 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/BlinkWithoutDelay/BlinkWithoutDelay.ino: -------------------------------------------------------------------------------- 1 | /* Blink without Delay 2 | 3 | Turns on and off a light emitting diode(LED) connected to a digital 4 | pin, without using the delay() function. This means that other code 5 | can run at the same time without being interrupted by the LED code. 6 | 7 | The circuit: 8 | * LED attached from pin 13 to ground. 9 | * Note: on most Arduinos, there is already an LED on the board 10 | that's attached to pin 13, so no hardware is needed for this example. 11 | 12 | 13 | created 2005 14 | by David A. Mellis 15 | modified 8 Feb 2010 16 | by Paul Stoffregen 17 | 18 | This example code is in the public domain. 19 | 20 | 21 | http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay 22 | */ 23 | 24 | // constants won't change. Used here to 25 | // set pin numbers: 26 | const int ledPin = 13; // the number of the LED pin 27 | 28 | // Variables will change: 29 | int ledState = LOW; // ledState used to set the LED 30 | long previousMillis = 0; // will store last time LED was updated 31 | 32 | // the follow variables is a long because the time, measured in miliseconds, 33 | // will quickly become a bigger number than can be stored in an int. 34 | long interval = 1000; // interval at which to blink (milliseconds) 35 | 36 | void setup() { 37 | // set the digital pin as output: 38 | pinMode(ledPin, OUTPUT); 39 | } 40 | 41 | void loop() 42 | { 43 | // here is where you'd put code that needs to be running all the time. 44 | 45 | // check to see if it's time to blink the LED; that is, if the 46 | // difference between the current time and last time you blinked 47 | // the LED is bigger than the interval at which you want to 48 | // blink the LED. 49 | unsigned long currentMillis = millis(); 50 | 51 | if(currentMillis - previousMillis > interval) { 52 | // save the last time you blinked the LED 53 | previousMillis = currentMillis; 54 | 55 | // if the LED is off turn it on and vice-versa: 56 | if (ledState == LOW) 57 | ledState = HIGH; 58 | else 59 | ledState = LOW; 60 | 61 | // set the LED with the ledState of the variable: 62 | digitalWrite(ledPin, ledState); 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/MakefileExample/Makefile-3rd_party-board.mk: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER 2 | ### This is an example Makefile and it MUST be configured to suit your needs. 3 | ### For detailed explanations about all of the available options, please refer 4 | ### to https://github.com/sudar/Arduino-Makefile/blob/master/arduino-mk-vars.md 5 | 6 | ### How to setup a project using a board definition provided by the 3rd party 7 | ### ========================================================================= 8 | 9 | ### Some vendors provide definitions/configuration of their boards separately, 10 | ### as so-called addon packages. Originally, they are supposed to be used in 11 | ### the Arduino IDE but they can be used with Arduino-Makefile as well: 12 | 13 | ### 1. get the package from the vendor 14 | ### if they provide .json file, look into it and take the URL of the package 15 | ### archive from there 16 | ### 17 | ### 2. extract the package into your ARDUINO_SKETCHBOOK directory 18 | ### you have to end with the directory structure like this, in your 19 | ### ARDUINO_SKETCHBOOK directory (sparkfun is the vendor name): 20 | 21 | ### hardware/ 22 | ### ├── sparkfun/ 23 | ### │ └── avr/ 24 | ### │ ├── boards.txt 25 | ### │ ├── bootloaders/ 26 | ### │ ├── driver/ 27 | ### │ ├── platform.txt 28 | ### │ ├── signed_driver/ 29 | ### │ └── variants/ 30 | 31 | ### 3. Create this Makefile (use your vendor/package name) 32 | 33 | ### ALTERNATE_CORE = sparkfun 34 | ### include $(HOME)/Arduino-Makefile/Arduino.mk 35 | 36 | ### 4. run 'make show_boards' 37 | ### check that you can see (only) boards provided by this vendor 38 | 39 | ### 5. select the name of your board 40 | ### and add a line "BOARD_TAG = ...." to your Makefile 41 | 42 | ### 6. if your board has more cpu variants, run 'make show_submenu' 43 | ### to see them; select your one and add a line "BOARD_SUB = ...." 44 | ### to your Makefile 45 | 46 | ##### 47 | 48 | ### The basic configuration should be done now. 49 | ### The example follows: 50 | 51 | ARDUINO_SKETCHBOOK = $(HOME)/sketchbook 52 | ALTERNATE_CORE = sparkfun 53 | BOARD_TAG = promicro 54 | BOARD_SUB = 8MHzatmega32U4 55 | include $(ARDMK_DIR)/Arduino.mk 56 | 57 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/toneMelody/pitches.h: -------------------------------------------------------------------------------- 1 | /************************************************* 2 | * Public Constants 3 | *************************************************/ 4 | 5 | #define NOTE_B0 31 6 | #define NOTE_C1 33 7 | #define NOTE_CS1 35 8 | #define NOTE_D1 37 9 | #define NOTE_DS1 39 10 | #define NOTE_E1 41 11 | #define NOTE_F1 44 12 | #define NOTE_FS1 46 13 | #define NOTE_G1 49 14 | #define NOTE_GS1 52 15 | #define NOTE_A1 55 16 | #define NOTE_AS1 58 17 | #define NOTE_B1 62 18 | #define NOTE_C2 65 19 | #define NOTE_CS2 69 20 | #define NOTE_D2 73 21 | #define NOTE_DS2 78 22 | #define NOTE_E2 82 23 | #define NOTE_F2 87 24 | #define NOTE_FS2 93 25 | #define NOTE_G2 98 26 | #define NOTE_GS2 104 27 | #define NOTE_A2 110 28 | #define NOTE_AS2 117 29 | #define NOTE_B2 123 30 | #define NOTE_C3 131 31 | #define NOTE_CS3 139 32 | #define NOTE_D3 147 33 | #define NOTE_DS3 156 34 | #define NOTE_E3 165 35 | #define NOTE_F3 175 36 | #define NOTE_FS3 185 37 | #define NOTE_G3 196 38 | #define NOTE_GS3 208 39 | #define NOTE_A3 220 40 | #define NOTE_AS3 233 41 | #define NOTE_B3 247 42 | #define NOTE_C4 262 43 | #define NOTE_CS4 277 44 | #define NOTE_D4 294 45 | #define NOTE_DS4 311 46 | #define NOTE_E4 330 47 | #define NOTE_F4 349 48 | #define NOTE_FS4 370 49 | #define NOTE_G4 392 50 | #define NOTE_GS4 415 51 | #define NOTE_A4 440 52 | #define NOTE_AS4 466 53 | #define NOTE_B4 494 54 | #define NOTE_C5 523 55 | #define NOTE_CS5 554 56 | #define NOTE_D5 587 57 | #define NOTE_DS5 622 58 | #define NOTE_E5 659 59 | #define NOTE_F5 698 60 | #define NOTE_FS5 740 61 | #define NOTE_G5 784 62 | #define NOTE_GS5 831 63 | #define NOTE_A5 880 64 | #define NOTE_AS5 932 65 | #define NOTE_B5 988 66 | #define NOTE_C6 1047 67 | #define NOTE_CS6 1109 68 | #define NOTE_D6 1175 69 | #define NOTE_DS6 1245 70 | #define NOTE_E6 1319 71 | #define NOTE_F6 1397 72 | #define NOTE_FS6 1480 73 | #define NOTE_G6 1568 74 | #define NOTE_GS6 1661 75 | #define NOTE_A6 1760 76 | #define NOTE_AS6 1865 77 | #define NOTE_B6 1976 78 | #define NOTE_C7 2093 79 | #define NOTE_CS7 2217 80 | #define NOTE_D7 2349 81 | #define NOTE_DS7 2489 82 | #define NOTE_E7 2637 83 | #define NOTE_F7 2794 84 | #define NOTE_FS7 2960 85 | #define NOTE_G7 3136 86 | #define NOTE_GS7 3322 87 | #define NOTE_A7 3520 88 | #define NOTE_AS7 3729 89 | #define NOTE_B7 3951 90 | #define NOTE_C8 4186 91 | #define NOTE_CS8 4435 92 | #define NOTE_D8 4699 93 | #define NOTE_DS8 4978 94 | 95 | 96 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/tests/script/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | TESTS_DIR=examples 5 | export ARDMK_DIR="${ARDMK_DIR:-$SCRIPTS_DIR/../..}" 6 | 7 | failures=() 8 | 9 | if [[ "$1" == "-q" ]]; then 10 | QUIET=1 11 | fi 12 | 13 | runtest() { 14 | if [[ $QUIET ]]; then 15 | make $* TEST=1 > /dev/null 2>&1 16 | else 17 | output=`make $* TEST=1` 18 | fi 19 | } 20 | 21 | run() { 22 | if [[ $QUIET ]]; then 23 | "$@" > /dev/null 2>&1 24 | else 25 | "$@" 26 | fi 27 | } 28 | 29 | info() { 30 | if [[ $QUIET ]]; then 31 | return 32 | fi 33 | 34 | echo "$@" 35 | } 36 | 37 | run pushd $SCRIPTS_DIR/../.. 38 | 39 | # These examples cannot be tested easily at the moment as they require 40 | # alternate cores. The MakefileExample doesn't actually contain any source code 41 | # to compile. 42 | NON_TESTABLE_EXAMPLES=(ATtinyBlink MakefileExample TinySoftWareSerial BlinkOpenCM BlinkOpenCR BlinkTeensy BlinkNetworkRPi BlinkInAVRC DueBlink) 43 | 44 | for dir in $TESTS_DIR/*/ 45 | do 46 | dir=${dir%*/} 47 | example=${dir##*/} 48 | example_is_testable=true 49 | for non_testable_example in "${NON_TESTABLE_EXAMPLES[@]}"; do 50 | if [[ $example == $non_testable_example ]]; then 51 | example_is_testable=false 52 | break 53 | fi 54 | done 55 | 56 | if ! $example_is_testable; then 57 | info "Skipping non-testable example $example..." 58 | continue 59 | fi 60 | 61 | run pushd $dir 62 | info "Compiling $example..." 63 | runtest clean 64 | runtest 65 | 66 | if [[ $? -ne 0 ]]; then 67 | failures+=("$example") 68 | info "Example $example failed" 69 | fi 70 | 71 | runtest disasm 72 | if [[ $? -ne 0 ]]; then 73 | failures+=("$example disasm") 74 | info "Example $example disasm failed" 75 | fi 76 | 77 | runtest generate_assembly 78 | if [[ $? -ne 0 ]]; then 79 | failures+=("$example generate_assembly") 80 | info "Example $example generate_assembly failed" 81 | fi 82 | 83 | runtest symbol_sizes 84 | if [[ $? -ne 0 ]]; then 85 | failures+=("$example symbol_sizes") 86 | info "Example $example symbol_sizes failed" 87 | fi 88 | 89 | run popd 90 | done 91 | 92 | if [[ ${#failures[@]} -eq 0 ]]; then 93 | echo "All tests passed." 94 | else 95 | for failure in "${failures[@]}"; do 96 | echo "Example $failure failed" 97 | done 98 | 99 | exit 1 100 | fi 101 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/WebServer/WebServer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Web Server 3 | 4 | A simple web server that shows the value of the analog input pins. 5 | using an Arduino Wiznet Ethernet shield. 6 | 7 | Circuit: 8 | * Ethernet shield attached to pins 10, 11, 12, 13 9 | * Analog inputs attached to pins A0 through A5 (optional) 10 | 11 | created 18 Dec 2009 12 | by David A. Mellis 13 | modified 4 Sep 2010 14 | by Tom Igoe 15 | 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | // Enter a MAC address and IP address for your controller below. 22 | // The IP address will be dependent on your local network: 23 | byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 24 | IPAddress ip(192,168,1, 178); 25 | 26 | // Initialize the Ethernet server library 27 | // with the IP address and port you want to use 28 | // (port 80 is default for HTTP): 29 | EthernetServer server(80); 30 | 31 | void setup() 32 | { 33 | // start the Ethernet connection and the server: 34 | Ethernet.begin(mac, ip); 35 | server.begin(); 36 | } 37 | 38 | void loop() 39 | { 40 | // listen for incoming clients 41 | EthernetClient client = server.available(); 42 | if (client) { 43 | // an http request ends with a blank line 44 | boolean currentLineIsBlank = true; 45 | while (client.connected()) { 46 | if (client.available()) { 47 | char c = client.read(); 48 | // if you've gotten to the end of the line (received a newline 49 | // character) and the line is blank, the http request has ended, 50 | // so you can send a reply 51 | if (c == '\n' && currentLineIsBlank) { 52 | // send a standard http response header 53 | client.println("HTTP/1.1 200 OK"); 54 | client.println("Content-Type: text/html"); 55 | client.println(); 56 | 57 | // output the value of each analog input pin 58 | for (int analogChannel = 0; analogChannel < 6; analogChannel++) { 59 | client.print("analog input "); 60 | client.print(analogChannel); 61 | client.print(" is "); 62 | client.print(analogRead(analogChannel)); 63 | client.println("
"); 64 | } 65 | break; 66 | } 67 | if (c == '\n') { 68 | // you're starting a new line 69 | currentLineIsBlank = true; 70 | } 71 | else if (c != '\r') { 72 | // you've gotten a character on the current line 73 | currentLineIsBlank = false; 74 | } 75 | } 76 | } 77 | // give the web browser time to receive the data 78 | delay(1); 79 | // close the connection: 80 | client.stop(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/bin/robotis-loader: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | # This script sends a program on a robotis board (OpenCM9.04 or CM900) 4 | # using the robotis bootloader (used in OpenCM IDE) 5 | # 6 | # Usage: 7 | # python robotis-loader.py 8 | # 9 | # Example: 10 | # python robotis-loader.py /dev/ttyACM0 firmware.bin 11 | # 12 | # https://github.com/Gregwar/robotis-loader 13 | 14 | import serial, sys, os, time 15 | 16 | print('~~ Robotis loader ~~') 17 | print('') 18 | 19 | # Reading command line 20 | if len(sys.argv) != 3: 21 | exit('! Usage: robotis-loader.py ') 22 | pgm, port, binary = sys.argv 23 | 24 | # Helper to prints a progress bar 25 | def progressBar(percent, precision=65): 26 | threshold=precision*percent/100.0 27 | sys.stdout.write('[ ') 28 | for x in xrange(0, precision): 29 | if x < threshold: sys.stdout.write('#') 30 | else: sys.stdout.write(' ') 31 | sys.stdout.write(' ] ') 32 | sys.stdout.flush() 33 | 34 | # Opening the firmware file 35 | try: 36 | stat = os.stat(binary) 37 | size = stat.st_size 38 | firmware = file(binary, 'rb') 39 | print('* Opening %s, size=%d' % (binary, size)) 40 | except: 41 | exit('! Unable to open file %s' % binary) 42 | 43 | # Opening serial port 44 | try: 45 | s = serial.Serial(port, baudrate=115200) 46 | except: 47 | exit('! Unable to open serial port %s' % port) 48 | 49 | print('* Resetting the board') 50 | s.setRTS(True) 51 | s.setDTR(False) 52 | time.sleep(0.1) 53 | s.setRTS(False) 54 | s.write('CM9X') 55 | s.close() 56 | time.sleep(1.0); 57 | 58 | print('* Connecting...') 59 | s = serial.Serial(port, baudrate=115200) 60 | s.write('AT&LD') 61 | print('* Download signal transmitted, waiting...') 62 | 63 | # Entering bootloader sequence 64 | while True: 65 | line = s.readline().strip() 66 | if line.endswith('Ready..'): 67 | print('* Board ready, sending data') 68 | cs = 0 69 | pos = 0 70 | while True: 71 | c = firmware.read(2048) 72 | if len(c): 73 | pos += len(c) 74 | sys.stdout.write("\r") 75 | progressBar(100*float(pos)/float(size)) 76 | s.write(c) 77 | for k in range(0,len(c)): 78 | cs = (cs+ord(c[k]))%256 79 | else: 80 | break 81 | print('') 82 | s.setDTR(True) 83 | print('* Checksum: %d' % (cs)) 84 | s.write(chr(cs)) 85 | print('* Firmware was sent') 86 | else: 87 | if line == 'Success..': 88 | print('* Success, running the code') 89 | print('') 90 | s.write('AT&RST') 91 | s.close() 92 | exit() 93 | else: 94 | print('Board -> '+line) 95 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/examples/MakefileExample/Makefile-example.mk: -------------------------------------------------------------------------------- 1 | ### DISCLAIMER 2 | ### This is an example Makefile and it MUST be configured to suit your needs. 3 | ### For detailed explanations about all of the available options, please refer 4 | ### to https://github.com/sudar/Arduino-Makefile/blob/master/arduino-mk-vars.md 5 | ### Original project where this Makefile comes from: https://github.com/WeAreLeka/Bare-Arduino-Project 6 | 7 | ### PROJECT_DIR 8 | ### This is the path to where you have created/cloned your project 9 | PROJECT_DIR = /Users/MyUserName/path/to/my/Project 10 | 11 | ### ARDMK_DIR 12 | ### Path to the Arduino-Makefile directory. 13 | ARDMK_DIR = $(PROJECT_DIR)/Arduino-Makefile 14 | 15 | ### ARDUINO_DIR 16 | ### Path to the Arduino application and resources directory. 17 | ### On OS X: 18 | ARDUINO_DIR = /Applications/Arduino.app/Contents/Java 19 | ### or on Linux: (remove the one you don't want) 20 | ARDUINO_DIR = /usr/share/arduino 21 | 22 | ### USER_LIB_PATH 23 | ### Path to where the your project's libraries are stored. 24 | USER_LIB_PATH := $(PROJECT_DIR)/lib 25 | 26 | ### BOARD_TAG 27 | ### It must be set to the board you are currently using. (i.e uno, mega2560, etc.) 28 | BOARD_TAG = uno 29 | 30 | ### MONITOR_BAUDRATE 31 | ### It must be set to Serial baudrate value you are using. 32 | MONITOR_BAUDRATE = 115200 33 | 34 | ### AVR_TOOLS_DIR 35 | ### Path to the AVR tools directory such as avr-gcc, avr-g++, etc. 36 | ### On OS X with `homebrew`: 37 | AVR_TOOLS_DIR = /usr/local 38 | ### or on Linux: (remove the one you don't want) 39 | AVR_TOOLS_DIR = /usr 40 | 41 | ### AVRDUDE 42 | ### Path to avrdude directory. 43 | ### On OS X with `homebrew`: 44 | AVRDUDE = /usr/local/bin/avrdude 45 | ### or on Linux: (remove the one you don't want) 46 | AVRDUDE = /usr/bin/avrdude 47 | 48 | ### CFLAGS_STD 49 | ### Set the C standard to be used during compilation. Documentation (https://github.com/WeAreLeka/Arduino-Makefile/blob/std-flags/arduino-mk-vars.md#cflags_std) 50 | CFLAGS_STD = -std=gnu11 51 | 52 | ### CXXFLAGS_STD 53 | ### Set the C++ standard to be used during compilation. Documentation (https://github.com/WeAreLeka/Arduino-Makefile/blob/std-flags/arduino-mk-vars.md#cxxflags_std) 54 | CXXFLAGS_STD = -std=gnu++11 55 | 56 | ### CXXFLAGS 57 | ### Flags you might want to set for debugging purpose. Comment to stop. 58 | CXXFLAGS += -pedantic -Wall -Wextra 59 | 60 | ### MONITOR_PORT 61 | ### The port your board is connected to. Using an '*' tries all the ports and finds the right one. 62 | MONITOR_PORT = /dev/tty.usbmodem* 63 | 64 | ### CURRENT_DIR 65 | ### Do not touch - used for binaries path 66 | CURRENT_DIR = $(shell basename $(CURDIR)) 67 | 68 | ### OBJDIR 69 | ### This is where you put the binaries you just compile using 'make' 70 | OBJDIR = $(PROJECT_DIR)/bin/$(BOARD_TAG)/$(CURRENT_DIR) 71 | 72 | ### Do not touch - the path to Arduino.mk, inside the ARDMK_DIR 73 | include $(ARDMK_DIR)/Arduino.mk 74 | 75 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/packaging/fedora/arduino-mk.spec: -------------------------------------------------------------------------------- 1 | Name: arduino-mk 2 | Version: 1.6.0 3 | Release: 2%{dist} 4 | Summary: Program your Arduino from the command line 5 | Packager: Simon John 6 | URL: https://github.com/sudar/Arduino-Makefile 7 | Source: %{name}-%{version}.tar.gz 8 | Group: Development/Tools 9 | License: LGPLv2+ 10 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 11 | BuildArch: noarch 12 | Requires: arduino-core python3-pyserial 13 | 14 | %description 15 | Arduino is an open-source electronics prototyping platform based on 16 | flexible, easy-to-use hardware and software. It's intended for artists, 17 | designers, hobbyists, and anyone interested in creating interactive 18 | objects or environments. 19 | 20 | This package will install a Makefile to allow for CLI programming of the 21 | Arduino platform. 22 | 23 | %prep 24 | %setup -q 25 | 26 | %install 27 | mkdir -p %{buildroot}/%{_datadir}/arduino 28 | mkdir -p %{buildroot}/%{_bindir} 29 | mkdir -p %{buildroot}/%{_mandir}/man1 30 | mkdir -p %{buildroot}/%{_docdir}/%{name}/examples 31 | install -m 755 -d %{buildroot}/%{_docdir}/%{name} 32 | install -m 755 -d %{buildroot}/%{_docdir}/%{name}/examples 33 | for dir in `find examples -type d` ; do install -m 755 -d %{buildroot}/%{_docdir}/%{name}/$dir ; done 34 | for file in `find examples -type f ! -name .gitignore` ; do install -m 644 $file %{buildroot}/%{_docdir}/%{name}/$file ; done 35 | install -m 644 *.mk arduino-mk-vars.md %{buildroot}/%{_datadir}/arduino 36 | install -m 644 licence.txt %{buildroot}/%{_docdir}/%{name} 37 | install -m 755 bin/ard-reset-arduino %{buildroot}/%{_bindir}/ard-reset-arduino 38 | install -m 644 ard-reset-arduino.1 %{buildroot}/%{_mandir}/man1 39 | install -m 755 bin/robotis-loader %{buildroot}/%{_bindir}/robotis-loader 40 | install -m 644 robotis-loader.1 %{buildroot}/%{_mandir}/man1 41 | install -m 755 bin/ardmk-init %{buildroot}/%{_bindir}/ardmk-init 42 | install -m 644 ardmk-init.1 %{buildroot}/%{_mandir}/man1 43 | 44 | %clean 45 | rm -rf %{buildroot} 46 | 47 | %files 48 | %defattr(-,root,root,-) 49 | %{_bindir}/ard-reset-arduino 50 | %{_mandir}/man1/ard-reset-arduino.1* 51 | %{_bindir}/robotis-loader 52 | %{_mandir}/man1/robotis-loader.1* 53 | %{_bindir}/ardmk-init 54 | %{_mandir}/man1/ardmk-init.1* 55 | %{_datadir}/arduino/*.mk 56 | %{_datadir}/arduino/arduino-mk-vars.md 57 | %doc %{_docdir}/%{name}/licence.txt 58 | %docdir %{_docdir}/%{name}/examples 59 | %{_docdir}/%{name}/examples 60 | 61 | %changelog 62 | * Thu Oct 24 2019 Simon John 63 | - Removed BuildRequires 64 | * Thu Oct 05 2017 Simon John 65 | - Added ardmk-init binary and manpage 66 | * Tue Jul 11 2017 Karl Semich 67 | - Added robotis-loader binary and manpage 68 | * Sat Apr 12 2014 Simon John 69 | - Put manpage back. 70 | * Fri Apr 04 2014 Simon John 71 | - Removed BuildRequires of python3/pyserial. 72 | * Wed Apr 02 2014 Simon John 73 | - Added BuildRequires of python3-pyserial. Need to look into Requires. 74 | * Mon Mar 24 2014 Simon John 75 | - Replaced perl/help2man with pyserial for reset script. 76 | * Tue Feb 04 2014 Simon John 77 | - Added arduino-mk-vars.md to the files to be installed/packaged. 78 | * Sat Feb 01 2014 Simon John 79 | - Updated version. 80 | * Mon Jan 13 2014 Simon John 81 | - Removed arduino-mk subdirectory 82 | * Mon Dec 30 2013 Simon John 83 | - Initial release. 84 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/chipKIT.mk: -------------------------------------------------------------------------------- 1 | # 2 | # chipKIT extensions for Arduino Makefile 3 | # System part (i.e. project independent) 4 | # 5 | # Copyright (C) 2011, 2012, 2013 Christopher Peplin 6 | # , based on work that is Copyright Martin 7 | # Oldfield 8 | # 9 | # This file is free software; you can redistribute it and/or modify it 10 | # under the terms of the GNU Lesser General Public License as 11 | # published by the Free Software Foundation; either version 2.1 of the 12 | # License, or (at your option) any later version. 13 | # 14 | # Modified by John Wallbank for Visual Studio 15 | # 16 | # Development changes, John Wallbank, 17 | # 18 | # - made inclusion of WProgram.h optional so that 19 | # including it in the source doesn't mess up compile error line numbers 20 | # - parameterised the routine used to reset the serial port 21 | # 22 | 23 | ######################################################################## 24 | # Makefile distribution path 25 | # 26 | 27 | # The show_config_variable is unavailable before we include the common makefile, 28 | # so we defer logging the ARDMK_DIR info until it happens in Arduino.mk 29 | ifndef ARDMK_DIR 30 | # presume it's the same path to our own file 31 | ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))) 32 | endif 33 | 34 | include $(ARDMK_DIR)/Common.mk 35 | 36 | ifndef MPIDE_DIR 37 | AUTO_MPIDE_DIR := $(firstword \ 38 | $(call dir_if_exists,/usr/share/mpide) \ 39 | $(call dir_if_exists,/Applications/Mpide.app/Contents/Resources/Java) ) 40 | ifdef AUTO_MPIDE_DIR 41 | MPIDE_DIR = $(AUTO_MPIDE_DIR) 42 | $(call show_config_variable,MPIDE_DIR,[autodetected]) 43 | else 44 | echo $(error "mpide_dir is not defined") 45 | endif 46 | else 47 | $(call show_config_variable,MPIDE_DIR,[USER]) 48 | endif 49 | 50 | ifeq ($(CURRENT_OS),WINDOWS) 51 | ifneq ($(shell echo $(ARDUINO_DIR) | egrep '^(/|[a-zA-Z]:\\)'),) 52 | echo $(error On Windows, MPIDE_DIR must be a relative path) 53 | endif 54 | endif 55 | 56 | ifndef MPIDE_PREFERENCES_PATH 57 | AUTO_MPIDE_PREFERENCES_PATH := $(firstword \ 58 | $(call dir_if_exists,$(HOME)/.mpide/preferences.txt) \ 59 | $(call dir_if_exists,$(HOME)/Library/Mpide/preferences.txt) ) 60 | ifdef AUTO_MPIDE_PREFERENCES_PATH 61 | MPIDE_PREFERENCES_PATH = $(AUTO_MPIDE_PREFERENCES_PATH) 62 | $(call show_config_variable,MPIDE_PREFERENCES_PATH,[autodetected]) 63 | endif 64 | endif 65 | 66 | # The same as in Arduino, the Linux distribution contains avrdude and # 67 | # avrdude.conf in a different location, but for chipKIT it's even slightly 68 | # different than the Linux paths for Arduino, so we have to "double override". 69 | ifeq ($(CURRENT_OS),LINUX) 70 | AVRDUDE_DIR = $(ARDUINO_DIR)/hardware/tools 71 | AVRDUDE = $(AVRDUDE_DIR)/avrdude 72 | AVRDUDE_CONF = $(AVRDUDE_DIR)/avrdude.conf 73 | endif 74 | 75 | AVR_TOOLS_DIR = $(ARDUINO_DIR)/hardware/pic32/compiler/pic32-tools 76 | 77 | ALTERNATE_CORE = pic32 78 | ALTERNATE_CORE_PATH = $(MPIDE_DIR)/hardware/pic32 79 | ARDUINO_CORE_PATH = $(ALTERNATE_CORE_PATH)/cores/$(ALTERNATE_CORE) 80 | ARDUINO_PREFERENCES_PATH = $(MPIDE_PREFERENCES_PATH) 81 | ARDUINO_DIR = $(MPIDE_DIR) 82 | 83 | CORE_AS_SRCS = $(ARDUINO_CORE_PATH)/vector_table.S \ 84 | $(ARDUINO_CORE_PATH)/cpp-startup.S \ 85 | $(ARDUINO_CORE_PATH)/crti.S \ 86 | $(ARDUINO_CORE_PATH)/crtn.S \ 87 | $(ARDUINO_CORE_PATH)/pic32_software_reset.S 88 | 89 | ARDUINO_VERSION = 23 90 | 91 | TOOL_PREFIX = pic32 92 | 93 | LDSCRIPT = $(call PARSE_BOARD,$(BOARD_TAG),ldscript) 94 | LDSCRIPT_FILE = $(ARDUINO_CORE_PATH)/$(LDSCRIPT) 95 | 96 | MCU_FLAG_NAME=mprocessor 97 | LDFLAGS += -mdebugger -mno-peripheral-libs -nostartfiles -Wl,--gc-sections 98 | LINKER_SCRIPTS += -T $(ARDUINO_CORE_PATH)/$(LDSCRIPT) 99 | LINKER_SCRIPTS += -T $(ARDUINO_CORE_PATH)/chipKIT-application-COMMON.ld 100 | CPPFLAGS += -mno-smart-io -fno-short-double -fframe-base-loclist \ 101 | -g3 -Wcast-align -D_BOARD_MEGA_ 102 | CFLAGS_STD = 103 | 104 | include $(ARDMK_DIR)/Arduino.mk 105 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/bin/ard-reset-arduino: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import serial 4 | import serial.tools.list_ports 5 | import os.path 6 | import argparse 7 | from time import sleep 8 | 9 | parser = argparse.ArgumentParser(description='Reset an Arduino') 10 | parser.add_argument('--zero', action='store_true', help='Reset Arduino Zero or similar Native USB to enter bootloader') 11 | parser.add_argument('--caterina', action='store_true', help='Reset a Leonardo, Micro, Robot or LilyPadUSB.') 12 | parser.add_argument('--verbose', action='store_true', help="Watch what's going on on STDERR.") 13 | parser.add_argument('--period', default=0.1, help='Specify the DTR pulse width in seconds.') 14 | parser.add_argument('port', nargs=1, help='Serial device e.g. /dev/ttyACM0') 15 | args = parser.parse_args() 16 | 17 | 18 | def list_ports(output=False): 19 | """ Lists serial ports attached 20 | 21 | :returns 22 | A list of paths to serial ports on system 23 | """ 24 | ports = serial.tools.list_ports.comports() 25 | connected = [port[0] for port in ports] 26 | if output: 27 | print(connected) 28 | 29 | return connected 30 | 31 | 32 | def new_port(old, new): 33 | """ Checks if a new port has attached 34 | 35 | Args: 36 | old: previous list of ports to check 37 | new: current list of ports to check 38 | Returns: 39 | index of port in 'new' if new port found, otherwise -1 40 | """ 41 | new_port = -1 42 | 43 | for port in new: 44 | if port not in old: 45 | new_port = new.index(port) 46 | break 47 | 48 | return new_port 49 | 50 | 51 | if args.zero: 52 | # number of trys to attempt 53 | zero_attempts = 20 # ~2 seconds 54 | initial_ports = list_ports(args.verbose) 55 | 56 | if args.verbose: 57 | print('Attempting to enter bootloader using 1200 bps open/close on port %s' % args.port[0]) 58 | 59 | ser = serial.Serial(args.port[0], 57600) 60 | ser.close() 61 | ser.baudrate = 1200 62 | 63 | # do the open/close at 1200 BAUD 64 | ser.open() 65 | ser.close() 66 | 67 | if args.verbose: 68 | print('Done. Waiting for bootloader port to attach...') 69 | 70 | # get new list of ports 71 | reset_ports = list_ports(args.verbose) 72 | 73 | # wait for new port or port to return 74 | port_index = new_port(initial_ports, reset_ports) 75 | 76 | # keep checking until new port appears or timeout 77 | while port_index < 0: 78 | # count down attempts and leave if expired 79 | zero_attempts -= 1 80 | if zero_attempts < 0: 81 | break 82 | sleep(0.1) 83 | # get list of ports after bootloader toggle performed 84 | reset_ports = list_ports(args.verbose) 85 | # if a port drops, set initial ports to reset ports so that 86 | # next attached device will be new port 87 | if (len(reset_ports) < len(initial_ports)): 88 | initial_ports = reset_ports 89 | # check if a new port has attached and return the index if it has 90 | port_index = new_port(initial_ports, reset_ports) 91 | # return the new port if detected, otherwise return passed port 92 | if port_index == -1: 93 | bootloader_port = args.port[0] 94 | else: 95 | bootloader_port = reset_ports[port_index] 96 | 97 | # print so that `tail -1` can be piped for bootloader port 98 | print(bootloader_port) 99 | elif args.caterina: 100 | if args.verbose: print('Forcing reset using 1200bps open/close on port %s' % args.port[0]) 101 | ser = serial.Serial(args.port[0], 57600) 102 | ser.close() 103 | 104 | if pyserial_version < 3: 105 | ser.setBaudrate (1200) 106 | else: 107 | ser.baudrate = 1200 108 | 109 | ser.open() 110 | ser.setRTS(True) # RTS line needs to be held high and DTR low 111 | ser.setDTR(False) # (see Arduino IDE source code) 112 | ser.close() 113 | sleep(1) 114 | 115 | while not os.path.exists(args.port[0]): 116 | if args.verbose: print('Waiting for %s to come back' % args.port[0]) 117 | sleep(1) 118 | 119 | if args.verbose: print('%s has come back after reset' % args.port[0]) 120 | else: 121 | if args.verbose: print('Setting DTR high on %s for %ss' % (args.port[0],args.period)) 122 | ser = serial.Serial(args.port[0], 115200) 123 | ser.setDTR(False) 124 | sleep(args.period) 125 | ser.setDTR(True) 126 | ser.close() 127 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/Teensy.mk: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # 3 | # Support for Teensy 3.x boards 4 | # 5 | # https://www.pjrc.com/teensy/ 6 | # 7 | # You must install teensyduino for this Makefile to work: 8 | # 9 | # http://www.pjrc.com/teensy/teensyduino.html 10 | # 11 | # Copyright (C) 2014 Jeremy Shaw based on 12 | # work that is copyright Sudar, Nicholas Zambetti, David A. Mellis 13 | # & Hernando Barragan. 14 | # 15 | # This file is free software; you can redistribute it and/or modify it 16 | # under the terms of the GNU Lesser General Public License as 17 | # published by the Free Software Foundation; either version 2.1 of the 18 | # License, or (at your option) any later version. 19 | # 20 | # Adapted from Arduino 0011 Makefile by M J Oldfield 21 | # 22 | # Original Arduino adaptation by mellis, eighthave, oli.keller 23 | # 24 | # Refer to HISTORY.md file for complete history of changes 25 | # 26 | ######################################################################## 27 | 28 | 29 | ifndef ARDMK_DIR 30 | ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))) 31 | endif 32 | 33 | # include Common.mk now we know where it is 34 | include $(ARDMK_DIR)/Common.mk 35 | 36 | ARDMK_VENDOR = teensy 37 | ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/teensy/avr/cores/teensy3 38 | BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/avr/boards.txt 39 | 40 | 41 | ifndef F_CPU 42 | ifndef BOARD_SUB 43 | SPEEDS := $(call PARSE_BOARD,"$(BOARD_TAG),menu.speed.*.build.fcpu") # Obtain sequence of supported frequencies. 44 | SPEEDS := $(shell printf "%d\n" $(SPEEDS) | sort -g) # Sort it, just in case. Printf to re-append newlines so that sort works. 45 | F_CPU := $(lastword $(SPEEDS)) # List is sorted in ascending order. Take the fastest speed. 46 | #$(info "speeds is " $(SPEEDS)) # Good for debugging 47 | else 48 | F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),menu.speed.$(BOARD_SUB).build.fcpu) 49 | endif 50 | endif 51 | 52 | # if boards.txt gets modified, look there, else hard code it 53 | ARCHITECTURE = $(call PARSE_BOARD,$(BOARD_TAG),build.architecture) 54 | ifeq ($(strip $(ARCHITECTURE)),) 55 | ARCHITECTURE = arm 56 | endif 57 | 58 | AVR_TOOLS_DIR = $(call dir_if_exists,$(ARDUINO_DIR)/hardware/tools/$(ARCHITECTURE)) 59 | 60 | # define plaform lib dir ignoring teensy's oversight on putting it all in avr 61 | ifndef ARDUINO_PLATFORM_LIB_PATH 62 | ARDUINO_PLATFORM_LIB_PATH = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/avr/libraries 63 | $(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[COMPUTED],(from ARDUINO_DIR)) 64 | endif 65 | 66 | ######################################################################## 67 | # command names 68 | 69 | TOOL_PREFIX = arm-none-eabi 70 | 71 | # processor stuff 72 | ifndef MCU 73 | MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu) 74 | endif 75 | 76 | ifndef MCU_FLAG_NAME 77 | MCU_FLAG_NAME=mcpu 78 | endif 79 | 80 | ######################################################################## 81 | # FLAGS 82 | ifndef USB_TYPE 83 | USB_TYPE = USB_SERIAL 84 | endif 85 | 86 | CPPFLAGS += -DLAYOUT_US_ENGLISH -D$(USB_TYPE) 87 | 88 | CPPFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.option) 89 | 90 | CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.cppoption) 91 | ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.gnu0x)","true") 92 | CXXFLAGS_STD += -std=gnu++0x 93 | endif 94 | 95 | ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.elide_constructors)", "true") 96 | CXXFLAGS += -felide-constructors 97 | endif 98 | 99 | CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.common) 100 | CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu) 101 | CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.defs) 102 | CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpp) 103 | 104 | CFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.common) 105 | CFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu) 106 | CFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.defs) 107 | 108 | ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.common) 109 | ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu) 110 | ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.defs) 111 | ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.S) 112 | 113 | LDFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu) 114 | 115 | AMCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu) 116 | LDFLAGS += -Wl,--gc-sections,--relax 117 | LINKER_SCRIPTS ?= -T${ARDUINO_CORE_PATH}/${AMCU}.ld 118 | OTHER_LIBS = $(call PARSE_BOARD,$(BOARD_TAG),build.flags.libs) 119 | 120 | CPUFLAGS = $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu) 121 | # usually defined as per teensy31.build.mcu=mk20dx256 but that isn't valid switch 122 | MCU := $(shell echo ${CPUFLAGS} | sed -n -e 's/.*-mcpu=\([a-zA-Z0-9_-]*\).*/\1/p') 123 | 124 | ######################################################################## 125 | # some fairly odd settings so that 'make upload' works 126 | # 127 | # may require additional patches for Windows support 128 | 129 | do_upload: override get_monitor_port="" 130 | AVRDUDE=@true 131 | RESET_CMD = nohup $(ARDUINO_DIR)/hardware/tools/teensy_post_compile -board=$(BOARD_TAG) -tools=$(abspath $(ARDUINO_DIR)/hardware/tools) -path=$(abspath $(OBJDIR)) -file=$(TARGET) > /dev/null ; $(ARDUINO_DIR)/hardware/tools/teensy_reboot 132 | 133 | ######################################################################## 134 | # automatially include Arduino.mk for the user 135 | 136 | include $(ARDMK_DIR)/Arduino.mk 137 | 138 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/OpenCM.mk: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # 3 | # Support for Robotis OpenCM boards 4 | # 5 | # http://en.robotis.com/index/product.php?cate_code=131010 6 | # 7 | # You must install the OpenCM IDE for this Makefile to work: 8 | # 9 | # http://support.robotis.com/en/software/robotis_opencm/robotis_opencm.htm 10 | # 11 | # Based on work that is copyright Jeremy Shaw, Sudar, Nicholas Zambetti, 12 | # David A. Mellis & Hernando Barragan. 13 | # 14 | # This file is free software; you can redistribute it and/or modify it 15 | # under the terms of the GNU Lesser General Public License as 16 | # published by the Free Software Foundation; either version 2.1 of the 17 | # License, or (at your option) any later version. 18 | # 19 | # Adapted from Teensy 3.x makefile which was adapted from Arduino 0011 20 | # Makefile by M J Oldfield 21 | # 22 | # Original Arduino adaptation by mellis, eighthave, oli.keller 23 | # 24 | ######################################################################## 25 | 26 | ifndef ARDMK_DIR 27 | ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))) 28 | endif 29 | 30 | # include Common.mk now we know where it is 31 | include $(ARDMK_DIR)/Common.mk 32 | 33 | ARDUINO_DIR = $(OPENCMIDE_DIR) 34 | 35 | ifndef ARDMK_VENDOR 36 | ARDMK_VENDOR = robotis 37 | endif 38 | 39 | ifndef ARDUINO_CORE_PATH 40 | ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/robotis/cores/robotis 41 | endif 42 | 43 | ifndef BOARDS_TXT 44 | BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/boards.txt 45 | endif 46 | 47 | ifndef F_CPU 48 | F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),build.f_cpu) 49 | endif 50 | 51 | # if boards.txt gets modified, look there, else hard code it 52 | ARCHITECTURE = $(call PARSE_BOARD,$(BOARD_TAG),build.architecture) 53 | ifeq ($(strip $(ARCHITECTURE)),) 54 | ARCHITECTURE = arm 55 | endif 56 | 57 | AVR_TOOLS_DIR = $(call dir_if_exists,$(ARDUINO_DIR)/hardware/tools/$(ARCHITECTURE)) 58 | 59 | # Robotis has moved the platform lib dir to their root folder 60 | ifndef ARDUINO_PLATFORM_LIB_PATH 61 | ARDUINO_PLATFORM_LIB_PATH = $(ARDUINO_DIR)/libraries 62 | $(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[COMPUTED],(from ARDUINO_DIR)) 63 | endif 64 | 65 | ifndef ARDUINO_HEADER 66 | ARDUINO_HEADER = wirish.h 67 | endif 68 | 69 | ######################################################################## 70 | # command names 71 | 72 | TOOL_PREFIX = arm-none-eabi 73 | 74 | # processor stuff 75 | ifndef MCU 76 | MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.family) 77 | endif 78 | 79 | ifndef MCU_FLAG_NAME 80 | MCU_FLAG_NAME=mcpu 81 | endif 82 | 83 | ######################################################################## 84 | # FLAGS 85 | ifndef USB_TYPE 86 | USB_TYPE = USB_SERIAL 87 | endif 88 | 89 | CPPFLAGS += -DBOARD_$(call PARSE_BOARD,$(BOARD_TAG),build.board) 90 | CPPFLAGS += -DMCU_$(call PARSE_BOARD,$(BOARD_TAG),build.mcu) 91 | CPPFLAGS += -DSTM32_MEDIUM_DENSITY -DVECT_TAB_FLASH 92 | 93 | CPPFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.option) 94 | 95 | CXXFLAGS += -fno-rtti 96 | 97 | CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.cppoption) 98 | ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.gnu0x)","true") 99 | CXXFLAGS_STD += -std=gnu++0x 100 | endif 101 | 102 | ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.elide_constructors)", "true") 103 | CXXFLAGS += -felide-constructors 104 | endif 105 | 106 | CPPFLAGS += -mthumb -march=armv7-m -nostdlib -Wl,--gc-sections -Wall 107 | 108 | LDFLAGS += -T$(ARDUINO_DIR)/hardware/robotis/cores/robotis/CM900/flash.ld 109 | LDFLAGS += -L$(ARDUINO_CORE_PATH) 110 | LDFLAGS += -mthumb -Xlinker --gc-sections -Wall 111 | 112 | OTHER_LIBS += -lstdc++ 113 | 114 | ######################################################################## 115 | # Reset is handled by upload script 116 | override RESET_CMD = 117 | 118 | ######################################################################## 119 | # Object conversion & uploading magic, modified from Arduino.mk 120 | override TARGET_HEX = $(OBJDIR)/$(TARGET).bin 121 | 122 | ifndef AVRDUDE 123 | AVRDUDE := $(shell which robotis-loader 2>/dev/null) 124 | ifndef AVRDUDE 125 | AVRDUDE = $(ARDMK_DIR)/bin/robotis-loader 126 | endif 127 | endif 128 | 129 | override avr_size = $(SIZE) --target=binary $(2) 130 | 131 | override AVRDUDE_COM_OPTS = 132 | ifeq ($(CURRENT_OS), WINDOWS) 133 | override AVRDUDE_ARD_OPTS = $(COM_STYLE_MONITOR_PORT) 134 | else 135 | override AVRDUDE_ARD_OPTS = $(call get_monitor_port) 136 | endif 137 | 138 | override AVRDUDE_UPLOAD_HEX = $(TARGET_HEX) 139 | 140 | ######################################################################## 141 | # automatically include Arduino.mk 142 | 143 | include $(ARDMK_DIR)/Arduino.mk 144 | 145 | ######################################################################## 146 | # Object conversion & uploading magic, modified from Arduino.mk 147 | 148 | $(OBJDIR)/%.bin: $(OBJDIR)/%.elf $(COMMON_DEPS) 149 | @$(MKDIR) $(dir $@) 150 | $(OBJCOPY) -v -Obinary $< $@ 151 | @$(ECHO) '\n' 152 | $(call avr_size,$<,$@) 153 | ifneq ($(strip $(HEX_MAXIMUM_SIZE)),) 154 | @if [ `$(SIZE) --target=binary $@ | awk 'FNR == 2 {print $$2}'` -le $(HEX_MAXIMUM_SIZE) ]; then touch $@.sizeok; fi 155 | else 156 | @$(ECHO) "Maximum flash memory of $(BOARD_TAG) is not specified. Make sure the size of $@ is less then $(BOARD_TAG)\'s flash memory" 157 | @touch $@.sizeok 158 | endif 159 | 160 | # link fails to plug _sbrk into libc if core is a lib, seems a bug in the linker 161 | CORE_LIB = $(CORE_OBJS) 162 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/Common.mk: -------------------------------------------------------------------------------- 1 | COMMON_INCLUDED = TRUE 2 | # Useful functions 3 | # Returns the first argument (typically a directory), if the file or directory 4 | # named by concatenating the first and optionally second argument 5 | # (directory and optional filename) exists 6 | dir_if_exists = $(if $(wildcard $(1)$(2)),$(1)) 7 | 8 | # result = $(call READ_BOARD_TXT, 'boardname', 'parameter') 9 | PARSE_BOARD = $(shell if [ -f $(BOARDS_TXT) ]; \ 10 | then \ 11 | $(GREP_CMD) -Ev '^\#' $(BOARDS_TXT) | \ 12 | $(GREP_CMD) -E "^[ \t]*$(1).$(2)=" | \ 13 | cut -d = -f 2- | \ 14 | cut -d : -f 2; \ 15 | fi) 16 | 17 | # Run a shell script if it exists. Stops make on error. 18 | runscript_if_exists = \ 19 | $(if $(wildcard $(1)), \ 20 | $(if $(findstring 0, \ 21 | $(lastword $(shell $(abspath $(wildcard $(1))); echo $$?))), \ 22 | $(info Info: $(1) success), \ 23 | $(error ERROR: $(1) failed))) 24 | 25 | # For message printing: pad the right side of the first argument with spaces to 26 | # the number of bytes indicated by the second argument. 27 | space_pad_to = $(shell echo "$(1) " | head -c$(2)) 28 | 29 | # Call with some text, and a prefix tag if desired (like [AUTODETECTED]), 30 | show_config_info = $(call arduino_output,- $(call space_pad_to,$(2),20) $(1)) 31 | 32 | # Call with the name of the variable, a prefix tag if desired (like [AUTODETECTED]), 33 | # and an explanation if desired (like (found in $$PATH) 34 | show_config_variable = $(call show_config_info,$(1) = $($(1)) $(3),$(2)) 35 | 36 | # Just a nice simple visual separator 37 | show_separator = $(call arduino_output,-------------------------) 38 | 39 | # Master Arduino Makefile include (after user Makefile) 40 | ardmk_include = $(shell basename $(word 2,$(MAKEFILE_LIST))) 41 | 42 | $(call show_separator) 43 | $(call arduino_output,$(call ardmk_include) Configuration:) 44 | 45 | ######################################################################## 46 | # 47 | # Detect OS 48 | 49 | ifeq ($(OS),Windows_NT) 50 | CURRENT_OS = WINDOWS 51 | GREP_CMD = grep 52 | else 53 | UNAME_S := $(shell uname -s) 54 | ifeq ($(UNAME_S),Linux) 55 | CURRENT_OS = LINUX 56 | GREP_CMD = grep 57 | endif 58 | ifeq ($(UNAME_S),Darwin) 59 | CURRENT_OS = MAC 60 | ifeq (, $(shell which gggrep)) 61 | $(info Using macOS BSD grep, please install GNU grep to avoid warnings) 62 | GREP_CMD = grep 63 | else 64 | GREP_CMD = ggrep 65 | endif 66 | endif 67 | endif 68 | $(call show_config_variable,CURRENT_OS,[AUTODETECTED]) 69 | 70 | ######################################################################## 71 | # 72 | # Travis-CI 73 | ifneq ($(TEST),) 74 | DEPENDENCIES_DIR = /var/tmp/Arduino-Makefile-testing-dependencies 75 | 76 | DEPENDENCIES_MPIDE_DIR := $(shell find $(DEPENDENCIES_DIR) -name 'mpide-0023-*' -type d -exec ls -dt {} + | head -n 1) 77 | 78 | ifeq ($(MPIDE_DIR),) 79 | MPIDE_DIR = $(DEPENDENCIES_MPIDE_DIR) 80 | endif 81 | 82 | ifndef ARDUINO_IDE_DIR 83 | ifeq ($(CURRENT_OS),MAC) 84 | ARDUINO_IDE_DIR = Arduino.app/Contents/Resources/Java 85 | else 86 | ARDUINO_IDE_DIR := $(shell basename $(basename $(basename $(lastword $(wildcard $(DEPENDENCIES_DIR)/arduino*))))) 87 | endif 88 | endif 89 | DEPENDENCIES_ARDUINO_DIR = $(DEPENDENCIES_DIR)/$(ARDUINO_IDE_DIR) 90 | ifeq ($(ARDUINO_DIR),) 91 | ARDUINO_DIR = $(DEPENDENCIES_ARDUINO_DIR) 92 | endif 93 | endif 94 | 95 | ######################################################################## 96 | # Arduino Directory 97 | 98 | ifndef ARDUINO_DIR 99 | AUTO_ARDUINO_DIR := $(firstword \ 100 | $(call dir_if_exists,/usr/share/arduino) \ 101 | $(call dir_if_exists,/Applications/Arduino.app/Contents/Resources/Java) \ 102 | $(call dir_if_exists,/Applications/Arduino.app/Contents/Java) ) 103 | ifdef AUTO_ARDUINO_DIR 104 | ARDUINO_DIR = $(AUTO_ARDUINO_DIR) 105 | $(call show_config_variable,ARDUINO_DIR,[AUTODETECTED]) 106 | else 107 | echo $(error "ARDUINO_DIR is not defined") 108 | endif 109 | else 110 | $(call show_config_variable,ARDUINO_DIR,[USER]) 111 | endif 112 | 113 | ifeq ($(CURRENT_OS),WINDOWS) 114 | ifneq ($(shell echo $(ARDUINO_DIR) | egrep '\\|[[:space:]]|cygdrive'),) 115 | echo $(error On Windows, ARDUINO_DIR and other defines must use forward slash and not contain spaces, special characters or be cygdrive relative) 116 | endif 117 | endif 118 | 119 | ######################################################################## 120 | # System Python 121 | 122 | ifndef PYTHON_CMD 123 | # try for Python 3 first 124 | PYTHON_CMD := $(shell which python3 2> /dev/null) 125 | ifdef PYTHON_CMD 126 | $(call show_config_variable,PYTHON_CMD,[AUTODETECTED]) 127 | else 128 | # fall-back to any Python 129 | PYTHON_CMD := $(shell which python 2> /dev/null) 130 | ifdef PYTHON_CMD 131 | $(call show_config_variable,PYTHON_CMD,[AUTODETECTED]) 132 | else 133 | echo $(error "Unable to find system Python! Utility scipts won't work. Override this error by defining PYTHON_CMD") 134 | endif 135 | endif 136 | else 137 | $(call show_config_variable,PYTHON_CMD,[USER]) 138 | endif 139 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/tests/script/bootstrap/common.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | 6 | if [ -z $COMMON_SOURCED ]; then 7 | 8 | # TODO this is kind of a hacky way of determining if root is required - 9 | # ideally we wouuld set up a little virtualenv in the dependencies folder 10 | SUDO_CMD= 11 | if command -v sudo >/dev/null 2>&1; then 12 | SUDO_CMD="sudo -E" 13 | 14 | if [ -z $CI ] && [ -z $VAGRANT ]; then 15 | echo "The bootstrap script needs to install a few packages to your system as an admin, and we will use the 'sudo' command - enter your password to continue" 16 | $SUDO_CMD ls > /dev/null 17 | fi 18 | fi 19 | 20 | KERNEL=`uname` 21 | ARCH=`uname -m` 22 | if [ ${KERNEL:0:7} == "MINGW32" ]; then 23 | OS="windows" 24 | elif [ ${KERNEL:0:6} == "CYGWIN" ]; then 25 | OS="cygwin" 26 | elif [ $KERNEL == "Darwin" ]; then 27 | OS="mac" 28 | else 29 | OS="linux" 30 | if ! command -v lsb_release >/dev/null 2>&1; then 31 | # Arch Linux 32 | if command -v pacman>/dev/null 2>&1; then 33 | $SUDO_CMD pacman -S lsb-release 34 | fi 35 | fi 36 | 37 | DISTRO=`lsb_release -si` 38 | fi 39 | 40 | 41 | die() { 42 | echo >&2 "${bldred}$@${txtrst}" 43 | exit 1 44 | } 45 | 46 | _cygwin_error() { 47 | echo 48 | echo "${bldred}Missing \"$1\"${txtrst} - run the Cygwin installer again and select the base package set:" 49 | echo " $CYGWIN_PACKAGES" 50 | echo "After installing the packages, re-run this bootstrap script." 51 | die 52 | } 53 | 54 | if ! command -v tput >/dev/null 2>&1; then 55 | if [ $OS == "cygwin" ]; then 56 | echo "OPTIONAL: Install the \"ncurses\" package in Cygwin to get colored shell output" 57 | fi 58 | else 59 | set +e 60 | # These exit with 1 when provisioning in a Vagrant box...? 61 | txtrst=$(tput sgr0) # reset 62 | bldred=${txtbld}$(tput setaf 1) 63 | bldgreen=${txtbld}$(tput setaf 2) 64 | set -e 65 | fi 66 | 67 | 68 | _pushd() { 69 | pushd $1 > /dev/null 70 | } 71 | 72 | _popd() { 73 | popd > /dev/null 74 | } 75 | 76 | _wait() { 77 | if [ -z $CI ] && [ -z $VAGRANT ]; then 78 | echo "Press Enter when done" 79 | read 80 | fi 81 | } 82 | 83 | _install() { 84 | if [ $OS == "cygwin" ]; then 85 | _cygwin_error $1 86 | elif [ $OS == "mac" ]; then 87 | # brew exists with 1 if it's already installed 88 | set +e 89 | brew install $1 90 | set -e 91 | else 92 | if [ -z $DISTRO ]; then 93 | echo 94 | echo "Missing $1 - install it using your distro's package manager or build from source" 95 | _wait 96 | else 97 | if [ $DISTRO == "arch" ]; then 98 | $SUDO_CMD pacman -S $1 99 | elif [ $DISTRO == "Ubuntu" ]; then 100 | $SUDO_CMD apt-get update -qq 101 | $SUDO_CMD apt-get install $1 -y 102 | else 103 | echo 104 | echo "Missing $1 - install it using your distro's package manager or build from source" 105 | _wait 106 | fi 107 | fi 108 | fi 109 | } 110 | 111 | download() { 112 | url=$1 113 | filename=$2 114 | curl $url -L -o $filename 115 | } 116 | 117 | if [ `id -u` == 0 ]; then 118 | die "Error: running as root - don't use 'sudo' with this script" 119 | fi 120 | 121 | if ! command -v unzip >/dev/null 2>&1; then 122 | _install "unzip" 123 | fi 124 | 125 | if ! command -v curl >/dev/null 2>&1; then 126 | if [ $OS == "cygwin" ]; then 127 | _cygwin_error "curl" 128 | else 129 | _install curl 130 | fi 131 | fi 132 | 133 | echo "Storing all downloaded dependencies in the \"dependencies\" folder" 134 | 135 | DEPENDENCIES_FOLDER="/var/tmp/Arduino-Makefile-testing-dependencies" 136 | mkdir -p $DEPENDENCIES_FOLDER 137 | 138 | if ! command -v make >/dev/null 2>&1; then 139 | if [ $OS == "cygwin" ]; then 140 | _cygwin_error "make" 141 | elif [ $OS == "mac" ]; then 142 | die "Missing 'make' - install the Xcode CLI tools" 143 | else 144 | if [ $DISTRO == "arch" ]; then 145 | _install "base-devel" 146 | elif [ $DISTRO == "Ubuntu" ]; then 147 | _install "build-essential" 148 | fi 149 | fi 150 | fi 151 | 152 | if [ $DISTRO == "Ubuntu" ] && [ $ARCH == "x86_64" ]; then 153 | _install "libc6-i386" 154 | _install "lib32gcc1" 155 | fi 156 | 157 | if ! command -v g++ >/dev/null 2>&1; then 158 | if [ $DISTRO == "Ubuntu" ]; then 159 | _install "g++" 160 | fi 161 | fi 162 | 163 | if ! command -v python3 >/dev/null 2>&1; then 164 | echo "Installing Python..." 165 | _install "python3" 166 | fi 167 | 168 | if ! command -v pip3 >/dev/null 2>&1; then 169 | echo "Installing Pip..." 170 | _install "python3-pip" 171 | fi 172 | 173 | PIP_SUDO_CMD= 174 | if [ -z $VIRTUAL_ENV ]; then 175 | # Only use sudo if the user doesn't have an active virtualenv 176 | PIP_SUDO_CMD=$SUDO_CMD 177 | fi 178 | 179 | $PIP_SUDO_CMD pip3 install --src dependencies --pre -Ur $BOOTSTRAP_DIR/pip-requirements.txt 180 | 181 | COMMON_SOURCED=1 182 | fi 183 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/bin/ardmk-init: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | """ 4 | Arduino-mk Makefile and project initialiser 5 | 6 | This script can be used in its basic form create a project specific Makefile 7 | for use with Arduino-mk. Addionally, it can be used to create a template 8 | Arduino source file and a traditional boilerplate project file structure. 9 | 10 | Example: 11 | * Run prompted within current working directory (requires Clint): `ardmk-init --cli` 12 | * Create Arduino Uno Makefile (useful within a library example): `ardmk-init -b uno` 13 | * Create boilerplate Arduino Uno project in current working directory of same 14 | name: `ardmk-init -b uno --project` 15 | * Create Arduino-mk nano Makefile in current working directory with template .ino: 16 | `ardmk-init -b nano -u atmega328 -tn my-project` 17 | 18 | See `armk-init --help` for CLI arguments 19 | """ 20 | 21 | import os 22 | import argparse 23 | 24 | ## Global Vars 25 | VERSION = "1.2" 26 | ARD_TEMPLATE = "\n\ 27 | #include \n\ 28 | #include \n\ 29 | \n\ 30 | \n\ 31 | void setup() {\n\ 32 | }\n\ 33 | \n\ 34 | void loop() {\n\ 35 | }\n\ 36 | " 37 | 38 | ## Command Parser 39 | PARSER = argparse.ArgumentParser(prog='ardmk-init', 40 | description='Arduino Makefile and boilerplate project generator.\ 41 | For use with Ard-Makefile: https://github.com/sudar/Arduino-Makefile.\ 42 | Script created by John Whittington https://github.com/tuna-f1sh 2017\ 43 | \n\nVersion: ' + VERSION) 44 | PARSER.add_argument('-v', '--verbose', action='store_true', 45 | help="print file contents during creation") 46 | PARSER.add_argument('-d', '--directory', default=os.getcwd(), help='directory to run generator, default cwd') 47 | PARSER.add_argument('-b', '--board', default='uno', help='board tag') 48 | PARSER.add_argument('-u', '--micro', default='AUTO', help='microcontroller on board') 49 | PARSER.add_argument('-f', '--freq', default='AUTO', help='clock frequency') 50 | PARSER.add_argument('-p', '--port', default='AUTO', help='monitor port') 51 | PARSER.add_argument('-n', '--name', default=os.path.basename(os.getcwd()), help='project name') 52 | PARSER.add_argument('-s', '--sam', action='store_true', help='sam device, will include Sam.mk rather than Arduino.mk') 53 | PARSER.add_argument('--cli', action='store_true', help='run with user prompts (requires "Clint" module), rather than args') 54 | PARSER.add_argument('-P', '--project', action='store_true', 55 | help='create boilerplate project with src, lib and bin folder structure') 56 | PARSER.add_argument('-t', '--template', action='store_true', 57 | help='create bare minimum Arduino source file') 58 | PARSER.add_argument('-V', '--version', action='version', version='%(prog)s '+ VERSION) 59 | ARGS = PARSER.parse_args() 60 | 61 | try: 62 | from clint.textui import prompt, validators 63 | except ImportError: 64 | if ARGS.cli: 65 | print("Python module 'clint' is required for running prompted. Install the module or run with arguments only") 66 | quit() 67 | 68 | 69 | def generate_makefile(): 70 | """ 71 | Generate the Makefile content using prompts or parsed arguments 72 | """ 73 | # Header 74 | file_content = "# Generated by ard-make version " + VERSION + "\n\n" 75 | 76 | # Basic 77 | if ARGS.cli: 78 | print("Generating Arduino Ard-Makefile project in " 79 | + os.path.abspath(ARGS.directory)) 80 | btag = prompt.query('Board tag?', default='uno') 81 | if btag != 'uno': 82 | bsub = prompt.query('Board sub micro?', default='atmega328') 83 | f_cpu = prompt.query('Board frequency', default='16000000L') 84 | else: 85 | bsub = 'AUTO' 86 | f_cpu = 'AUTO' 87 | monitor_port = prompt.query('Arduino port?', default='AUTO') 88 | else: 89 | btag = ARGS.board 90 | bsub = ARGS.micro 91 | f_cpu = ARGS.freq 92 | monitor_port = ARGS.port 93 | 94 | file_content += check_define('BOARD_TAG', btag) 95 | file_content += check_define('BOARD_SUB', bsub) 96 | file_content += check_define('F_CPU', f_cpu) 97 | file_content += check_define('MONITOR_PORT', monitor_port) 98 | 99 | # Extended 100 | if ARGS.cli: 101 | if not prompt.yn('Extended options?', default='n'): 102 | if not prompt.yn('Define local folders?', default='n'): 103 | src_dir = prompt.query('Sources folder (Makefile will be created here)?', 104 | default='', validators=[]) 105 | userlibs = prompt.query('Library folder (will create if does not exist) - AUTO is Sketchbook directory?', 106 | default='AUTO', validators=[]) 107 | obj_dir = prompt.query('Output directory?', default='AUTO', validators=[]) 108 | else: 109 | src_dir = '' 110 | userlibs = 'AUTO' 111 | obj_dir = 'AUTO' 112 | boards_txt = prompt.query('Boards file?', default='AUTO') 113 | isp_prog = prompt.query('ISP programmer?', default='atmelice_isp') 114 | isp_port = prompt.query('ISP port?', default='AUTO') 115 | if not prompt.yn('Quiet make?', default='n'): 116 | file_content += "ARDUINO_QUIET = 1\n" 117 | 118 | file_content += check_define('ISP_PROG', isp_prog) 119 | file_content += check_define('ISP_PORT', isp_port) 120 | file_content += check_define('BOARDS_TXT', boards_txt) 121 | 122 | # Check andd create folders 123 | check_create_folder(src_dir) 124 | check_create_folder(userlibs) 125 | check_create_folder(obj_dir) 126 | 127 | # Makefile will be in src_dir so lib and bin must be relative 128 | if src_dir: 129 | userlibs = "../" + userlibs 130 | obj_dir = "../" + obj_dir 131 | 132 | file_content += check_define('USER_LIB_PATH', userlibs) 133 | file_content += check_define('OBJDIR', obj_dir) 134 | else: 135 | src_dir = '' 136 | 137 | if ARGS.template or not prompt.yn('Create template Arduino source?', default='n'): 138 | source_filename = prompt.query('Name of project?', 139 | default=os.path.basename(os.getcwd())) 140 | if src_dir: 141 | write_template(src_dir + "/" + source_filename) 142 | else: 143 | write_template(source_filename) 144 | file_content += check_define('TARGET', source_filename) 145 | 146 | else: 147 | if ARGS.project: 148 | src_dir = 'src' 149 | userlibs = 'lib' 150 | obj_dir = 'bin' 151 | else: 152 | src_dir = '' 153 | userlibs = 'AUTO' 154 | obj_dir = 'AUTO' 155 | 156 | # Check andd create folders 157 | check_create_folder(src_dir) 158 | check_create_folder(userlibs) 159 | check_create_folder(obj_dir) 160 | 161 | # Makefile will be in src_dir so lib and bin must be relative 162 | if src_dir: 163 | userlibs = "../" + userlibs 164 | obj_dir = "../" + obj_dir 165 | 166 | file_content += check_define('USER_LIB_PATH', userlibs) 167 | file_content += check_define('OBJDIR', obj_dir) 168 | 169 | if ARGS.project or ARGS.template: 170 | if src_dir: 171 | write_template(src_dir + "/" + ARGS.name) 172 | else: 173 | write_template(ARGS.name) 174 | file_content += check_define('TARGET', ARGS.name) 175 | 176 | if not "ARDMK_DIR" in os.environ: 177 | if not ARGS.cli: 178 | print("Warning: ARDMK_DIR environment variable not defined. \ 179 | Must be defined for Makefile to work") 180 | else: 181 | ardmk = prompt.query('Arduino Makefile path?', 182 | default='/usr/share/arduino', 183 | validators=[validators.PathValidator()]) 184 | ardmk = "ARDMK_DIR := " + ardmk + "\n" 185 | 186 | if ARGS.sam: 187 | file_content += "\ninclude $(ARDMK_DIR)/Sam.mk" 188 | else: 189 | file_content += "\ninclude $(ARDMK_DIR)/Arduino.mk" 190 | 191 | # Add forward slash if source directory exists 192 | if src_dir: 193 | write_to_makefile(file_content, (src_dir + "/")) 194 | else: 195 | write_to_makefile(file_content, "") 196 | 197 | return file_content 198 | 199 | def write_to_makefile(file_content, path): 200 | """ 201 | Write the Makefile file 202 | """ 203 | makefile = open(path + "Makefile", 'w') 204 | print("Writing Makefile...") 205 | if ARGS.verbose: 206 | print(file_content) 207 | makefile.write(file_content) 208 | makefile.close() 209 | 210 | def write_template(filename): 211 | """ 212 | Write template Arduino .ino source 213 | """ 214 | print("Writing " + os.path.abspath(filename) + ".ino...") 215 | if os.path.isfile(filename + '.ino'): 216 | if not ARGS.cli: 217 | print(filename + '.ino' + ' already exists! Stopping.') 218 | return 219 | print(filename + '.ino' + ' already exists! Overwrite?') 220 | if prompt.yn('Continue?', default='n'): 221 | return 222 | src = open((filename + ".ino"), 'w') 223 | if ARGS.verbose: 224 | print(ARD_TEMPLATE) 225 | src.write("/* Project: " + filename + " */\n" + ARD_TEMPLATE) 226 | src.close() 227 | 228 | def check_create_folder(folder): 229 | """ 230 | Check if folder exists and make it if it doesn't and hasn't been set to AUTO 231 | """ 232 | if folder and not folder == 'AUTO': 233 | if not os.path.exists(folder): 234 | print("Creating " + os.path.abspath(folder) + " folder") 235 | os.makedirs(folder) 236 | 237 | def check_define(define, user): 238 | """ 239 | Check whether user has set define and return Makefile formatted string if they have 240 | """ 241 | # Return is empty unless user has passed value 242 | string = "" 243 | 244 | # Set define only if not empty or set to AUTO 245 | if user and not user == 'AUTO': 246 | string = define + " = " + user + "\n" 247 | 248 | return string 249 | 250 | def check_args(): 251 | """ 252 | Check input args will work with Makefile 253 | """ 254 | # Micro should be defined for non uno boards 255 | if ARGS.board != 'uno' and ARGS.micro == 'AUTO': 256 | print('\n!!! Warning: --micro should be defined and not left AUTO for non-Uno boards\n') 257 | 258 | 259 | if __name__ == '__main__': 260 | # Create directory if not exist 261 | check_create_folder(ARGS.directory) 262 | # Check input args 263 | check_args() 264 | # Change to dir so all commands are run relative 265 | os.chdir(ARGS.directory) 266 | if os.path.isfile('Makefile'): 267 | if not ARGS.cli: 268 | print('Makefile in ' + os.path.abspath(ARGS.directory) 269 | + ' already exists! Please remove before generating. Stopping.') 270 | quit() 271 | 272 | # Confirm with user if not quiet mode 273 | print('Makefile in ' + os.path.abspath(ARGS.directory) 274 | + ' already exists! Overwrite?') 275 | if prompt.yn('Continue?', default='n'): 276 | quit() 277 | # Run it 278 | generate_makefile() 279 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/OpenCR.mk: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # 3 | # Support for Robotis OpenCR boards 4 | # 5 | # Written by Dowhan Jeong, EunJin Jeong 6 | # 7 | # Based on work that is copyright Jeremy Shaw, Sudar, Nicholas Zambetti, 8 | # David A. Mellis & Hernando Barragan. 9 | # 10 | # This file is free software; you can redistribute it and/or modify it 11 | # under the terms of the GNU Lesser General Public License as 12 | # published by the Free Software Foundation; either version 2.1 of the 13 | # License, or (at your option) any later version. 14 | # 15 | ######################################################################## 16 | 17 | ifndef ARDUINO_DIR 18 | echo $(error ARDUINO_DIR should be specified) 19 | endif 20 | 21 | ifndef BOARD_TAG 22 | echo $(error BOARD_TAG should be specified. check board list with 'make show_boards') 23 | endif 24 | 25 | ifndef ARDMK_DIR 26 | ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))) 27 | endif 28 | 29 | include $(ARDMK_DIR)/Common.mk 30 | 31 | ifndef ARDUINO_PACKAGE_DIR 32 | # attempt to find based on Linux, macOS and Windows default 33 | ARDUINO_PACKAGE_DIR := $(firstword \ 34 | $(call dir_if_exists,$(HOME)/.arduino15/packages) \ 35 | $(call dir_if_exists,$(ARDUINO_DIR)/packages) \ 36 | $(call dir_if_exists,$(HOME)/Library/Arduino15/packages) \ 37 | $(call dir_if_exists,$(realpath $(USERPROFILE))/AppData/Local/Arduino15/packages) ) 38 | $(call show_config_variable,ARDUINO_PACKAGE_DIR,[AUTODETECTED],(from DEFAULT)) 39 | else 40 | $(call show_config_variable,ARDUINO_PACKAGE_DIR,[USER]) 41 | endif 42 | 43 | ifndef ARDMK_VENDOR 44 | ARDMK_VENDOR = OpenCR 45 | endif 46 | 47 | ifndef ARCHITECTURE 48 | ARCHITECTURE := OpenCR 49 | endif 50 | 51 | ifndef CORE_VER 52 | CORE_VER := $(wildcard $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/hardware/$(ARCHITECTURE)/1.*) 53 | ifneq ($(CORE_VER),) 54 | CORE_VER := $(shell basename $(CORE_VER)) 55 | $(call show_config_variable,CORE_VER,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR)) 56 | endif 57 | else 58 | $(call show_config_variable,CORE_VER,[USER]) 59 | endif 60 | 61 | ARCHITECTURE := sam 62 | 63 | arduino_output = 64 | # When output is not suppressed and we're in the top-level makefile, 65 | # running for the first time (i.e., not after a restart after 66 | # regenerating the dependency file), then output the configuration. 67 | ifndef ARDUINO_QUIET 68 | ifeq ($(MAKE_RESTARTS),) 69 | ifeq ($(MAKELEVEL),0) 70 | arduino_output = $(info $(1)) 71 | endif 72 | endif 73 | endif 74 | 75 | # Arduino Settings (will get shown in Arduino.mk as computed) 76 | ifndef ALTERNATE_CORE_PATH 77 | ifdef CORE_VER 78 | ALTERNATE_CORE_PATH = $(ARDUINO_PACKAGE_DIR)/OpenCR/hardware/OpenCR/$(CORE_VER) 79 | else 80 | echo $(error Cannot find $(CORE_VER). Check directory settings.) 81 | endif 82 | endif 83 | 84 | ifndef ARDUINO_CORE_PATH 85 | ARDUINO_CORE_PATH= $(ALTERNATE_CORE_PATH)/cores/arduino 86 | endif 87 | 88 | ifndef BOARDS_TXT 89 | BOARDS_TXT= $(ALTERNATE_CORE_PATH)/boards.txt 90 | endif 91 | 92 | ifndef VARIANT 93 | VARIANT := $(call PARSE_BOARD,$(BOARD_TAG),build.variant) 94 | endif 95 | 96 | ARDUINO_VAR_PATH = $(ALTERNATE_CORE_PATH)/variants/$(VARIANT) 97 | 98 | 99 | # Check boards file exists before continuing as parsing non-existant file can create problems 100 | ifneq ($(findstring boards.txt, $(wildcard $(ALTERNATE_CORE_PATH)/*.txt)), boards.txt) 101 | echo $(error $(CORE_VER) Cannot find boards file $(BOARDS_TXT). Check ?? and board support installed) 102 | endif 103 | 104 | # grab any sources in the variant core path. 105 | # directorys were manually checked. 106 | # Core sources(used to generate libcore.a archive) 107 | OPENCR_CORE_C_SRCS_1 := $(wildcard $(ARDUINO_CORE_PATH)/avr/*.c) 108 | OPENCR_CORE_C_SRCS_2 := $(wildcard $(ARDUINO_CORE_PATH)/*.c) 109 | OPENCR_CORE_CPP_SRCS := $(wildcard $(ARDUINO_CORE_PATH)/*.cpp) 110 | 111 | # library sources 112 | OPENCR_LIB_C_SRCS_1 := $(wildcard $(ARDUINO_VAR_PATH)/bsp/opencr/*.c) 113 | OPENCR_LIB_C_SRCS_2 := $(wildcard $(ARDUINO_VAR_PATH)/hw/*.c) 114 | OPENCR_LIB_C_SRCS_3 := $(wildcard $(ARDUINO_VAR_PATH)/hw/driver/*.c) 115 | OPENCR_LIB_C_SRCS_4 := $(wildcard $(ARDUINO_VAR_PATH)/hw/usb_cdc/*.c) 116 | OPENCR_LIB_C_SRCS_5 := $(wildcard $(ARDUINO_VAR_PATH)/lib/STM32F7xx_HAL_Driver/Src/*.c) 117 | OPENCR_LIB_CPP_SRCS := $(wildcard $(ARDUINO_VAR_PATH)/*.cpp) 118 | OPENCR_LIB_S_SRCS := $(wildcard $(ARDUINO_VAR_PATH)/bsp/opencr/startup/*.S) 119 | 120 | ifndef F_CPU 121 | F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),build.f_cpu) 122 | endif 123 | 124 | OPENCR_LIB_OBJ_FILES = $(notdir $(OPENCR_LIB_C_SRCS_1:.c=.c.o)) $(notdir $(OPENCR_LIB_C_SRCS_2:.c=.c.o)) $(notdir $(OPENCR_LIB_C_SRCS_3:.c=.c.o)) $(notdir $(OPENCR_LIB_C_SRCS_4:.c=.c.o)) $(notdir $(OPENCR_LIB_C_SRCS_5:.c=.c.o)) $(notdir $(OPENCR_LIB_CPP_SRCS:.cpp=.cpp.o)) $(notdir $(OPENCR_LIB_S_SRCS:.S=.S.o)) 125 | OTHER_OBJS = $(patsubst %, \ 126 | $(OBJDIR)/OpenCRlib/%, $(OPENCR_LIB_OBJ_FILES)) 127 | 128 | OPENCR_CORE_OBJ_FILES = $(notdir $(OPENCR_CORE_C_SRCS_1:.c=.c.o)) $(notdir $(OPENCR_CORE_C_SRCS_2:.c=.c.o)) $(notdir $(OPENCR_CORE_CPP_SRCS:.cpp=.cpp.o)) 129 | # override is used since opencr dosen't need other sam core objects 130 | override CORE_OBJS = $(patsubst %, \ 131 | $(OBJDIR)/core/%, $(OPENCR_CORE_OBJ_FILES)) 132 | 133 | ifndef AVR_TOOLS_DIR 134 | AVR_TOOLS_DIR = $(call dir_if_exists,$(ARDUINO_PACKAGE_DIR)/OpenCR/tools/opencr_gcc/5.4.0-2016q2) 135 | endif 136 | ifeq ($(strip $(AVR_TOOLS_DIR)),) 137 | echo $(error $(AVR_TOOLS_DIR) Cannot find AVR_TOOLS_DIR. Check AVR_TOOLS_DIR) 138 | endif 139 | 140 | # Robotis OpenCR platform library directory 141 | ifndef ARDUINO_PLATFORM_LIB_PATH 142 | ARDUINO_PLATFORM_LIB_PATH = $(ALTERNATE_CORE_PATH)/libraries 143 | $(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[COMPUTED],(from OPENCR_DIR)) 144 | endif 145 | 146 | ######################################################################## 147 | # command names 148 | 149 | TOOL_PREFIX = arm-none-eabi 150 | 151 | # processor stuff 152 | ifndef MCU 153 | MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu) 154 | endif 155 | 156 | ifndef MCU_FLAG_NAME 157 | MCU_FLAG_NAME=mcpu 158 | endif 159 | 160 | ######################################################################## 161 | # FLAGS 162 | ifndef USB_TYPE 163 | USB_TYPE = USB_SERIAL 164 | endif 165 | 166 | # from platform.txt 167 | CPPFLAGS += -DARDUINO_OpenCR 168 | CPPFLAGS += -DARDUINO_ARCH_OPENCR 169 | 170 | CPPFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.common_flags) 171 | 172 | OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc1) 173 | OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc2) 174 | OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc3) 175 | OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc4) 176 | OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc5) 177 | OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc6) 178 | OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc7) 179 | CPPFLAGS += $(OPENCR_COMPILER_LIBS_C_FLAGS) 180 | 181 | CFLAGS_STD += -c -g -O2 -std=gnu11 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -Wall -Wextra -DDEBUG_LEVEL=DEBUG_ALL -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DBOARD_$(VARIANT) 182 | 183 | CXXFLAGS_STD += -c -g -O2 -std=gnu++11 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -Wall -Wextra -DDEBUG_LEVEL=DEBUG_ALL -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_$(VARIANT) 184 | 185 | ASFLAGS += -c -g -x assembler-with-cpp -MMD 186 | 187 | LDFLAGS += -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-unresolved-symbols -Wl,--start-group -Wl,--whole-archive 188 | 189 | LINKER_SCRIPTS = -T$(ARDUINO_VAR_PATH)/bsp/opencr/ldscript/opencr_flash.ld 190 | ######################################################################## 191 | # Reset is handled by upload script. OpenCR don't neet reset command. 192 | override RESET_CMD = 193 | 194 | ######################################################################## 195 | # Object conversion & uploading magic, modified from Arduino.mk 196 | override TARGET_HEX = $(OBJDIR)/$(TARGET).bin 197 | 198 | override avr_size = $(SIZE) --target=binary $(2) 199 | 200 | # Define UPLOAD_TOOL as avrdude to use avrdude upload recipe in Arduino.mk 201 | override UPLOAD_TOOL = avrdude 202 | 203 | ifeq ($(CURRENT_OS), WINDOWS) 204 | override AVRDUDE = $(ARDUINO_PACKAGE_DIR)/OpenCR/tools/opencr_tools/1.0.0/win/opencr_ld.exe 205 | else 206 | override AVRDUDE = $(ARDUINO_PACKAGE_DIR)/OpenCR/tools/opencr_tools/1.0.0/linux/opencr_ld 207 | endif 208 | override AVRDUDE_COM_OPTS = $(DEVICE_PATH) 209 | override AVRDUDE_ISP_OPTS = 115200 $(TARGET_HEX) 1 210 | override AVRDUDE_ISPLOAD_OPTS = 211 | 212 | ######################################################################## 213 | # automatically include Arduino.mk 214 | 215 | include $(ARDMK_DIR)/Arduino.mk 216 | 217 | ######################################################################## 218 | 219 | # OpenCR core files 220 | $(OBJDIR)/core/%.c.o: $(ARDUINO_CORE_PATH)/avr/%.c $(COMMON_DEPS) | $(OBJDIR) 221 | @$(MKDIR) $(dir $@) 222 | $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ 223 | 224 | $(OBJDIR)/core/%.c.o: $(ARDUINO_CORE_PATH)/%.c $(COMMON_DEPS) | $(OBJDIR) 225 | @$(MKDIR) $(dir $@) 226 | $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ 227 | 228 | $(OBJDIR)/core/%.cpp.o: $(ARDUINO_CORE_PATH)/%.cpp $(COMMON_DEPS) | $(OBJDIR) 229 | @$(MKDIR) $(dir $@) 230 | $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ 231 | 232 | # OpenCR lib files 233 | $(OBJDIR)/OpenCRlib/%.c.o: $(ARDUINO_VAR_PATH)/bsp/opencr/%.c $(COMMON_DEPS) | $(OBJDIR) 234 | @$(MKDIR) $(dir $@) 235 | $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ 236 | $(OBJDIR)/OpenCRlib/%.c.o: $(ARDUINO_VAR_PATH)/hw/%.c $(COMMON_DEPS) | $(OBJDIR) 237 | @$(MKDIR) $(dir $@) 238 | $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ 239 | 240 | $(OBJDIR)/OpenCRlib/%.c.o: $(ARDUINO_VAR_PATH)/hw/driver/%.c $(COMMON_DEPS) | $(OBJDIR) 241 | @$(MKDIR) $(dir $@) 242 | $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ 243 | 244 | $(OBJDIR)/OpenCRlib/%.c.o: $(ARDUINO_VAR_PATH)/hw/usb_cdc/%.c $(COMMON_DEPS) | $(OBJDIR) 245 | @$(MKDIR) $(dir $@) 246 | $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ 247 | 248 | $(OBJDIR)/OpenCRlib/%.c.o: $(ARDUINO_VAR_PATH)/lib/STM32F7xx_HAL_Driver/Src/%.c $(COMMON_DEPS) | $(OBJDIR) 249 | @$(MKDIR) $(dir $@) 250 | $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ 251 | 252 | $(OBJDIR)/OpenCRlib/%.cpp.o: $(ARDUINO_VAR_PATH)/%.cpp $(COMMON_DEPS) | $(OBJDIR) 253 | @$(MKDIR) $(dir $@) 254 | $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ 255 | 256 | $(OBJDIR)/OpenCRlib/%.S.o: $(ARDUINO_VAR_PATH)/bsp/opencr/startup/%.S $(COMMON_DEPS) | $(OBJDIR) 257 | @$(MKDIR) $(dir $@) 258 | $(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ 259 | 260 | # Object conversion & uploading magic, modified from Arduino.mk 261 | $(OBJDIR)/%.bin: $(OBJDIR)/%.elf $(COMMON_DEPS) 262 | @$(MKDIR) $(dir $@) 263 | $(OBJCOPY) -v -Obinary $< $@ 264 | @$(ECHO) '\n' 265 | $(call avr_size,$<,$@) 266 | ifneq ($(strip $(HEX_MAXIMUM_SIZE)),) 267 | @if [ `$(SIZE) --target=binary $@ | awk 'FNR == 2 {print $$2}'` -le $(HEX_MAXIMUM_SIZE) ]; then touch $@.sizeok; fi 268 | else 269 | @$(ECHO) "Maximum flash memory of $(BOARD_TAG) is not specified. Make sure the size of $@ is less then $(BOARD_TAG)\'s flash memory" 270 | @touch $@.sizeok 271 | endif 272 | 273 | CORE_LIB += -Wl,--no-whole-archive -lstdc++ 274 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/Sam.mk: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # 3 | # Support for Arduino Atmel SAM boards (sam and samd) 4 | # 5 | # You must install a SAM board hardware support package (such as Arduino Zero) 6 | # to use this, then define ARDUINO_PACKAGE_DIR as the path to the root 7 | # directory containing the support package. 8 | # 9 | # 2018 John Whittington @j_whittington 10 | # 11 | ######################################################################## 12 | 13 | arduino_output = 14 | # When output is not suppressed and we're in the top-level makefile, 15 | # running for the first time (i.e., not after a restart after 16 | # regenerating the dependency file), then output the configuration. 17 | ifndef ARDUINO_QUIET 18 | ifeq ($(MAKE_RESTARTS),) 19 | ifeq ($(MAKELEVEL),0) 20 | arduino_output = $(info $(1)) 21 | endif 22 | endif 23 | endif 24 | 25 | ifndef ARDMK_DIR 26 | ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))) 27 | endif 28 | 29 | # include Common.mk now we know where it is 30 | ifndef COMMON_INCLUDED 31 | include $(ARDMK_DIR)/Common.mk 32 | endif 33 | 34 | ifneq ($(TEST),) 35 | CORE_VER = 1.8.6 36 | CMSIS_VER = 4.5.0 37 | CMSIS_ATMEL_VER = 1.2.0 38 | ALTERNATE_CORE_PATH = $(DEPENDENCIES_DIR)/samd 39 | CMSIS_DIR = $(DEPENDENCIES_DIR)/CMSIS/CMSIS 40 | CMSIS_ATMEL_DIR = $(DEPENDENCIES_DIR)/CMSIS-Atmel/CMSIS 41 | ARM_TOOLS_DIR := $(basename $(basename $(firstword $(wildcard $(DEPENDENCIES_DIR)/gcc-arm-none-eabi*)))) 42 | endif 43 | 44 | ifndef ARDUINO_PACKAGE_DIR 45 | # attempt to find based on Linux, macOS and Windows default 46 | ARDUINO_PACKAGE_DIR := $(firstword \ 47 | $(call dir_if_exists,$(HOME)/.arduino15/packages) \ 48 | $(call dir_if_exists,$(ARDUINO_DIR)/packages) \ 49 | $(call dir_if_exists,$(HOME)/Library/Arduino15/packages) \ 50 | $(call dir_if_exists,$(USERPROFILE)/AppData/Local/Arduino15/packages) ) 51 | $(call show_config_variable,ARDUINO_PACKAGE_DIR,[AUTODETECTED],(from DEFAULT)) 52 | else 53 | $(call show_config_variable,ARDUINO_PACKAGE_DIR,[USER]) 54 | endif 55 | 56 | ifndef ARDMK_VENDOR 57 | ARDMK_VENDOR := arduino 58 | endif 59 | 60 | ifndef ARCHITECTURE 61 | ARCHITECTURE := samd 62 | endif 63 | 64 | ifndef CORE_VER 65 | CORE_VER := $(wildcard $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/hardware/$(ARCHITECTURE)/1.*) 66 | ifneq ($(CORE_VER),) 67 | CORE_VER := $(shell basename $(CORE_VER)) 68 | $(call show_config_variable,CORE_VER,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR)) 69 | endif 70 | else 71 | $(call show_config_variable,CORE_VER,[USER]) 72 | endif 73 | 74 | ifndef CMSIS_VER 75 | CMSIS_VER := $(wildcard $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/CMSIS/4.*) 76 | ifneq ($(CMSIS_VER),) 77 | CMSIS_VER := $(shell basename $(CMSIS_VER)) 78 | $(call show_config_variable,CMSIS_VER,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR)) 79 | endif 80 | else 81 | $(call show_config_variable,CMSIS_VER,[USER]) 82 | endif 83 | 84 | ifndef CMSIS_ATMEL_VER 85 | CMSIS_ATMEL_VER := $(wildcard $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/CMSIS-Atmel/1.*) 86 | ifneq ($(CMSIS_ATMEL_VER),) 87 | CMSIS_ATMEL_VER := $(shell basename $(CMSIS_ATMEL_VER)) 88 | $(call show_config_variable,CMSIS_ATMEL_VER,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR)) 89 | endif 90 | else 91 | $(call show_config_variable,CMSIS_ATMEL_VER,[USER]) 92 | endif 93 | 94 | ifndef CMSIS_DIR 95 | ifeq ($(findstring samd, $(strip $(ARCHITECTURE))), samd) 96 | CMSIS_DIR := $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/CMSIS/$(CMSIS_VER)/CMSIS 97 | else 98 | CMSIS_DIR = $(ALTERNATE_CORE_PATH)/system/CMSIS/CMSIS 99 | endif 100 | $(call show_config_variable,CMSIS_DIR,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR)) 101 | else 102 | $(call show_config_variable,CMSIS_DIR,[USER]) 103 | endif 104 | 105 | ifndef CMSIS_ATMEL_DIR 106 | ifeq ($(findstring samd, $(strip $(ARCHITECTURE))), samd) 107 | CMSIS_ATMEL_DIR := $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/CMSIS-Atmel/$(CMSIS_ATMEL_VER)/CMSIS 108 | else 109 | CMSIS_ATMEL_DIR = $(ALTERNATE_CORE_PATH)/system/CMSIS 110 | endif 111 | $(call show_config_variable,CMSIS_ATMEL_DIR,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR)) 112 | else 113 | $(call show_config_variable,CMSIS_ATMEL_DIR,[USER]) 114 | endif 115 | 116 | # Arduino Settings (will get shown in Arduino.mk as computed) 117 | ifndef ALTERNATE_CORE_PATH 118 | ifdef CORE_VER 119 | ALTERNATE_CORE_PATH = $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/hardware/$(ARCHITECTURE)/$(CORE_VER) 120 | else 121 | ALTERNATE_CORE_PATH = $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/hardware/$(ARCHITECTURE) 122 | endif 123 | endif 124 | ifndef ARDUINO_CORE_PATH 125 | ARDUINO_CORE_PATH = $(ALTERNATE_CORE_PATH)/cores/arduino 126 | endif 127 | ifndef BOARDS_TXT 128 | BOARDS_TXT = $(ALTERNATE_CORE_PATH)/boards.txt 129 | endif 130 | 131 | # Check boards file exists before continuing as parsing non-existant file can create problems 132 | ifneq ($(findstring boards.txt, $(wildcard $(ALTERNATE_CORE_PATH)/*.txt)), boards.txt) 133 | echo $(error $(CORE_VER) Cannot find boards file $(BOARDS_TXT). Check ARDUINO_PACKAGE_DIR path: $(ARDUINO_PACKAGE_DIR) and board support installed) 134 | endif 135 | 136 | # add CMSIS includes 137 | CPPFLAGS += -I$(CMSIS_DIR)/Include/ 138 | CPPFLAGS += -I$(CMSIS_ATMEL_DIR)/Device/ATMEL 139 | # path for Cortex library 140 | LIB_PATH = $(CMSIS_DIR)/Lib/GCC 141 | BOOTLOADER_PARENT = $(ALTERNATE_CORE_PATH)/bootloaders 142 | 143 | ifndef VARIANT 144 | VARIANT := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).build.variant) 145 | ifndef VARIANT 146 | VARIANT := $(call PARSE_BOARD,$(BOARD_TAG),build.variant) 147 | endif 148 | endif 149 | 150 | # grab any sources in the variant core path (variant.cpp defines pin/port mapping on SAM devices) 151 | ifndef SAM_CORE_PATH 152 | SAM_CORE_PATH := $(ALTERNATE_CORE_PATH)/variants/$(VARIANT) 153 | endif 154 | SAM_CORE_C_SRCS := $(wildcard $(SAM_CORE_PATH)/*.c) 155 | SAM_CORE_CPP_SRCS := $(wildcard $(SAM_CORE_PATH)/*.cpp) 156 | SAM_CORE_S_SRCS := $(wildcard $(SAM_CORE_PATH)/*.S) 157 | 158 | # due/sam specific paths hard define chip type for SystemInit function in system_CHIP.c as not included in core like samd 159 | ifeq ($(findstring arduino_due, $(strip $(VARIANT))), arduino_due) 160 | ifndef SAM_SYSTEM_PATH 161 | SAM_SYSTEM_PATH := $(CMSIS_ATMEL_DIR)/Device/ATMEL/sam3xa 162 | endif 163 | ifndef SAM_LIBSAM_PATH 164 | SAM_LIBSAM_PATH := $(ALTERNATE_CORE_PATH)/system/libsam 165 | endif 166 | CPPFLAGS += -I$(SAM_SYSTEM_PATH)/include 167 | CPPFLAGS += -I$(SAM_LIBSAM_PATH) 168 | CPPFLAGS += -I$(SAM_LIBSAM_PATH)/include 169 | SAM_CORE_C_SRCS += $(wildcard $(SAM_LIBSAM_PATH)/source/*.c) 170 | SAM_CORE_C_SRCS += $(wildcard $(SAM_SYSTEM_PATH)/source/*.c) 171 | endif 172 | 173 | # define plaform lib dir from Arduino ARM support 174 | ifndef ARDUINO_PLATFORM_LIB_PATH 175 | ARDUINO_PLATFORM_LIB_PATH := $(ALTERNATE_CORE_PATH)/libraries 176 | $(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[COMPUTED],(from ARDUINO_PACKAGE_DIR)) 177 | endif 178 | 179 | ######################################################################## 180 | # command names 181 | 182 | TOOL_PREFIX = arm-none-eabi 183 | 184 | # Use arm-toolchain from Arduino package install if exists and user has not defined global version 185 | # if undefined, AVR_TOOLS_DIR will resolve in Arduino.mk as a last resort as Arduino now installs with arm-gcc 186 | ifndef ARM_TOOLS_DIR 187 | ifndef ARM_TOOLS_VER 188 | ARM_TOOLS_VER := $(shell basename $(lastword $(wildcard $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/$(TOOL_PREFIX)-gcc/*))) 189 | endif 190 | ARM_TOOLS_DIR = $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/$(TOOL_PREFIX)-gcc/$(ARM_TOOLS_VER) 191 | ifdef ARM_TOOLS_DIR 192 | $(call show_config_variable,ARM_TOOLS_DIR,[COMPUTED],(from ARDUINO_PACKAGE_DIR)) 193 | endif 194 | else 195 | $(call show_config_variable,ARM_TOOLS_DIR,[USER]) 196 | endif 197 | 198 | ifndef GDB_NAME 199 | GDB_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.gdb) 200 | ifndef GDB_NAME 201 | GDB_NAME := $(TOOL_PREFIX)-gdb 202 | else 203 | $(call show_config_variable,GDB_NAME,[COMPUTED]) 204 | endif 205 | endif 206 | 207 | ifndef UPLOAD_TOOL 208 | UPLOAD_TOOL := $(call PARSE_BOARD,$(BOARD_TAG),upload.tool) 209 | ifndef UPLOAD_TOOL 210 | UPLOAD_TOOL := openocd 211 | else 212 | $(call show_config_variable,UPLOAD_TOOL,[COMPUTED]) 213 | endif 214 | endif 215 | 216 | ifndef BOOTLOADER_UPLOAD_TOOL 217 | BOOTLOADER_UPLOAD_TOOL := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.tool) 218 | ifndef BOOTLOADER_UPLOAD_TOOL 219 | BOOTLOADER_UPLOAD_TOOL := openocd 220 | else 221 | $(call show_config_variable,BOOTLOADER_UPLOAD_TOOL,[COMPUTED]) 222 | endif 223 | endif 224 | 225 | # processor stuff 226 | ifndef MCU 227 | MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu) 228 | endif 229 | 230 | ifndef MCU_FLAG_NAME 231 | MCU_FLAG_NAME=mcpu 232 | endif 233 | 234 | # native port emulates an AVR chip to use AVRDUDE 235 | ifndef AVRDUDE_MCU 236 | AVRDUDE_MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.emu.mcu) 237 | endif 238 | 239 | # GDP settings 240 | ifndef GDB_PORT 241 | # default to localhost default OpenOCD port 242 | GDB_PORT = localhost:3333 243 | endif 244 | 245 | ifndef GDB_OPTS 246 | # if using BMP do a scan and attach 247 | ifeq ($(findstring /dev/tty, $(strip $(GDB_PORT))), /dev/tty) 248 | GDB_OPTS = -ex "target extended-remote $(GDB_PORT)" -ex "monitor swdp_scan" -ex "attach 1" -ex "load" -d $(OBJDIR) $(TARGET_ELF) 249 | else 250 | GDB_OPTS = -ex "target extended-remote $(GDB_PORT)" -ex "load" -d $(OBJDIR) $(TARGET_ELF) 251 | endif 252 | endif 253 | 254 | ifndef GDB_UPLOAD_OPTS 255 | GDB_UPLOAD_OPTS = $(GDB_OPTS) -ex "set confirm off" -ex "set target-async off" -ex "set remotetimeout 30" -ex "detach" -ex "kill" -ex "quit" 256 | endif 257 | 258 | ######################################################################## 259 | # OpenOCD for SAM devices 260 | 261 | ifndef OPENOCD 262 | BUNDLED_OPENOCD_DIR := $(call dir_if_exists,$(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/openocd) 263 | # Try Arduino support package first 264 | ifdef BUNDLED_OPENOCD_DIR 265 | ifndef OPENOCD_VER 266 | OPENOCD_VER := $(shell basename $(lastword $(wildcard $(BUNDLED_OPENOCD_DIR)/*))) 267 | endif 268 | OPENOCD = $(BUNDLED_OPENOCD_DIR)/$(OPENOCD_VER)/bin/openocd -s $(BUNDLED_OPENOCD_DIR)/$(OPENOCD_VER)/share/openocd/scripts/ 269 | $(call show_config_variable,OPENOCD,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR)) 270 | else 271 | # Otherwise look on user path 272 | OPENOCD := $(shell which openocd 2>/dev/null) 273 | ifdef OPENOCD 274 | $(call show_config_variable,OPENOCD,[AUTODETECTED],(found in $$PATH)) 275 | endif 276 | endif 277 | else 278 | $(call show_config_variable,OPENOCD,[USER]) 279 | endif 280 | 281 | ifndef OPENOCD_OPTS 282 | OPENOCD_OPTS += -d2 -f $(ALTERNATE_CORE_PATH)/variants/$(VARIANT)/$(OPENOCD_SCRIPT) 283 | endif 284 | 285 | ######################################################################## 286 | # Bossa for SAM devices 287 | 288 | ifndef BOSSA 289 | BUNDLED_BOSSA_DIR := $(call dir_if_exists,$(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/bossac) 290 | # Try Arduino support package first 291 | ifdef BUNDLED_BOSSA_DIR 292 | ifndef BOSSA_VER 293 | BOSSA_VER := $(shell basename $(lastword $(wildcard $(BUNDLED_BOSSA_DIR)/*))) 294 | endif 295 | BOSSA = $(BUNDLED_BOSSA_DIR)/$(BOSSA_VER)/bossac 296 | $(call show_config_variable,BOSSA,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR)) 297 | else 298 | # Otherwise look on user path 299 | BOSSA := $(shell which bossac 2>/dev/null) 300 | ifdef BOSSA 301 | $(call show_config_variable,BOSSA,[AUTODETECTED],(found in $$PATH)) 302 | endif 303 | endif 304 | else 305 | $(call show_config_variable,BOSSA,[USER]) 306 | endif 307 | 308 | ifndef BOSSA_OPTS 309 | BOSSA_OPTS += -d --info --erase --write --verify --reset 310 | # Arduino Due forces RS-232 mode and boots from flash 311 | ifeq ($(findstring arduino_due, $(strip $(VARIANT))), arduino_due) 312 | BOSSA_OPTS += -U false -b 313 | endif 314 | endif 315 | 316 | get_bootloader = $(shell $(RESET_CMD) | tail -1) 317 | 318 | # if not bootloader port defined (ISP_PORT), automatically grab first port after reset 319 | # if not on windows 320 | ifndef ISP_PORT 321 | ifeq ($(CURRENT_OS), WINDOWS) 322 | BOSSA_OPTS += --port=$(COM_STYLE_MONITOR_PORT) 323 | else 324 | BOSSA_OPTS += --port=$(notdir $(call get_monitor_port)) 325 | endif 326 | else 327 | BOSSA_OPTS += --port=$(ISP_PORT) 328 | endif 329 | 330 | ######################################################################## 331 | # EXECUTABLES 332 | # Define them here to use ARM_TOOLS_PATH and allow auto finding of AVR_TOOLS_PATH 333 | 334 | AVR_TOOLS_DIR := $(ARM_TOOLS_DIR) 335 | #GDB = $(ARM_TOOLS_PATH)/$(GDB_NAME) 336 | # Use system gdb for now as Arduino supplied has lib error? 337 | GDB = $(GDB_NAME) 338 | 339 | ######################################################################## 340 | # FLAGS 341 | 342 | ifndef USB_TYPE 343 | USB_TYPE = USBCON 344 | endif 345 | 346 | ifndef USB_PRODUCT 347 | USB_PRODUCT := $(call PARSE_BOARD,$(BOARD_TAG),build.usb_product) 348 | ifdef USB_PRODUCT 349 | $(call show_config_variable,USB_PRODUCT,[COMPUTED]) 350 | endif 351 | endif 352 | 353 | ifndef USB_MANUFACTURER 354 | USB_MANUFACTURER := $(call PARSE_BOARD,$(BOARD_TAG),build.usb_manufacturer) 355 | ifndef USB_MANUFACTURER 356 | USB_MANUFACTURER = "Unknown" 357 | else 358 | $(call show_config_variable,USB_MANUFACTURER,[COMPUTED]) 359 | endif 360 | endif 361 | 362 | ifndef USB_VID 363 | USB_VID := $(call PARSE_BOARD,$(BOARD_TAG),build.vid) 364 | ifdef USB_VID 365 | $(call show_config_variable,USB_VID,[COMPUTED]) 366 | endif 367 | endif 368 | 369 | ifndef USB_PID 370 | USB_PID := $(call PARSE_BOARD,$(BOARD_TAG),build.pid) 371 | ifdef USB_PID 372 | $(call show_config_variable,USB_PID,[COMPUTED]) 373 | endif 374 | endif 375 | 376 | # Bootloader settings 377 | ifndef BOOTLOADER_SIZE 378 | BOOTLOADER_SIZE := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.size) 379 | ifndef BOOTLOADER_SIZE 380 | BOOTLOADER_SIZE := 0x2000 381 | else 382 | $(call show_config_variable,BOOTLOADER_SIZE,[COMPUTED]) 383 | endif 384 | endif 385 | 386 | ifndef BOOTLOADER_UNPROTECT 387 | BOOTLOADER_UNPROTECT := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.cmd_unprotect) 388 | ifndef BOOTLOADER_UNPROTECT 389 | BOOTLOADER_UNPROTECT := at91samd bootloader 0 390 | else 391 | $(call show_config_variable,BOOTLOADER_UNPROTECT,[COMPUTED]) 392 | endif 393 | endif 394 | 395 | ifndef BOOTLOADER_PROTECT 396 | BOOTLOADER_PROTECT := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.cmd_protect) 397 | ifndef BOOTLOADER_PROTECT 398 | BOOTLOADER_PROTECT := at91samd bootloader 16384 399 | else 400 | $(call show_config_variable,BOOTLOADER_PROTECT,[COMPUTED]) 401 | endif 402 | endif 403 | 404 | ifndef BOOTLOADER_PROTECT_VERIFY 405 | BOOTLOADER_PROTECT_VERIFY := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.cmd_protect_verify) 406 | ifndef BOOTLOADER_PROTECT_VERIFY 407 | BOOTLOADER_PROTECT_VERIFY := at91samd bootloader 408 | else 409 | $(call show_config_variable,BOOTLOADER_PROTECT_VERIFY,[COMPUTED]) 410 | endif 411 | endif 412 | 413 | CFLAGS_STD += -std=gnu11 414 | CPPFLAGS += -DMD -D$(USB_TYPE) '-DUSB_PRODUCT=$(USB_PRODUCT)' '-DUSB_MANUFACTURER=$(USB_MANUFACTURER)' 415 | 416 | # Get extra define flags from boards.txt 417 | EXFLAGS := $(shell echo $(call PARSE_BOARD,$(BOARD_TAG),build.extra_flags) | $(GREP_CMD) -oE '(-D)\w+') 418 | 419 | # Strip only defines from extra flags as boards file appends user {build.usb} 420 | CPPFLAGS += $(EXFLAGS) 421 | CPPFLAGS += -DUSB_VID=$(USB_VID) 422 | CPPFLAGS += -DUSB_PID=$(USB_PID) 423 | # Cortex compiler flags 424 | CPPFLAGS += -mthumb -nostdlib --param max-inline-insns-single=500 -fno-exceptions -Wl,-Map=$(OBJDIR)/$(TARGET).map 425 | CXXFLAGS += -fno-rtti -fno-threadsafe-statics -std=gnu++11 426 | 427 | ifndef SIZEFLAGS 428 | SIZEFLAGS += -B 429 | endif 430 | 431 | AMCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu) 432 | BOARD_LINKER_SCRIPT := $(call PARSE_BOARD,$(BOARD_TAG),build.ldscript) 433 | OPENOCD_SCRIPT := $(call PARSE_BOARD,$(BOARD_TAG),build.openocdscript) 434 | LINKER_SCRIPTS := -T$(ALTERNATE_CORE_PATH)/variants/$(VARIANT)/$(BOARD_LINKER_SCRIPT) 435 | OTHER_LIBS := $(call PARSE_BOARD,$(BOARD_TAG),build.flags.libs) 436 | 437 | # Due and SAMD boards have different flags/chip specific libs 438 | ifeq ($(findstring arduino_due, $(strip $(VARIANT))), arduino_due) 439 | CPPFLAGS += -Dprintf=iprintf -DARDUINO_SAM_DUE 440 | LDFLAGS += -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group -u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid 441 | LDFLAGS += -L$(LIB_PATH) -lm # -larm_cortexM3l_math # IDE doesn't include Cortex-M3 math lib on Due for some reason 442 | OTHER_LIBS += $(ALTERNATE_CORE_PATH)/variants/$(VARIANT)/libsam_sam3x8e_gcc_rel.a 443 | else 444 | LDFLAGS += --specs=nano.specs --specs=nosys.specs -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group 445 | LDFLAGS += -larm_cortexM0l_math -L$(LIB_PATH) -lm 446 | endif 447 | 448 | # OpenOCD reset command only for now 449 | ifeq ($(strip $(UPLOAD_TOOL)), openocd) 450 | RESET_CMD = $(OPENOCD) $(OPENOCD_OPTS) -c "telnet_port disabled; init; targets; reset run; shutdown" 451 | else 452 | # Set zero flag for ard-reset for 1200 baud boot to bootloader 453 | ARD_RESET_OPTS += --zero 454 | endif 455 | 456 | ######################################################################## 457 | # automatially include Arduino.mk for the user 458 | 459 | $(call show_separator) 460 | $(call arduino_output,Arduino.mk Configuration:) 461 | include $(ARDMK_DIR)/Arduino.mk 462 | 463 | print-% : ; @echo $* = $($*) 464 | -------------------------------------------------------------------------------- /crouse-of-the-hedospace/Arduino.mk: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # 3 | # Makefile for compiling Arduino sketches from command line 4 | # System part (i.e. project independent) 5 | # 6 | # Copyright (C) 2012 Sudar , based on 7 | # M J Oldfield work: https://github.com/mjoldfield/Arduino-Makefile 8 | # 9 | # Copyright (C) 2010,2011,2012 Martin Oldfield , based on 10 | # work that is copyright Nicholas Zambetti, David A. Mellis & Hernando 11 | # Barragan. 12 | # 13 | # This file is free software; you can redistribute it and/or modify it 14 | # under the terms of the GNU Lesser General Public License as 15 | # published by the Free Software Foundation; either version 2.1 of the 16 | # License, or (at your option) any later version. 17 | # 18 | # Adapted from Arduino 0011 Makefile by M J Oldfield 19 | # 20 | # Original Arduino adaptation by mellis, eighthave, oli.keller 21 | # 22 | # Current version: 1.6.0 23 | # 24 | # Refer to HISTORY.md file for complete history of changes 25 | # 26 | ######################################################################## 27 | # 28 | # PATHS YOU NEED TO SET UP 29 | # 30 | # We need to worry about three different sorts of files: 31 | # 32 | # 1. The directory where the *.mk files are stored 33 | # => ARDMK_DIR 34 | # 35 | # 2. Things which are always in the Arduino distribution e.g. 36 | # boards.txt, libraries, etc. 37 | # => ARDUINO_DIR 38 | # 39 | # 3. Things which might be bundled with the Arduino distribution, but 40 | # might come from the system. Most of the toolchain is like this: 41 | # on Linux it is supplied by the system. 42 | # => AVR_TOOLS_DIR 43 | # 44 | # Having set these three variables, we can work out the rest assuming 45 | # that things are canonically arranged beneath the directories defined 46 | # above. 47 | # 48 | # On the Mac with IDE 1.0 you might want to set: 49 | # 50 | # ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java 51 | # ARDMK_DIR = /usr/local 52 | # 53 | # On the Mac with IDE 1.5+ you might want to set: 54 | # 55 | # ARDUINO_DIR = /Applications/Arduino.app/Contents/Java 56 | # ARDMK_DIR = /usr/local 57 | # 58 | # On Linux, you might prefer: 59 | # 60 | # ARDUINO_DIR = /usr/share/arduino 61 | # ARDMK_DIR = /usr/share/arduino 62 | # AVR_TOOLS_DIR = /usr 63 | # 64 | # On Windows declare this environmental variables using the windows 65 | # configuration options or Cygwin .bashrc. Control Panel > System > Advanced system settings 66 | # The paths must use Unix style forward slash and not have any spaces 67 | # or escape charactors. One must use a symbolic link if the path does 68 | # contain spaces. 69 | # 70 | # This are just examples, you have to adapt this variables accordingly to 71 | # your system. Note the difference between ARDMK_DIR, which can use /cygdrive/ 72 | # and USER_LIB_PATH, which cannnot due to invoking with the build tools. 73 | # It is best practice to avoid cygdrive all together. 74 | # 75 | # ARDUINO_DIR = C:/Arduino 76 | # AVR_TOOLS_DIR = C:/Arduino/hardware/tools/avr 77 | # ARDMK_DIR = /cygdrive/c/Users/"YourUser"/Arduino-Makefile 78 | # 79 | # On Windows it is highly recommended that you create a symbolic link directory 80 | # for avoiding using the normal directories name of windows such as 81 | # C:\Program Files (x86)\Arduino 82 | # For this use the command mklink on the console. 83 | # 84 | # 85 | # You can either set these up in the Makefile, or put them in your 86 | # environment e.g. in your .bashrc 87 | # 88 | # If you don't specify these, we can try to guess, but that might not work 89 | # or work the way you want it to. 90 | # 91 | # If you'd rather not see the configuration output, define ARDUINO_QUIET. 92 | # 93 | ######################################################################## 94 | # 95 | # DEPENDENCIES 96 | # 97 | # to reset a board the (python) pySerial program is used. 98 | # please install it prior to continue. 99 | # 100 | ######################################################################## 101 | # 102 | # STANDARD ARDUINO WORKFLOW 103 | # 104 | # Given a normal sketch directory, all you need to do is to create 105 | # a small Makefile which defines a few things, and then includes this one. 106 | # 107 | # For example: 108 | # 109 | # ARDUINO_LIBS = Ethernet SPI 110 | # BOARD_TAG = uno 111 | # MONITOR_PORT = /dev/cu.usb* 112 | # 113 | # include /usr/share/arduino/Arduino.mk 114 | # 115 | # Hopefully these will be self-explanatory but in case they're not: 116 | # 117 | # ARDUINO_LIBS - A list of any libraries used by the sketch (we 118 | # assume these are in $(ARDUINO_DIR)/hardware/libraries 119 | # or your sketchbook's libraries directory) 120 | # 121 | # MONITOR_PORT - The port where the Arduino can be found (only needed 122 | # when uploading) 123 | # 124 | # BOARD_TAG - The tag for the board e.g. uno or mega 125 | # 'make show_boards' shows a list 126 | # 127 | # If you have your additional libraries relative to your source, rather 128 | # than in your "sketchbook", also set USER_LIB_PATH, like this example: 129 | # 130 | # USER_LIB_PATH := $(realpath ../../libraries) 131 | # 132 | # If you've added the Arduino-Makefile repository to your git repo as a 133 | # submodule (or other similar arrangement), you might have lines like this 134 | # in your Makefile: 135 | # 136 | # ARDMK_DIR := $(realpath ../../tools/Arduino-Makefile) 137 | # include $(ARDMK_DIR)/Arduino.mk 138 | # 139 | # In any case, once this file has been created the typical workflow is just 140 | # 141 | # $ make upload 142 | # 143 | # All of the object files are created in the build-{BOARD_TAG} subdirectory 144 | # All sources should be in the current directory and can include: 145 | # - at most one .pde or .ino file which will be treated as C++ after 146 | # the standard Arduino header and footer have been affixed. 147 | # - any number of .c, .cpp, .s and .h files 148 | # 149 | # Included libraries are built in the build-{BOARD_TAG}/libs subdirectory. 150 | # 151 | # Besides make upload, there are a couple of other targets that are available. 152 | # Do make help to get the complete list of targets and their description 153 | # 154 | ######################################################################## 155 | # 156 | # SERIAL MONITOR 157 | # 158 | # The serial monitor just invokes the GNU screen program with suitable 159 | # options. For more information see screen (1) and search for 160 | # 'character special device'. 161 | # 162 | # The really useful thing to know is that ^A-k gets you out! 163 | # 164 | # The fairly useful thing to know is that you can bind another key to 165 | # escape too, by creating $HOME{.screenrc} containing e.g. 166 | # 167 | # bindkey ^C kill 168 | # 169 | # If you want to change the baudrate, just set MONITOR_BAUDRATE. If you 170 | # don't set it, it tries to read from the sketch. If it couldn't read 171 | # from the sketch, then it defaults to 9600 baud. 172 | # 173 | ######################################################################## 174 | # 175 | # ARDUINO WITH ISP 176 | # 177 | # You need to specify some details of your ISP programmer and might 178 | # also need to specify the fuse values: 179 | # 180 | # ISP_PROG = stk500v2 181 | # ISP_PORT = /dev/ttyACM0 182 | # 183 | # You might also need to set the fuse bits, but typically they'll be 184 | # read from boards.txt, based on the BOARD_TAG variable: 185 | # 186 | # ISP_LOCK_FUSE_PRE = 0x3f 187 | # ISP_LOCK_FUSE_POST = 0xcf 188 | # ISP_HIGH_FUSE = 0xdf 189 | # ISP_LOW_FUSE = 0xff 190 | # ISP_EXT_FUSE = 0x01 191 | # 192 | # You can specify to also upload the EEPROM file: 193 | # ISP_EEPROM = 1 194 | # 195 | # I think the fuses here are fine for uploading to the ATmega168 196 | # without bootloader. 197 | # 198 | # To actually do this upload use the ispload target: 199 | # 200 | # make ispload 201 | # 202 | # 203 | ######################################################################## 204 | # 205 | # ALTERNATIVE CORES 206 | # 207 | # To use alternative cores for platforms such as ATtiny, you need to 208 | # specify a few more variables, depending on the core in use. 209 | # 210 | # The HLT (attiny-master) core can be used just by specifying 211 | # ALTERNATE_CORE, assuming your core is in your ~/sketchbook/hardware 212 | # directory. For example: 213 | # 214 | # ISP_PORT = /dev/ttyACM0 215 | # BOARD_TAG = attiny85 216 | # ALTERNATE_CORE = attiny-master 217 | # 218 | # To use the more complex arduino-tiny and TinyCore2 cores, you must 219 | # also set ARDUINO_CORE_PATH and ARDUINO_VAR_PATH to the core 220 | # directory, as these cores essentially replace the main Arduino core. 221 | # For example: 222 | # 223 | # ISP_PORT = /dev/ttyACM0 224 | # BOARD_TAG = attiny85at8 225 | # ALTERNATE_CORE = arduino-tiny 226 | # ARDUINO_VAR_PATH = ~/sketchbook/hardware/arduino-tiny/cores/tiny 227 | # ARDUINO_CORE_PATH = ~/sketchbook/hardware/arduino-tiny/cores/tiny 228 | # 229 | # or.... 230 | # 231 | # ISP_PORT = /dev/ttyACM0 232 | # BOARD_TAG = attiny861at8 233 | # ALTERNATE_CORE = tiny2 234 | # ARDUINO_VAR_PATH = ~/sketchbook/hardware/tiny2/cores/tiny 235 | # ARDUINO_CORE_PATH = ~/sketchbook/hardware/tiny2/cores/tiny 236 | # 237 | ######################################################################## 238 | 239 | arduino_output = 240 | # When output is not suppressed and we're in the top-level makefile, 241 | # running for the first time (i.e., not after a restart after 242 | # regenerating the dependency file), then output the configuration. 243 | ifndef ARDUINO_QUIET 244 | ARDUINO_QUIET = 0 245 | endif 246 | ifeq ($(ARDUINO_QUIET),0) 247 | ifeq ($(MAKE_RESTARTS),) 248 | ifeq ($(MAKELEVEL),0) 249 | arduino_output = $(info $(1)) 250 | endif 251 | endif 252 | endif 253 | 254 | ######################################################################## 255 | # Makefile distribution path 256 | 257 | ifndef ARDMK_DIR 258 | # presume it's the same path to our own file 259 | ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))) 260 | else 261 | # show_config_variable macro is defined in Common.mk file and is not available yet. 262 | # Let's define a variable to know that user specified ARDMK_DIR 263 | ARDMK_DIR_MSG = USER 264 | endif 265 | 266 | # include Common.mk now we know where it is 267 | ifndef COMMON_INCLUDED 268 | include $(ARDMK_DIR)/Common.mk 269 | endif 270 | 271 | # show_config_variable macro is available now. So let's print config details for ARDMK_DIR 272 | ifndef ARDMK_DIR_MSG 273 | $(call show_config_variable,ARDMK_DIR,[COMPUTED],(relative to $(notdir $(lastword $(MAKEFILE_LIST))))) 274 | else 275 | $(call show_config_variable,ARDMK_DIR,[USER]) 276 | endif 277 | 278 | ######################################################################## 279 | # Default TARGET to pwd (ex Daniele Vergini) 280 | 281 | ifndef TARGET 282 | space := 283 | space += 284 | TARGET = $(notdir $(subst $(space),_,$(CURDIR))) 285 | endif 286 | 287 | ######################################################################## 288 | # Arduino version number 289 | 290 | ifndef ARDUINO_VERSION 291 | # Remove all the decimals, remove anything before/including ":", remove anything after/including "+" and finally grab the last 5 bytes. 292 | # Works for 1.0 and 1.0.1 and 1.6.10 and debian-style 2:1.0.5+dfsg2-4 293 | VERSION_FILE := $(ARDUINO_DIR)/lib/version.txt 294 | AUTO_ARDUINO_VERSION := $(shell [ -e $(VERSION_FILE) ] && cat $(VERSION_FILE) | sed -e 's/^[0-9]://g' -e 's/[.]//g' -e 's/\+.*//g' | head -c5) 295 | ifdef AUTO_ARDUINO_VERSION 296 | ARDUINO_VERSION = $(AUTO_ARDUINO_VERSION) 297 | $(call show_config_variable,ARDUINO_VERSION,[AUTODETECTED]) 298 | else 299 | ARDUINO_VERSION = 100 300 | $(call show_config_variable,ARDUINO_VERSION,[DEFAULT]) 301 | endif 302 | else 303 | $(call show_config_variable,ARDUINO_VERSION,[USER]) 304 | endif 305 | 306 | ######################################################################## 307 | # 1.5.x architecture - avr or sam for arduino vendor 308 | ifndef ARCHITECTURE 309 | ifeq ($(shell expr $(ARDUINO_VERSION) '>' 150), 1) 310 | # default to avr for 1.5 311 | ARCHITECTURE = avr 312 | ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_AVR 313 | else 314 | # unset for 1.0 315 | ARCHITECTURE = 316 | endif 317 | $(call show_config_variable,ARCHITECTURE,[DEFAULT]) 318 | else 319 | $(call show_config_variable,ARCHITECTURE,[USER]) 320 | 321 | #avoid using shell for known architectures 322 | ifeq ($(ARCHITECTURE),avr) 323 | ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_AVR 324 | else 325 | ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_$(shell echo $(ARCHITECTURE) | tr '[:lower:]' '[:upper:]') 326 | endif 327 | endif 328 | 329 | ######################################################################## 330 | # 1.5.x vendor - defaults to arduino 331 | ifndef ARDMK_VENDOR 332 | ARCH_LINUX := $(shell grep "Arch Linux" /etc/os-release 2>/dev/null) 333 | ifdef ARCH_LINUX 334 | ARDMK_VENDOR = archlinux-arduino 335 | else 336 | ARDMK_VENDOR = arduino 337 | endif 338 | $(call show_config_variable,ARDMK_VENDOR,[DEFAULT]) 339 | else 340 | $(call show_config_variable,ARDMK_VENDOR,[USER]) 341 | endif 342 | 343 | ######################################################################## 344 | # Arduino Sketchbook folder 345 | 346 | ifndef ARDUINO_SKETCHBOOK 347 | ifndef ARDUINO_PREFERENCES_PATH 348 | ifeq ($(shell expr $(ARDUINO_VERSION) '>' 150), 1) 349 | AUTO_ARDUINO_PREFERENCES := $(firstword \ 350 | $(call dir_if_exists,$(HOME)/.arduino15/preferences.txt) \ 351 | $(call dir_if_exists,$(HOME)/Library/Arduino15/preferences.txt) ) 352 | else 353 | AUTO_ARDUINO_PREFERENCES := $(firstword \ 354 | $(call dir_if_exists,$(HOME)/.arduino/preferences.txt) \ 355 | $(call dir_if_exists,$(HOME)/Library/Arduino/preferences.txt) ) 356 | endif 357 | 358 | ifdef AUTO_ARDUINO_PREFERENCES 359 | ARDUINO_PREFERENCES_PATH = $(AUTO_ARDUINO_PREFERENCES) 360 | $(call show_config_variable,ARDUINO_PREFERENCES_PATH,[AUTODETECTED]) 361 | endif 362 | 363 | else 364 | $(call show_config_variable,ARDUINO_PREFERENCES_PATH,[USER]) 365 | endif 366 | 367 | ifneq ($(ARDUINO_PREFERENCES_PATH),) 368 | ARDUINO_SKETCHBOOK := $(shell grep --max-count=1 --regexp='sketchbook.path=' \ 369 | $(ARDUINO_PREFERENCES_PATH) | \ 370 | sed -e 's/sketchbook.path=//' ) 371 | endif 372 | 373 | ifneq ($(ARDUINO_SKETCHBOOK),) 374 | $(call show_config_variable,ARDUINO_SKETCHBOOK,[AUTODETECTED],(from arduino preferences file)) 375 | else 376 | ifeq ($(CURRENT_OS), WINDOWS) 377 | ARDUINO_SKETCHBOOK := $(firstword \ 378 | $(call dir_if_exists,$(USERPROFILE)/sketchbook) \ 379 | $(call dir_if_exists,$(USERPROFILE)/Documents/Arduino) ) 380 | else 381 | ARDUINO_SKETCHBOOK := $(firstword \ 382 | $(call dir_if_exists,$(HOME)/sketchbook) \ 383 | $(call dir_if_exists,$(HOME)/Documents/Arduino) ) 384 | endif 385 | $(call show_config_variable,ARDUINO_SKETCHBOOK,[DEFAULT]) 386 | endif 387 | else 388 | $(call show_config_variable,ARDUINO_SKETCHBOOK,[USER]) 389 | endif 390 | 391 | ######################################################################## 392 | # Arduino and system paths 393 | 394 | # Third party hardware and core like ATtiny or ATmega 16 395 | ifdef ALTERNATE_CORE 396 | $(call show_config_variable,ALTERNATE_CORE,[USER]) 397 | 398 | ifndef ALTERNATE_CORE_PATH 399 | ALTERNATE_CORE_PATH = $(ARDUINO_SKETCHBOOK)/hardware/$(ALTERNATE_CORE)/$(ARCHITECTURE) 400 | endif 401 | endif 402 | 403 | ifdef ALTERNATE_CORE_PATH 404 | 405 | ifdef ALTERNATE_CORE 406 | $(call show_config_variable,ALTERNATE_CORE_PATH,[COMPUTED], (from ARDUINO_SKETCHBOOK and ALTERNATE_CORE)) 407 | else 408 | $(call show_config_variable,ALTERNATE_CORE_PATH,[USER]) 409 | endif 410 | 411 | ifndef ARDUINO_VAR_PATH 412 | ARDUINO_VAR_PATH = $(ALTERNATE_CORE_PATH)/variants 413 | $(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ALTERNATE_CORE_PATH)) 414 | endif 415 | 416 | ifndef BOARDS_TXT 417 | BOARDS_TXT = $(ALTERNATE_CORE_PATH)/boards.txt 418 | $(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ALTERNATE_CORE_PATH)) 419 | endif 420 | 421 | else 422 | 423 | ifndef ARDUINO_VAR_PATH 424 | ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/variants 425 | $(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ARDUINO_DIR)) 426 | else 427 | $(call show_config_variable,ARDUINO_VAR_PATH,[USER]) 428 | endif 429 | 430 | ifndef BOARDS_TXT 431 | BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/boards.txt 432 | $(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ARDUINO_DIR)) 433 | else 434 | $(call show_config_variable,BOARDS_TXT,[USER]) 435 | endif 436 | 437 | endif 438 | 439 | ifeq (,$(wildcard $(BOARDS_TXT))) 440 | $(error Currently BOARDS_TXT='$(BOARDS_TXT)', which is not an existing file or an invalid filename.) 441 | endif 442 | 443 | ifndef TOOL_PREFIX 444 | TOOL_PREFIX = avr 445 | endif 446 | 447 | ifndef CC_NAME 448 | CC_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.gcc) 449 | ifndef CC_NAME 450 | CC_NAME := $(TOOL_PREFIX)-gcc 451 | else 452 | $(call show_config_variable,CC_NAME,[COMPUTED]) 453 | endif 454 | endif 455 | 456 | ifndef CXX_NAME 457 | CXX_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.g++) 458 | ifndef CXX_NAME 459 | CXX_NAME := $(TOOL_PREFIX)-g++ 460 | else 461 | $(call show_config_variable,CXX_NAME,[COMPUTED]) 462 | endif 463 | endif 464 | 465 | ifndef AS_NAME 466 | AS_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.as) 467 | ifndef AS_NAME 468 | AS_NAME := $(TOOL_PREFIX)-as 469 | else 470 | $(call show_config_variable,AS_NAME,[COMPUTED]) 471 | endif 472 | endif 473 | 474 | ifndef OBJCOPY_NAME 475 | OBJCOPY_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.objcopy) 476 | ifndef OBJCOPY_NAME 477 | OBJCOPY_NAME := $(TOOL_PREFIX)-objcopy 478 | else 479 | $(call show_config_variable,OBJCOPY_NAME,[COMPUTED]) 480 | endif 481 | endif 482 | 483 | ifndef OBJDUMP_NAME 484 | OBJDUMP_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.objdump) 485 | ifndef OBJDUMP_NAME 486 | OBJDUMP_NAME := $(TOOL_PREFIX)-objdump 487 | else 488 | $(call show_config_variable,OBJDUMP_NAME,[COMPUTED]) 489 | endif 490 | endif 491 | 492 | ifndef AR_NAME 493 | AR_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.ar) 494 | ifndef AR_NAME 495 | AR_NAME := $(TOOL_PREFIX)-ar 496 | else 497 | $(call show_config_variable,AR_NAME,[COMPUTED]) 498 | endif 499 | endif 500 | 501 | ifndef SIZE_NAME 502 | SIZE_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.size) 503 | ifndef SIZE_NAME 504 | SIZE_NAME := $(TOOL_PREFIX)-size 505 | else 506 | $(call show_config_variable,SIZE_NAME,[COMPUTED]) 507 | endif 508 | endif 509 | 510 | ifndef NM_NAME 511 | NM_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.nm) 512 | ifndef NM_NAME 513 | NM_NAME := $(TOOL_PREFIX)-nm 514 | else 515 | $(call show_config_variable,NM_NAME,[COMPUTED]) 516 | endif 517 | endif 518 | 519 | ifndef AVR_TOOLS_DIR 520 | 521 | BUNDLED_AVR_TOOLS_DIR := $(call dir_if_exists,$(ARDUINO_DIR)/hardware/tools/avr) 522 | 523 | ifdef BUNDLED_AVR_TOOLS_DIR 524 | AVR_TOOLS_DIR = $(BUNDLED_AVR_TOOLS_DIR) 525 | $(call show_config_variable,AVR_TOOLS_DIR,[BUNDLED],(in Arduino distribution)) 526 | 527 | # In Linux distribution of Arduino, the path to avrdude and avrdude.conf are different 528 | # More details at https://github.com/sudar/Arduino-Makefile/issues/48 and 529 | # https://groups.google.com/a/arduino.cc/d/msg/developers/D_m97jGr8Xs/uQTt28KO_8oJ 530 | ifeq ($(CURRENT_OS),LINUX) 531 | 532 | ifndef AVRDUDE 533 | ifeq ($(shell expr $(ARDUINO_VERSION) '>' 157), 1) 534 | # 1.5.8 has different location than all prior versions! 535 | AVRDUDE = $(AVR_TOOLS_DIR)/bin/avrdude 536 | else 537 | AVRDUDE = $(AVR_TOOLS_DIR)/../avrdude 538 | endif 539 | endif 540 | 541 | ifndef AVRDUDE_CONF 542 | ifeq ($(shell expr $(ARDUINO_VERSION) '>' 157), 1) 543 | AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf 544 | else 545 | AVRDUDE_CONF = $(AVR_TOOLS_DIR)/../avrdude.conf 546 | endif 547 | endif 548 | 549 | else 550 | 551 | ifndef AVRDUDE_CONF 552 | AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf 553 | endif 554 | 555 | endif 556 | 557 | else 558 | 559 | SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which $(CC_NAME)))/..)) 560 | ifdef SYSTEMPATH_AVR_TOOLS_DIR 561 | AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR) 562 | $(call show_config_variable,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH)) 563 | else 564 | # One last attempt using $(TOOL_PREFIX)-gcc in case using arm 565 | SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which $($(TOOL_PREFIX)-gcc)))/..)) 566 | ifdef SYSTEMPATH_AVR_TOOLS_DIR 567 | AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR) 568 | $(call show_config_variable,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH)) 569 | else 570 | echo $(error No AVR tools directory found) 571 | endif 572 | endif # SYSTEMPATH_AVR_TOOLS_DIR 573 | 574 | endif # BUNDLED_AVR_TOOLS_DIR 575 | 576 | else 577 | $(call show_config_variable,AVR_TOOLS_DIR,[USER]) 578 | 579 | # ensure we can still find avrdude.conf 580 | ifndef AVRDUDE_CONF 581 | ifeq ($(shell expr $(ARDUINO_VERSION) '>' 157), 1) 582 | AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf 583 | else 584 | AVRDUDE_CONF = $(AVR_TOOLS_DIR)/../avrdude.conf 585 | endif 586 | endif 587 | 588 | endif #ndef AVR_TOOLS_DIR 589 | 590 | ifndef TOOLS_PATH 591 | TOOLS_PATH = $(AVR_TOOLS_DIR)/bin 592 | endif 593 | 594 | ifndef ARDUINO_LIB_PATH 595 | ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries 596 | $(call show_config_variable,ARDUINO_LIB_PATH,[COMPUTED],(from ARDUINO_DIR)) 597 | else 598 | $(call show_config_variable,ARDUINO_LIB_PATH,[USER]) 599 | endif 600 | 601 | # 1.5.x platform dependent libs path 602 | ifndef ARDUINO_PLATFORM_LIB_PATH 603 | ifeq ($(shell expr $(ARDUINO_VERSION) '>' 150), 1) 604 | # only for 1.5 605 | ARDUINO_PLATFORM_LIB_PATH = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/libraries 606 | $(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[COMPUTED],(from ARDUINO_DIR)) 607 | endif 608 | else 609 | $(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[USER]) 610 | endif 611 | 612 | ######################################################################## 613 | # Miscellaneous 614 | 615 | ifndef USER_LIB_PATH 616 | USER_LIB_PATH = $(ARDUINO_SKETCHBOOK)/libraries 617 | $(call show_config_variable,USER_LIB_PATH,[DEFAULT],(in user sketchbook)) 618 | else 619 | $(call show_config_variable,USER_LIB_PATH,[USER]) 620 | endif 621 | 622 | ifndef PRE_BUILD_HOOK 623 | PRE_BUILD_HOOK = pre-build-hook.sh 624 | $(call show_config_variable,PRE_BUILD_HOOK,[DEFAULT]) 625 | else 626 | $(call show_config_variable,PRE_BUILD_HOOK,[USER]) 627 | endif 628 | 629 | ######################################################################## 630 | # boards.txt parsing 631 | 632 | ifdef BOARD_SUB 633 | BOARD_SUB := $(strip $(BOARD_SUB)) 634 | $(call show_config_variable,BOARD_SUB,[USER]) 635 | endif 636 | 637 | ifndef BOARD_TAG 638 | BOARD_TAG = uno 639 | $(call show_config_variable,BOARD_TAG,[DEFAULT]) 640 | else 641 | # Strip the board tag of any extra whitespace, since it was causing the makefile to fail 642 | # https://github.com/sudar/Arduino-Makefile/issues/57 643 | BOARD_TAG := $(strip $(BOARD_TAG)) 644 | $(call show_config_variable,BOARD_TAG,[USER]) 645 | endif 646 | 647 | ifdef BOARD_CLOCK 648 | BOARD_CLOCK := $(strip $(BOARD_CLOCK)) 649 | $(call show_config_variable,BOARD_CLOCK,[USER]) 650 | endif 651 | 652 | # If NO_CORE is set, then we don't have to parse boards.txt file 653 | # But the user might have to define MCU, F_CPU etc 654 | ifeq ($(strip $(NO_CORE)),) 655 | 656 | # Select a core from the 'cores' directory. Two main values: 'arduino' or 657 | # 'robot', but can also hold 'tiny', for example, if using 658 | # https://code.google.com/p/arduino-tiny alternate core. 659 | ifndef CORE 660 | CORE = $(call PARSE_BOARD,$(BOARD_TAG),build.core) 661 | $(call show_config_variable,CORE,[COMPUTED],(from build.core)) 662 | else 663 | $(call show_config_variable,CORE,[USER]) 664 | endif 665 | 666 | # Which variant ? This affects the include path 667 | ifndef VARIANT 668 | VARIANT := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).build.variant) 669 | ifndef VARIANT 670 | VARIANT := $(call PARSE_BOARD,$(BOARD_TAG),build.variant) 671 | endif 672 | $(call show_config_variable,VARIANT,[COMPUTED],(from build.variant)) 673 | else 674 | $(call show_config_variable,VARIANT,[USER]) 675 | endif 676 | 677 | ifndef BOARD 678 | BOARD := $(call PARSE_BOARD,$(BOARD_TAG),build.board) 679 | ifndef BOARD 680 | BOARD := $(shell echo $(ARCHITECTURE)_$(BOARD_TAG) | tr '[:lower:]' '[:upper:]') 681 | endif 682 | $(call show_config_variable,BOARD,[COMPUTED],(from build.board)) 683 | else 684 | $(call show_config_variable,BOARD,[USER]) 685 | endif 686 | 687 | # see if we are a caterina device like leonardo or micro 688 | CATERINA := $(findstring caterina,$(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.file)) 689 | ifndef CATERINA 690 | # 1.5+ method if not a submenu 691 | CATERINA := $(findstring caterina,$(call PARSE_BOARD,$(BOARD_TAG),bootloader.file)) 692 | endif 693 | ifndef CATERINA 694 | # 1.0 method uses deprecated bootloader.path 695 | CATERINA := $(findstring caterina,$(call PARSE_BOARD,$(BOARD_TAG),bootloader.path)) 696 | endif 697 | 698 | # processor stuff 699 | ifndef MCU 700 | MCU := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).build.mcu) 701 | ifndef MCU 702 | MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu) 703 | endif 704 | endif 705 | 706 | ifndef F_CPU 707 | ifdef BOARD_CLOCK 708 | F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),menu.(speed|clock).$(BOARD_CLOCK).build.f_cpu) 709 | endif 710 | ifndef F_CPU 711 | F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).build.f_cpu) 712 | endif 713 | ifndef F_CPU 714 | F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),build.f_cpu) 715 | endif 716 | endif 717 | 718 | ifneq ($(CATERINA),) 719 | # USB IDs for the caterina devices like leonardo or micro 720 | ifndef USB_VID 721 | USB_VID = $(call PARSE_BOARD,$(BOARD_TAG),build.vid) 722 | endif 723 | 724 | # coping with 2-3 methods sparkfun use for usb.pid 725 | ifndef USB_PID 726 | USB_PID := $(call PARSE_BOARD,$(BOARD_TAG),build.pid) 727 | ifndef USB_PID 728 | USB_PID := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).build.pid) 729 | endif 730 | endif 731 | 732 | ifndef USB_PRODUCT 733 | USB_PRODUCT := $(call PARSE_BOARD,$(BOARD_TAG),build.usb_product) 734 | ifdef USB_PRODUCT 735 | $(call show_config_variable,USB_PRODUCT,[COMPUTED]) 736 | endif 737 | endif 738 | 739 | ifndef USB_MANUFACTURER 740 | USB_MANUFACTURER := $(call PARSE_BOARD,$(BOARD_TAG),build.usb_manufacturer) 741 | ifndef USB_MANUFACTURER 742 | USB_MANUFACTURER = "Unknown" 743 | else 744 | $(call show_config_variable,USB_MANUFACTURER,[COMPUTED]) 745 | endif 746 | endif 747 | 748 | # add caterina flag to ARD_RESET_OPTS 749 | ARD_RESET_OPTS += --caterina 750 | endif 751 | 752 | # normal programming info 753 | ifndef AVRDUDE_ARD_PROGRAMMER 754 | AVRDUDE_ARD_PROGRAMMER := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).upload.protocol) 755 | ifndef AVRDUDE_ARD_PROGRAMMER 756 | AVRDUDE_ARD_PROGRAMMER := $(call PARSE_BOARD,$(BOARD_TAG),upload.protocol) 757 | endif 758 | endif 759 | 760 | ifndef AVRDUDE_ARD_BAUDRATE 761 | AVRDUDE_ARD_BAUDRATE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).upload.speed) 762 | ifndef AVRDUDE_ARD_BAUDRATE 763 | AVRDUDE_ARD_BAUDRATE := $(call PARSE_BOARD,$(BOARD_TAG),upload.speed) 764 | endif 765 | endif 766 | 767 | # fuses if you're using e.g. ISP 768 | ifndef ISP_LOCK_FUSE_PRE 769 | ISP_LOCK_FUSE_PRE = $(call PARSE_BOARD,$(BOARD_TAG),bootloader.unlock_bits) 770 | endif 771 | 772 | ifndef ISP_HIGH_FUSE 773 | ifdef BOARD_CLOCK 774 | ISP_HIGH_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(speed|clock).$(BOARD_CLOCK).bootloader.high_fuses) 775 | endif 776 | ifndef ISP_HIGH_FUSE 777 | ISP_HIGH_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.high_fuses) 778 | endif 779 | ifndef ISP_HIGH_FUSE 780 | ISP_HIGH_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.high_fuses) 781 | endif 782 | endif 783 | 784 | ifndef ISP_LOW_FUSE 785 | ifdef BOARD_CLOCK 786 | ISP_LOW_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(speed|clock).$(BOARD_CLOCK).bootloader.low_fuses) 787 | endif 788 | ifndef ISP_LOW_FUSE 789 | ISP_LOW_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.low_fuses) 790 | endif 791 | ifndef ISP_LOW_FUSE 792 | ISP_LOW_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.low_fuses) 793 | endif 794 | endif 795 | 796 | ifndef ISP_EXT_FUSE 797 | ifdef BOARD_CLOCK 798 | ISP_EXT_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(speed|clock).$(BOARD_CLOCK).bootloader.extended_fuses) 799 | endif 800 | ifndef ISP_EXT_FUSE 801 | ISP_EXT_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.extended_fuses) 802 | endif 803 | ifndef ISP_EXT_FUSE 804 | ISP_EXT_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.extended_fuses) 805 | endif 806 | endif 807 | 808 | ifndef BOOTLOADER_PATH 809 | BOOTLOADER_PATH = $(call PARSE_BOARD,$(BOARD_TAG),bootloader.path) 810 | endif 811 | 812 | ifndef BOOTLOADER_FILE 813 | BOOTLOADER_FILE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.file) 814 | ifndef BOOTLOADER_FILE 815 | BOOTLOADER_FILE := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.file) 816 | endif 817 | endif 818 | 819 | ifndef ISP_LOCK_FUSE_POST 820 | ISP_LOCK_FUSE_POST = $(call PARSE_BOARD,$(BOARD_TAG),bootloader.lock_bits) 821 | endif 822 | 823 | ifndef HEX_MAXIMUM_SIZE 824 | HEX_MAXIMUM_SIZE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).upload.maximum_size) 825 | ifndef HEX_MAXIMUM_SIZE 826 | HEX_MAXIMUM_SIZE := $(call PARSE_BOARD,$(BOARD_TAG),upload.maximum_size) 827 | endif 828 | endif 829 | 830 | endif 831 | 832 | # Everything gets built in here (include BOARD_TAG now) 833 | ifndef OBJDIR 834 | OBJDIR = build-$(BOARD_TAG) 835 | ifdef BOARD_SUB 836 | OBJDIR = build-$(BOARD_TAG)-$(BOARD_SUB) 837 | endif 838 | $(call show_config_variable,OBJDIR,[COMPUTED],(from BOARD_TAG)) 839 | else 840 | $(call show_config_variable,OBJDIR,[USER]) 841 | endif 842 | 843 | # Now that we have ARDUINO_DIR, ARDMK_VENDOR, ARCHITECTURE and CORE, 844 | # we can set ARDUINO_CORE_PATH. 845 | ifndef ARDUINO_CORE_PATH 846 | ifeq ($(strip $(CORE)),) 847 | ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/cores/arduino 848 | $(call show_config_variable,ARDUINO_CORE_PATH,[DEFAULT]) 849 | else 850 | ARDUINO_CORE_PATH = $(ALTERNATE_CORE_PATH)/cores/$(CORE) 851 | ifeq ($(wildcard $(ARDUINO_CORE_PATH)),) 852 | ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/cores/$(CORE) 853 | $(call show_config_variable,ARDUINO_CORE_PATH,[COMPUTED],(from ARDUINO_DIR, BOARD_TAG and boards.txt)) 854 | else 855 | $(call show_config_variable,ARDUINO_CORE_PATH,[COMPUTED],(from ALTERNATE_CORE_PATH, BOARD_TAG and boards.txt)) 856 | endif 857 | endif 858 | else 859 | $(call show_config_variable,ARDUINO_CORE_PATH,[USER]) 860 | endif 861 | 862 | ######################################################################## 863 | # Reset 864 | 865 | ifndef RESET_CMD 866 | ARD_RESET_ARDUINO_PATH := $(shell which ard-reset-arduino 2> /dev/null) 867 | ifndef ARD_RESET_ARDUINO_PATH 868 | # same level as *.mk in bin directory when checked out from git 869 | # or in $PATH when packaged 870 | ARD_RESET_ARDUINO_PATH = $(ARDMK_DIR)/bin/ard-reset-arduino 871 | endif 872 | ARD_RESET_ARDUINO := $(PYTHON_CMD) $(ARD_RESET_ARDUINO_PATH) 873 | ifneq (,$(findstring CYGWIN,$(shell uname -s))) 874 | # confirm user is using default cygwin unix Python (which uses ttySx) and not Windows Python (which uses COMx) 875 | ifeq ($(PYTHON_CMD),/usr/bin/python) 876 | RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(DEVICE_PATH) 877 | else 878 | RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(call get_monitor_port) 879 | endif 880 | else 881 | RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(call get_monitor_port) 882 | endif 883 | $(call show_config_variable,RESET_CMD,[COMPUTED],(from PYTHON_CMD, ARD_RESET_OPTS and MONITOR_PORT)) 884 | else 885 | $(call show_config_variable,RESET_CMD,[USER]) 886 | endif 887 | 888 | ifneq ($(CATERINA),) 889 | ERROR_ON_CATERINA = $(error On $(BOARD_TAG), raw_xxx operation is not supported) 890 | else 891 | ERROR_ON_CATERINA = 892 | endif 893 | 894 | ######################################################################## 895 | # Local sources 896 | 897 | LOCAL_C_SRCS ?= $(wildcard *.c) 898 | LOCAL_CPP_SRCS ?= $(wildcard *.cpp) 899 | LOCAL_CC_SRCS ?= $(wildcard *.cc) 900 | LOCAL_PDE_SRCS ?= $(wildcard *.pde) 901 | LOCAL_INO_SRCS ?= $(wildcard *.ino) 902 | LOCAL_AS_SRCS ?= $(wildcard *.S) 903 | LOCAL_SRCS = $(LOCAL_C_SRCS) $(LOCAL_CPP_SRCS) \ 904 | $(LOCAL_CC_SRCS) $(LOCAL_PDE_SRCS) \ 905 | $(LOCAL_INO_SRCS) $(LOCAL_AS_SRCS) 906 | LOCAL_OBJ_FILES = $(LOCAL_C_SRCS:.c=.c.o) $(LOCAL_CPP_SRCS:.cpp=.cpp.o) \ 907 | $(LOCAL_CC_SRCS:.cc=.cc.o) $(LOCAL_PDE_SRCS:.pde=.pde.o) \ 908 | $(LOCAL_INO_SRCS:.ino=.ino.o) $(LOCAL_AS_SRCS:.S=.S.o) 909 | LOCAL_OBJS = $(patsubst %,$(OBJDIR)/%,$(LOCAL_OBJ_FILES)) 910 | 911 | ifeq ($(words $(LOCAL_SRCS)), 0) 912 | $(error At least one source file (*.ino, *.pde, *.cpp, *c, *cc, *.S) is needed) 913 | endif 914 | 915 | # CHK_SOURCES is used by flymake 916 | # flymake creates a tmp file in the same directory as the file under edition 917 | # we must skip the verification in this particular case 918 | ifeq ($(strip $(CHK_SOURCES)),) 919 | ifeq ($(strip $(NO_CORE)),) 920 | 921 | # Ideally, this should just check if there are more than one file 922 | ifneq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 1) 923 | ifeq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 0) 924 | $(call show_config_info,No .pde or .ino files found. If you are compiling .c or .cpp files then you need to explicitly include Arduino header files) 925 | else 926 | #TODO: Support more than one file. https://github.com/sudar/Arduino-Makefile/issues/49 927 | $(error Need exactly one .pde or .ino file. This makefile doesn\'t support multiple .ino/.pde files yet) 928 | endif 929 | endif 930 | 931 | endif 932 | endif 933 | 934 | # core sources 935 | ifeq ($(strip $(NO_CORE)),) 936 | ifdef ARDUINO_CORE_PATH 937 | CORE_C_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.c) 938 | CORE_C_SRCS += $(wildcard $(ARDUINO_CORE_PATH)/$(TOOL_PREFIX)-libc/*.c) 939 | CORE_CPP_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.cpp) 940 | CORE_AS_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.S) 941 | 942 | # ArduinoCore-API 943 | CORE_C_SRCS += $(wildcard $(ARDUINO_CORE_PATH)/api/*.c) 944 | CORE_CPP_SRCS += $(wildcard $(ARDUINO_CORE_PATH)/api/*.cpp) 945 | 946 | # USB Core if samd or sam 947 | ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam) 948 | CORE_C_SRCS += $(wildcard $(ARDUINO_CORE_PATH)/avr/*.c) # avr core emulation files 949 | CORE_C_SRCS += $(wildcard $(ARDUINO_CORE_PATH)/USB/*.c) 950 | CORE_CPP_SRCS += $(wildcard $(ARDUINO_CORE_PATH)/USB/*.cpp) 951 | endif 952 | 953 | ifneq ($(strip $(NO_CORE_MAIN_CPP)),) 954 | CORE_CPP_SRCS := $(filter-out %main.cpp, $(CORE_CPP_SRCS)) 955 | $(call show_config_info,NO_CORE_MAIN_CPP set so core library will not include main.cpp,[MANUAL]) 956 | endif 957 | 958 | # Add core files for sam devices in CORE_OJBS filtering specific paths 959 | ifdef SAM_CORE_PATH 960 | SAM_CORE_OBJ_FILES = $(SAM_CORE_C_SRCS:.c=.c.o) $(SAM_CORE_CPP_SRCS:.cpp=.cpp.o) $(SAM_CORE_AS_SRCS:.S=.S.o) 961 | # variant core files 962 | CORE_OBJS += $(patsubst $(SAM_CORE_PATH)/%, \ 963 | $(OBJDIR)/core/%, $(filter $(SAM_CORE_PATH)/%, $(SAM_CORE_OBJ_FILES))) 964 | # libsam on Due 965 | ifdef SAM_LIBSAM_PATH 966 | CORE_OBJS += $(patsubst $(SAM_LIBSAM_PATH)/source/%, \ 967 | $(OBJDIR)/core/%, $(filter $(SAM_LIBSAM_PATH)/source/%, $(SAM_CORE_OBJ_FILES))) 968 | endif 969 | # chip sources on Due 970 | ifdef SAM_SYSTEM_PATH 971 | CORE_OBJS += $(patsubst $(SAM_SYSTEM_PATH)/source/%, \ 972 | $(OBJDIR)/core/%, $(filter $(SAM_SYSTEM_PATH)/source/%, $(SAM_CORE_OBJ_FILES))) 973 | endif 974 | endif 975 | 976 | CORE_OBJ_FILES = $(CORE_C_SRCS:.c=.c.o) $(CORE_CPP_SRCS:.cpp=.cpp.o) $(CORE_AS_SRCS:.S=.S.o) 977 | CORE_OBJS += $(patsubst $(ARDUINO_CORE_PATH)/%, \ 978 | $(OBJDIR)/core/%,$(CORE_OBJ_FILES)) 979 | endif 980 | else 981 | $(call show_config_info,NO_CORE set so core library will not be built,[MANUAL]) 982 | endif 983 | 984 | 985 | ######################################################################## 986 | # Determine ARDUINO_LIBS automatically 987 | 988 | ifndef ARDUINO_LIBS 989 | # automatically determine included libraries 990 | ARDUINO_LIBS += $(filter $(notdir $(wildcard $(ARDUINO_DIR)/libraries/*)), \ 991 | $(shell sed -ne 's/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p' $(LOCAL_SRCS))) 992 | ARDUINO_LIBS += $(filter $(notdir $(wildcard $(ARDUINO_SKETCHBOOK)/libraries/*)), \ 993 | $(shell sed -ne 's/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p' $(LOCAL_SRCS))) 994 | ARDUINO_LIBS += $(filter $(notdir $(wildcard $(USER_LIB_PATH)/*)), \ 995 | $(shell sed -ne 's/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p' $(LOCAL_SRCS))) 996 | ARDUINO_LIBS += $(filter $(notdir $(wildcard $(ARDUINO_PLATFORM_LIB_PATH)/*)), \ 997 | $(shell sed -ne 's/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p' $(LOCAL_SRCS))) 998 | endif 999 | 1000 | ######################################################################## 1001 | # Serial monitor (just a screen wrapper) 1002 | 1003 | # Quite how to construct the monitor command seems intimately tied 1004 | # to the command we're using (here screen). So, read the screen docs 1005 | # for more information (search for 'character special device'). 1006 | 1007 | ifeq ($(strip $(NO_CORE)),) 1008 | ifndef MONITOR_BAUDRATE 1009 | ifeq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 1) 1010 | SPEED = $(shell egrep -h 'Serial.begin *\([0-9]+\)' $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS) | sed -e 's/[^0-9]//g'| head -n1) 1011 | MONITOR_BAUDRATE = $(findstring $(SPEED),300 1200 2400 4800 9600 14400 19200 28800 38400 57600 115200) 1012 | endif 1013 | 1014 | ifeq ($(MONITOR_BAUDRATE),) 1015 | MONITOR_BAUDRATE = 9600 1016 | $(call show_config_variable,MONITOR_BAUDRATE,[ASSUMED]) 1017 | else 1018 | $(call show_config_variable,MONITOR_BAUDRATE,[DETECTED], (in sketch)) 1019 | endif 1020 | else 1021 | $(call show_config_variable,MONITOR_BAUDRATE,[USER]) 1022 | endif 1023 | 1024 | ifndef MONITOR_CMD 1025 | MONITOR_CMD = screen 1026 | endif 1027 | endif 1028 | 1029 | ######################################################################## 1030 | # Include Arduino Header file 1031 | 1032 | ifndef ARDUINO_HEADER 1033 | # We should check for Arduino version, not just the file extension 1034 | # because, a .pde file can be used in Arduino 1.0 as well 1035 | ifeq ($(shell expr $(ARDUINO_VERSION) '<' 100), 1) 1036 | ARDUINO_HEADER=WProgram.h 1037 | else 1038 | ARDUINO_HEADER=Arduino.h 1039 | endif 1040 | endif 1041 | 1042 | ######################################################################## 1043 | # Rules for making stuff 1044 | 1045 | # The name of the main targets 1046 | TARGET_HEX = $(OBJDIR)/$(TARGET).hex 1047 | TARGET_ELF = $(OBJDIR)/$(TARGET).elf 1048 | TARGET_EEP = $(OBJDIR)/$(TARGET).eep 1049 | TARGET_BIN = $(OBJDIR)/$(TARGET).bin 1050 | CORE_LIB = $(OBJDIR)/libcore.a 1051 | 1052 | # Names of executables 1053 | # In the rare case of wanting to override a path and/or excecutable 1054 | # name, the OVERRIDE_EXECUTABLES variable must be defned and _all_ 1055 | # the excecutables (CC, CXX, AS, OBJCOPY, OBJDUMP AR, SIZE and NM) 1056 | # _must_ be defined in the calling makefile. 1057 | # We can't use "?=" assignment because these are already implicitly 1058 | # defined by Make (e.g. $(CC) == cc). 1059 | ifndef OVERRIDE_EXECUTABLES 1060 | CC = $(TOOLS_PATH)/$(CC_NAME) 1061 | CXX = $(TOOLS_PATH)/$(CXX_NAME) 1062 | AS = $(TOOLS_PATH)/$(AS_NAME) 1063 | OBJCOPY = $(TOOLS_PATH)/$(OBJCOPY_NAME) 1064 | OBJDUMP = $(TOOLS_PATH)/$(OBJDUMP_NAME) 1065 | AR = $(TOOLS_PATH)/$(AR_NAME) 1066 | SIZE = $(TOOLS_PATH)/$(SIZE_NAME) 1067 | NM = $(TOOLS_PATH)/$(NM_NAME) 1068 | endif 1069 | 1070 | REMOVE = rm -rf 1071 | MV = mv -f 1072 | CAT = cat 1073 | ECHO = printf 1074 | MKDIR = mkdir -p 1075 | 1076 | # recursive wildcard function, call with params: 1077 | # - start directory (finished with /) or empty string for current dir 1078 | # - glob pattern 1079 | # (taken from http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html) 1080 | rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) 1081 | 1082 | # functions used to determine various properties of library 1083 | # called with library path. Needed because of differences between library 1084 | # layouts in arduino 1.0.x and 1.5.x. 1085 | # Assuming new 1.5.x layout when there is "src" subdirectory in main directory 1086 | # and library.properties file 1087 | 1088 | # Gets include flags for library 1089 | get_library_includes = $(if $(and $(wildcard $(1)/src), $(wildcard $(1)/library.properties)), \ 1090 | -I$(1)/src, \ 1091 | $(addprefix -I,$(1) $(wildcard $(1)/utility))) 1092 | 1093 | # Gets all sources with given extension (param2) for library (path = param1) 1094 | # for old (1.0.x) layout looks in . and "utility" directories 1095 | # for new (1.5.x) layout looks in src and recursively its subdirectories 1096 | get_library_files = $(if $(and $(wildcard $(1)/src), $(wildcard $(1)/library.properties)), \ 1097 | $(call rwildcard,$(1)/src/,*.$(2)), \ 1098 | $(wildcard $(1)/*.$(2) $(1)/utility/*.$(2))) 1099 | 1100 | # General arguments 1101 | USER_LIBS := $(sort $(wildcard $(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS)))) 1102 | USER_LIB_NAMES := $(patsubst $(USER_LIB_PATH)/%,%,$(USER_LIBS)) 1103 | 1104 | # Let user libraries override system ones. 1105 | SYS_LIBS := $(sort $(wildcard $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(filter-out $(USER_LIB_NAMES),$(ARDUINO_LIBS))))) 1106 | SYS_LIB_NAMES := $(patsubst $(ARDUINO_LIB_PATH)/%,%,$(SYS_LIBS)) 1107 | 1108 | ifdef ARDUINO_PLATFORM_LIB_PATH 1109 | PLATFORM_LIBS := $(sort $(wildcard $(patsubst %,$(ARDUINO_PLATFORM_LIB_PATH)/%,$(filter-out $(USER_LIB_NAMES),$(ARDUINO_LIBS))))) 1110 | PLATFORM_LIB_NAMES := $(patsubst $(ARDUINO_PLATFORM_LIB_PATH)/%,%,$(PLATFORM_LIBS)) 1111 | endif 1112 | 1113 | 1114 | # Error here if any are missing. 1115 | LIBS_NOT_FOUND = $(filter-out $(USER_LIB_NAMES) $(SYS_LIB_NAMES) $(PLATFORM_LIB_NAMES),$(ARDUINO_LIBS)) 1116 | ifneq (,$(strip $(LIBS_NOT_FOUND))) 1117 | ifdef ARDUINO_PLATFORM_LIB_PATH 1118 | $(error The following libraries specified in ARDUINO_LIBS could not be found (searched USER_LIB_PATH, ARDUINO_LIB_PATH and ARDUINO_PLATFORM_LIB_PATH): $(LIBS_NOT_FOUND)) 1119 | else 1120 | $(error The following libraries specified in ARDUINO_LIBS could not be found (searched USER_LIB_PATH and ARDUINO_LIB_PATH): $(LIBS_NOT_FOUND)) 1121 | endif 1122 | endif 1123 | 1124 | SYS_INCLUDES := $(foreach lib, $(SYS_LIBS), $(call get_library_includes,$(lib))) 1125 | USER_INCLUDES := $(foreach lib, $(USER_LIBS), $(call get_library_includes,$(lib))) 1126 | LIB_C_SRCS := $(foreach lib, $(SYS_LIBS), $(call get_library_files,$(lib),c)) 1127 | LIB_CPP_SRCS := $(foreach lib, $(SYS_LIBS), $(call get_library_files,$(lib),cpp)) 1128 | LIB_AS_SRCS := $(foreach lib, $(SYS_LIBS), $(call get_library_files,$(lib),S)) 1129 | USER_LIB_CPP_SRCS := $(foreach lib, $(USER_LIBS), $(call get_library_files,$(lib),cpp)) 1130 | USER_LIB_C_SRCS := $(foreach lib, $(USER_LIBS), $(call get_library_files,$(lib),c)) 1131 | USER_LIB_AS_SRCS := $(foreach lib, $(USER_LIBS), $(call get_library_files,$(lib),S)) 1132 | LIB_OBJS = $(patsubst $(ARDUINO_LIB_PATH)/%.c,$(OBJDIR)/libs/%.c.o,$(LIB_C_SRCS)) \ 1133 | $(patsubst $(ARDUINO_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.cpp.o,$(LIB_CPP_SRCS)) \ 1134 | $(patsubst $(ARDUINO_LIB_PATH)/%.S,$(OBJDIR)/libs/%.S.o,$(LIB_AS_SRCS)) 1135 | USER_LIB_OBJS = $(patsubst $(USER_LIB_PATH)/%.cpp,$(OBJDIR)/userlibs/%.cpp.o,$(USER_LIB_CPP_SRCS)) \ 1136 | $(patsubst $(USER_LIB_PATH)/%.c,$(OBJDIR)/userlibs/%.c.o,$(USER_LIB_C_SRCS)) \ 1137 | $(patsubst $(USER_LIB_PATH)/%.S,$(OBJDIR)/userlibs/%.S.o,$(USER_LIB_AS_SRCS)) 1138 | 1139 | ifdef ARDUINO_PLATFORM_LIB_PATH 1140 | PLATFORM_INCLUDES := $(foreach lib, $(PLATFORM_LIBS), $(call get_library_includes,$(lib))) 1141 | PLATFORM_LIB_CPP_SRCS := $(foreach lib, $(PLATFORM_LIBS), $(call get_library_files,$(lib),cpp)) 1142 | PLATFORM_LIB_C_SRCS := $(foreach lib, $(PLATFORM_LIBS), $(call get_library_files,$(lib),c)) 1143 | PLATFORM_LIB_AS_SRCS := $(foreach lib, $(PLATFORM_LIBS), $(call get_library_files,$(lib),S)) 1144 | PLATFORM_LIB_OBJS := $(patsubst $(ARDUINO_PLATFORM_LIB_PATH)/%.cpp,$(OBJDIR)/platformlibs/%.cpp.o,$(PLATFORM_LIB_CPP_SRCS)) \ 1145 | $(patsubst $(ARDUINO_PLATFORM_LIB_PATH)/%.c,$(OBJDIR)/platformlibs/%.c.o,$(PLATFORM_LIB_C_SRCS)) \ 1146 | $(patsubst $(ARDUINO_PLATFORM_LIB_PATH)/%.S,$(OBJDIR)/platformlibs/%.S.o,$(PLATFORM_LIB_AS_SRCS)) 1147 | 1148 | endif 1149 | 1150 | # Dependency files 1151 | DEPS = $(LOCAL_OBJS:.o=.d) $(LIB_OBJS:.o=.d) $(PLATFORM_OBJS:.o=.d) $(USER_LIB_OBJS:.o=.d) $(CORE_OBJS:.o=.d) 1152 | 1153 | # Optimization level for the compiler. 1154 | # You can get the list of options at http://www.nongnu.org/avr-libc/user-manual/using_tools.html#gcc_optO 1155 | # Also read http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_optflags 1156 | ifndef OPTIMIZATION_LEVEL 1157 | OPTIMIZATION_LEVEL=s 1158 | $(call show_config_variable,OPTIMIZATION_LEVEL,[DEFAULT]) 1159 | else 1160 | $(call show_config_variable,OPTIMIZATION_LEVEL,[USER]) 1161 | endif 1162 | 1163 | ifndef DEBUG_FLAGS 1164 | DEBUG_FLAGS = -O0 -g 1165 | endif 1166 | 1167 | # SoftwareSerial requires -Os (some delays are tuned for this optimization level) 1168 | %SoftwareSerial.cpp.o : OPTIMIZATION_FLAGS = -Os 1169 | %Uart.cpp.o : OPTIMIZATION_FLAGS = -Os 1170 | 1171 | ifndef MCU_FLAG_NAME 1172 | MCU_FLAG_NAME = mmcu 1173 | $(call show_config_variable,MCU_FLAG_NAME,[DEFAULT]) 1174 | else 1175 | $(call show_config_variable,MCU_FLAG_NAME,[USER]) 1176 | endif 1177 | 1178 | # Using += instead of =, so that CPPFLAGS can be set per sketch level 1179 | CPPFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) -DARDUINO_$(BOARD) $(ARDUINO_ARCH_FLAG) \ 1180 | "-DARDUINO_BOARD=\"$(BOARD)\"" "-DARDUINO_VARIANT=\"$(VARIANT)\"" \ 1181 | -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_CORE_PATH)/api -I$(ARDUINO_VAR_PATH)/$(VARIANT) \ 1182 | $(SYS_INCLUDES) $(PLATFORM_INCLUDES) $(USER_INCLUDES) -Wall -ffunction-sections \ 1183 | -fdata-sections 1184 | 1185 | # PROG_TYPES_COMPAT is enabled by default for compatibility with the Arduino IDE. 1186 | # By placing it before the user-provided CPPFLAGS rather than after, we allow the 1187 | # the user to disable it if they like, by adding the negation of the flag 1188 | # (-U__PROG_TYPES_COMPAT__) to the user-provided CPPFLAGS. 1189 | CPPFLAGS := -D__PROG_TYPES_COMPAT__ $(CPPFLAGS) 1190 | 1191 | ifdef DEBUG 1192 | OPTIMIZATION_FLAGS= $(DEBUG_FLAGS) 1193 | else 1194 | OPTIMIZATION_FLAGS = -O$(OPTIMIZATION_LEVEL) 1195 | endif 1196 | 1197 | CPPFLAGS += $(OPTIMIZATION_FLAGS) 1198 | 1199 | # USB IDs for the Caterina devices like leonardo or micro 1200 | ifneq ($(CATERINA),) 1201 | CPPFLAGS += -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) 1202 | ifdef USB_PRODUCT 1203 | CPPFLAGS += -DUSB_PRODUCT='$(USB_PRODUCT)' -DUSB_MANUFACTURER='$(USB_MANUFACTURER)' 1204 | endif 1205 | endif 1206 | 1207 | # $(TOOL_PREFIX)-gcc version that we can do maths on 1208 | CC_VERNUM = $(shell $(CC) -dumpversion | sed 's/\.//g') 1209 | 1210 | # moved from above so we can find version-dependant ar 1211 | ifeq ($(TOOL_PREFIX), avr) 1212 | ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1) 1213 | AR_NAME := $(TOOL_PREFIX)-gcc-ar 1214 | else 1215 | AR_NAME := $(TOOL_PREFIX)-ar 1216 | endif 1217 | endif 1218 | 1219 | ifndef CFLAGS_STD 1220 | ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1) 1221 | CFLAGS_STD = -std=gnu11 1222 | else 1223 | CFLAGS_STD = 1224 | endif 1225 | $(call show_config_variable,CFLAGS_STD,[DEFAULT]) 1226 | else 1227 | $(call show_config_variable,CFLAGS_STD,[USER]) 1228 | endif 1229 | 1230 | ifndef CXXFLAGS_STD 1231 | ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1) 1232 | CXXFLAGS_STD = -std=gnu++11 1233 | else 1234 | CXXFLAGS_STD = 1235 | endif 1236 | $(call show_config_variable,CXXFLAGS_STD,[DEFAULT]) 1237 | else 1238 | $(call show_config_variable,CXXFLAGS_STD,[USER]) 1239 | endif 1240 | 1241 | CFLAGS += $(CFLAGS_STD) 1242 | CXXFLAGS += -fpermissive -fno-exceptions $(CXXFLAGS_STD) 1243 | ASFLAGS += -x assembler-with-cpp 1244 | DIAGNOSTICS_COLOR_WHEN ?= always 1245 | 1246 | # Flags for AVR 1247 | ifeq ($(findstring avr, $(strip $(CC_NAME))), avr) 1248 | ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1) 1249 | ASFLAGS += -flto 1250 | CXXFLAGS += -fno-threadsafe-statics -flto -fno-devirtualize -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN) 1251 | CFLAGS += -flto -fno-fat-lto-objects -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN) 1252 | LDFLAGS += -flto -fuse-linker-plugin 1253 | endif 1254 | # Flags for ARM (most set in Sam.mk) 1255 | else 1256 | ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1) 1257 | CXXFLAGS += -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN) 1258 | CFLAGS += -fdiagnostics-color=$(DIAGNOSTICS_COLOR_WHEN) 1259 | endif 1260 | endif 1261 | 1262 | LDFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -Wl,--gc-sections -O$(OPTIMIZATION_LEVEL) 1263 | SIZEFLAGS ?= --mcu=$(MCU) -C 1264 | 1265 | # for backwards compatibility, grab ARDUINO_PORT if the user has it set 1266 | # instead of MONITOR_PORT 1267 | MONITOR_PORT ?= $(ARDUINO_PORT) 1268 | 1269 | ifneq ($(strip $(MONITOR_PORT)),) 1270 | ifeq ($(CURRENT_OS), WINDOWS) 1271 | # Expect MONITOR_PORT to be '1' or 'com1' for COM1 in Windows. Split it up 1272 | # into the two styles required: /dev/ttyS* for ard-reset-arduino and com* 1273 | # for avrdude. This also could work with /dev/com* device names and be more 1274 | # consistent, but the /dev/com* is not recommended by Cygwin and doesn't 1275 | # always show up. 1276 | COM_PORT_ID = $(subst com,,$(MONITOR_PORT)) 1277 | COM_STYLE_MONITOR_PORT = com$(COM_PORT_ID) 1278 | DEVICE_PATH = /dev/ttyS$(shell awk 'BEGIN{ print $(COM_PORT_ID) - 1 }') 1279 | else 1280 | # set DEVICE_PATH based on user-defined MONITOR_PORT or ARDUINO_PORT 1281 | DEVICE_PATH = $(MONITOR_PORT) 1282 | endif 1283 | $(call show_config_variable,DEVICE_PATH,[COMPUTED],(from MONITOR_PORT)) 1284 | else 1285 | # If no port is specified, try to guess it from wildcards. 1286 | # Will only work if the Arduino is the only/first device matched. 1287 | DEVICE_PATH = $(firstword $(wildcard \ 1288 | /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbserial* /dev/tty.usbmodem* /dev/tty.wchusbserial*)) 1289 | $(call show_config_variable,DEVICE_PATH,[AUTODETECTED]) 1290 | endif 1291 | 1292 | ifndef FORCE_MONITOR_PORT 1293 | $(call show_config_variable,FORCE_MONITOR_PORT,[DEFAULT]) 1294 | else 1295 | $(call show_config_variable,FORCE_MONITOR_PORT,[USER]) 1296 | endif 1297 | 1298 | ifdef FORCE_MONITOR_PORT 1299 | # Skips the DEVICE_PATH existance check. 1300 | get_monitor_port = $(DEVICE_PATH) 1301 | else 1302 | # Returns the Arduino port (first wildcard expansion) if it exists, otherwise it errors. 1303 | ifeq ($(CURRENT_OS), WINDOWS) 1304 | get_monitor_port = $(COM_STYLE_MONITOR_PORT) 1305 | else 1306 | get_monitor_port = $(if $(wildcard $(DEVICE_PATH)),$(firstword $(wildcard $(DEVICE_PATH))),$(error Arduino port $(DEVICE_PATH) not found!)) 1307 | endif 1308 | endif 1309 | 1310 | # Returns the ISP port (first wildcard expansion) if it exists, otherwise it errors. 1311 | get_isp_port = $(if $(wildcard $(ISP_PORT)),$(firstword $(wildcard $(ISP_PORT))),$(if $(findstring Xusb,X$(ISP_PORT)),$(ISP_PORT),$(error ISP port $(ISP_PORT) not found!))) 1312 | 1313 | # Command for avr_size: do $(call avr_size,elffile,hexfile) 1314 | ifneq (,$(findstring AVR,$(shell $(SIZE) --help))) 1315 | # We have a patched version of binutils that mentions AVR - pass the MCU 1316 | # and the elf to get nice output. 1317 | avr_size = $(SIZE) $(SIZEFLAGS) --format=avr $(1) 1318 | $(call show_config_info,Size utility: AVR-aware for enhanced output,[AUTODETECTED]) 1319 | else 1320 | ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam) 1321 | avr_size = $(SIZE) $(SIZEFLAGS) $(1) 1322 | $(call show_config_info,Size utility: ARM,[AUTODETECTED]) 1323 | else 1324 | # We have a plain-old binutils version - just give it the hex. 1325 | avr_size = $(SIZE) $(2) 1326 | $(call show_config_info,Size utility: Basic (not AVR-aware),[AUTODETECTED]) 1327 | endif 1328 | endif 1329 | 1330 | ifneq (,$(strip $(ARDUINO_LIBS))) 1331 | $(call arduino_output,-) 1332 | $(call show_config_info,ARDUINO_LIBS =) 1333 | endif 1334 | 1335 | ifneq (,$(strip $(USER_LIB_NAMES))) 1336 | $(foreach lib,$(USER_LIB_NAMES),$(call show_config_info, $(lib),[USER])) 1337 | endif 1338 | 1339 | ifneq (,$(strip $(SYS_LIB_NAMES))) 1340 | $(foreach lib,$(SYS_LIB_NAMES),$(call show_config_info, $(lib),[SYSTEM])) 1341 | endif 1342 | 1343 | ifneq (,$(strip $(PLATFORM_LIB_NAMES))) 1344 | $(foreach lib,$(PLATFORM_LIB_NAMES),$(call show_config_info, $(lib),[PLATFORM])) 1345 | endif 1346 | 1347 | # either calculate parent dir from arduino dir, or user-defined path 1348 | ifndef BOOTLOADER_PARENT 1349 | BOOTLOADER_PARENT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/bootloaders 1350 | $(call show_config_variable,BOOTLOADER_PARENT,[COMPUTED],(from ARDUINO_DIR)) 1351 | else 1352 | $(call show_config_variable,BOOTLOADER_PARENT,[USER]) 1353 | endif 1354 | 1355 | ######################################################################## 1356 | # Tools version info 1357 | ARDMK_VERSION = 1.6 1358 | $(call show_config_variable,ARDMK_VERSION,[COMPUTED]) 1359 | 1360 | CC_VERSION := $(shell $(CC) -dumpversion) 1361 | $(call show_config_variable,CC_VERSION,[COMPUTED],($(CC_NAME))) 1362 | 1363 | # end of config output 1364 | $(call show_separator) 1365 | 1366 | # Implicit rules for building everything (needed to get everything in 1367 | # the right directory) 1368 | # 1369 | # Rather than mess around with VPATH there are quasi-duplicate rules 1370 | # here for building e.g. a system C++ file and a local C++ 1371 | # file. Besides making things simpler now, this would also make it 1372 | # easy to change the build options in future 1373 | 1374 | # library sources 1375 | $(OBJDIR)/libs/%.c.o: $(ARDUINO_LIB_PATH)/%.c 1376 | @$(MKDIR) $(dir $@) 1377 | $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ 1378 | 1379 | $(OBJDIR)/libs/%.cpp.o: $(ARDUINO_LIB_PATH)/%.cpp 1380 | @$(MKDIR) $(dir $@) 1381 | $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ 1382 | 1383 | $(OBJDIR)/libs/%.S.o: $(ARDUINO_LIB_PATH)/%.S 1384 | @$(MKDIR) $(dir $@) 1385 | $(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ 1386 | 1387 | $(OBJDIR)/platformlibs/%.c.o: $(ARDUINO_PLATFORM_LIB_PATH)/%.c 1388 | @$(MKDIR) $(dir $@) 1389 | $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ 1390 | 1391 | $(OBJDIR)/platformlibs/%.cpp.o: $(ARDUINO_PLATFORM_LIB_PATH)/%.cpp 1392 | @$(MKDIR) $(dir $@) 1393 | $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ 1394 | 1395 | $(OBJDIR)/platformlibs/%.S.o: $(ARDUINO_PLATFORM_LIB_PATH)/%.S 1396 | @$(MKDIR) $(dir $@) 1397 | $(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ 1398 | 1399 | $(OBJDIR)/userlibs/%.cpp.o: $(USER_LIB_PATH)/%.cpp 1400 | @$(MKDIR) $(dir $@) 1401 | $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ 1402 | 1403 | $(OBJDIR)/userlibs/%.c.o: $(USER_LIB_PATH)/%.c 1404 | @$(MKDIR) $(dir $@) 1405 | $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ 1406 | 1407 | $(OBJDIR)/userlibs/%.S.o: $(USER_LIB_PATH)/%.S 1408 | @$(MKDIR) $(dir $@) 1409 | $(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ 1410 | 1411 | ifdef COMMON_DEPS 1412 | COMMON_DEPS := $(COMMON_DEPS) $(MAKEFILE_LIST) 1413 | else 1414 | COMMON_DEPS := $(MAKEFILE_LIST) 1415 | endif 1416 | 1417 | # normal local sources 1418 | $(OBJDIR)/%.c.o: %.c $(COMMON_DEPS) | $(OBJDIR) 1419 | @$(MKDIR) $(dir $@) 1420 | $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ 1421 | 1422 | $(OBJDIR)/%.cc.o: %.cc $(COMMON_DEPS) | $(OBJDIR) 1423 | @$(MKDIR) $(dir $@) 1424 | $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ 1425 | 1426 | $(OBJDIR)/%.cpp.o: %.cpp $(COMMON_DEPS) | $(OBJDIR) 1427 | @$(MKDIR) $(dir $@) 1428 | $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ 1429 | 1430 | $(OBJDIR)/%.S.o: %.S $(COMMON_DEPS) | $(OBJDIR) 1431 | @$(MKDIR) $(dir $@) 1432 | $(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ 1433 | 1434 | $(OBJDIR)/%.s.o: %.s $(COMMON_DEPS) | $(OBJDIR) 1435 | @$(MKDIR) $(dir $@) 1436 | $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ 1437 | 1438 | # the pde -> o file 1439 | $(OBJDIR)/%.pde.o: %.pde $(COMMON_DEPS) | $(OBJDIR) 1440 | @$(MKDIR) $(dir $@) 1441 | $(CXX) -x c++ -include $(ARDUINO_HEADER) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ 1442 | 1443 | # the ino -> o file 1444 | $(OBJDIR)/%.ino.o: %.ino $(COMMON_DEPS) | $(OBJDIR) 1445 | @$(MKDIR) $(dir $@) 1446 | $(CXX) -x c++ -include $(ARDUINO_HEADER) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ 1447 | 1448 | # generated assembly 1449 | $(OBJDIR)/%.s: %.pde $(COMMON_DEPS) | $(OBJDIR) 1450 | @$(MKDIR) $(dir $@) 1451 | $(CXX) -x c++ -include $(ARDUINO_HEADER) -MMD -S -fverbose-asm $(CPPFLAGS) $(CXXFLAGS) $< -o $@ 1452 | 1453 | $(OBJDIR)/%.s: %.ino $(COMMON_DEPS) | $(OBJDIR) 1454 | @$(MKDIR) $(dir $@) 1455 | $(CXX) -x c++ -include $(ARDUINO_HEADER) -MMD -S -fverbose-asm $(CPPFLAGS) $(CXXFLAGS) $< -o $@ 1456 | 1457 | $(OBJDIR)/%.s: %.cpp $(COMMON_DEPS) | $(OBJDIR) 1458 | @$(MKDIR) $(dir $@) 1459 | $(CXX) -x c++ -MMD -S -fverbose-asm $(CPPFLAGS) $(CXXFLAGS) $< -o $@ 1460 | 1461 | # core files 1462 | $(OBJDIR)/core/%.c.o: $(ARDUINO_CORE_PATH)/%.c $(COMMON_DEPS) | $(OBJDIR) 1463 | @$(MKDIR) $(dir $@) 1464 | $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ 1465 | 1466 | $(OBJDIR)/core/%.cpp.o: $(ARDUINO_CORE_PATH)/%.cpp $(COMMON_DEPS) | $(OBJDIR) 1467 | @$(MKDIR) $(dir $@) 1468 | $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ 1469 | 1470 | $(OBJDIR)/core/%.S.o: $(ARDUINO_CORE_PATH)/%.S $(COMMON_DEPS) | $(OBJDIR) 1471 | @$(MKDIR) $(dir $@) 1472 | $(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ 1473 | 1474 | # sam core files 1475 | $(OBJDIR)/core/%.c.o: $(SAM_CORE_PATH)/%.c $(COMMON_DEPS) | $(OBJDIR) 1476 | @$(MKDIR) $(dir $@) 1477 | $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ 1478 | 1479 | $(OBJDIR)/core/%.cpp.o: $(SAM_CORE_PATH)/%.cpp $(COMMON_DEPS) | $(OBJDIR) 1480 | @$(MKDIR) $(dir $@) 1481 | $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ 1482 | 1483 | $(OBJDIR)/core/%.S.o: $(SAM_CORE_PATH)/%.S $(COMMON_DEPS) | $(OBJDIR) 1484 | @$(MKDIR) $(dir $@) 1485 | $(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ 1486 | 1487 | # due specific sources from sam core as doesn't core doesn't have SystemInit startup file 1488 | $(OBJDIR)/core/%.c.o: $(SAM_LIBSAM_PATH)/source/%.c $(COMMON_DEPS) | $(OBJDIR) 1489 | @$(MKDIR) $(dir $@) 1490 | $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ 1491 | 1492 | $(OBJDIR)/core/%.c.o: $(SAM_SYSTEM_PATH)/source/%.c $(COMMON_DEPS) | $(OBJDIR) 1493 | @$(MKDIR) $(dir $@) 1494 | $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ 1495 | 1496 | # various object conversions 1497 | $(OBJDIR)/%.bin: $(OBJDIR)/%.elf $(COMMON_DEPS) 1498 | @$(MKDIR) $(dir $@) 1499 | -$(OBJCOPY) -O binary $< $@ 1500 | 1501 | $(OBJDIR)/%.hex: $(OBJDIR)/%.elf $(COMMON_DEPS) 1502 | @$(MKDIR) $(dir $@) 1503 | $(OBJCOPY) -O ihex -R .eeprom $< $@ 1504 | @$(ECHO) '\n' 1505 | $(call avr_size,$<,$@) 1506 | ifneq ($(strip $(HEX_MAXIMUM_SIZE)),) 1507 | @if [ `$(SIZE) $@ | awk 'FNR == 2 {print $$2}'` -le $(HEX_MAXIMUM_SIZE) ]; then touch $@.sizeok; fi 1508 | else 1509 | @$(ECHO) "Maximum flash memory of $(BOARD_TAG) is not specified. Make sure the size of $@ is less than $(BOARD_TAG)\'s flash memory" 1510 | @touch $@.sizeok 1511 | endif 1512 | 1513 | $(OBJDIR)/%.eep: $(OBJDIR)/%.elf $(COMMON_DEPS) 1514 | @$(MKDIR) $(dir $@) 1515 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom='alloc,load' \ 1516 | --no-change-warnings --change-section-lma .eeprom=0 -O ihex $< $@ 1517 | 1518 | $(OBJDIR)/%.lss: $(OBJDIR)/%.elf $(COMMON_DEPS) 1519 | @$(MKDIR) $(dir $@) 1520 | $(OBJDUMP) -h --source --demangle --wide $< > $@ 1521 | 1522 | $(OBJDIR)/%.sym: $(OBJDIR)/%.elf $(COMMON_DEPS) 1523 | @$(MKDIR) $(dir $@) 1524 | $(NM) --size-sort --demangle --reverse-sort --line-numbers $< > $@ 1525 | 1526 | ######################################################################## 1527 | # Ctags 1528 | 1529 | # Assume ctags is on path unless has been specified 1530 | ifndef CTAGS_EXEC 1531 | CTAGS_EXEC = ctags 1532 | endif 1533 | 1534 | # Default to 'tags' unless user has specified a tags file 1535 | ifndef TAGS_FILE 1536 | TAGS_FILE = tags 1537 | endif 1538 | 1539 | # ctags command: append, flags unsort (as will be sorted after) and specify filename 1540 | CTAGS_CMD = $(CTAGS_EXEC) $(CTAGS_OPTS) -auf 1541 | 1542 | ######################################################################## 1543 | # Avrdude 1544 | 1545 | # If avrdude is installed separately, it can find its own config file 1546 | ifndef AVRDUDE 1547 | AVRDUDE = $(TOOLS_PATH)/avrdude 1548 | endif 1549 | 1550 | # Default avrdude options 1551 | # -V Do not verify 1552 | # -q - suppress progress output 1553 | ifndef AVRDUDE_OPTS 1554 | AVRDUDE_OPTS = -q -V 1555 | endif 1556 | 1557 | # Decouple the mcu between the compiler options (-mmcu) and the avrdude options (-p). 1558 | # This is needed to be able to compile for attiny84a but specify the upload mcu as attiny84. 1559 | # We default to picking the -mmcu flag, but you can override this by setting 1560 | # AVRDUDE_MCU in your makefile. 1561 | ifndef AVRDUDE_MCU 1562 | AVRDUDE_MCU = $(MCU) 1563 | endif 1564 | 1565 | AVRDUDE_COM_OPTS = $(AVRDUDE_OPTS) -p $(AVRDUDE_MCU) 1566 | ifdef AVRDUDE_CONF 1567 | AVRDUDE_COM_OPTS += -C $(AVRDUDE_CONF) 1568 | endif 1569 | 1570 | # -D - Disable auto erase for flash memory 1571 | # Note: -D is needed for Mega boards. 1572 | # (See https://github.com/sudar/Arduino-Makefile/issues/114#issuecomment-25011005) 1573 | ifeq ($(AVRDUDE_AUTOERASE_FLASH), yes) 1574 | else 1575 | AVRDUDE_ARD_OPTS = -D 1576 | endif 1577 | AVRDUDE_ARD_OPTS += -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P 1578 | ifeq ($(CURRENT_OS), WINDOWS) 1579 | # get_monitor_port checks to see if the monitor port exists, assuming it is 1580 | # a file. In Windows, avrdude needs the port in the format 'com1' which is 1581 | # not a file, so we have to add the COM-style port directly. 1582 | AVRDUDE_ARD_OPTS += $(COM_STYLE_MONITOR_PORT) 1583 | else 1584 | AVRDUDE_ARD_OPTS += $(call get_monitor_port) 1585 | endif 1586 | 1587 | ifndef ISP_PROG 1588 | ifneq ($(strip $(AVRDUDE_ARD_PROGRAMMER)),) 1589 | ISP_PROG = $(AVRDUDE_ARD_PROGRAMMER) 1590 | else 1591 | ISP_PROG = stk500v1 1592 | endif 1593 | endif 1594 | 1595 | ifndef AVRDUDE_ISP_BAUDRATE 1596 | ifneq ($(strip $(AVRDUDE_ARD_BAUDRATE)),) 1597 | AVRDUDE_ISP_BAUDRATE = $(AVRDUDE_ARD_BAUDRATE) 1598 | else 1599 | AVRDUDE_ISP_BAUDRATE = 19200 1600 | endif 1601 | endif 1602 | 1603 | # Fuse settings copied from Arduino IDE. 1604 | # https://github.com/arduino/Arduino/blob/master/app/src/processing/app/debug/AvrdudeUploader.java#L254 1605 | 1606 | # Pre fuse settings 1607 | ifndef AVRDUDE_ISP_FUSES_PRE 1608 | ifneq ($(strip $(ISP_LOCK_FUSE_PRE)),) 1609 | AVRDUDE_ISP_FUSES_PRE += -U lock:w:$(ISP_LOCK_FUSE_PRE):m 1610 | endif 1611 | 1612 | ifneq ($(strip $(ISP_EXT_FUSE)),) 1613 | AVRDUDE_ISP_FUSES_PRE += -U efuse:w:$(ISP_EXT_FUSE):m 1614 | endif 1615 | 1616 | ifneq ($(strip $(ISP_HIGH_FUSE)),) 1617 | AVRDUDE_ISP_FUSES_PRE += -U hfuse:w:$(ISP_HIGH_FUSE):m 1618 | endif 1619 | 1620 | ifneq ($(strip $(ISP_LOW_FUSE)),) 1621 | AVRDUDE_ISP_FUSES_PRE += -U lfuse:w:$(ISP_LOW_FUSE):m 1622 | endif 1623 | endif 1624 | 1625 | # Bootloader file settings 1626 | ifndef AVRDUDE_ISP_BURN_BOOTLOADER 1627 | ifneq ($(strip $(BOOTLOADER_FILE)),) 1628 | AVRDUDE_ISP_BURN_BOOTLOADER += -U flash:w:$(BOOTLOADER_PARENT)/$(BOOTLOADER_PATH)/$(BOOTLOADER_FILE):i 1629 | endif 1630 | endif 1631 | 1632 | # Post fuse settings 1633 | ifndef AVRDUDE_ISP_FUSES_POST 1634 | ifneq ($(strip $(ISP_LOCK_FUSE_POST)),) 1635 | AVRDUDE_ISP_FUSES_POST += -U lock:w:$(ISP_LOCK_FUSE_POST):m 1636 | endif 1637 | endif 1638 | 1639 | # Note: setting -D to disable flash erase before programming may cause issues 1640 | # with some boards like attiny84a, making the program not "take", 1641 | # so we do not set it by default. 1642 | AVRDUDE_ISP_OPTS = -c $(ISP_PROG) -b $(AVRDUDE_ISP_BAUDRATE) 1643 | 1644 | ifndef ISP_PORT 1645 | ifneq ($(strip $(ISP_PROG)),$(filter $(ISP_PROG), atmelice_isp usbasp usbtiny gpio linuxgpio avrispmkii dragon_isp dragon_dw)) 1646 | # switch for sam devices as bootloader will be on usb serial if using stk500_v2 1647 | ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam) 1648 | AVRDUDE_ISP_OPTS += -P $(call get_monitor_port) 1649 | else 1650 | AVRDUDE_ISP_OPTS += -P $(call get_isp_port) 1651 | endif 1652 | endif 1653 | else 1654 | ifeq ($(CURRENT_OS), WINDOWS) 1655 | AVRDUDE_ISP_OPTS += -P $(ISP_PORT) 1656 | else 1657 | AVRDUDE_ISP_OPTS += -P $(call get_isp_port) 1658 | endif 1659 | endif 1660 | 1661 | ifndef ISP_EEPROM 1662 | ISP_EEPROM = 0 1663 | endif 1664 | 1665 | AVRDUDE_UPLOAD_HEX = -U flash:w:$(TARGET_HEX):i 1666 | AVRDUDE_UPLOAD_EEP = -U eeprom:w:$(TARGET_EEP):i 1667 | AVRDUDE_ISPLOAD_OPTS = $(AVRDUDE_UPLOAD_HEX) 1668 | 1669 | ifneq ($(ISP_EEPROM), 0) 1670 | AVRDUDE_ISPLOAD_OPTS += $(AVRDUDE_UPLOAD_EEP) 1671 | endif 1672 | 1673 | ######################################################################## 1674 | # Explicit targets start here 1675 | 1676 | all: $(TARGET_EEP) $(TARGET_BIN) $(TARGET_HEX) 1677 | 1678 | # Rule to create $(OBJDIR) automatically. All rules with recipes that 1679 | # create a file within it, but do not already depend on a file within it 1680 | # should depend on this rule. They should use a "order-only 1681 | # prerequisite" (e.g., put "| $(OBJDIR)" at the end of the prerequisite 1682 | # list) to prevent remaking the target when any file in the directory 1683 | # changes. 1684 | $(OBJDIR): pre-build 1685 | $(MKDIR) $(OBJDIR) 1686 | 1687 | pre-build: 1688 | $(call runscript_if_exists,$(PRE_BUILD_HOOK)) 1689 | 1690 | # copied from arduino with start-group, end-group 1691 | $(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) 1692 | # sam devices need start and end group, and must be linked using C++ compiler 1693 | ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam) 1694 | $(CXX) $(LINKER_SCRIPTS) -Wl,-Map=$(OBJDIR)/$(TARGET).map -o $@ $(LOCAL_OBJS) $(OTHER_OBJS) $(OTHER_LIBS) $(LDFLAGS) $(CORE_LIB) -Wl,--end-group 1695 | # otherwise traditional 1696 | else 1697 | $(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(OTHER_OBJS) $(OTHER_LIBS) $(CORE_LIB) -lc -lm $(LINKER_SCRIPTS) 1698 | endif 1699 | 1700 | $(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(PLATFORM_LIB_OBJS) $(USER_LIB_OBJS) 1701 | $(AR) rcs $@ $(CORE_OBJS) $(LIB_OBJS) $(PLATFORM_LIB_OBJS) $(USER_LIB_OBJS) 1702 | 1703 | error_on_caterina: 1704 | $(ERROR_ON_CATERINA) 1705 | 1706 | # Use submake so we can guarantee the reset happens 1707 | # before the upload, even with make -j 1708 | upload: $(TARGET_HEX) verify_size 1709 | ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam) 1710 | # do reset toggle at 1200 BAUD to enter bootloader if using avrdude or bossa 1711 | ifeq ($(strip $(UPLOAD_TOOL)), avrdude) 1712 | $(MAKE) reset 1713 | else ifeq ($(findstring bossac, $(strip $(UPLOAD_TOOL))), bossac) 1714 | $(MAKE) reset 1715 | endif 1716 | $(MAKE) do_sam_upload 1717 | else 1718 | $(MAKE) reset 1719 | $(MAKE) do_upload 1720 | endif 1721 | 1722 | raw_upload: $(TARGET_HEX) verify_size 1723 | ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam) 1724 | $(MAKE) do_sam_upload 1725 | else 1726 | $(MAKE) error_on_caterina 1727 | $(MAKE) do_upload 1728 | endif 1729 | 1730 | do_upload: 1731 | $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ 1732 | $(AVRDUDE_UPLOAD_HEX) 1733 | 1734 | do_sam_upload: $(TARGET_BIN) verify_size 1735 | ifeq ($(findstring openocd, $(strip $(UPLOAD_TOOL))), openocd) 1736 | $(OPENOCD) $(OPENOCD_OPTS) -c "telnet_port disabled; program {{$(TARGET_BIN)}} verify reset $(BOOTLOADER_SIZE); shutdown" 1737 | else ifeq ($(findstring bossac, $(strip $(UPLOAD_TOOL))), bossac) 1738 | $(BOSSA) $(BOSSA_OPTS) $(TARGET_BIN) 1739 | else ifeq ($(findstring gdb, $(strip $(UPLOAD_TOOL))), gdb) 1740 | $(GDB) $(GDB_UPLOAD_OPTS) 1741 | else ifeq ($(strip $(UPLOAD_TOOL)), avrdude) 1742 | $(MAKE) ispload 1743 | else 1744 | @$(ECHO) "$(BOOTLOADER_UPLOAD_TOOL) not currently supported!\n\n" 1745 | endif 1746 | 1747 | do_eeprom: $(TARGET_EEP) $(TARGET_HEX) 1748 | $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ 1749 | $(AVRDUDE_UPLOAD_EEP) 1750 | 1751 | eeprom: $(TARGET_HEX) verify_size 1752 | $(MAKE) reset 1753 | $(MAKE) do_eeprom 1754 | 1755 | raw_eeprom: $(TARGET_HEX) verify_size 1756 | $(MAKE) error_on_caterina 1757 | $(MAKE) do_eeprom 1758 | 1759 | reset: 1760 | $(call arduino_output,Resetting Arduino...) 1761 | $(RESET_CMD) 1762 | 1763 | # stty on MacOS likes -F, but on Debian it likes -f redirecting 1764 | # stdin/out appears to work but generates a spurious error on MacOS at 1765 | # least. Perhaps it would be better to just do it in perl ? 1766 | reset_stty: 1767 | for STTYF in 'stty -F' 'stty --file' 'stty -f' 'stty <' ; \ 1768 | do $$STTYF /dev/tty >/dev/null 2>&1 && break ; \ 1769 | done ; \ 1770 | $$STTYF $(call get_monitor_port) hupcl ; \ 1771 | (sleep 0.1 2>/dev/null || sleep 1) ; \ 1772 | $$STTYF $(call get_monitor_port) -hupcl 1773 | 1774 | ispload: $(TARGET_EEP) $(TARGET_HEX) verify_size 1775 | $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e \ 1776 | $(AVRDUDE_ISPLOAD_OPTS) 1777 | 1778 | burn_bootloader: 1779 | ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam) 1780 | ifeq ($(strip $(BOOTLOADER_UPLOAD_TOOL)), openocd) 1781 | $(OPENOCD) $(OPENOCD_OPTS) -c "telnet_port disabled; init; halt; $(BOOTLOADER_UNPROTECT); program {{$(BOOTLOADER_PARENT)/$(BOOTLOADER_FILE)}} verify reset; shutdown" 1782 | else 1783 | @$(ECHO) "$(BOOTLOADER_UPLOAD_TOOL) not currently supported!\n\n" 1784 | endif 1785 | else 1786 | ifneq ($(strip $(AVRDUDE_ISP_FUSES_PRE)),) 1787 | $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e $(AVRDUDE_ISP_FUSES_PRE) 1788 | endif 1789 | ifneq ($(strip $(AVRDUDE_ISP_BURN_BOOTLOADER)),) 1790 | $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) $(AVRDUDE_ISP_BURN_BOOTLOADER) 1791 | endif 1792 | ifneq ($(strip $(AVRDUDE_ISP_FUSES_POST)),) 1793 | $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) $(AVRDUDE_ISP_FUSES_POST) 1794 | endif 1795 | endif 1796 | 1797 | set_fuses: 1798 | ifneq ($(strip $(AVRDUDE_ISP_FUSES_PRE)),) 1799 | $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) $(AVRDUDE_ISP_FUSES_PRE) 1800 | endif 1801 | ifneq ($(strip $(AVRDUDE_ISP_FUSES_POST)),) 1802 | $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) $(AVRDUDE_ISP_FUSES_POST) 1803 | endif 1804 | 1805 | clean:: 1806 | $(REMOVE) $(OBJDIR) 1807 | 1808 | size: $(TARGET_HEX) 1809 | $(call avr_size,$(TARGET_ELF),$(TARGET_HEX)) 1810 | 1811 | show_boards: 1812 | @$(CAT) $(BOARDS_TXT) | grep -E '^[a-zA-Z0-9_\-]+.name' | sort -uf | sed 's/.name=/:/' | column -s: -t 1813 | 1814 | show_submenu: 1815 | @$(CAT) $(BOARDS_TXT) | grep -E '[a-zA-Z0-9_\-]+.menu.(cpu|chip).[a-zA-Z0-9_\-]+=' | sort -uf | sed 's/.menu.\(cpu\|chip\)./:/' | sed 's/=/:/' | column -s: -t 1816 | 1817 | monitor: 1818 | ifeq ($(notdir $(MONITOR_CMD)), putty) 1819 | ifneq ($(strip $(MONITOR_PARAMS)),) 1820 | $(MONITOR_CMD) -serial -sercfg $(MONITOR_BAUDRATE),$(MONITOR_PARAMS) $(call get_monitor_port) 1821 | else 1822 | $(MONITOR_CMD) -serial -sercfg $(MONITOR_BAUDRATE) $(call get_monitor_port) 1823 | endif 1824 | else ifeq ($(notdir $(MONITOR_CMD)), picocom) 1825 | $(MONITOR_CMD) -b $(MONITOR_BAUDRATE) $(MONITOR_PARAMS) $(call get_monitor_port) 1826 | else ifeq ($(notdir $(MONITOR_CMD)), cu) 1827 | $(MONITOR_CMD) -l $(call get_monitor_port) -s $(MONITOR_BAUDRATE) 1828 | else 1829 | $(MONITOR_CMD) $(call get_monitor_port) $(MONITOR_BAUDRATE) 1830 | endif 1831 | 1832 | debug_init: 1833 | $(OPENOCD) $(OPENOCD_OPTS) 1834 | 1835 | debug: 1836 | $(GDB) $(GDB_OPTS) 1837 | 1838 | disasm: $(OBJDIR)/$(TARGET).lss 1839 | @$(ECHO) "The compiled ELF file has been disassembled to $(OBJDIR)/$(TARGET).lss\n\n" 1840 | 1841 | symbol_sizes: $(OBJDIR)/$(TARGET).sym 1842 | @$(ECHO) "A symbol listing sorted by their size have been dumped to $(OBJDIR)/$(TARGET).sym\n\n" 1843 | 1844 | verify_size: 1845 | ifeq ($(strip $(HEX_MAXIMUM_SIZE)),) 1846 | @$(ECHO) "\nMaximum flash memory of $(BOARD_TAG) is not specified. Make sure the size of $(TARGET_HEX) is less than $(BOARD_TAG)\'s flash memory\n\n" 1847 | endif 1848 | @if [ ! -f $(TARGET_HEX).sizeok ]; then echo >&2 "\nThe size of the compiled binary file is greater than the $(BOARD_TAG)'s flash memory. \ 1849 | See http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it."; false; fi 1850 | 1851 | generate_assembly: $(OBJDIR)/$(TARGET).s 1852 | @$(ECHO) "Compiler-generated assembly for the main input source has been dumped to $(OBJDIR)/$(TARGET).s\n\n" 1853 | 1854 | generated_assembly: generate_assembly 1855 | @$(ECHO) "\"generated_assembly\" target is deprecated. Use \"generate_assembly\" target instead\n\n" 1856 | 1857 | tags: 1858 | ifneq ($(words $(wildcard $(TAGS_FILE))), 0) 1859 | rm -f $(TAGS_FILE) 1860 | endif 1861 | @$(ECHO) "Generating tags for local sources (INO an PDE files as C++): " 1862 | $(CTAGS_CMD) $(TAGS_FILE) --langmap=c++:+.ino.pde $(LOCAL_SRCS) 1863 | ifneq ($(words $(ARDUINO_LIBS)), 0) 1864 | @$(ECHO) "Generating tags for project libraries: " 1865 | $(CTAGS_CMD) $(TAGS_FILE) $(foreach lib, $(ARDUINO_LIBS),$(USER_LIB_PATH)/$(lib)/*) 1866 | endif 1867 | @$(ECHO) "Generating tags for Arduino core: " 1868 | $(CTAGS_CMD) $(TAGS_FILE) $(ARDUINO_CORE_PATH)/* 1869 | @$(ECHO) "Sorting..\n" 1870 | @sort $(TAGS_FILE) -o $(TAGS_FILE) 1871 | @$(ECHO) "Tag file generation complete, output: $(TAGS_FILE)\n" 1872 | 1873 | help_vars: 1874 | @$(CAT) $(ARDMK_DIR)/arduino-mk-vars.md 1875 | 1876 | help: 1877 | @$(ECHO) "\nAvailable targets:\n\ 1878 | make - compile the code\n\ 1879 | make upload - upload\n\ 1880 | make ispload - upload using an ISP\n\ 1881 | make raw_upload - upload without first resetting\n\ 1882 | make eeprom - upload the eep file\n\ 1883 | make raw_eeprom - upload the eep file without first resetting\n\ 1884 | make clean - remove all our dependencies\n\ 1885 | make depends - update dependencies\n\ 1886 | make reset - reset the Arduino by tickling DTR or changing baud\n\ 1887 | rate on the serial port.\n\ 1888 | make show_boards - list all the boards defined in boards.txt\n\ 1889 | make show_submenu - list all board submenus defined in boards.txt\n\ 1890 | make monitor - connect to the Arduino's serial port\n\ 1891 | make debug_init - start openocd gdb server\n\ 1892 | make debug - connect to gdb target and begin debugging\n\ 1893 | make size - show the size of the compiled output (relative to\n\ 1894 | resources, if you have a patched $(TOOL_PREFIX)-size).\n\ 1895 | make verify_size - verify that the size of the final file is less than\n\ 1896 | the capacity of the micro controller.\n\ 1897 | make symbol_sizes - generate a .sym file containing symbols and their\n\ 1898 | sizes.\n\ 1899 | make disasm - generate a .lss file that contains disassembly\n\ 1900 | of the compiled file interspersed with your\n\ 1901 | original source code.\n\ 1902 | make generate_assembly - generate a .s file containing the compiler\n\ 1903 | generated assembly of the main sketch.\n\ 1904 | make burn_bootloader - burn bootloader and fuses\n\ 1905 | make set_fuses - set fuses without burning bootloader\n\ 1906 | make tags - generate tags file including project libs and Arduino core\n\ 1907 | make help_vars - print all variables that can be overridden\n\ 1908 | make help - show this help\n\ 1909 | " 1910 | @$(ECHO) "Please refer to $(ARDMK_DIR)/Arduino.mk for more details.\n" 1911 | 1912 | .PHONY: all upload raw_upload raw_eeprom error_on_caterina reset reset_stty ispload \ 1913 | clean depends size show_boards monitor disasm symbol_sizes generated_assembly \ 1914 | generate_assembly verify_size burn_bootloader help pre-build tags debug debug_init 1915 | 1916 | # added - in the beginning, so that we don't get an error if the file is not present 1917 | -include $(DEPS) 1918 | --------------------------------------------------------------------------------