diff options
| -rw-r--r-- | Arduino.mk | 66 | ||||
| -rw-r--r-- | Common.mk | 4 | ||||
| -rw-r--r-- | HISTORY.md | 6 | ||||
| -rw-r--r-- | OpenCR.mk | 273 | ||||
| -rw-r--r-- | README.md | 11 | ||||
| -rw-r--r-- | Sam.mk | 18 | ||||
| -rw-r--r-- | arduino-mk-vars.md | 27 | ||||
| -rwxr-xr-x | bin/ardmk-init | 8 | ||||
| -rw-r--r-- | examples/BlinkOpenCR/BlinkOpenCR.ino | 48 | ||||
| -rw-r--r-- | examples/BlinkOpenCR/Makefile | 8 | ||||
| -rwxr-xr-x | tests/script/runtests.sh | 2 |
11 files changed, 444 insertions, 27 deletions
@@ -241,6 +241,9 @@ arduino_output = # running for the first time (i.e., not after a restart after # regenerating the dependency file), then output the configuration. ifndef ARDUINO_QUIET + ARDUINO_QUIET = 0 +endif +ifeq ($(ARDUINO_QUIET),0) ifeq ($(MAKE_RESTARTS),) ifeq ($(MAKELEVEL),0) arduino_output = $(info $(1)) @@ -641,6 +644,11 @@ else $(call show_config_variable,BOARD_TAG,[USER]) endif +ifdef BOARD_CLOCK + BOARD_CLOCK := $(strip $(BOARD_CLOCK)) + $(call show_config_variable,BOARD_CLOCK,[USER]) +endif + # If NO_CORE is set, then we don't have to parse boards.txt file # But the user might have to define MCU, F_CPU etc ifeq ($(strip $(NO_CORE)),) @@ -686,7 +694,12 @@ ifeq ($(strip $(NO_CORE)),) endif ifndef F_CPU - F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).build.f_cpu) + ifdef BOARD_CLOCK + F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),menu.(speed|clock).$(BOARD_CLOCK).build.f_cpu) + endif + ifndef F_CPU + F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).build.f_cpu) + endif ifndef F_CPU F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),build.f_cpu) endif @@ -706,6 +719,22 @@ ifeq ($(strip $(NO_CORE)),) endif endif + ifndef USB_PRODUCT + USB_PRODUCT := $(call PARSE_BOARD,$(BOARD_TAG),build.usb_product) + ifdef USB_PRODUCT + $(call show_config_variable,USB_PRODUCT,[COMPUTED]) + endif + endif + + ifndef USB_MANUFACTURER + USB_MANUFACTURER := $(call PARSE_BOARD,$(BOARD_TAG),build.usb_manufacturer) + ifndef USB_MANUFACTURER + USB_MANUFACTURER = "Unknown" + else + $(call show_config_variable,USB_MANUFACTURER,[COMPUTED]) + endif + endif + # add caterina flag to ARD_RESET_OPTS ARD_RESET_OPTS += --caterina endif @@ -731,21 +760,36 @@ ifeq ($(strip $(NO_CORE)),) endif ifndef ISP_HIGH_FUSE - ISP_HIGH_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.high_fuses) + ifdef BOARD_CLOCK + ISP_HIGH_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(speed|clock).$(BOARD_CLOCK).bootloader.high_fuses) + endif + ifndef ISP_HIGH_FUSE + ISP_HIGH_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.high_fuses) + endif ifndef ISP_HIGH_FUSE ISP_HIGH_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.high_fuses) endif endif ifndef ISP_LOW_FUSE - ISP_LOW_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.low_fuses) + ifdef BOARD_CLOCK + ISP_LOW_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(speed|clock).$(BOARD_CLOCK).bootloader.low_fuses) + endif + ifndef ISP_LOW_FUSE + ISP_LOW_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.low_fuses) + endif ifndef ISP_LOW_FUSE ISP_LOW_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.low_fuses) endif endif ifndef ISP_EXT_FUSE - ISP_EXT_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.extended_fuses) + ifdef BOARD_CLOCK + ISP_EXT_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(speed|clock).$(BOARD_CLOCK).bootloader.extended_fuses) + endif + ifndef ISP_EXT_FUSE + ISP_EXT_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.extended_fuses) + endif ifndef ISP_EXT_FUSE ISP_EXT_FUSE := $(call PARSE_BOARD,$(BOARD_TAG),bootloader.extended_fuses) endif @@ -1136,6 +1180,9 @@ CPPFLAGS += $(OPTIMIZATION_FLAGS) # USB IDs for the Caterina devices like leonardo or micro ifneq ($(CATERINA),) CPPFLAGS += -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) + ifdef USB_PRODUCT + CPPFLAGS += -DUSB_PRODUCT='$(USB_PRODUCT)' -DUSB_MANUFACTURER='$(USB_MANUFACTURER)' + endif endif # $(TOOL_PREFIX)-gcc version that we can do maths on @@ -1242,9 +1289,14 @@ ifneq (,$(findstring AVR,$(shell $(SIZE) --help))) avr_size = $(SIZE) $(SIZEFLAGS) --format=avr $(1) $(call show_config_info,Size utility: AVR-aware for enhanced output,[AUTODETECTED]) else - # We have a plain-old binutils version - just give it the hex. - avr_size = $(SIZE) $(2) - $(call show_config_info,Size utility: Basic (not AVR-aware),[AUTODETECTED]) + ifeq ($(findstring sam, $(strip $(ARCHITECTURE))), sam) + avr_size = $(SIZE) $(SIZEFLAGS) $(1) + $(call show_config_info,Size utility: ARM,[AUTODETECTED]) + else + # We have a plain-old binutils version - just give it the hex. + avr_size = $(SIZE) $(2) + $(call show_config_info,Size utility: Basic (not AVR-aware),[AUTODETECTED]) + endif endif ifneq (,$(strip $(ARDUINO_LIBS))) @@ -5,16 +5,14 @@ COMMON_INCLUDED = TRUE # (directory and optional filename) exists dir_if_exists = $(if $(wildcard $(1)$(2)),$(1)) -ifndef PARSE_BOARD # result = $(call READ_BOARD_TXT, 'boardname', 'parameter') PARSE_BOARD = $(shell if [ -f $(BOARDS_TXT) ]; \ then \ grep -Ev '^\#' $(BOARDS_TXT) | \ grep -E "^[ \t]*$(1).$(2)=" | \ - cut -d = -f 2 | \ + cut -d = -f 2- | \ cut -d : -f 2; \ fi) -endif # Run a shell script if it exists. Stops make on error. runscript_if_exists = \ @@ -10,11 +10,14 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - Fix: Add -fno-devirtualize flag to workaround g++ segfault bug (issue #486). (https://github.com/sej7278) - Fix: Quote the prefix tag in the space_pad_to function - Fix: recognize serial monitors with full path in MONITOR_CMD +- Fix: Grab USB_PRODUCT and USB_MANUFACTURER from boards.txt for 32u4 boards (issue #594). +- Fix: Show the configuration when ARDUINO_QUIET=0 - Tweak: Move chip erase flag from set_fuses to ispload to prevent sketch being nuked when setting fuses - Tweak: Set ARDMK_VERSION to 1.6 (https://github.com/sej7278) - Tweak: Move non-standard-related items from CxxFLAGS_STD to CxxFLAGS (issue #523) (https://github.com/sej7278) - Tweak: Update Windows usage documentation and allow non-relative paths (issue #519) (https://github.com/tuna-f1sh) - Tweak: Support Cygwin Unix Python and Windows installation on Windows to pass correct port binding. (https://github.com/tuna-f1sh) +- Tweak: Update how avr-size is called on Sam, also moved to gnu11 std (issue #602) (https://github.com/tuna-f1sh) - New: Added -fdiagnostics-color to \*STD flags (https://github.com/sej7278) - New: Made -fdiagnostics-color take a variiable DIAGNOSTICS_COLOR_WHEN: never, always, auto. (https://github.com/wingunder) - New: Add generation of tags file using ctags, which automatically includes project libs and Arduino core. (https://github.com/tuna-f1sh) @@ -25,6 +28,9 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - New: Support Arduino ARM SAM devices (Due). (https://github.com/tuna-f1sh) - New: Moved the PARSE_BOARD macro to Common.mk and use only this to parse the boards.txt file. (https://github.com/wingunder) - New: Added the TOOL_PREFIX variable for setting up the executable tools centrally and generically. (https://github.com/wingunder) +- New: Add support for BOARD_CLOCK for board.menu.speed and board.menu.clock entries in boards.txt files. (https://github.com/dewhisna) +- New: Updated Arch instructions. (https://github.com/Akram-Chehaima) +- New: Add support for Robotis OpenCR 1.0 boards. ### 1.6.0 (2017-07-11) - Fix: Allowed for SparkFun's weird usb pid/vid submenu shenanigans (issue #499). (https://github.com/sej7278) diff --git a/OpenCR.mk b/OpenCR.mk new file mode 100644 index 0000000..da97dc8 --- /dev/null +++ b/OpenCR.mk @@ -0,0 +1,273 @@ +########################################################################
+#
+# Support for Robotis OpenCR boards
+#
+# Written by Dowhan Jeong, EunJin Jeong
+#
+# Based on work that is copyright Jeremy Shaw, Sudar, Nicholas Zambetti,
+# David A. Mellis & Hernando Barragan.
+#
+# 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.
+#
+########################################################################
+
+ifndef ARDUINO_DIR
+echo $(error ARDUINO_DIR should be specified)
+endif
+
+ifndef BOARD_TAG
+echo $(error BOARD_TAG should be specified. check board list with 'make show_boards')
+endif
+
+ifndef ARDMK_DIR
+ ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
+endif
+
+include $(ARDMK_DIR)/Common.mk
+
+ifndef ARDUINO_PACKAGE_DIR
+ # attempt to find based on Linux, macOS and Windows default
+ ARDUINO_PACKAGE_DIR := $(firstword \
+ $(call dir_if_exists,$(HOME)/.arduino15/packages) \
+ $(call dir_if_exists,$(ARDUINO_DIR)/packages) \
+ $(call dir_if_exists,$(HOME)/Library/Arduino15/packages) \
+ $(call dir_if_exists,$(realpath $(USERPROFILE))/AppData/Local/Arduino15/packages) )
+ $(call show_config_variable,ARDUINO_PACKAGE_DIR,[AUTODETECTED],(from DEFAULT))
+else
+ $(call show_config_variable,ARDUINO_PACKAGE_DIR,[USER])
+endif
+
+ifndef ARDMK_VENDOR
+ ARDMK_VENDOR = OpenCR
+endif
+
+ifndef ARCHITECTURE
+ ARCHITECTURE := OpenCR
+endif
+
+ifndef CORE_VER
+ CORE_VER := $(wildcard $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/hardware/$(ARCHITECTURE)/1.*)
+ ifneq ($(CORE_VER),)
+ CORE_VER := $(shell basename $(CORE_VER))
+ $(call show_config_variable,CORE_VER,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
+ endif
+else
+ $(call show_config_variable,CORE_VER,[USER])
+endif
+
+ARCHITECTURE := sam
+
+arduino_output =
+# When output is not suppressed and we're in the top-level makefile,
+# running for the first time (i.e., not after a restart after
+# regenerating the dependency file), then output the configuration.
+ifndef ARDUINO_QUIET
+ ifeq ($(MAKE_RESTARTS),)
+ ifeq ($(MAKELEVEL),0)
+ arduino_output = $(info $(1))
+ endif
+ endif
+endif
+
+# Arduino Settings (will get shown in Arduino.mk as computed)
+ifndef ALTERNATE_CORE_PATH
+ ifdef CORE_VER
+ ALTERNATE_CORE_PATH = $(ARDUINO_PACKAGE_DIR)/OpenCR/hardware/OpenCR/$(CORE_VER)
+ else
+ echo $(error Cannot find $(CORE_VER). Check directory settings.)
+ endif
+endif
+
+ifndef ARDUINO_CORE_PATH
+ ARDUINO_CORE_PATH= $(ALTERNATE_CORE_PATH)/cores/arduino
+endif
+
+ifndef BOARDS_TXT
+ BOARDS_TXT= $(ALTERNATE_CORE_PATH)/boards.txt
+endif
+
+ifndef VARIANT
+ VARIANT := $(call PARSE_BOARD,$(BOARD_TAG),build.variant)
+endif
+
+ARDUINO_VAR_PATH = $(ALTERNATE_CORE_PATH)/variants/$(VARIANT)
+
+
+# Check boards file exists before continuing as parsing non-existant file can create problems
+ifneq ($(findstring boards.txt, $(wildcard $(ALTERNATE_CORE_PATH)/*.txt)), boards.txt)
+ echo $(error $(CORE_VER) Cannot find boards file $(BOARDS_TXT). Check ?? and board support installed)
+endif
+
+# grab any sources in the variant core path.
+# directorys were manually checked.
+# Core sources(used to generate libcore.a archive)
+OPENCR_CORE_C_SRCS_1 := $(wildcard $(ARDUINO_CORE_PATH)/avr/*.c)
+OPENCR_CORE_C_SRCS_2 := $(wildcard $(ARDUINO_CORE_PATH)/*.c)
+OPENCR_CORE_CPP_SRCS := $(wildcard $(ARDUINO_CORE_PATH)/*.cpp)
+
+# library sources
+OPENCR_LIB_C_SRCS_1 := $(wildcard $(ARDUINO_VAR_PATH)/bsp/opencr/*.c)
+OPENCR_LIB_C_SRCS_2 := $(wildcard $(ARDUINO_VAR_PATH)/hw/*.c)
+OPENCR_LIB_C_SRCS_3 := $(wildcard $(ARDUINO_VAR_PATH)/hw/driver/*.c)
+OPENCR_LIB_C_SRCS_4 := $(wildcard $(ARDUINO_VAR_PATH)/hw/usb_cdc/*.c)
+OPENCR_LIB_C_SRCS_5 := $(wildcard $(ARDUINO_VAR_PATH)/lib/STM32F7xx_HAL_Driver/Src/*.c)
+OPENCR_LIB_CPP_SRCS := $(wildcard $(ARDUINO_VAR_PATH)/*.cpp)
+OPENCR_LIB_S_SRCS := $(wildcard $(ARDUINO_VAR_PATH)/bsp/opencr/startup/*.S)
+
+ifndef F_CPU
+ F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),build.f_cpu)
+endif
+
+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))
+ OTHER_OBJS = $(patsubst %, \
+ $(OBJDIR)/OpenCRlib/%, $(OPENCR_LIB_OBJ_FILES))
+
+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))
+# override is used since opencr dosen't need other sam core objects
+override CORE_OBJS = $(patsubst %, \
+ $(OBJDIR)/core/%, $(OPENCR_CORE_OBJ_FILES))
+
+ifndef AVR_TOOLS_DIR
+ AVR_TOOLS_DIR = $(call dir_if_exists,$(ARDUINO_PACKAGE_DIR)/OpenCR/tools/opencr_gcc/5.4.0-2016q2)
+endif
+ifeq ($(strip $(AVR_TOOLS_DIR)),)
+ echo $(error $(AVR_TOOLS_DIR) Cannot find AVR_TOOLS_DIR. Check AVR_TOOLS_DIR)
+endif
+
+# Robotis OpenCR platform library directory
+ifndef ARDUINO_PLATFORM_LIB_PATH
+ ARDUINO_PLATFORM_LIB_PATH = $(ALTERNATE_CORE_PATH)/libraries
+ $(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[COMPUTED],(from OPENCR_DIR))
+endif
+
+########################################################################
+# command names
+
+TOOL_PREFIX = arm-none-eabi
+
+# processor stuff
+ifndef MCU
+ MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
+endif
+
+ifndef MCU_FLAG_NAME
+ MCU_FLAG_NAME=mcpu
+endif
+
+########################################################################
+# FLAGS
+ifndef USB_TYPE
+ USB_TYPE = USB_SERIAL
+endif
+
+# from platform.txt
+CPPFLAGS += -DARDUINO_OpenCR
+CPPFLAGS += -DARDUINO_ARCH_OPENCR
+
+CPPFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.common_flags)
+
+OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc1)
+OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc2)
+OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc3)
+OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc4)
+OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc5)
+OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc6)
+OPENCR_COMPILER_LIBS_C_FLAGS +=-I$(ARDUINO_VAR_PATH)/$(call PARSE_BOARD,$(BOARD_TAG),build.inc7)
+CPPFLAGS += $(OPENCR_COMPILER_LIBS_C_FLAGS)
+
+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)
+
+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)
+
+ASFLAGS += -c -g -x assembler-with-cpp -MMD
+
+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
+
+LINKER_SCRIPTS = -T$(ARDUINO_VAR_PATH)/bsp/opencr/ldscript/opencr_flash.ld
+########################################################################
+# Reset is handled by upload script. OpenCR don't neet reset command.
+override RESET_CMD =
+
+########################################################################
+# Object conversion & uploading magic, modified from Arduino.mk
+override TARGET_HEX = $(OBJDIR)/$(TARGET).bin
+
+override avr_size = $(SIZE) --target=binary $(2)
+
+# Define UPLOAD_TOOL as avrdude to use avrdude upload recipe in Arduino.mk
+override UPLOAD_TOOL = avrdude
+
+ifeq ($(CURRENT_OS), WINDOWS)
+ override AVRDUDE = $(ARDUINO_PACKAGE_DIR)/OpenCR/tools/opencr_tools/1.0.0/win/opencr_ld.exe
+else
+ override AVRDUDE = $(ARDUINO_PACKAGE_DIR)/OpenCR/tools/opencr_tools/1.0.0/linux/opencr_ld
+endif
+override AVRDUDE_COM_OPTS = $(DEVICE_PATH)
+override AVRDUDE_ISP_OPTS = 115200 $(TARGET_HEX) 1
+override AVRDUDE_ISPLOAD_OPTS =
+
+########################################################################
+# automatically include Arduino.mk
+
+include $(ARDMK_DIR)/Arduino.mk
+
+########################################################################
+
+# OpenCR core files
+$(OBJDIR)/core/%.c.o: $(ARDUINO_CORE_PATH)/avr/%.c $(COMMON_DEPS) | $(OBJDIR)
+ @$(MKDIR) $(dir $@)
+ $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
+
+$(OBJDIR)/core/%.c.o: $(ARDUINO_CORE_PATH)/%.c $(COMMON_DEPS) | $(OBJDIR)
+ @$(MKDIR) $(dir $@)
+ $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
+
+$(OBJDIR)/core/%.cpp.o: $(ARDUINO_CORE_PATH)/%.cpp $(COMMON_DEPS) | $(OBJDIR)
+ @$(MKDIR) $(dir $@)
+ $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
+
+# OpenCR lib files
+$(OBJDIR)/OpenCRlib/%.c.o: $(ARDUINO_VAR_PATH)/bsp/opencr/%.c $(COMMON_DEPS) | $(OBJDIR)
+ @$(MKDIR) $(dir $@)
+ $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
+$(OBJDIR)/OpenCRlib/%.c.o: $(ARDUINO_VAR_PATH)/hw/%.c $(COMMON_DEPS) | $(OBJDIR)
+ @$(MKDIR) $(dir $@)
+ $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
+
+$(OBJDIR)/OpenCRlib/%.c.o: $(ARDUINO_VAR_PATH)/hw/driver/%.c $(COMMON_DEPS) | $(OBJDIR)
+ @$(MKDIR) $(dir $@)
+ $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
+
+$(OBJDIR)/OpenCRlib/%.c.o: $(ARDUINO_VAR_PATH)/hw/usb_cdc/%.c $(COMMON_DEPS) | $(OBJDIR)
+ @$(MKDIR) $(dir $@)
+ $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
+
+$(OBJDIR)/OpenCRlib/%.c.o: $(ARDUINO_VAR_PATH)/lib/STM32F7xx_HAL_Driver/Src/%.c $(COMMON_DEPS) | $(OBJDIR)
+ @$(MKDIR) $(dir $@)
+ $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
+
+$(OBJDIR)/OpenCRlib/%.cpp.o: $(ARDUINO_VAR_PATH)/%.cpp $(COMMON_DEPS) | $(OBJDIR)
+ @$(MKDIR) $(dir $@)
+ $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
+
+$(OBJDIR)/OpenCRlib/%.S.o: $(ARDUINO_VAR_PATH)/bsp/opencr/startup/%.S $(COMMON_DEPS) | $(OBJDIR)
+ @$(MKDIR) $(dir $@)
+ $(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
+
+# Object conversion & uploading magic, modified from Arduino.mk
+$(OBJDIR)/%.bin: $(OBJDIR)/%.elf $(COMMON_DEPS)
+ @$(MKDIR) $(dir $@)
+ $(OBJCOPY) -v -Obinary $< $@
+ @$(ECHO) '\n'
+ $(call avr_size,$<,$@)
+ifneq ($(strip $(HEX_MAXIMUM_SIZE)),)
+ @if [ `$(SIZE) --target=binary $@ | awk 'FNR == 2 {print $$2}'` -le $(HEX_MAXIMUM_SIZE) ]; then touch $@.sizeok; fi
+else
+ @$(ECHO) "Maximum flash memory of $(BOARD_TAG) is not specified. Make sure the size of $@ is less then $(BOARD_TAG)\'s flash memory"
+ @touch $@.sizeok
+endif
+
+CORE_LIB += -Wl,--no-whole-archive -lstdc++
@@ -11,6 +11,7 @@ This is a very simple Makefile which knows how to build Arduino sketches. It def and includes on-device debugging targets. - Supports chipKIT - Supports Teensy 3.x (via Teensyduino) +- Supports Robotis OpenCR 1.0 - Works on all three major OS (Mac, Linux, Windows) - Auto detects serial baud rate and libraries used - Support for `*.ino` and `*.pde` sketches as well as raw `*.c` and `*.cpp` @@ -53,10 +54,10 @@ $ brew install --HEAD arduino-mk #### Arch Linux Arch Linux users can use the unofficial AUR package [arduino-mk](https://aur.archlinux.org/packages/arduino-mk/). -It can be installed using the following command. +It can be installed with [AUR] helper using the following command. ```sh -yaourt -S arduino-mk +yay -S arduino-mk ``` #### Fedora @@ -116,6 +117,12 @@ On openSUSE: zypper install python-serial ``` +On Arch: + +```sh +sudo pacman -S python-pyserial +``` + On Mac using MacPorts: ```sh @@ -114,7 +114,7 @@ endif ifndef ARDUINO_CORE_PATH ARDUINO_CORE_PATH = $(ALTERNATE_CORE_PATH)/cores/arduino endif -ifndef BOARD_TXT +ifndef BOARDS_TXT BOARDS_TXT = $(ALTERNATE_CORE_PATH)/boards.txt endif @@ -130,11 +130,6 @@ CPPFLAGS += -I$(CMSIS_ATMEL_DIR)/Device/ATMEL LIB_PATH = $(CMSIS_DIR)/Lib/GCC BOOTLOADER_PARENT = $(ALTERNATE_CORE_PATH)/bootloaders -# Utility from ard-mk to parse boards.txt for flags -ifndef PARSE_BOARD - PARSE_BOARD = $(shell grep -Ev '^\#' $(BOARDS_TXT) | grep -E '^[ \t]*$(1).$(2)=' | cut -d = -f 2 | cut -d : -f 2) -endif - ifndef VARIANT VARIANT := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).build.variant) ifndef VARIANT @@ -395,12 +390,7 @@ ifndef BOOTLOADER_PROTECT_VERIFY endif endif -# C99 with GNU extensions required for C sources using old compiler -CC_VERNUM = $(shell $(CC) -dumpversion | sed 's/\.//g') -ifneq ($(shell expr $(CC_VERNUM) '>' 490), 1) - CFLAGS_STD = -std=gnu99 -endif - +CFLAGS_STD += -std=gnu11 CPPFLAGS += -DMD -D$(USB_TYPE) '-DUSB_PRODUCT=$(USB_PRODUCT)' '-DUSB_MANUFACTURER=$(USB_MANUFACTURER)' # Get extra define flags from boards.txt @@ -414,6 +404,10 @@ CPPFLAGS += -DUSB_PID=$(USB_PID) CPPFLAGS += -mthumb -nostdlib --param max-inline-insns-single=500 -fno-exceptions -Wl,-Map=$(OBJDIR)/$(TARGET).map CXXFLAGS += -fno-rtti -fno-threadsafe-statics -std=gnu++11 +ifndef SIZEFLAGS + SIZEFLAGS += -B +endif + AMCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu) BOARD_LINKER_SCRIPT := $(call PARSE_BOARD,$(BOARD_TAG),build.ldscript) OPENOCD_SCRIPT := $(call PARSE_BOARD,$(BOARD_TAG),build.openocdscript) diff --git a/arduino-mk-vars.md b/arduino-mk-vars.md index 7434316..85fbd9f 100644 --- a/arduino-mk-vars.md +++ b/arduino-mk-vars.md @@ -344,6 +344,33 @@ BOARD_SUB=atmega168 ---- +### BOARD_CLOCK + +**Description:** + +Allow selection of f_cpu and fuses specified in `boards.txt` as `{BOARD_TAG}.menu.clock.{BOARD_CLOCK}`. +This works for microprocessor board definitions like ATtiny that specify not only the clock speed but fuse settings as clock overrides. + +It also works for f_cpu values specified in `boards.txt` as `{BOARD_TAG}.menu.speed.{BOARD_CLOCK}`. +For example, the Watterott ATmega328PB library [https://github.com/watterott/ATmega328PB-Testing](https://github.com/watterott/ATmega328PB-Testing). + +**Example:** + +```Makefile +# Select external 16 MHz clock +BOARD_CLOCK=external16 +``` + +**Example:** +```Makefile +# Select 20MHz speed +BOARD_CLOCK=20mhz +``` + +**Requirement:** *Optional to override main board f_cpu and/or fuse settings.* + +---- + ### MONITOR_PORT **Description:** diff --git a/bin/ardmk-init b/bin/ardmk-init index 1a01cd3..51b12f0 100755 --- a/bin/ardmk-init +++ b/bin/ardmk-init @@ -22,7 +22,7 @@ import os import argparse ## Global Vars -VERSION = "1.1" +VERSION = "1.2" ARD_TEMPLATE = "\n\ #include <Arduino.h>\n\ #include <Wire.h>\n\ @@ -49,6 +49,7 @@ PARSER.add_argument('-u', '--micro', default='AUTO', help='microcontroller on bo PARSER.add_argument('-f', '--freq', default='AUTO', help='clock frequency') PARSER.add_argument('-p', '--port', default='AUTO', help='monitor port') PARSER.add_argument('-n', '--name', default=os.path.basename(os.getcwd()), help='project name') +PARSER.add_argument('-s', '--sam', action='store_true', help='sam device, will include Sam.mk rather than Arduino.mk') PARSER.add_argument('--cli', action='store_true', help='run with user prompts (requires "Clint" module), rather than args') PARSER.add_argument('-P', '--project', action='store_true', help='create boilerplate project with src, lib and bin folder structure') @@ -182,7 +183,10 @@ def generate_makefile(): validators=[validators.PathValidator()]) ardmk = "ARDMK_DIR := " + ardmk + "\n" - file_content += "\ninclude $(ARDMK_DIR)/Arduino.mk" + if ARGS.sam: + file_content += "\ninclude $(ARDMK_DIR)/Sam.mk" + else: + file_content += "\ninclude $(ARDMK_DIR)/Arduino.mk" # Add forward slash if source directory exists if src_dir: diff --git a/examples/BlinkOpenCR/BlinkOpenCR.ino b/examples/BlinkOpenCR/BlinkOpenCR.ino new file mode 100644 index 0000000..aabf2a8 --- /dev/null +++ b/examples/BlinkOpenCR/BlinkOpenCR.ino @@ -0,0 +1,48 @@ +/*
+ * Blink(LED)
+ */
+
+
+#define BDPIN_LED_USER_1 22
+#define BDPIN_LED_USER_2 23
+#define BDPIN_LED_USER_3 24
+#define BDPIN_LED_USER_4 25
+
+
+int led_pin = 13;
+int led_pin_user[4] = { BDPIN_LED_USER_1, BDPIN_LED_USER_2, BDPIN_LED_USER_3, BDPIN_LED_USER_4 };
+
+void setup() {
+ // Set up the built-in LED pin as an output:
+ pinMode(led_pin, OUTPUT);
+ pinMode(led_pin_user[0], OUTPUT);
+ pinMode(led_pin_user[1], OUTPUT);
+ pinMode(led_pin_user[2], OUTPUT);
+ pinMode(led_pin_user[3], OUTPUT);
+
+ Serial.begin(115200);
+
+}
+
+void loop() {
+ int i;
+
+ digitalWrite(led_pin, HIGH); // set to as HIGH LED is turn-off
+ delay(100); // Wait for 0.1 second
+ digitalWrite(led_pin, LOW); // set to as LOW LED is turn-on
+ delay(100); // Wait for 0.1 second
+
+
+ for( i=0; i<4; i++ )
+ {
+ digitalWrite(led_pin_user[i], HIGH);
+ delay(100);
+ }
+ for( i=0; i<4; i++ )
+ {
+ digitalWrite(led_pin_user[i], LOW);
+ delay(100);
+ }
+
+ Serial.println( String(10) );
+}
diff --git a/examples/BlinkOpenCR/Makefile b/examples/BlinkOpenCR/Makefile new file mode 100644 index 0000000..d4422f4 --- /dev/null +++ b/examples/BlinkOpenCR/Makefile @@ -0,0 +1,8 @@ +BOARD_TAG = OpenCR + + +ARDUINO_LIBS = + +#MONITOR_PORT = /dev/ttyACM0 + +include ../../OpenCR.mk diff --git a/tests/script/runtests.sh b/tests/script/runtests.sh index 60ee73e..fd05c30 100755 --- a/tests/script/runtests.sh +++ b/tests/script/runtests.sh @@ -7,7 +7,7 @@ failures=() # These examples cannot be tested easily at the moment as they require # alternate cores. The MakefileExample doesn't actually contain any source code # to compile. -NON_TESTABLE_EXAMPLES=(ATtinyBlink MakefileExample TinySoftWareSerial BlinkOpenCM BlinkTeensy BlinkNetworkRPi BlinkInAVRC MZeroBlink ZeroBlink DueBlink) +NON_TESTABLE_EXAMPLES=(ATtinyBlink MakefileExample TinySoftWareSerial BlinkOpenCM BlinkOpenCR BlinkTeensy BlinkNetworkRPi BlinkInAVRC MZeroBlink ZeroBlink DueBlink) for dir in $TESTS_DIR/*/ do |
