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.
User avatar
rcolistete
Posts: 205
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil

Re: Teensy 4.0

Post by rcolistete » Mon Jan 13, 2020 1:02 pm

@Roberthh : there are many differences between CircuitPython x MicroPython :
https://circuitpython.readthedocs.io/en ... icropython
AFAIK, even v5.0.0 doesn't have interrupts and deepsleep, so I can't use CircuitPython in many projects.

And some features are simplified, e. g., "analogio.AnalogIn(pin)" doesn't allow to configure the ADC of each board (resolution, gain, etc).

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

Re: Teensy 4.0

Post by Roberthh » Mon Jan 13, 2020 3:41 pm

Yes. I gave it a short test. The core features seem to be there. I could run upysh and easily adapt the pye() Editor.
But with other test it simply stalls, like entering microcontroller.cpu.temperature
But they have added some functionality to disable concurrent access by the host and the module to the file system. No example yet how to disable host file access and keep USB REPL.

User avatar
rcolistete
Posts: 205
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil

Re: Teensy 4.0

Post by rcolistete » Mon Jan 13, 2020 4:54 pm

Bugs so far :
- CircuitPython halts after :

Code: Select all

import microcontroller
microcontroller.cpu.temperature
Also pointed by @Roberthh;
- REPL disconnects after pasting more than approx. 4 lines in paste mode (CTRL+E). I have to disconnect from the USB port and connect to REPL work again.

User avatar
pythoncoder
Posts: 4242
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Teensy 4.0

Post by pythoncoder » Tue Jan 14, 2020 7:57 am

Roberthh wrote:
Mon Jan 13, 2020 7:19 am
...Porting driver code from Circuitpython to Micropython typically results in throwing away pretty many lines of code...
Indeed, I was amazed how many. I understand what they are trying to do: make the driver easily used by absolute beginners. In consequence the code is hard to follow and performance is sacrificed. Porting drivers from C is often simpler than porting them from CP.

I guess it's a matter of coding style but I assume drivers will be used by experimenters and aim to make their operation understandable.
Peter Hinch

User avatar
rcolistete
Posts: 205
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil

Re: Teensy 4.0

Post by rcolistete » Tue Jan 14, 2020 3:29 pm

rcolistete wrote:
Mon Jan 13, 2020 4:54 pm
Bugs so far :
- CircuitPython halts after :

Code: Select all

import microcontroller
microcontroller.cpu.temperature
Also pointed by @Roberthh;
- REPL disconnects after pasting more than approx. 4 lines in paste mode (CTRL+E). I have to disconnect from the USB port and connect to REPL work again.
One new issue :
- ampy doesn't work with Teensy 4.0 #2516.

Neither 'mpfshell' and 'rshell', but they aren't compatible with CircuitPython boards. Ampy is from Adafruit and should work with all CircuitPython boards.

Mu Editor in CircuitPython mode works with Teensy 4.0.

User avatar
jimmo
Posts: 1681
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Teensy 4.0

Post by jimmo » Thu Jan 23, 2020 1:54 am

I implemented the start of a basic port of MicroPython to the Teensy 4.0 -- PR at https://github.com/micropython/micropython/pull/5558

It's at the same level as the SAMD port in functionality (REPL over USB VCP), but it should be very straightforward to add basic Pin support.

One thing I noticed straight off the bat... as expected, this chip (the i.MX RT 1062) is _fast_. Power consumption is pretty low too, and it's very fast to flash firmware onto thanks to the way the loader works.

User avatar
rcolistete
Posts: 205
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil

Re: Teensy 4.0

Post by rcolistete » Fri Jan 24, 2020 11:27 pm

jimmo wrote:
Thu Jan 23, 2020 1:54 am
I implemented the start of a basic port of MicroPython to the Teensy 4.0 -- PR at https://github.com/micropython/micropython/pull/5558
Thanks a lot ! Great to see MicroPython, as well as CircuitPython, on Teensy 4.0.

My 1st test :

Code: Select all

MicroPython v1.9.3-2582-g691ce3dd5 on 2020-01-24; Teensy 4.0 with MIMXRT1062DVJ6A
>>> import gc
>>> gc.collect()
>>> gc.mem_free()
774000
How-to-compile, worked for me (but I'm not sure if all the commands are needed) :

Code: Select all

$ git clone -b teensy40 --recurse-submodules https://github.com/jimmo/micropython.git 
$ cd micropython/mpy-cross
$ make -j 4
$ ./mpy-cross --version   # MicroPython v1.9.3-2582-g691ce3dd5 on 2020-01-24; mpy-cross emitting mpy v5
$ cd ../ports/mimxrt
$ make -j 4 submodules
$ make BOARD=TEENSY40 clean
$ make -j 4 BOARD=TEENSY40
MicroPython on REPL = only 55 mA. CircuitPython (firmware from 2020-01-18) on REPL = 91 mA.

manitou
Posts: 68
Joined: Wed Feb 25, 2015 12:15 am

Re: Teensy 4.0

Post by manitou » Mon Feb 03, 2020 11:41 pm

OK, i built and uploaded the micropython to my Teensy4 and got a /dev/ttyACM0 REPL. But no "pop up" USB drive ... is there a way import .py files ? rebuild with the .py files in some special folder or ?

I've got some comparative numbers of micropython and circuitpython on a few different MCUs, see
https://forum.pjrc.com/threads/59040-Ci ... post226210

User avatar
jimmo
Posts: 1681
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Teensy 4.0

Post by jimmo » Tue Feb 04, 2020 12:51 am

manitou wrote:
Mon Feb 03, 2020 11:41 pm
OK, i built and uploaded the micropython to my Teensy4 and got a /dev/ttyACM0 REPL. But no "pop up" USB drive ... is there a way import .py files ? rebuild with the .py files in some special folder or ?
Not yet -- this is currently just the minimum possible port and doesn't have an onboard filesystem. I just wanted to get the skeleton in place so that other people can start adding drivers.

A block device driver for the flash memory is required, (as well as enabling USB MSC in tinyusb, which is fairly straightforward).

The best option for now would be to add support for frozen python code (via the manifest system), which would be a relatively small change to the Makefile (copy from STM32).

User avatar
RobH
Posts: 20
Joined: Fri Mar 23, 2018 3:37 pm
Location: Netherlands
Contact:

Re: Teensy 4.0

Post by RobH » Tue Apr 21, 2020 8:01 am

I'm curious about any progress of MicroPython for the Teensy 4.0.....

Did a performance comparison with MicroPython on an ESP32 and CircuitPython on a Teensy 4.0 with (to me) surprising results.

Code: Select all

 pystone_lowmem.py:             ESP32        1057 pystones/sec
 pystone_lowmem_monotonic.py:  Teensy 4.0    1087 pystones/sec 
 
So when the differences in hardware features between ESP32 and Teensy 4.0 are not of immediate importance - but Python is - then an ESP32 is "good enough'. But looking at the potential of the Teensy 4.0 MicroPython might blow away the ESP32 (apart from Wifi!).

Looking forward....

Regards, Rob.

Post Reply