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

Thread: using Teensy Makefile

  1. #1
    Junior Member
    Join Date
    Mar 2020
    Posts
    10

    using Teensy Makefile

    I'm trying to use the supplied Makefile to compile code for the teensy4

    On my machine the Makefile is at /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy4

    (I had initially installed Teensyduino over Arduino 1.8.11 but I understand this isn't supported - so I installed Arduino 1.6.13 and reinstalled Teensyduino. Teensyduino reports Arduino 1.8.11 and Teensy 1.5.0 but it also reports that there's an update available, as does Arduino 1.6.13 so I'm not sure exactly what's going on.)

    I can succesfully compile the Blink example with the Makefile if I change Blink.ino to Blink.cpp and add #include "core_pins.h"

    When I flash this .elf onto the Teensy nothing happens. The .elf file from the Makefile is 131K whereas if I compile the sketch using the Teensyduino IDE, Blink.ino.elf is 44K

    The Makefile .elf contains these symbols:

    Code:
    Tims-MacBook-Pro:teensy_template tim$ nm main.elf 
             U ImageVectorTable
             w _Jv_RegisterClasses
             U __bss_end__
             U __bss_start__
             w __deregister_frame_info
    00000020 t __do_global_dtors_aux
             U __fini_array_end
             U __fini_array_start
    6000100c n __frame_dummy_init_array_entry
    60001010 n __init_array_end
    6000100c n __init_array_start
             U __libc_fini
    6000100c n __preinit_array_end
    6000100c n __preinit_array_start
             w __register_frame_info
             U __stack
    20000040 B _ebss
    20000000 D _edata
    20078000 B _estack
    00000080 T _etext
             U _exit
    00000080 T _fini
    00001090 A _flashimagelen
    aaaaaaab A _flexram_bank_config
    20280000 B _heap_end
    20200000 B _heap_start
    60001000 N _init
    00000001 A _itcm_block_count
    20000000 B _sbss
    20000000 D _sdata
    60001094 A _sdataload
    00000000 T _stext
    60001010 A _stextload
    00000024 A _teensy_model_identifier
    20000000 b completed.8605
             U delay
             U digitalWrite
    00000044 t frame_dummy
             U free
             U hardware_init_hook
             U main
             U malloc
    20000004 b object.8610
             U pinMode
             U software_init_hook
    Whereas Blink.ino.elf contains many more symbols:

    Code:
    Tims-MacBook-Pro:Blink tim$ nm /var/folders/29/gch7qs111rbcf0tflgp8cwtw0000gn/T/arduino_build_941999/Blink.ino.elf
    60001020 T BootData
    20000354 D F_BUS_ACTUAL
    20000358 D F_CPU_ACTUAL
    60000000 T FlexSPI_NOR_Config
    00000248 W HardFault_HandlerC
    60001000 T ImageVectorTable
    60001034 T ResetHandler
             w _Jv_RegisterClasses
    00000238 t _MSP
    20000c00 B _VectorsRam
    00001a88 W _Z11serialEventv
    20000848 B _ZN11MillisTimer10listActiveE
    20000858 B _ZN11MillisTimer11listWaitingE
    000011f8 T _ZN11MillisTimer12runFromTimerEv
    00001190 T _ZN11MillisTimer15addToActiveListEv
    20000850 B _ZN14EventResponder10firstYieldE
    0000112c W _ZN14EventResponder12triggerEventEiPv
    20000844 B _ZN14EventResponder13lastInterruptE
    20000840 B _ZN14EventResponder14firstInterruptE
    00001148 T _ZN14EventResponder16runFromInterruptEv
    20000854 B _ZN14EventResponder16runningFromYieldE
    000010ac T _ZN14EventResponder24triggerEventNotImmediateEv
    2000084c B _ZN14EventResponder9lastYieldE
    00001a60 T _ZN14HardwareSerial19processSerialEventsEv
    20000860 B _ZN14HardwareSerial27serial_event_handler_checksE
    2000087c B _ZN14HardwareSerial28serial_event_handlers_activeE
    2000085c b _ZZ5yieldE7running
    60001710 t ____libc_init_array_veneer
    00001b80 t ___init_veneer
             U __bss_end__
             U __bss_start__
    60001720 t __delay_veneer
             w __deregister_frame_info
    00000020 t __do_global_dtors_aux
             U __fini_array_end
             U __fini_array_start
    60001758 t __frame_dummy_init_array_entry
    6000175c T __init_array_end
    60001758 T __init_array_start
             U __libc_fini
    00001a94 T __libc_init_array
    60001738 t __main_veneer
    60001718 t __memset_veneer
    60001758 T __preinit_array_end
    60001758 T __preinit_array_start
    60001740 t __pwm_init_veneer
             w __register_frame_info
    60001750 t __set_arm_clock_veneer
             U __stack
    60001728 t __startup_early_hook_veneer
    60001748 t __startup_late_hook_veneer
    60001730 t __usb_init_serialnumber_veneer
    200022a0 B _ebss
    20000360 D _edata
    20078000 B _estack
    00001b90 T _etext
    00001b90 T _fini
    00003650 A _flashimagelen
    aaaaaaab A _flexram_bank_config
    20280000 B _heap_end
    20201880 b _heap_start
    60001704 T _init
    00000001 A _itcm_block_count
    20000360 B _sbss
    20000000 D _sdata
    600032f4 A _sdataload
    00000000 T _stext
    60001760 A _stextload
    00000024 A _teensy_model_identifier
    60001584 T analog_init
    2000085d b calibrating
    20000360 b completed.8605
    6000129c T configure_cache
    000000ac T delay
    20000328 d device_descriptor
    0000019c T digitalWrite
    00000178 t digitalWrite.part.0
    20000000 D digital_pin_to_info_PGM
    200003c8 b endpoint0_buffer
    200003ac b endpoint0_notify_mask
    200003b8 b endpoint0_setupdata
    20001020 B endpoint0_transfer_ack
    20001000 B endpoint0_transfer_data
    00000368 t endpoint0_transmit.constprop.1
    2000039c b endpointN_notify_mask
    20002000 B endpoint_queue_head
    00000044 t frame_dummy
             U hardware_init_hook
    0000040c t isr
    00000084 T loop
    000012b0 T main
    00001360 T memcpy
    00001ae4 T memset
    20000364 b object.8610
    0000118c T pendablesrvreq_isr
    000001a8 T pinMode
    000017a8 T pwm_init
    600016f8 t qualifier_descriptor
    200003c0 b reply_buffer
    00000330 t run_callbacks
    200004c0 b rx_available
    2000069c b rx_available
    20200080 b rx_buffer
    20201480 b rx_buffer
    200003dc b rx_count
    00000c9c t rx_event
    00000ed4 t rx_event
    200003d8 b rx_head
    200006a0 b rx_head
    200004c4 b rx_index
    20000680 b rx_index
    20000564 b rx_list
    20000690 b rx_list
    200003d2 b rx_packet_size
    00000c30 t rx_queue_transfer
    00000e70 t rx_queue_transfer
    200003da b rx_tail
    2000056b b rx_tail
    20000400 b rx_transfer
    20000580 b rx_transfer
    20000394 b s_hotCount
    20000388 b s_hotTemp
    2000038c b s_hot_ROOM
    20000390 b s_roomC_hotC
    20000380 B scale_cpu_cycles_to_microseconds
    000002d4 t schedule_transfer
    20000304 d seremu_report_desc
    00001494 T set_arm_clock
    0000007c T setup
    200003a0 b sof_usage
             U software_init_hook
    00000240 T startup_default_early_hook
    00000244 T startup_default_late_hook
    00000240 W startup_early_hook
    00000244 W startup_late_hook
    6000160c T string0
    2000037c B systick_cycle_count
    00001290 T systick_isr
    20000384 B systick_millis_count
    20000880 B systick_safe_read
    600013a0 T tempmon_init
    200003db b transmit_previous_timeout
    200003d4 b tx_available
    2000069a b tx_available
    20000560 b tx_head
    2000056d b tx_head
    200003d9 b tx_noautoflush
    2000056c b tx_noautoflush
    200003d6 b tx_packet_size
    00001028 T tx_queue_transfer
    200004e0 b tx_transfer
    200006c0 b tx_transfer
    00000ff8 T tx_zero_pad
    20200c80 b txbuffer
    20201580 b txbuffer
    00001758 T ultoa
    00000228 T unused_interrupt_vector
    60001610 T usb_config_descriptor_12
    60001684 T usb_config_descriptor_480
    00000a90 T usb_config_rx
    00000af4 T usb_config_tx
    200003d0 B usb_configuration
    20200000 B usb_descriptor_buffer
    20000280 D usb_descriptor_list
    2000035c D usb_enable_serial_event_processing
    200003a8 B usb_high_speed
    60001498 T usb_init
    00000bd8 T usb_init_serialnumber
    00000d00 T usb_midi_configure
    00000dd4 T usb_midi_flush_output
    6000133c T usb_pll_start
    00000b5c T usb_prepare_transfer
    200003b0 b usb_reboot_timer
    00000bb4 T usb_receive
    00000fe0 T usb_seremu_available
    00000f2c T usb_seremu_configure
    00001090 t usb_seremu_flush_callback
    00000a64 T usb_stop_sof_interrupts
    600015f4 V usb_string_manufacturer_name
    600015f4 T usb_string_manufacturer_name_default
    600015dc V usb_string_product_name
    600015dc T usb_string_product_name_default
    2000033c V usb_string_serial_number
    2000033c D usb_string_serial_number_default
    20000398 B usb_timer0_callback
    200003a4 B usb_timer1_callback
    00000b8c T usb_transmit
    6000102c T vector_table
    000012c0 W yield
    Any suggestions?

  2. #2
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,566
    there is no Arduino1.8.13 supported (could be a typo?) Install 1.8.12

  3. #3
    Junior Member
    Join Date
    Mar 2020
    Posts
    10
    Quote Originally Posted by WMXZ View Post
    there is no Arduino1.8.13 supported (could be a typo?) Install 1.8.12
    Yes, sorry that is a typo.

    I installed Arduino 1.6.13 as it says on this site that this is the latest supported version. However Teensyduino reports the Arduino version as 1.8.11, maybe the installer is standalone now?

  4. #4
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,933
    On a MAC right? On the TeensyDuino download page are two MAC versions. Lower numbered is an IDE 1.8.12 then TD 1.51 install.

    For newer version MAC OS the Higher number - it is a single install: TeensyDuino 1.51 is packed in the Arduino 1.8.12.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,473
    Quote Originally Posted by TimRedfern View Post
    Arduino 1.6.13 as it says on this site that this is the latest supported version.
    The website's download page says "Teensyduino 1.51 supports Arduino versions 1.8.5 and 1.8.9 and 1.8.11 and 1.8.12".

    Click image for larger version. 

