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

Thread: Compiled for Teensy 4.0 (IMXRT1062), This board is: Teensy 4.1 (IMXRT1062)

  1. #1
    Junior Member
    Join Date
    Jul 2020
    Posts
    6

    Compiled for Teensy 4.0 (IMXRT1062), This board is: Teensy 4.1 (IMXRT1062)

    Hi,
    I'm getting that complaint when my build completes and the Teensy 4.1 I have should be downloaded & reboot. It did work from inside the Arduino environment.

    Build log would be attached, but somehow that's not a valid file. Here's the final few lines of the build output:

    Code:
        /home/chris/Apps/arduino-1.8.13/hardware/tools/arm/bin/arm-none-eabi-g++ -std=gnu++14 -felide-constructors -fno-exceptions -fpermissive -fno-rtti -Wno-error=narrowing -Wall -g -O2 -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -mthumb -MMD -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DU/home/chris/Apps/arduino-1.8.13/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 mainb.elf keylayouts.o usb_midi.o digital.o pwm.o bootdata.o tempmon.o usb_touch.o usb_rawhid.o usb_serial2.o nonstd.o debugprintf.o eeprom.o rtc.o startup.o usb_desc.o analog.o usb_serial3.o interrupt.o usb_mouse.o delay.o usb_joystick.o usb_seremu.o usb.o usb_keyboard.o clockspeed.o usb_serial.o HardwareSerial.o usb_flightsim.o new.o HardwareSerial3.o DMAChannel.o serialEvent.o Print.o serialEventUSB1.o usb_inst.o HardwareSerial7.o serialEvent1.o Stream.o usb_audio.o serialEvent2.o serialEvent7.o AudioStream.o HardwareSerial6.o IPAddress.o serialEvent3.o Tone.o WString.o serialEvent6.o HardwareSerial1.o WMath.o serialEvent8.o serialEvent5.o serialEventUSB2.o HardwareSerial4.o mainb.o HardwareSerial5.o yield.o HardwareSerial8.o HardwareSerial2.o EventResponder.o IntervalTimer.o serialEvent4.o -larm_cortexM7lfsp_math -lm -lstdc++
        /home/chris/Apps/arduino-1.8.13/hardware/tools/arm/bin/arm-none-eabi-size mainb.elf
           text    data     bss     dec     hex filename
          39696    3184   22192   65072    fe30 mainb.elf
        /home/chris/Apps/arduino-1.8.13/hardware/tools/arm/bin/arm-none-eabi-objcopy -O ihex -R .eeprom mainb.elf mainb.hex
        /home/chris/Apps/arduino-1.8.13/hardware/tools/teensy_post_compile -file=mainb -path=/home/chris/Projects/teensy4 -tools=/home/chris/Apps/arduino-1.8.13/hardware/tools
        /home/chris/Apps/arduino-1.8.13/hardware/tools/teensy_reboot
    This is based almost entirely on the teensy4 directory, except I changed the main to write to another GPIO pin (41), and changed ARDUINO_TEENSY40 to ARDUINO_TEENSY41 in the Makefile.
    Everything builds, but something is saying teensy4.0 and not teensy4.1! What's saying that? I put a #error directive in the usb_desc.c file under the ARDUINO_TEENSY40 branch, and that didn't trigger, so the BUILD thinks it is 4.1

    Thanks,
    madGambol

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,701
    This "-Timxrt1062.ld " shows the build process was told the target T_4.0 not T_4.1 which would show "-Timxrt1062_t41.ld "

    The makefile needs to pass in whatever fashion as appropriate :: "model=teensy41" not "model=teensy40"

  3. #3
    Junior Member
    Join Date
    Jul 2020
    Posts
    6
    Thanks for that. I made it work.
    Just changing the symbol MCU to IMXRT1062_T41 didn't fix it. I got a bunch of undefined symbols under core_pins.h.
    I had to copy the contents of imxrt1062_t41.ld into imxrt1062.ld to make it work. But it's working like a 4.0.
    Was the teensy4 directory set up for the teensy4.0 is some prior step? I thought that since the directory wasn't teensy40, that it was intended to cover both parts. To make it work the right way, what should i have done in the beginning?
    Thanks,
    madGambol
    Last edited by madGambol; 07-11-2020 at 10:46 PM. Reason: additional bad news

  4. #4
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,701
    T_4.0 came first and was set up for that device with imxrt design versus the architecture to prior ARM Teensy.

    Using proper build commands that same directory supports the newer T_4.1 as well by selecting the files unique to it - as well as the controlling defines to differentiate where needed on common files.

    There is a problem in the makefile in use not properly indicating the build target.

    The IDE controls this with the indicated : model=teensy41

    How that relates to the makefile build tools in use is not clear.

    Hacking the CORES files should not be needed. It risks confusion and they will be re-written with a new TeensyDuino install - and it also prevents general use switching between 4.0 and 4.1 if needed.

  5. #5
    Junior Member
    Join Date
    Jul 2020
    Posts
    6
    Which IDE are you referring to? The Arduino IDE or some other?
    The Arduino IDE knows that the board is a Teensy 4.1 because it shows that in the Tools->Board selection, but a GPIO bit I'm trying to operate has stopped responding, as though something else thinks its a 4.0. I'm trying to use "LED" pin 41, which isn't on a 4.0.
    This was working earlier inside the Arduino IDE.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,041
    Oh, yeah, the Makefile was designed for Teensy 4.0. It really needs to be updated...

    I believe you need 2 things to make it work properly for Teensy 4.1. As mentioned, you need imxrt1062_t41.ld rather than imxrt1062.ld. But you also need to edit this line:

    Code:
    OPTIONS += -D__$(MCU)__ -DARDUINO=10810 -DTEENSYDUINO=149 -DARDUINO_TEENSY40
    Change -DARDUINO_TEENSY40 to -DARDUINO_TEENSY41.

  7. #7
    Junior Member
    Join Date
    Jul 2020
    Posts
    6
    Paul,

    Quote Originally Posted by PaulStoffregen View Post
    Oh, yeah, the Makefile was designed for Teensy 4.0. It really needs to be updated...

    I believe you need 2 things to make it work properly for Teensy 4.1. As mentioned, you need imxrt1062_t41.ld rather than imxrt1062.ld. But you also need to edit this line:

    Code:
    OPTIONS += -D__$(MCU)__ -DARDUINO=10810 -DTEENSYDUINO=149 -DARDUINO_TEENSY40
    Change -DARDUINO_TEENSY40 to -DARDUINO_TEENSY41.
    When I changed the MCU to IMXRT1062_T41 to properly select the imxrt1062_t41.ld by setting the MCU value, the build fails with complaints about:

    Code:
    /home/chris/Apps/arduino-1.8.13/hardware/tools/arm/bin/arm-none-eabi-gcc  -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_T41__ -DARDUINO=10810 -DTEENSYDUINO=149 -DARDUINO_TEENSY41 -I. -ffunction-sections -fdata-sections  -c -o usb_midi.o usb_midi.c
    In file included from usb_midi.c:33:0:
    core_pins.h: In function 'digitalWriteFast':
    core_pins.h:1232:5: error: 'CORE_PIN0_PORTSET' undeclared (first use in this function)
         CORE_PIN0_PORTSET = CORE_PIN0_BITMASK;
         ^
    core_pins.h:1232:5: note: each undeclared identifier is reported only once for each function it appears in
    core_pins.h:1232:25: error: 'CORE_PIN0_BITMASK' undeclared (first use in this function)
         CORE_PIN0_PORTSET = CORE_PIN0_BITMASK;
                             ^
    core_pins.h:1234:5: error: 'CORE_PIN1_PORTSET' undeclared (first use in this function)
    ...
    The MCU value is used to generate the compile line parameter "-D__IMXRT1062_T41__" which is selecting some bank of symbols in core_pins.h at line 550 with

    Code:
    #elif defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41)
    So generating the __IMXRT1062__ symbol from the MCU doesn't work unless core_pins.h uses the T41 suffix on the symbol at line 550. That little disconnect is repeated in a couple of other files.
    The files: core_pins.h, AudioStream.cpp and pwm.c need adjustment to use the symbol __IMXRT1062_T41__ to make the build go without errors.
    However, the main.hex loads but doesn't run. I think more experience is needed to solve this. I'm just poking at it.

    madGambol

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,041
    Here is a copy of the makefile with the edits I described in msg #6. I tested just now to confirm it does work with Teensy 4.1. But it does not work with Teensy 4.0, so please know you must use either the original or this copy, depending on which board. Eventually I will update the sample makefile in a nicer way, but this is all I can for this moment.
    Attached Files Attached Files

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,041
    I updated the sample Makefile

    https://github.com/PaulStoffregen/co...6b1b05bc1ce044

    Compiling for Teensy 4.1 vs 4.0 involves uncommenting a few lines at the top of the file. Hopefully it's easy to understand from the comments.

Posting Permissions

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