From 61d37eab82f4260567c369601cd4b2376c238124 Mon Sep 17 00:00:00 2001 From: Christopher Peplin Date: Mon, 2 Apr 2012 10:50:00 -0400 Subject: [PATCH] Add support for the chipKIT Max32 and Uno32. --- README.md | 34 +++++++++++++++--- arduino-mk/Arduino.mk | 20 ++++++++--- arduino-mk/chipKIT.mk | 60 ++++++++++++++++++++++++++++++++ examples/Blink-chipKIT/Blink.pde | 19 ++++++++++ examples/Blink-chipKIT/Makefile | 7 ++++ 5 files changed, 132 insertions(+), 8 deletions(-) create mode 100644 arduino-mk/chipKIT.mk create mode 100644 examples/Blink-chipKIT/Blink.pde create mode 100644 examples/Blink-chipKIT/Makefile diff --git a/README.md b/README.md index ec38ba9..cd3ec3b 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,35 @@ This is a very simple Makefile which knows how to build Arduino sketches. -Until March 2012, this was simply posted on my website where you can -still find [what -documentation](http://mjo.tc/atelier/2009/02/arduino-cli.html -"Documentation") exists. +Until March 2012, this was simply posted on my website where you can still find +[what documentation][docs] exists. If you're using Debian or Ubuntu, you can find this in the arduino-core package. + +This Makefile current requires either Arduino 1.0 or MPIDE 0023. + +## chipKIT Support + +In addition to regular Arduino boards, this Makefile supports the Digilent +chipKIT Uno32 and Max32, both Arduino-compatible microcontrollers. To use this +Makefile with one of those, include `chipKIT.mk` instead of `Arduino.mk` at the +bottom of your Makefile. + + include /path/to/chipKIT.mk + +You can adjust the same variables [as described for the Arduino][docs], but the +`ARDUINO_DIR` variable must point to an MPIDE installation (which includes the +chipKIT toolchain) instead of the Arduino IDE. + + +Some details on the addition of chipKIT support can be found in another +[blog post](http://christopherpeplin.com/2011/12/chipkit-arduino-makefile/). + +[docs]: http://mjo.tc/atelier/2009/02/arduino-cli.html + +## Contributors + +* Martin Oldfield (initial version) +* Chris Peplin (chipKIT) +* rei_vilo / Olivier +* Edward Comer diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 0522621..d9fe585 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -186,11 +186,23 @@ endif ifneq (ARDUINO_DIR,) ifndef AVR_TOOLS_PATH -AVR_TOOLS_PATH = $(ARDUINO_DIR)/hardware/tools/avr/bin +AVR_TOOLS_PATH = $(ARDUINO_DIR)/hardware/tools endif -ifndef ARDUINO_ETC_PATH -ARDUINO_ETC_PATH = $(ARDUINO_DIR)/hardware/tools/avr/etc +ifndef AVRDUDE_TOOLS_PATH +ifeq ($(OSTYPE),Linux) +AVRDUDE_TOOLS_PATH = $(AVR_TOOLS_PATH) +else +AVRDUDE_TOOLS_PATH = $(AVR_TOOLS_PATH)/avr/bin +endif +endif + +ifndef AVRDUDE_ETC_PATH +ifeq ($(OSTYPE),Linux) +AVRDUDE_ETC_PATH = $(AVRDUDE_TOOLS_PATH) +else +AVRDUDE_ETC_PATH = $(AVR_TOOLS_PATH)/avr/etc +endif endif ifndef AVRDUDE_CONF @@ -476,7 +488,7 @@ $(OBJDIR)/%.sym: $(OBJDIR)/%.elf # Avrdude # ifndef AVRDUDE -AVRDUDE = $(AVR_TOOLS_PATH)/avrdude +AVRDUDE = $(AVRDUDE_TOOLS_PATH)/avrdude endif AVRDUDE_COM_OPTS = -q -V -p $(MCU) diff --git a/arduino-mk/chipKIT.mk b/arduino-mk/chipKIT.mk new file mode 100644 index 0000000..3126991 --- /dev/null +++ b/arduino-mk/chipKIT.mk @@ -0,0 +1,60 @@ +# +# chipKIT extensions for Arduino Makefile +# System part (i.e. project independent) +# +# Copyright (C) 2011 Christopher Peplin , +# based on work that is Copyright Martin Oldfield +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2.1 of the +# License, or (at your option) any later version. +# + +OSTYPE := $(shell uname) + +AVR_TOOLS_PATH = $(ARDUINO_DIR)/hardware/pic32/compiler/pic32-tools/bin + +ifneq ($(OSTYPE),Linux) +AVRDUDE_TOOLS_PATH = $(ARDUINO_DIR)/hardware/tools/avr/bin +else +AVRDUDE_TOOLS_PATH = $(ARDUINO_DIR)/hardware/tools +endif + +ifneq ($(OSTYPE),Linux) +AVRDUDE_ETC_PATH = $(ARDUINO_DIR)/hardware/tools/avr/etc +else +AVRDUDE_ETC_PATH = $(AVRDUDE_TOOLS_PATH) +endif + +ifndef BOARD +BOARD = $(shell $(PARSE_BOARD) $(BOARD_TAG) board) +endif + +ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/pic32/cores/pic32 +ARDUINO_LIB_PATH = $(ARDUINO_DIR)/hardware/pic32/libraries +BOARDS_TXT = $(ARDUINO_DIR)/hardware/pic32/boards.txt +ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/pic32/variants +ARDUINO_VERSION = 23 + +CC_NAME = pic32-gcc +CXX_NAME = pic32-g++ +AR_NAME = pic32-ar +OBJDUMP_NAME = pic32-objdump +OBJCOPY_NAME = pic32-objcopy + +LDSCRIPT = $(shell $(PARSE_BOARD) $(BOARD_TAG) ldscript) +LDSCRIPT_FILE = $(ARDUINO_CORE_PATH)/$(LDSCRIPT) + +MCU_FLAG_NAME=mprocessor +EXTRA_LDFLAGS = -T$(ARDUINO_CORE_PATH)/$(LDSCRIPT) +EXTRA_CXXFLAGS = -mno-smart-io -D$(BOARD) + +CHIPKIT_MK_PATH := $(dir $(lastword $(MAKEFILE_LIST))) + +include $(CHIPKIT_MK_PATH)/Arduino.mk + +# MPIDE still comes with the compilers on Linux, unlike Arduino +CC = $(AVR_TOOLS_PATH)/$(CC_NAME) +CXX = $(AVR_TOOLS_PATH)/$(CXX_NAME) +OBJCOPY = $(AVR_TOOLS_PATH)/$(OBJCOPY_NAME) diff --git a/examples/Blink-chipKIT/Blink.pde b/examples/Blink-chipKIT/Blink.pde new file mode 100644 index 0000000..1953c39 --- /dev/null +++ b/examples/Blink-chipKIT/Blink.pde @@ -0,0 +1,19 @@ +/* + Blink + Turns on an LED on for one second, then off for one second, repeatedly. + + This example code is in the public domain. + */ + +void setup() { + // initialize the digital pin as an output. + // Pin 13 has an LED connected on most Arduino boards: + pinMode(13, OUTPUT); +} + +void loop() { + digitalWrite(13, HIGH); // set the LED on + delay(1000); // wait for a second + digitalWrite(13, LOW); // set the LED off + delay(1000); // wait for a second +} diff --git a/examples/Blink-chipKIT/Makefile b/examples/Blink-chipKIT/Makefile new file mode 100644 index 0000000..dc617e9 --- /dev/null +++ b/examples/Blink-chipKIT/Makefile @@ -0,0 +1,7 @@ +BOARD_TAG = uno_pic32 +ARDUINO_PORT = /dev/cu.usb* + +ARDUINO_LIBS = + +include ../../arduino-mk/chipKIT.mk +