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.01k stars 448 forks source link

BOARD_TAG = teensy41, but teensy3 core is still selected. #654

Open mcastillof opened 3 years ago

mcastillof commented 3 years ago

Hello, I was just trying to build for teensy41 board, but it wasn't working as teensy3 core was still selected. I made a change in a var and it worked as a workaround, but I lack the knowledge about Makefiles to set it up as a good and permanent solution. teensy40 may have the same problem.

Teensy41 seems to be partially supported, as it is listed, but it can't build for it as it is (or maybe I'm doing something wrong):

faf@home:~/project/test$ make show_boards
teensy2     Teensy 2.0
teensy30   Teensy 3.0
teensy31   Teensy 3.2 / 3.1
teensy35   Teensy 3.5
teensy36   Teensy 3.6
teensy40   Teensy 4.0
teensy41   Teensy 4.1
teensyLC   Teensy LC
teensypp2  Teensy++ 2.0

My Makefile has this vars:

...
BOARD_TAG    = teensy41
include $(ARDMK_DIR)/Teensy.mk
...

If I try to build a project, you may notice that it is using teensy3 as ARDUINO_CORE_PATH:

faf@home:~/project/test$ make
- [USER]               ARDMK_DIR = /home/faf/tools/Arduino-Makefile 
- [AUTODETECTED]       ARDUINO_VERSION = 1813 
- [USER]               ARCHITECTURE = arm 
- [USER]               ARDMK_VENDOR = teensy 
- [AUTODETECTED]       ARDUINO_PREFERENCES_PATH = /home/faf/.arduino15/preferences.txt 
- [AUTODETECTED]       ARDUINO_SKETCHBOOK = /home/faf/Arduino (from arduino preferences file)
- [COMPUTED]           ARDUINO_VAR_PATH = /opt/arduino/hardware/teensy/arm/variants (from ARDUINO_DIR)
- [USER]               BOARDS_TXT = /opt/arduino/hardware/teensy/avr/boards.txt 
- [COMPUTED]           CC_NAME = arm-none-eabi-gcc 
- [COMPUTED]           OBJCOPY_NAME = arm-none-eabi-objcopy 
- [COMPUTED]           OBJDUMP_NAME = arm-none-eabi-objdump 
- [COMPUTED]           AR_NAME = arm-none-eabi-gcc-ar 
- [COMPUTED]           SIZE_NAME = arm-none-eabi-size 
- [USER]               AVR_TOOLS_DIR = /opt/arduino/hardware/tools/arm 
- [COMPUTED]           ARDUINO_LIB_PATH = /opt/arduino/libraries (from ARDUINO_DIR)
- [USER]               ARDUINO_PLATFORM_LIB_PATH = /opt/arduino/hardware/teensy/avr/libraries 
- [DEFAULT]            USER_LIB_PATH = /home/faf/Arduino/libraries (in user sketchbook)
- [DEFAULT]            PRE_BUILD_HOOK = pre-build-hook.sh 
- [USER]               BOARD_TAG = teensy41 
- [COMPUTED]           CORE = teensy4 (from build.core)
- [COMPUTED]           VARIANT =  (from build.variant)
- [COMPUTED]           BOARD = TEENSY41 (from build.board)
- [COMPUTED]           OBJDIR = build-teensy41 (from BOARD_TAG)
- [USER]               ARDUINO_CORE_PATH = /opt/arduino/hardware/teensy/avr/cores/teensy3 
- [USER]               RESET_CMD = nohup /opt/arduino/hardware/tools/teensy_post_compile -board=teensy41 -tools=/opt/arduino/hardware/tools -path=/home/faf/project/test/build-teensy41 -file=test_ > /dev/null ; /opt/arduino/hardware/tools/teensy_reboot 
- [DETECTED]           MONITOR_BAUDRATE = 115200  (in sketch)
- [DEFAULT]            OPTIMIZATION_LEVEL = s 
- [USER]               MCU_FLAG_NAME = mcpu 
- [DEFAULT]            CFLAGS_STD = -std=gnu11 
- [DEFAULT]            CXXFLAGS_STD = -std=gnu++11 
- [COMPUTED]           DEVICE_PATH = /dev/ttyACM0 (from MONITOR_PORT)
- [DEFAULT]            FORCE_MONITOR_PORT =  
- [AUTODETECTED]       Size utility: Basic (not AVR-aware)
-
-                      ARDUINO_LIBS =
- [USER]                 ArduinoJson
- [USER]                 Base64
- [USER]                 LiquidCrystal
- [USER]                 SD
- [USER]                 SdFat
- [PLATFORM]             Encoder
- [PLATFORM]             LiquidCrystalFast
- [PLATFORM]             SPI
- [PLATFORM]             TeensyThreads
- [COMPUTED]           BOOTLOADER_PARENT = /opt/arduino/hardware/teensy/arm/bootloaders (from ARDUINO_DIR)
- [COMPUTED]           ARDMK_VERSION = 1.6 
- [COMPUTED]           CC_VERSION = 5.4.1 (arm-none-eabi-gcc)
-------------------------
mkdir -p build-teensy41
/opt/arduino/hardware/tools/arm/bin/arm-none-eabi-g++ -MMD -c -D__PROG_TYPES_COMPAT__ -DLAYOUT_US_ENGLISH -DUSB_SERIAL  -mcpu=cortex-m7 -DF_CPU=1008000000  -DARDUINO=1813 -DARDUINO_TEENSY41 -DARDUINO_ARCH_ARM "-DARDUINO_BOARD=\"TEENSY41\"" "-DARDUINO_VARIANT=\"\"" -I/opt/arduino/hardware/teensy/avr/cores/teensy3 -I/opt/arduino/hardware/teensy/avr/cores/teensy3/api -I/opt/arduino/hardware/teensy/arm/variants/    -I/opt/arduino/hardware/teensy/avr/libraries/Encoder -I/opt/arduino/hardware/teensy/avr/libraries/Encoder/utility   -I/opt/arduino/hardware/teensy/avr/libraries/LiquidCrystalFast   -I/opt/arduino/hardware/teensy/avr/libraries/SPI   -I/opt/arduino/hardware/teensy/avr/libraries/TeensyThreads   -I/home/faf/Arduino/libraries/ArduinoJson/src   -I/home/faf/Arduino/libraries/Base64/src   -I/home/faf/Arduino/libraries/LiquidCrystal/src   -I/home/faf/Arduino/libraries/SD/src   -I/home/faf/Arduino/libraries/SdFat/src -Wall -ffunction-sections -fdata-sections -Os  -g -Wall -ffunction-sections -fdata-sections -nostdlib -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=153 -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -fpermissive -fno-exceptions -std=gnu++11 -fdiagnostics-color=always Adau1452.cpp -o build-teensy41/Adau1452.cpp.o
In file included from /opt/arduino/hardware/teensy/avr/cores/teensy3/core_pins.h:34:0,
                 from /opt/arduino/hardware/teensy/avr/cores/teensy3/wiring.h:39,
                 from /opt/arduino/hardware/teensy/avr/cores/teensy3/WProgram.h:45,
                 from /opt/arduino/hardware/teensy/avr/cores/teensy3/Arduino.h:6,
                 from /opt/arduino/hardware/teensy/avr/libraries/SPI/SPI.h:16,
                 from Adau1452.h:5,
                 from Adau1452.cpp:2:
/opt/arduino/hardware/teensy/avr/cores/teensy3/kinetis.h:5858:28: error: 'NVIC_NUM_INTERRUPTS' was not declared in this scope
 extern void (* _VectorsRam[NVIC_NUM_INTERRUPTS+16])(void);
                            ^
/opt/arduino/hardware/teensy/avr/cores/teensy3/kinetis.h:5859:36: error: 'NVIC_NUM_INTERRUPTS' was not declared in this scope
 extern void (* const _VectorsFlash[NVIC_NUM_INTERRUPTS+16])(void);
                                    ^
...

As soon as I spotted this, I modified in the file Teensy.mk the line: ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/teensy/avr/cores/teensy3 to: ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/teensy/avr/cores/teensy4 and it built succesfully.

I hope somebody with better Makefile skills could change the scripts to select the proper teensy core given BOARD_TAG variable.

Thanks mcastillof