Name:	sc.png 
Views:	6 
Size:	67.8 KB 
ID:	19270

  6. #6
    Junior Member
    Join Date
    Mar 2020
    Posts
    10
    ok thanks, I'll update to 1.51 and try the Makefile again

  7. #7
    Member
    Join Date
    Jan 2020
    Location
    Port Elizabeth
    Posts
    46
    Tim, if you don't mind me asking. What is your goal using make? Is it an educational experiment? Do you need a makefile so that you can integrate Arduino into your favourite editor/programming environment? Or do you have certain very specific needs that can only be met with a customized build process?

  8. #8
    Junior Member
    Join Date
    Mar 2020
    Posts
    10
    I'm working on a hardware prototyping project and we are presently using Teensy4 for it's USB MIDI support.

    I find the Arduino IDE too limiting for serious work, and the build system isn't transparent - it leads to source code that gcc can't compile.

    I want to get the Makefile build working so as to develop in eclipse, and to allow a CI workflow.

  9. #9
    Member
    Join Date
    Jan 2020
    Location
    Port Elizabeth
    Posts
    46
    Tim, like you I found the Arduino to be impossibly limiting for serious work. The main problem is this. Large programs became difficult to edit in the Arduino IDE because I was spending too much time scrolling back and forth through several thousand lines hunting for specific functions, variables, structs classes, objects and their methods.

    What I wanted was an editor that displays in the left hand pane all available classes, structs, functions, variables etc. This would serve as the master index to my program and I could easily jump to the relevant portion of the program by clicking on an entry in the left hand pane. This was really important to me and the only program that fully met these requirements was Geany.

    Geany allows one to call makefiles and I thought I had the answer. But creating the Arduino/Teensy makefile turned out to be more tricky than I would have liked. I abandoned this path because I discovered that I could achieve exactly the same thing by calling arduino-builder. Arduino-builder is called by the Arduino IDE to create and execute the makefile.

    And so I created a bash script that is called from Geany as follows:- build-arduino base_path target_path target_name [-verbose] It assembles all the necessary parameters and passes them to arduino-builder and this does all the hard work.
    This is my bash script
    Code:
    #!/bin/bash
    #teensy builder
    
    BASE_PATH=$1
    TARGET_PATH=$2
    TARGET_NAME=$3
    VERBOSE=$4
    
    p0="-dump-prefs"
    p1="-compile"
    p2="-logger=human"
    p3="-hardware $BASE_PATH/../installation/hardware"
    p4="-hardware $HOME/.arduino15/packages"
    p5="-tools $BASE_PATH/../installation/tools-builder"
    p6="-tools $BASE_PATH/../installation/hardware/tools/avr"
    p7="-tools $HOME/.arduino15/packages"
    p8="-built-in-libraries $BASE_PATH/../installation/libraries"
    p9="-libraries $BASE_PATH/../libraries"
    p10="-libraries $BASE_PATH/libraries"
    p11="-libraries $TARGET_PATH/libraries"
    p12="-fqbn=teensy:avr:teensy40:usb=serial,speed=600,opt=o2std,keys=en-us"
    p13="-ide-version=10812"
    p14="-build-path $TARGET_PATH/build"
    p15="-warnings=default"
    p16="-build-cache $TARGET_PATH/cache"
    p17=""
    p18="$TARGET_PATH/$TARGET_NAME" 
    
    echo "$VERBOSE Compile started, watch this space..."
    
    if [ "$VERBOSE" == "-verbose" ];
    then
      p17="-verbose"
      $HOME/Arduino/installation/arduino-builder $p0 $p2 $p3 $p4 $p5 $p6 $p7 $p8 $p9 $p10 $p11 $p12 $p13 $p14 $p15 $p16 $p17 $p18
    fi
    
    $HOME/Arduino/installation/arduino-builder $p1 $p2 $p3 $p4 $p5 $p6 $p7 $p8 $p9 $p10 $p11 $p12 $p13 $p14 $p15 $p16 $p17 $p18
    RETURN=$?
    echo "Compile completed"
    echo "Project: $1"
    echo "Folder: $2"
    echo "Target: $3"
    
    exit $RETURN
    The output integrates nicely into Geany.
    The compiled file I load into the Teensy with the following Bash script:-
    Code:
    #!/bin/bash
    # upload Teensy
    
    BASE_PATH=$1
    TARGET_PATH=$2
    TARGET_NAME=$3
    
    echo "Teensy upload"
    echo $BASE_PATH
    echo $TARGET_PATH
    echo $TARGET_NAME
    
    suffix="/manufacturer"
    string=`ack -s -l "Teensyduino" "/sys/devices/pci0000:00"`
    TARGET_PORT=${string%"$suffix"}
    echo $TARGET_PORT
    
    
    p1="-file=$TARGET_NAME"
    p2="-path=$TARGET_PATH/build"
    p3="-tools=$BASE_PATH/../installation/hardware/tools"
    p4="-board=TEENSY40"
    p5="-reboot"
    p6="-port=$TARGET_PORT"
    p7="-portlabel=/dev/bus/usb/001/054 Bootloader"
    p8="-portprotocol=Teensy"
    
    $HOME/Arduino/installation/hardware/tools/teensy_post_compile $p1 $p2 $p3 $p4 $p5 $p6 $p7 $p8
    RETURN=$?
    echo "Upload completed"
    sleep 2  # don't start putty too quickly
    nohup /usr/bin/putty -load arduino &
    exit $RETURN
    I use the custom build command in Geany to call my build and upload bash scripts. In my case F8 does the build and F5 does the upload.
    When the upload process is completed PuTTY is called to view the output of Serial. I like PuTTY because it placys nicely with the Teensy.

    Note that I find the USB path to the Teensy as follows
    Code:
    suffix="/manufacturer"
    string=`ack -s -l "Teensyduino" "/sys/devices/pci0000:00"`
    TARGET_PORT=${string%"$suffix"}
    It is a bit of a sledgehammer approach but it works well for me. It might work differently on the Mac.

    My experience so far has been very good. I now have a pleasant and very productive programming environment.
    I have described all this in the hope that it might help you with your problem.

  10. #10
    Member
    Join Date
    Jan 2020
    Location
    Port Elizabeth
    Posts
    46
    I should have mentioned that my programming environment is Ubuntu Linux 19.10

  11. #11
    Junior Member
    Join Date
    Mar 2020
    Posts
    10
    I'm trying the 1.51 Makefile and I still get the same problem.

    I think the issue probably stems from this command/ error:

    Code:
    /Applications/Teensyduino.app/Contents/Java/hardware/tools/arm/bin/arm-none-eabi-g++ -std=gnu++14 -felide-constructors -fno-exceptions -fpermissive -fno-rtti -Wno-error=narrowing -I/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy4 -Wall -g -O2 -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -mthumb -MMD -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE -D__IMXRT1062__ -DARDUINO=10810 -DTEENSYDUINO=149 -DARDUINO_TEENSY40 -I. -ffunction-sections -fdata-sections  -c -o main.o main.cpp
    /Applications/Teensyduino.app/Contents/Java/hardware/tools/arm/bin/arm-none-eabi-gcc -Os -Wl,--gc-sections,--relax  -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -mthumb -T/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy4/imxrt1062.ld -o main.elf  main.o -larm_cortexM7lfsp_math -lm -lstdc++
    /Applications/Teensyduino.app/Contents/Java/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol ImageVectorTable; not setting start address
    To explain my approach, I copied the Makefile to the directory with my source code and I set the variable ARDUINOPATH - I had to change a few other lines

    Code:
    Tims-MacBook-Pro:teensy_template tim$ diff /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy4/Makefile Makefile
    68c68
    < ARDUINOPATH ?= ../../../../..
    ---
    > ARDUINOPATH = /Applications/Teensyduino.app/Contents/Java
    70a71,73
    > TEENSYPATH = $(ARDUINOPATH)/hardware/teensy/avr/cores/teensy4
    > CPPFLAGS = -I$(TEENSYPATH)
    > 
    94c97
    < CPPFLAGS = -Wall -g -O2 $(CPUOPTIONS) -MMD $(OPTIONS) -I. -ffunction-sections -fdata-sections
    ---
    > CPPFLAGS += -Wall -g -O2 $(CPUOPTIONS) -MMD $(OPTIONS) -I. -ffunction-sections -fdata-sections
    142c145
    < MCU_LD = $(LOWER_MCU).ld
    ---
    > MCU_LD = $(ARDUINOPATH)/hardware/teensy/avr/cores/teensy4/$(LOWER_MCU).ld
    Has anyone had any luck with the Makefile?

  12. #12
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,473
    Quote Originally Posted by TimRedfern View Post
    Has anyone had any luck with the Makefile?
    As a quick sanity check, I just ran "make" from the command line on MacOS 10.15.3, using the original Makefile from within the folder deep in the Teensyduino.app bundle. It compiles without any error. Here's a screenshot.

    Click image for larger version. 

Name:	sc.jpg 
Views:	18 
Size:	143.5 KB 
ID:	19289

    The "Error 1 (ignored)" on the last line is simply because I didn't have a Teensy plugged into that Mac at the time. You can see it did indeed compile main.hex successfully.

  13. #13
    Junior Member
    Join Date
    Mar 2020
    Posts
    10
    Hi, thanks, could you explain how you ran make using the original Makefile?

    I tried this:

    Code:
    Tims-MacBook-Pro:Blink tim$ export ARDUINOPATH=/Applications/Teensyduino.app/Contents/Java
    Tims-MacBook-Pro:Blink tim$ make -f /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy4/Makefile
    /Applications/Teensyduino.app/Contents/Java/hardware/tools/arm/bin/arm-none-eabi-gcc -Os -Wl,--gc-sections,--relax  -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -mthumb -Timxrt1062.ld -o main.elf   -larm_cortexM7lfsp_math -lm -lstdc++
    /Applications/Teensyduino.app/Contents/Java/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: cannot open linker script file imxrt1062.ld: No such file or directory
    collect2: error: ld returned 1 exit status
    make: *** [main.elf] Error 1

  14. #14
    Member
    Join Date
    Jan 2020
    Location
    Port Elizabeth
    Posts
    46
    Tim, this is why I think the 'arduino-builder' approach is the better way to go. It takes care of all the details, is simple and is guaranteed to work. And you can embed it into the workflow of your choice so that you no longer have to use the Arduino IDE, although you must have it installed.

  15. #15
    Junior Member
    Join Date
    Mar 2020
    Posts
    10
    Hi, I hear what you're saying, my main problem with arduino builder is that it uses the arduino build system, which is opaque and non standard. Arduino source code isn't valid C++

  16. #16
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,566
    Quote Originally Posted by TimRedfern View Post
    Hi, I hear what you're saying, my main problem with arduino builder is that it uses the arduino build system, which is opaque and non standard. Arduino source code isn't valid C++
    Since you are insisting:
    1) Arduino pre-compiler does not mind if you use standard C++
    2) Apart from pre-compiler, standard C++ compilers are used to generate execitable
    3) You can put all your code into a cpp file and keep ino files empty, Arduino does not complain.
    4) If you are so qualified to discuss Arduino pre-compiler, why do you struggle with simple makefiles?

  17. #17
    Junior Member
    Join Date
    Mar 2020
    Posts
    10
    Quote Originally Posted by WMXZ View Post
    Since you are insisting:
    1) Arduino pre-compiler does not mind if you use standard C++
    2) Apart from pre-compiler, standard C++ compilers are used to generate execitable
    3) You can put all your code into a cpp file and keep ino files empty, Arduino does not complain.
    My problem is that code that works with the Arduino pre-compiler won't necessarily work when brought to a normal compiler so I prefer not to use it.

    4) If you are so qualified to discuss Arduino pre-compiler, why do you struggle with simple makefiles?
    Nice.

  18. #18
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,566
    Quote Originally Posted by TimRedfern View Post
    My problem is that code that works with the Arduino pre-compiler won't necessarily work when brought to a normal compiler so I prefer not to use it.
    That is why most of my programs use empty ino files and have all code in cpp file. Arduino does not interfere with cpp files. And I use makefiles.
    HOWEVER, before asking on this forum for help, or providing SW for other teensy users, I test my program so that it compiles and run from Arduino IDE.
    As you know, you can easily change editor.

  19. #19
    Member
    Join Date
    Jan 2020
    Location
    Port Elizabeth
    Posts
    46
    Tim, what you are doing is a great educational exercise and for that reason is well worth doing. But is it a practical necessity, given your goals? That is your call. All I can do is quote my own experience. I needed to get results and the Arduino IDE was a formidable obstacle. Embedding the build process, via 'arduino-builder' into a more productive programming environment solved my problem. I am working within the Arduino ecosystem so I accepted the necessary commitment to a certain programming style that it entailed.

    But then every environment is like that and I have been through many of them. I still have fond memories of the HP1000 with its real time operating system, RTE-A. See https://en.wikipedia.org/wiki/HP-1000/RTE. But note that this brief Wikipedia entry is a disservice to a magnificent machine.

    Good luck with your search and please keep us updated.

  20. #20
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,473
    Quote Originally Posted by TimRedfern View Post
    could you explain how you ran make using the original Makefile?
    First, you need to have Apple's command line developer tools. If you lack the command line tools, "make" will be a command not found. The tools can be installed with "xcode-select --install". You probably already have this if you're been running make, but I'm spelling this part out just in case (and for people who may find this in the future by searching).

    Once you have the command line tools, just open Terminal. Use the "cd" command to change to the folder deep within the Teensyduino.app folder where the Makefile is located. See the screenshot (msg #12). In my case, Teensyduino.app was in my Downloads folder. If you have it somewhere else on your Mac, type the pathname where it actually is located.

    Then just type "make". That's it. So easy.

  21. #21
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,543
    His problem is, he tries to use it from his sourcecode directory.
    Should be not too difficult to solve that.

  22. #22
    Junior Member
    Join Date
    Mar 2020
    Posts
    10
    Quote Originally Posted by PaulStoffregen View Post
    First, you need to have Apple's command line developer tools. If you lack the command line tools, "make" will be a command not found. The tools can be installed with "xcode-select --install". You probably already have this if you're been running make, but I'm spelling this part out just in case (and for people who may find this in the future by searching).

    Once you have the command line tools, just open Terminal. Use the "cd" command to change to the folder deep within the Teensyduino.app folder where the Makefile is located. See the screenshot (msg #12). In my case, Teensyduino.app was in my Downloads folder. If you have it somewhere else on your Mac, type the pathname where it actually is located.

    Then just type "make". That's it. So easy.
    Hi Paul, I have commandline tools installed etc. To give context, I work with several other embedded toolchains.

    I would normally expect to run make from the project sourcecode directory. Looking at the Makefile, CPP_FILES := $(wildcard *.cpp) so this seems to be the case.

    I don't understand how the Makefile would find the project sourcecode files, if make is run from the directory within the teensyduino app were the teensy4 source code lives.

    This is what I see when I run make in the teensy4 source code directory:

    Code:
    Tims-MacBook-Pro:teensy4 tim$ make
    /Applications/Teensyduino.app/Contents/Java/hardware/tools/arm/bin/arm-none-eabi-gcc -Os -Wl,--gc-sections,--relax  -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -mthumb -Timxrt1062.ld -o main.elf analog.o bootdata.o clockspeed.o debugprintf.o delay.o digital.o eeprom.o interrupt.o keylayouts.o nonstd.o pwm.o rtc.o startup.o tempmon.o usb.o usb_desc.o usb_joystick.o usb_keyboard.o usb_midi.o usb_mouse.o usb_rawhid.o usb_seremu.o usb_serial.o usb_touch.o AudioStream.o DMAChannel.o EventResponder.o HardwareSerial.o HardwareSerial1.o HardwareSerial2.o HardwareSerial3.o HardwareSerial4.o HardwareSerial5.o HardwareSerial6.o HardwareSerial7.o HardwareSerial8.o IPAddress.o IntervalTimer.o Print.o Stream.o Tone.o WMath.o WString.o main.o new.o usb_flightsim.o usb_inst.o yield.o -larm_cortexM7lfsp_math -lm -lstdc++
    startup.o: In function `ResetHandler':
    /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy4/startup.c:137: undefined reference to `main'
    collect2: error: ld returned 1 exit status
    make: *** [main.elf] Error 1
    Last edited by TimRedfern; 03-06-2020 at 03:05 PM.

  23. #23
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,543
    I don't understand how the Makefile would find the project sourcecode files, if make is run from the directory within the teensyduino app were the teensy4 source code lives.
    It uses the main.cpp file in the core directory. It is an example only. If you want to use it from your sourcecode-directory you have to write your own Makefile.
    There are some examples mentioned as comment in"Makefile"

    Quote Originally Posted by TimRedfern View Post
    Hi Paul, I have commandline tools installed etc. To give context, I work with several other embedded toolchains.
    So you are used to make and its makefiles.

    Not sure why you don't use the builder. Make can call the builder, too. It's a commandline-tool. Or just use the builder instead of make.
    You win nothing with your system and a std compilation, and it will be compatible to nothing but your ideas. All you can expect is running into compatibility-problems.
    Edit: If you use the Arduino-libraries you're using Arduino anyway. Your're just trying to make it invisible! Using Arduino but not its build-system is a hack.

    PDOS showed in Post#9 how to use the builder.
    Last edited by Frank B; 03-06-2020 at 09:52 PM.

  24. #24
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,473
    Quote Originally Posted by TimRedfern View Post
    This is what I see when I run make in the teensy4 source code directory:
    I'm guessing you copied or moved the "teensy4" folder outside of its original location from deep within Teensyduino.app. Is that right?

    Did you try simply running "make" from that original directory location within Teensyduino.app? As you can see in the screenshot I posted on msg #12, it absolutely does work when run there. Before you start moving and modifying stuff, maybe run it there first and know it works before you change things?

    There are many other makefiles and other ways. Using arduino-builder as Frank suggested can also work. But if you're stuck, before you try *anything* else, please do yourself a favor and at least get make to run successfully with the original known-good makefile in the original location.

    Or alternately, you could save yourself a lot of trouble fiddling with all this build stuff by just using Arduino. It has an "external editor" option in File > Preferences, so you can use your favorite editor and just use Arduino to build the code. If you're spending this much time and frustration merely to make what ought to be pretty minor makefile changes, perhaps in the end the minor extra moment to click Arduino's button to build is a net savings compared to all this time and struggle to fiddle with hacking makefiles?

  25. #25
    Junior Member
    Join Date
    Mar 2020
    Posts
    10
    I'm guessing you copied or moved the "teensy4" folder outside of its original location from deep within Teensyduino.app. Is that right?
    No, I didn't move or copy the folder

    Did you try simply running "make" from that original directory location within Teensyduino.app? As you can see in the screenshot I posted on msg #12, it absolutely does work when run there. Before you start moving and modifying stuff, maybe run it there first and know it works before you change things?
    Yes, this is what I tried, you can see the command and the result in my post above. Your screenshot in msg 12 shows that something succeeded but doesn't show what command you used.

    Anyway thanks for your help, it's not a big issue so don't worry about it! I just wanted to find out if this was workable.

Posting Permissions

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