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

Thread: Teensy 4.1 binary from alternate toolchain

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

    Teensy 4.1 binary from alternate toolchain

    Hi guys,

    I am a long time lurker, but first time poster. I have been building projects with Teensies for several years using MCUXpresso. I have never had any trouble getting a hello world or blink app up and running on Teensy 3.2, 3.5, or 3.6. I have a 4.1 that am interested in experimenting with FreeRTOS on and it works great building/uploading binaries from Arduino. I seem to have hit a brickwall with the 4.1 building in MCUXpresso, however.

    After studying the NXP docs and the Arduino produced hex file, it seems like I'm producing a proper hex, but I can't get it to run after a couple days of trying.

    At this point here is what I have:

    0x600000: FlexSPI Configuration Block - Basically just copied the Arduino generated block
    0x601000: IVT - Similar, but not identical to Arduino generated (Differences are minor differences in the generated binary, e.g. entry is 0x602000)
    0x601020: Boot Data Structure - Similar, but not identical, length is just set to 0x7C00 rather than the actual image size
    0x602000: Start of vector table and code

    From what I understand so far, this should be all that is needed. I'm assuming the HalfKay is setting the boot mode to b10 (Internal) either through the external pins or fuses.

    As best I can tell, my image never makes it to the startup code. I have tried turning on the LED early in the startup but I have never been able to get it to turn on.

    I would appreciate it if someone took pity on me and pointed out where I have gone astray. As an aside, I don't suppose there is any magic I could send to HalfKay that would boot the RT1062 in Serial Downloader mode??? Any and all suggestions welcome

  2. #2
    Junior Member
    Join Date
    Jul 2020
    Posts
    7
    I thought it might be helpful to include a disassembly so that those more knowledgeable than myself might see something that isn't correct.

    I had to truncate the file to meet the upload size limits, but I believe all the startup relevant data is still available.
    Attached Files Attached Files

  3. #3
    Junior Member
    Join Date
    Sep 2020
    Posts
    6
    I too would like to use a standard tool, such as MCUxpresso (NXP's version of Eclipse). I have been successful using the Teensy loader to load some of the LPUART examples from NXP's SDK, as well as blinky and a couple others. Those work, but the USB "Hello World" does not, it is a bit tough to debug without JTAG/SWdebug. Still looking at possible differences that matter between Teensy and NXP RT1062 eval kit. Wonder if anyone else has been successful going down this path.

  4. #4
    Junior Member
    Join Date
    Jul 2020
    Posts
    7
    Quote Originally Posted by bruceee View Post
    I too would like to use a standard tool, such as MCUxpresso (NXP's version of Eclipse). I have been successful using the Teensy loader to load some of the LPUART examples from NXP's SDK, as well as blinky and a couple others. Those work, but the USB "Hello World" does not, it is a bit tough to debug without JTAG/SWdebug. Still looking at possible differences that matter between Teensy and NXP RT1062 eval kit. Wonder if anyone else has been successful going down this path.
    Hi Bruce, good to know you are interested too. May ask what you are changing in the project in order to have successful boot via Teensy Loader? For example, I tried the evkmimxrt1060_iled_blinky example and I wasn't successful. The only thing I changed was the pin assignment (no LED) and I also added a PRINTF (no debug console output). Did you change the FlexSPI config block? Thanks!

  5. #5
    Junior Member
    Join Date
    Sep 2020
    Posts
    6
    I started with evkmimxrt1060_iled_blinky from the NXP SDK. Then add .hex generation to the project properties -> C build -> settings -Build Steps -> post build

    Code:
    arm-none-eabi-size "${BuildArtifactFileName}"
    arm-none-eabi-objcopy -v -O binary "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.bin"
    arm-none-eabi-objcopy -v -O ihex "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.hex"
    # checksum -p ${TargetChip} -d "${BuildArtifactFileBaseName}.bin"
    Then just accessed the appropriate pins connected to Teensy LED

    Code:
    /*!
     * @brief Main function
     */
    int main(void)
    {
    	volatile int i;
        /* Board pin init */
        BOARD_InitPins();
        BOARD_InitBootClocks();
        /* Update the core clock */
        SystemCoreClockUpdate();
    
         GPIO2->GDIR |= (1 << 3);
    
        while (1)
        {
            /* Delay 1000 ms */
            SysTick_DelayTicks(1000U);
            if (g_pinSet)
            {
                GPIO_PinWrite(GPIO2, 3, 0U);
                g_pinSet = false;
            }
            else
            {
                GPIO_PinWrite(GPIO2, 3, 1U);
                g_pinSet = true;
            }
        }
    Built this code, and then used the Teensy Loader 1.53 to find the .hex file, load it, and run it

    I did the same for a couple others including the LPUART1 example wires added to pins 24,25 and that worked

    But so far the "hello world" examples do not, It would be nice to get the USB serial port working in this environment, but so far no

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,767
    Quote Originally Posted by sceaj View Post
    I'm assuming the HalfKay is setting the boot mode to b10 (Internal) either through the external pins or fuses.
    Not sure if this really matters, but I can tell you boot mode 00 "Boot From Fuses" is used. We never use mode 10 "Internal Boot" on Teensy. The BOOT_MODE1 pin (AD_B0_05) is hard wired to GND, as you can see in the schematic.

    If anyone's curious, this stuff is documented starting on page 202 of the IMXRT1060 reference manual (rev 2).

  7. #7
    Junior Member
    Join Date
    Jul 2020
    Posts
    7
    Thanks for your input bruceee and Paul. I've been working my way through the reference manual and the Teensyduino startup code.

    bruceee: I wasn't so lucky with evkmimxrt1060_iled_blinky. For me, systicks are not generated. So the good news is that the Teensy boots and starts executing user code, but it was getting stuck in SysTick_DelayTicks so I had to modify it as:
    Code:
    void SysTick_DelayTicks(uint32_t n)
    {
        g_systickCounter = n * 20000U;
        while (g_systickCounter != 0U)
        {
        	--g_systickCounter;
        }
    }
    My other project that I started from scratch, never seems to exit from the ROM? As best I can tell everything relevant to boot is pretty much the same between the KSDK sample and my project.

    I'm developing on Windows and Teensy Loader 1.52 appears to be the latest version on that platform. I don't know why it would make a difference, but just out of curiosity, what platform are you developing on? Also, I'm using the latest KSDK, 2.8.2 - may I ask what version you're on?

    I have been able to get the USB virtual device working on all the previous Teensys, but until I can reliably build the simple blink/uart debug console I can't move on to that

  8. #8
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,769
    Quote Originally Posted by sceaj View Post

    I'm developing on Windows and Teensy Loader 1.52 appears to be the latest version on that platform. (
    latest TD is 1.53 (on all platforms)

  9. #9
    Junior Member
    Join Date
    Sep 2020
    Posts
    2
    Hi, I realized that I am not alone in the universe. I am also looking for a way to program Teensy 4.1 without Arduino. I have seen that someone did project by using CircuitPython. However, I want to write a code by using MCUXpresso and load it to Teensy. If someone find a way to program Teensy 4.1 without Arduino, pls let me know. I will be happy.

  10. #10
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,167
    If someone find a way to program Teensy 4.1 without Arduino, pls let me know. I will be happy.
    Maybe this https://github.com/TeensyUser/doc/wiki can make you happy. It has a chapter about alternative toolchains and uploaders.

  11. #11
    Junior Member
    Join Date
    Sep 2020
    Posts
    6
    I have a small debugger running on a Teensy 4.0 generated from MCUxpresso using pins 1,2 for serial (LPUART6 or RX1/TX1 according to PJRC)

    Here is the.hex file, I'll post a zip of the project later today
    https://eisenhard.net/eisenhard/file...interrupt6.hex

    The Teensy loader can load this (one way to get that loader is install the Arduino, then Teensy upgrade, then it is in Program Files (x86)/Arduino/hardware/tools directory.
    Last edited by bruceee; 09-24-2020 at 05:28 PM.

  12. #12
    Junior Member
    Join Date
    Sep 2020
    Posts
    6
    Here is a zip of the MCUxpresso workspace -- still has a number of warnings, as I am still playing with merging my sources with the SDK sources.

    https://eisenhard.net/eisenhard/file...art6_debug.zip

    Back to what I see so far, blinky and these LPUART examples work, though I do not have either SDK hello_world examples working, which leads me to believe there is something before the printf keeping those from working.

  13. #13
    Junior Member
    Join Date
    Jul 2020
    Posts
    7
    Quote Originally Posted by WMXZ View Post
    latest TD is 1.53 (on all platforms)
    WMXZ - I download from here, and the about dialog shows 1.52. Do I need to compile 1.53 from source?

  14. #14
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,769
    Quote Originally Posted by sceaj View Post
    WMXZ - I download from here, and the about dialog shows 1.52. Do I need to compile 1.53 from source?
    here is the link https://www.pjrc.com/teensy/td_download.html

    Teensy.exe is only the downloader program that indeed says 1.52, but the whole system including toolchain is on td_download page.
    maybe I misunderstood your comment (only on loader not on teensyduino)

  15. #15
    Junior Member
    Join Date
    Sep 2020
    Posts
    6
    can't seem to edit an earlier post, above my debugger talks to the serial lines on Teensy 4.0 pins 0,1

    good to know there is an easier way to download the Teensy loader without needing to install Arduino, thanks WMXZ

  16. #16
    Junior Member
    Join Date
    Jul 2020
    Posts
    7
    bruceee - I was able to get the evkmimxrt1060_dev_cdc_vcom_bm bare metal USB virtual com sample running tonight. The zip was too large so a stuffed in a GitHub repo: https://github.com/sceaj/teensy41_vcom

    I added some code that outputs a simple incrementing counter on the USB and a '.' on the debug console just so I could see something "happening". Some interesting points:

    * The code seems to hang in APPInit() until I actually open the COM port with a terminal program.
    * The code doesn't seem to be reading from the virtual COM port (it never echos what I type, but it writes fine).
    * The debug console is opened on LPUART1 (Teensy pins 24/25)

    BTW, that console monitor you had in your example is pretty neat. I'm still trying to understand what the difference between my from scratch project and these KSDK samples that run is

  17. #17
    Junior Member
    Join Date
    Sep 2020
    Posts
    2
    Quote Originally Posted by luni View Post
    Maybe this https://github.com/TeensyUser/doc/wiki can make you happy. It has a chapter about alternative toolchains and uploaders.

    Thank you very much

  18. #18
    Junior Member
    Join Date
    Sep 2020
    Posts
    6
    Sceaj- (finally back to Teensy4.0) I can compile and load the evkmimxrt1060_dev_cdc_vcom_bm MCUx example, and the VCOM port shows up, but I see no output (you seem to) and seems to accept no input.

    I added a heartbeat from led_blinky so I can see the code is alive.

    I tried Tera-Term and another Tcl based serial terminal. Neither see any output. So what are you using?

Posting Permissions

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