Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

Thread: How do I use the example Teensy 4.0 Makefile with latest Arduino 1.8.9?

  1. #1
    Junior Member
    Join Date
    Aug 2019
    Posts
    5

    How do I use the example Teensy 4.0 Makefile with latest Arduino 1.8.9?

    I have the latest official Arduino version 1.8.9 and Teensyduino 1.47 installed, and I'm able to successfully compile and flash my new Teensy 4.0 directly from Arduino.

    I'm having trouble trying to compile the example Blink source, using the provided teensy4 Makefile template (i.e., https://github.com/PaulStoffregen/co...ensy4/Makefile).

    Using the Arduino IDE compilation output as reference, I've tried updating the Makefile as follows:

    Code:
    CPUARCH = cortex-m7
    DEFS = -D__IMXRT1062__ -DTEENSYDUINO=147 -DARDUINO=10809 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH
    SECTIONS = -ffunction-sections -fdata-sections
    DBGFLAGS = -g
    CPPFLAGS = $(DBGFLAGS) -Wall -O2 $(SECTIONS) -mcpu=$(CPUARCH) -mthumb -mfloat-abi=hard -mfpu=fpv5-d16 -I. $(DEFS)
    CXXFLAGS = -std=gnu++14 -felide-constructors -fno-exceptions -fpermissive -fno-threadsafe-statics -fno-rtti -Wno-error=narrowing
    LDFLAGS = -Wl,--gc-sections,--relax,--print-memory-usage -Timxrt1062.ld -larm_cortexM7lfsp_math -lm -lstdc++ -nostdlib --specs=nano.specs
    
    C_FILES := $(wildcard *.c)
    CPP_FILES := $(wildcard *.cpp)
    
    OBJS := $(C_FILES:.c=.o) $(CPP_FILES:.cpp=.o)
    
    ARDUINOPATH = /home/andrew/.bin/arduino-1.8.9
    COMPILERPATH = $(abspath $(ARDUINOPATH)/hardware/tools/arm/bin)
    CC = $(COMPILERPATH)/arm-none-eabi-gcc
    CXX = $(COMPILERPATH)/arm-none-eabi-g++
    OBJCOPY = $(COMPILERPATH)/arm-none-eabi-objcopy
    OBJDUMP = $(COMPILERPATH)/arm-none-eabi-objdump
    SIZE = $(COMPILERPATH)/arm-none-eabi-size
    AR = $(COMPILERPATH)/arm-none-eabi-gcc-ar
    
    all: Blink.elf
    
    Blink.elf: Blink.o core.a
            $(CC) $(CPPFLAGS) $(LDFLAGS) -o $@ $^
            $(OBJDUMP) -d -S -C $@ > Blink.lst
            $(OBJDUMP) -t -C $@ > Blink.sym
            $(OBJCOPY) -O ihex -R .eeprom $@ Blink.hex
            $(SIZE) $@
    
    core.a: $(OBJS)
            $(AR) rcs core.a $(OBJS)
    
    clean:
            rm -f *.o *.d core.a *.elf *.lst *.sym *.hex
    The code compiles fine, prints the memory usage table, and then bails when linking the startup stuff:

    Code:
    ...
    /home/andrew/.bin/arduino-1.8.9/hardware/tools/arm/bin/arm-none-eabi-gcc-ar rcs core.a usb_serial.o usb_desc.o rtc.o keylayouts.o nonstd.o digital.o pwm.o interrupt.o bootdata.o tempmon.o analog.o delay.o eeprom.o usb.o clockspeed.o startup.o debugprintf.o HardwareSerial6.o Tone.o WString.o DMAChannel.o EventResponder.o HardwareSerial1.o WMath.o HardwareSerial8.o Print.o usb_inst.o IntervalTimer.o HardwareSerial7.o Stream.o IPAddress.o HardwareSerial2.o HardwareSerial4.o new.o AudioStream.o HardwareSerial3.o yield.o HardwareSerial5.o HardwareSerial.o
    /home/andrew/.bin/arduino-1.8.9/hardware/tools/arm/bin/arm-none-eabi-gcc -g -Wall -O2 -ffunction-sections -fdata-sections -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-d16 -I. -D__IMXRT1062__ -DTEENSYDUINO=147 -DARDUINO=10809 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -Wl,--gc-sections,--relax,--print-memory-usage -Timxrt1062.ld -larm_cortexM7lfsp_math -lm -lstdc++ -nostdlib --specs=nano.specs -o Blink.elf Blink.o core.a
    Memory region         Used Size  Region Size  %age Used
                ITCM:        5200 B       512 KB      0.99%
                DTCM:       12960 B       512 KB      2.47%
                 RAM:          0 GB       512 KB      0.00%
               FLASH:       11744 B      1984 KB      0.58%
    core.a(startup.o): In function `ResetHandler':
    /home/andrew/.bin/arduino-1.8.9/hardware/teensy/avr/cores/teensy4/startup.c:116: undefined reference to `__libc_init_array'
    core.a(usb.o): In function `usb_init':
    /home/andrew/.bin/arduino-1.8.9/hardware/teensy/avr/cores/teensy4/usb.c:171: undefined reference to `memset'
    core.a(usb.o): In function `usb_endpoint_config':
    /home/andrew/.bin/arduino-1.8.9/hardware/teensy/avr/cores/teensy4/usb.c:548: undefined reference to `memset'
    /home/andrew/.bin/arduino-1.8.9/hardware/teensy/avr/cores/teensy4/usb.c:548: undefined reference to `memset'
    core.a(usb_serial.o): In function `usb_serial_configure':
    /home/andrew/.bin/arduino-1.8.9/hardware/teensy/avr/cores/teensy4/usb_serial.c:92: undefined reference to `memset'
    /home/andrew/.bin/arduino-1.8.9/hardware/teensy/avr/cores/teensy4/usb_serial.c:95: undefined reference to `memset'
    collect2: error: ld returned 1 exit status
    Makefile:27: recipe for target 'Blink.elf' failed
    make: *** [Blink.elf] Error 1
    What else do I need to change?

  2. #2
    Junior Member
    Join Date
    Aug 2019
    Posts
    2
    I am having the same problem, using Arduino-IDE is too restrictive for me, but the makefile does not seem to work.

    Any update on the issue?

  3. #3
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,332
    Quote Originally Posted by exeless View Post
    I am having the same problem, using Arduino-IDE is too restrictive for me, but the makefile does not seem to work.

    Any update on the issue?
    When I wanted to understand how Arduino compiles I simply make the IDE verbose, check the output and note the different compile and link options.
    Only after that I modify the make file.

    If you wanted someone else to do the work for you, you are lucky, search the forum for VisualTeensy.

  4. #4
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    532
    In case you are running under Windows you can have a look at VisualTeensy . It generates makefiles and all the required *.json files to use vsCode as an IDE. If you don't want to use vsCode you should still be able to use the generated makefile as a stating point. If you are under Linux you will need to change the OS specific things (shell, copy, remove etc).

    Alternatively @Defragster maintains a build-script which simply calls the Arduino builder. It should be possible to call that script from any decent editor. You'll find info here in the forum.

    Here a quick youtube video (click on the youtube logo to get a full screen view)



    Edit: Ups, cross post with WMXZ.....
    Last edited by luni; 08-22-2019 at 12:14 PM.

  5. #5
    Junior Member
    Join Date
    Aug 2019
    Posts
    5
    Quote Originally Posted by WMXZ View Post
    When I wanted to understand how Arduino compiles I simply make the IDE verbose, check the output and note the different compile and link options.
    Only after that I modify the make file.

    If you wanted someone else to do the work for you, you are lucky, search the forum for VisualTeensy.
    Ouch. As I stated, I'm using the Arduino IDE verbose compilation output as reference for changes made to the provided teensy4 example Makefile. I can post a diff between the provided Makefile and my already-posted changes to it if that will help.

    The problem is that `make` will dynamically construct the compilation commands using the implicit target rule patterns defined, so there's some magic under the hood that I'm not sure how to cast in order to generate compiler/linker invocations identical to the Arduino IDE.

    Also I do not own a Windows PC for VisualTeensy.

  6. #6
    Junior Member
    Join Date
    Aug 2019
    Posts
    5
    Quote Originally Posted by luni View Post
    In case you are running under Windows you can have a look at VisualTeensy . It generates makefiles and all the required *.json files to use vsCode as an IDE. If you don't want to use vsCode you should still be able to use the generated makefile as a stating point. If you are under Linux you will need to change the OS specific things (shell, copy, remove etc).
    I also do not have access to a Windows PC. I would love if someone could provide one of these generated Makefiles from VisualTeensy. I'd try that as a starting point.

    Quote Originally Posted by luni View Post
    Alternatively @Defragster maintains a build-script which simply calls the Arduino builder. It should be possible to call that script from any decent editor. You'll find info here in the forum.
    Thanks! This seems like the better option instead of an independent Makefile. That way I'd be able to automatically use any updates made to the Arduino toolchain and available libs/boards. Will give this a try.
    Last edited by ardnew; 08-22-2019 at 03:00 PM. Reason: removing embedded video from quote

  7. #7
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    532
    Here a link to defragsters script https://github.com/Defragster/Tset

    I would love if someone could provide one of these generated Makefiles from VisualTeensy.
    Here you are:

    Code:
    #******************************************************************************
    # Generated by VisualTeensy (https://github.com/luni64/VisualTeensy)
    #
    # Board              Teensy 4.0
    # USB Type           Serial
    # CPU Speed          
    # Optimize           Faster
    # Keyboard Layout    US English
    #
    # 22.08.2019 18:07
    #******************************************************************************
    SHELL            := cmd.exe
    export SHELL
    
    TARGET_NAME      := newProject(2)
    BOARD_ID         := TEENSY40
    
    MCU              := imxrt1062
    
    LIBS_SHARED_BASE := C:\Users\lutz\Documents\Arduino\libraries
    LIBS_SHARED      := Encoder 
    
    LIBS_LOCAL_BASE  := lib
    LIBS_LOCAL       := 
    
    CORE_BASE        := C:\Arduino\arduino-1.8.5\hardware\teensy\avr\cores\teensy4
    GCC_BASE         := C:\Arduino\arduino-1.8.5\hardware\tools\arm\bin
    UPL_PJRC_B       := C:\Arduino\arduino-1.8.5\hardware\tools
    UPL_TYCMD_B      := C:\toolchain\TyTools
    
    #******************************************************************************
    # Flags and Defines
    #******************************************************************************
    FLAGS_CPU   := -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16
    FLAGS_OPT   := -O2
    FLAGS_COM   := -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD
    FLAGS_LSP   := 
    
    FLAGS_CPP   := -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing
    FLAGS_C     := 
    FLAGS_S     := -x assembler-with-cpp
    FLAGS_LD    := -Wl,--gc-sections,--relax,--defsym=__rtc_localtime=$(shell powershell [int](Get-Date -UFormat +%s)[0]) -T$(CORE_BASE)/imxrt1062.ld
    
    LIBS        := -larm_cortexM7lfsp_math -lm -lstdc++
    
    DEFINES     := -D__IMXRT1062__ -DTEENSYDUINO=147 -DARDUINO=10807
    DEFINES     += -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH
    
    CPP_FLAGS   := $(FLAGS_CPU) $(FLAGS_OPT) $(FLAGS_COM) $(DEFINES) $(FLAGS_CPP)
    C_FLAGS     := $(FLAGS_CPU) $(FLAGS_OPT) $(FLAGS_COM) $(DEFINES) $(FLAGS_C)
    S_FLAGS     := $(FLAGS_CPU) $(FLAGS_OPT) $(FLAGS_COM) $(DEFINES) $(FLAGS_S)
    LD_FLAGS    := $(FLAGS_CPU) $(FLAGS_OPT) $(FLAGS_LSP) $(FLAGS_LD)
    AR_FLAGS    := rcs
    
    #******************************************************************************
    # Colors
    #******************************************************************************
    COL_CORE    := 
    COL_LIB     := 
    COL_SRC     := 
    COL_LINK    := 
    COL_ERR     := 
    COL_OK      := 
    COL_RESET   := 
    
    #******************************************************************************
    # Folders and Files
    #******************************************************************************
    USR_SRC     := src
    LIB_SRC     := lib
    CORE_SRC    := $(CORE_BASE)
    
    BIN         := .vsteensy/build
    USR_BIN     := $(BIN)/src
    CORE_BIN    := $(BIN)/core
    LIB_BIN     := $(BIN)/lib
    CORE_LIB    := $(BIN)/core.a
    TARGET_HEX  := $(BIN)/$(TARGET_NAME).hex
    TARGET_ELF  := $(BIN)/$(TARGET_NAME).elf
    TARGET_LST  := $(BIN)/$(TARGET_NAME).lst
    
    #******************************************************************************
    # BINARIES
    #******************************************************************************
    CC          := $(GCC_BASE)/arm-none-eabi-gcc
    CXX         := $(GCC_BASE)/arm-none-eabi-g++
    AR          := $(GCC_BASE)/arm-none-eabi-gcc-ar
    OBJCOPY     := $(GCC_BASE)/arm-none-eabi-objcopy
    SIZE        := $(GCC_BASE)/arm-none-eabi-size
    OBJDUMP     := $(GCC_BASE)/arm-none-eabi-objdump
    UPL_PJRC    := "$(UPL_PJRC_B)/teensy_post_compile" -test -file=$(TARGET_NAME) -path=$(BIN) -tools="$(UPL_PJRC_B)" -board=$(BOARD_ID) -reboot
    UPL_TYCMD   := $(UPL_TYCMD_B)/tyCommanderC upload $(TARGET_HEX) --autostart --wait --multi
    UPL_CLICMD  := $(UPL_CLICMD_B)/teensy_loader_cli -mmcu=$(MCU) -v $(TARGET_HEX)
    UPL_JLINK   := $(UPL_JLINK_B)/jlink -commanderscript .vsteensy/flash.jlink
    
    #******************************************************************************
    # Source and Include Files
    #******************************************************************************
    # Recursively create list of source and object files in USR_SRC and CORE_SRC
    # and corresponding subdirectories.
    # The function rwildcard is taken from http://stackoverflow.com/a/12959694)
    
    rwildcard =$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
    
    #User Sources -----------------------------------------------------------------
    USR_C_FILES    := $(call rwildcard,$(USR_SRC)/,*.c)
    USR_CPP_FILES  := $(call rwildcard,$(USR_SRC)/,*.cpp)
    USR_S_FILES    := $(call rwildcard,$(USR_SRC)/,*.S)
    USR_OBJ        := $(USR_S_FILES:$(USR_SRC)/%.S=$(USR_BIN)/%.o) $(USR_C_FILES:$(USR_SRC)/%.c=$(USR_BIN)/%.o) $(USR_CPP_FILES:$(USR_SRC)/%.cpp=$(USR_BIN)/%.o)
    
    # Core library sources --------------------------------------------------------
    CORE_CPP_FILES := $(call rwildcard,$(CORE_SRC)/,*.cpp)
    CORE_C_FILES   := $(call rwildcard,$(CORE_SRC)/,*.c)
    CORE_S_FILES   := $(call rwildcard,$(CORE_SRC)/,*.S)
    CORE_OBJ       := $(CORE_S_FILES:$(CORE_SRC)/%.S=$(CORE_BIN)/%.o) $(CORE_C_FILES:$(CORE_SRC)/%.c=$(CORE_BIN)/%.o) $(CORE_CPP_FILES:$(CORE_SRC)/%.cpp=$(CORE_BIN)/%.o)
    
    
    # User library sources  (see) https://github.com/arduino/arduino/wiki/arduino-ide-1.5:-library-specification
    LIB_DIRS_SHARED  := $(foreach d, $(LIBS_SHARED), $(LIBS_SHARED_BASE)/$d/ $(LIBS_SHARED_BASE)/$d/utility/)  # base and /utility
    LIB_DIRS_SHARED  += $(foreach d, $(LIBS_SHARED), $(LIBS_SHARED_BASE)/$d/src/ $(dir $(call rwildcard,$(LIBS_SHARED_BASE)/$d/src/,*/.)))                           # src and all subdirs of base
    
    LIB_DIRS_LOCAL   := $(foreach d, $(LIBS_LOCAL), $(LIBS_LOCAL_BASE)/$d/ $(LIBS_LOCAL_BASE)/$d/utility/ )    # base and /utility
    LIB_DIRS_LOCAL   += $(foreach d, $(LIBS_LOCAL), $(LIBS_LOCAL_BASE)/$d/src/ $(dir $(call rwildcard,$(LIBS_LOCAL_BASE)/$d/src/,*/.)))                             # src and all subdirs of base
    
    LIB_CPP_SHARED  := $(foreach d, $(LIB_DIRS_SHARED),$(call wildcard,$d*.cpp))
    LIB_C_SHARED    := $(foreach d, $(LIB_DIRS_SHARED),$(call wildcard,$d*.c))
    LIB_S_SHARED    := $(foreach d, $(LIB_DIRS_SHARED),$(call wildcard,$d*.S))
    
    LIB_CPP_LOCAL   := $(foreach d, $(LIB_DIRS_LOCAL),$(call wildcard,$d/*.cpp))
    LIB_C_LOCAL     := $(foreach d, $(LIB_DIRS_LOCAL),$(call wildcard,$d/*.c))
    LIB_S_LOCAL     := $(foreach d, $(LIB_DIRS_LOCAL),$(call wildcard,$d/*.S))
    
    LIB_OBJ         := $(LIB_CPP_SHARED:$(LIBS_SHARED_BASE)/%.cpp=$(LIB_BIN)/%.o)  $(LIB_CPP_LOCAL:$(LIBS_LOCAL_BASE)/%.cpp=$(LIB_BIN)/%.o)
    LIB_OBJ         += $(LIB_C_SHARED:$(LIBS_SHARED_BASE)/%.c=$(LIB_BIN)/%.o)  $(LIB_C_LOCAL:$(LIBS_LOCAL_BASE)/%.c=$(LIB_BIN)/%.o)
    LIB_OBJ         += $(LIB_S_SHARED:$(LIBS_SHARED_BASE)/%.S=$(LIB_BIN)/%.o)  $(LIB_S_LOCAL:$(LIBS_LOCAL_BASE)/%.S=$(LIB_BIN)/%.o)
    
    # Includes -------------------------------------------------------------
    INCLUDE        := -I./$(USR_SRC) -I$(CORE_SRC)
    INCLUDE        += $(foreach d, $(LIB_DIRS_SHARED), -I$d)
    INCLUDE        += $(foreach d, $(LIB_DIRS_LOCAL), -I$d)
    
    # Generate directories --------------------------------------------------------
    DIRECTORIES :=  $(sort $(dir $(CORE_OBJ) $(USR_OBJ) $(LIB_OBJ)))
    generateDirs := $(foreach d, $(DIRECTORIES), $(shell if not exist "$d" mkdir "$d"))
    
    #$(info dirs: $(DIRECTORIES))
    
    $(info$(COL_RESET))
    
    #******************************************************************************
    # Rules:
    #******************************************************************************
    
    .PHONY: directories all rebuild upload uploadTy uploadCLI clean cleanUser cleanCore
    
    
    all:  $(TARGET_LST) $(TARGET_HEX)
    
    rebuild: cleanUser all
    
    clean:   cleanUser cleanCore cleanLib
    	@echo $(COL_OK)cleaning done$(COL_RESET)
    
    upload: all
    	@$(UPL_PJRC)
    
    uploadTy: all
    	@$(UPL_TYCMD)
    
    uploadCLI: all
    	@$(UPL_CLICMD)
    
    uploadJLink: all
    	@$(UPL_JLINK)
    
    
    # Core library ----------------------------------------------------------------
    $(CORE_BIN)/%.o: $(CORE_SRC)/%.S
    	@echo $(COL_CORE)CORE [ASM] $(notdir $<) $(COL_ERR)
    	@"$(CC)" $(S_FLAGS) $(INCLUDE) -o $@ -c $<
    
    $(CORE_BIN)/%.o: $(CORE_SRC)/%.c
    	@echo $(COL_CORE)CORE [CC]  $(notdir $<) $(COL_ERR)
    	@"$(CC)" $(C_FLAGS) $(INCLUDE) -o $@ -c $<
    
    $(CORE_BIN)/%.o: $(CORE_SRC)/%.cpp
    	@echo $(COL_CORE)CORE [CPP] $(notdir $<) $(COL_ERR)
    	@"$(CXX)" $(CPP_FLAGS) $(INCLUDE) -o $@ -c $<
    
    $(CORE_LIB) : $(CORE_OBJ)
    	@echo $(COL_LINK)CORE [AR]  $@ $(COL_ERR)
    	@$(AR) $(AR_FLAGS) $@ $^
    	@echo $(COL_OK)Teensy core built successfully &&echo. 
    
    # Shared Libraries ------------------------------------------------------------
    $(LIB_BIN)/%.o: $(LIBS_SHARED_BASE)/%.S
    	@echo $(COL_LIB)LIB  [ASM] $(notdir $<) $(COL_ERR)
    	@"$(CC)" $(S_FLAGS) $(INCLUDE) -o $@ -c $<
    
    $(LIB_BIN)/%.o: $(LIBS_SHARED_BASE)/%.cpp
    	@echo $(COL_LIB)LIB  [CPP] $(notdir $<) $(COL_ERR)
    	@"$(CXX)" $(CPP_FLAGS) $(INCLUDE) -o $@ -c $<
    
    $(LIB_BIN)/%.o: $(LIBS_SHARED_BASE)/%.c
    	@echo $(COL_LIB)LIB  [CC]  $(notdir $<) $(COL_ERR)
    	@"$(CC)" $(C_FLAGS) $(INCLUDE) -o $@ -c $<
    
    # Local Libraries -------------------------------------------------------------
    $(LIB_BIN)/%.o: $(LIBS_LOCAL_BASE)/%.S
    	@echo $(COL_LIB)LIB  [ASM] $(notdir $<) $(COL_ERR)
    	@"$(CC)" $(S_FLAGS) $(INCLUDE) -o $@ -c $<
    
    $(LIB_BIN)/%.o: $(LIBS_LOCAL_BASE)/%.cpp
    	@echo $(COL_LIB)LIB  [CPP] $(notdir $<) $(COL_ERR)
    	@"$(CXX)" $(CPP_FLAGS) $(INCLUDE) -o $@ -c $<
    
    $(LIB_BIN)/%.o: $(LIBS_LOCAL_BASE)/%.c
    	@echo $(COL_LIB)LIB  [CC]  $(notdir $<) $(COL_ERR)
    	@"$(CC)" $(C_FLAGS) $(INCLUDE) -o $@ -c $<
    
    # Handle user sources ---------------------------------------------------------
    $(USR_BIN)/%.o: $(USR_SRC)/%.S
    	@echo $(COL_SRC)USER [ASM] $< $(COL_ERR)
    	@"$(CC)" $(S_FLAGS) $(INCLUDE) -o $@ -c $< 
    
    $(USR_BIN)/%.o: $(USR_SRC)/%.c
    	@echo $(COL_SRC)USER [CC]  $(notdir $<) $(COL_ERR)
    	@"$(CC)" $(C_FLAGS) $(INCLUDE) -o "$@" -c $<
    
    $(USR_BIN)/%.o: $(USR_SRC)/%.cpp
    	@echo $(COL_SRC)USER [CPP] $(notdir $<) $(COL_ERR)
    	@"$(CXX)" $(CPP_FLAGS) $(INCLUDE) -o "$@" -c $<
    
    # Linking ---------------------------------------------------------------------
    $(TARGET_ELF): $(CORE_LIB) $(LIB_OBJ) $(USR_OBJ)
    	@echo $(COL_LINK)
    	@echo [LD]  $@ $(COL_ERR)
    	@$(CC) $(LD_FLAGS) -o "$@" $(USR_OBJ) $(LIB_OBJ) $(CORE_LIB) $(LIBS)
    	@echo $(COL_OK)User code built and linked to libraries &&echo.
    
    %.lst: %.elf
    	@echo $(COL_LINK)
    	@echo [LST] $@ $(COL_ERR)
    	@$(OBJDUMP) -d -S --demangle --no-show-raw-insn --syms "$<"  > "$@"	
    	@echo $(COL_OK)Sucessfully built project$(COL_RESET) &&echo.
    
    %.hex: %.elf
    	@echo $(COL_LINK)[HEX] $@ 
    	@$(SIZE) "$<"
    	@$(OBJCOPY) -O ihex -R.eeprom "$<" "$@"
    	
    	
    # Cleaning --------------------------------------------------------------------
    cleanUser:
    	@echo $(COL_LINK)Cleaning user binaries...$(COL_RESET)
    	@if exist $(USR_BIN) rd /s/q "$(USR_BIN)"
    	@if exist "$(TARGET_LST)" del $(subst /,\,$(TARGET_LST))
    
    cleanCore:
    	@echo $(COL_LINK)Cleaning core binaries...$(COL_RESET)
    	@if exist $(CORE_BIN) rd /s/q "$(CORE_BIN)"
    	@if exist $(CORE_LIB) del  $(subst /,\,$(CORE_LIB))	
    
    cleanLib:
    	@echo $(COL_LINK)Cleaning user library binaries...$(COL_RESET)
    	@if exist $(LIB_BIN) rd /s/q "$(LIB_BIN)"
    
    # compiler generated dependency info ------------------------------------------
    -include $(CORE_OBJ:.o=.d)
    -include $(USR_OBJ:.o=.d)
    -include $(LIB_OBJ:.o=.d)

  8. #8
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,700
    Quote Originally Posted by luni View Post
    Here a link to defragsters script https://github.com/Defragster/Tset

    ...
    That is the mods I made to FrankB's decoding of how command line can execute the Arduino Builder - combined with TyCommander and an editor like SublimeText I have a great system I like.

    Problem is it is WINDOWS ONLY - TyCommander compiles for Linux.

    But the Compile.CMD itself uses Windows CMD shell operations to make it work. And the TSet extensions likewise use CMD shell prompts and steps to help assemble a BOARD specific version of that on demand.

    Give it a look - I assume Linux script should be able to complete the same tasks …

    Here is a Teensy 4 Compile.cmd script:
    Code:
    @echo off
    SETLOCAL DisableDelayedExpansion EnableExtensions
    rem *******************************
    rem Frank Bösing 11/2018
    rem Windows Batch to compile Arduino sketches
    
    rem Usage:
    rem compile.cmd 0 : compile sketch
    rem compile.cmd 1 : compile & upload sketch
    rem compile.cmd 2 : rebuild & upload sketch
    rem - Attention: Place compile.cmd in Sketch folder!
    rem
    rem Edit these paths:
    
    set arduino=T:\arduino-1.8.9t4
    set TyTools=T:\TyComm
    set libs=T:\tCode\libraries
    set tools=T:\Programs\TSet
    
    rem *******************************
    rem Set Teensy-specific variables here:
    rem
    
    
    REM defragster was here 
    
    set model=teensy40
    set speed=396000000
    set opt=o2std
    set usb=serial
    cd.
    
    rem set keys=de-de
    set keys=en-us
    
    rem *******************************
    rem Don't edit below this line
    rem *******************************
    
    for %%i in (*.ino) do set sketchname=%%i
    if "%sketchname%"=="" (
      echo No Arduino Sketch found!
      exit 1
    )
    
    set myfolder=.\
    set ino="%myfolder%%sketchname%"
    set temp1="%temp%\\arduino_build_%sketchname%"
    set temp2="%temp%\\arduino_cache_%sketchname%"
    set fqbn=teensy:avr:%model%:usb=%usb%,speed=%speed%,opt=%opt%,keys=%keys%
    
    if "%1"=="2" (
      echo Temp: %temp1%
      echo Temp: %temp2%
      del /s /q %temp1%>NUL
      del /s /q %temp2%>NUL
      echo Temporary files deleted.
    )
    
    if not exist %temp1% mkdir %temp1%
    if not exist %temp2% mkdir %temp2%
    
    echo Building Sketch: %ino%
    "%arduino%\arduino-builder" -verbose=1 -warnings=more -compile -logger=human -hardware "%arduino%\hardware" -hardware "%LOCALAPPDATA%\Arduino15\packages" -tools "%arduino%\tools-builder" -tools "%arduino%\hardware\tools\avr" -tools "%LOCALAPPDATA%\Arduino15\packages" -built-in-libraries "%arduino%\libraries" -libraries "%libs%" -fqbn=%fqbn% -build-path %temp1% -build-cache "%temp2%"  %ino%
    
    if not "%1"=="0" (
      if "%errorlevel%"=="0" "%TyTools%\TyCommanderC.exe" upload --autostart --wait --multi "%temp1%\%sketchname%.%model%.hex"
      REM 1052 "%arduino%\hardware\tools\arm\bin\arm-none-eabi-gcc-nm.exe" "%temp1%\%sketchname%.elf" -n | "T:\Programs\TSet\imxrt-size.exe"
      "%arduino%\hardware\tools\arm\bin\arm-none-eabi-gcc-nm.exe" -n "%temp1%\%sketchname%.elf" | "%tools%\imxrt_size.exe"
    )
    
    exit %errorlevel%

  9. #9
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,332
    maybe
    Code:
    -lstdc++ -nostdlib
    is the source of your problem?
    why linking to standard c++ library if you then say no std library

    Also, are you by chance using a newer gcc version than Teensyduino?

  10. #10
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    532
    Might be wrong. but to me it looks like the OP makefile does not handle the *.S files?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •