Page 2 of 30

Re: Teensy 4.0

Posted: Mon Jan 13, 2020 1:02 pm
by rcolistete
@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).

Re: Teensy 4.0

Posted: Mon Jan 13, 2020 3:41 pm
by Roberthh
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.

Re: Teensy 4.0

Posted: Mon Jan 13, 2020 4:54 pm
by rcolistete
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.

Re: Teensy 4.0

Posted: Tue Jan 14, 2020 7:57 am
by pythoncoder
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.

Re: Teensy 4.0

Posted: Tue Jan 14, 2020 3:29 pm
by rcolistete
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.

Re: Teensy 4.0

Posted: Thu Jan 23, 2020 1:54 am
by jimmo
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.

Re: Teensy 4.0

Posted: Fri Jan 24, 2020 11:27 pm
by rcolistete
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.

Re: Teensy 4.0

Posted: Mon Feb 03, 2020 11:41 pm
by manitou
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

Re: Teensy 4.0

Posted: Tue Feb 04, 2020 12:51 am
by jimmo
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).

Re: Teensy 4.0

Posted: Tue Apr 21, 2020 8:01 am
by RobH
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.