Teensy 4.0 & 4.1

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
alphaFred
Posts: 31
Joined: Wed Apr 15, 2020 6:47 pm

Re: Teensy 4.0 & 4.1

Post by alphaFred » Mon Feb 07, 2022 9:15 pm

You are welcome.

Maybe to elaborate a bit more. The uSHDC peripheral does not support SPI mode. The machine.SDCard driver is configured to use 4bit SD high speed mode with 50MHz. That should give you superior performance in comparison to the SPI driver. If you can not use it however there is no other option right now but to use the SPI driver. As you rightfully did.

User avatar
rdagger
Posts: 143
Joined: Tue Feb 28, 2017 6:16 pm
Contact:

Re: Teensy 4.0 & 4.1

Post by rdagger » Tue Feb 08, 2022 8:41 pm

Mike Teachman wrote:
Mon Feb 07, 2022 5:49 am
@rdagger Some good news. I was able to use your driver to make a prototype of the Teensy playing through the audio shield. I committed a new folder "teensy_audio_shield" to this branch:
https://github.com/miketeachman/micropy ... ree/mimxrt
The folder contains a micropython binary for the Teensy4.1 that supports the I2S class, an example program to play a wav file, and your driver with a couple of minor changes (most important change is to the headphone_select() method).
I’ve been having intermittent issues with the prototype Teensy firmware. Everything works but frequently I’ll be uploading code to the Teensy and it will brick. I have to reload the firmware to get it running again. I'm using VS Code with Pymakr.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Teensy 4.0 & 4.1

Post by Roberthh » Tue Feb 08, 2022 8:48 pm

Try mpremote instead, or upload code to the file system and import if from repl. I do not trust pymakr.

User avatar
Mike Teachman
Posts: 155
Joined: Mon Jun 13, 2016 3:19 pm
Location: Victoria, BC, Canada

Re: Teensy 4.0 & 4.1

Post by Mike Teachman » Wed Feb 09, 2022 4:46 am

rdagger wrote:
Tue Feb 08, 2022 8:41 pm
Everything works but frequently I’ll be uploading code to the Teensy and it will brick.
You have a Teensy4.0, but I built the firmware for a Teensy4.1...could that be a possible root cause?

User avatar
rdagger
Posts: 143
Joined: Tue Feb 28, 2017 6:16 pm
Contact:

Re: Teensy 4.0 & 4.1

Post by rdagger » Wed Feb 09, 2022 5:04 am

Mike Teachman wrote:
Wed Feb 09, 2022 4:46 am
You have a Teensy4.0, but I built the firmware for a Teensy4.1...could that be a possible root cause?
It's possible because it has a lot less flash memory. I'll check if mpremote works better tomorrow.
Teensy Compare 4041.PNG
Teensy Compare 4041.PNG (19.58 KiB) Viewed 11941 times

alphaFred
Posts: 31
Joined: Wed Apr 15, 2020 6:47 pm

Re: Teensy 4.0 & 4.1

Post by alphaFred » Wed Feb 09, 2022 7:05 am

The virtual file system is located from 1 MB upwards.
Hence you are missing 7MB on your Teensy4.0 but your program does not know about it (it is a bit less due to the reserved area at the end of flash memory on the teensy devices - but to keep it simple you are missing 7MB).

When you are loading files to the board that could definitely create issues.

alphaFred
Posts: 31
Joined: Wed Apr 15, 2020 6:47 pm

Re: Teensy 4.0 & 4.1

Post by alphaFred » Wed Feb 09, 2022 7:08 am

Especially since a flash file system should distribute the writes over the whole available memory range to increase flash lifetime.

So I would assume that sometimes it works flawlessly and sometimes it crashes miserably, taking the file system down with it.

User avatar
Mike Teachman
Posts: 155
Joined: Mon Jun 13, 2016 3:19 pm
Location: Victoria, BC, Canada

Re: Teensy 4.0 & 4.1

Post by Mike Teachman » Thu Feb 10, 2022 4:46 am

I committed a firmware file for the Teensy 4.0. Maybe this will give better results?
https://github.com/miketeachman/micropy ... ree/mimxrt

User avatar
rdagger
Posts: 143
Joined: Tue Feb 28, 2017 6:16 pm
Contact:

Re: Teensy 4.0 & 4.1

Post by rdagger » Sat Feb 12, 2022 3:43 am

Mike Teachman wrote:
Thu Feb 10, 2022 4:46 am
I committed a firmware file for the Teensy 4.0. Maybe this will give better results?
https://github.com/miketeachman/micropy ... ree/mimxrt
Thanks for creating the 4.0 firmware!
Unfortunately, I'm getting the following error:
ValueError: invalid MCK pin
The error occurs when the audio_out is initialized:

Code: Select all

MCK_PIN = 23
audio_out = I2S(
    I2S_ID,
    sck=Pin(SCK_PIN),
    ws=Pin(WS_PIN),
    sd=Pin(SD_PIN),
    mck=Pin(MCK_PIN),
    mode=I2S.TX,
    bits=WAV_SAMPLE_SIZE_IN_BITS,
    format=FORMAT,
    rate=SAMPLE_RATE_IN_HZ,
    ibuf=BUFFER_LENGTH_IN_BYTES,
)
I tried uploading the latest 4.1 firmware and it still works.

User avatar
Mike Teachman
Posts: 155
Joined: Mon Jun 13, 2016 3:19 pm
Location: Victoria, BC, Canada

Re: Teensy 4.0 & 4.1

Post by Mike Teachman » Sat Feb 12, 2022 6:15 am

The Teensy 4.0 build was missing the MCK pin definitions. I added them, rebuilt the binary, and committed the updated binary. Hopefully it works now.

Post Reply