sudar / Arduino-Makefile

Makefile for Arduino sketches. It defines the workflows for compiling code, flashing it to Arduino and even communicating through Serial.
http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile
GNU Lesser General Public License v2.1
2.02k stars 448 forks source link

Teensy.mk doesn't parse CPUFLAGS, MCU etc correctly #606

Open dselvan opened 5 years ago

dselvan commented 5 years ago

Variables populated from board.txt that have more than one = sign no longer parse correctly leading the Makefile to fail as MCU isn't set correctly and redundant and empty flags are added to the flags list.

/opt/arduino-1.8.8//hardware/tools/arm/bin/arm-none-eabi-g++ -MMD -c -D__PROG_TYPES_COMPAT__ -DLAYOUT_US_ENGLISH -DUSB_SERIAL  -mcpu=mk66fx1m0 -DF_CPU=240000000  -DARDUINO=188 -DARDUINO_ARCH_ARM -I/opt/arduino-1.8.8//hardware/teensy/avr/cores/teensy3 -I/opt/arduino-1.8.8//hardware/teensy/arm/variants/    -I/opt/arduino-1.8.8//hardware/teensy/avr/libraries/Wire -I/opt/arduino-1.8.8//hardware/teensy/avr/libraries/Wire/utility  -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra  -g -Wall -ffunction-sections -fdata-sections -nostdlib -mthumb -mcpu -D__MK66FX1M0__ -DTEENSYDUINO -fno-exceptions -felide-constructors -std -fpermissive -fno-exceptions -std=gnu++17 -fno-threadsafe-statics -flto -fno-devirtualize -fdiagnostics-color=always main.cpp -o /home/deepak/projects/github.com/dselvan/open-sassy/build/src/teensy36/main.cpp.o
arm-none-eabi-g++: error: unrecognized argument in option '-mcpu=mk66fx1m0'
arm-none-eabi-g++: note: valid arguments to '-mcpu=' are: arm1020e arm1020t arm1022e arm1026ej-s arm10e arm10tdmi arm1136j-s arm1136jf-s arm1156t2-s arm1156t2f-s arm1176jz-s arm1176jzf-s arm2 arm250 arm3 arm6 arm60 arm600 arm610 arm620 arm7 arm70 arm700 arm700i arm710 arm7100 arm710c arm710t arm720 arm720t arm740t arm7500 arm7500fe arm7d arm7di arm7dm arm7dmi arm7m arm7tdmi arm7tdmi-s arm8 arm810 arm9 arm920 arm920t arm922t arm926ej-s arm940t arm946e-s arm966e-s arm968e-s arm9e arm9tdmi cortex-a12 cortex-a15 cortex-a15.cortex-a7 cortex-a17 cortex-a17.cortex-a7 cortex-a5 cortex-a53 cortex-a57 cortex-a57.cortex-a53 cortex-a7 cortex-a72 cortex-a72.cortex-a53 cortex-a8 cortex-a9 cortex-m0 cortex-m0.small-multiply cortex-m0plus cortex-m0plus.small-multiply cortex-m1 cortex-m1.small-multiply cortex-m3 cortex-m4 cortex-m7 cortex-r4 cortex-r4f cortex-r5 cortex-r7 cortex-r8 ep9312 exynos-m1 fa526 fa606te fa626 fa626te fa726te fmp626 generic-armv7-a iwmmxt iwmmxt2 marvell-pj4 mpcore mpcorenovfp native strongarm strongarm110 strongarm1100 strongarm1110 xgene1 xscale
arm-none-eabi-g++: error: unrecognized command line option '-mcpu'
arm-none-eabi-g++: error: unrecognized command line option '-std'

Using gdm CPUFLAGS is parsed incompletely MCU is unset and gets set by Adruino.mk to the wrong value and lots of empty flags get propagated.

Change #580 seems to have broken this as while PARSE_TEENSY seems to handle parameters like teensy36.build.flags.cpu=-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant with more than one = sign correctly while PARSE_BOARD does not.

Original with PARSE_BOARD:

1> v CPUFLAGS
/home/deepak/projects/github.com/dselvan/open-sassy/arduino_makefiles/Teensy.mk:135: CPUFLAGS has value '-mthumb -mcpu'
2> v MCU
/home/deepak/projects/github.com/dselvan/open-sassy/arduino_makefiles/Teensy.mk:135: MCU has value ''

Modified with PARSE_TEENSY:

1> v CPUFLAGS
/home/deepak/projects/github.com/dselvan/open-sassy/arduino_makefiles/Teensy.mk:139: CPUFLAGS has value '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant'
2> v MCU      
/home/deepak/projects/github.com/dselvan/open-sassy/arduino_makefiles/Teensy.mk:139: MCU has value 'cortex-m4'

Reverting Teensy.mk to have a def for PARSE_TEENSY and using the old parse command fixes the issue.

OS: Linux Ubuntu 18.04 x86_64 Arduino IDE: 1.8.8 Makefile: Using the example Linux Makefile

szeder commented 5 years ago

Please have a look at issue #601 and PR #604, as I think this is the same issue.