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.
Post Reply
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 » Thu Jul 15, 2021 4:46 pm

Just for a test, I made a version of mimxrt/machine_i2c.c, which supports the init() method with the keywords freq and drive. You 'll find it here: https://github.com/robert-hh/micropytho ... t_i2c_init. You can simply copy over the file mimxrt/machine_i2c.c for testing. Generally I would say that this is of almost no importance. One would usually instantiate an I2C bus with the right parameters. There is little use of changing them afterwards, since all devices on the bus must be capable of working with these settings.

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

Re: Teensy 4.0 & 4.1

Post by RobH » Thu Jul 15, 2021 6:16 pm

Thanks for the explanation! I suppose there is (/was) a good reason for this design, but without this knowledge the docs should be a little clearer about differences and/or exceptions.
BTW I don't need to change freq in my project, I just noticed my issues with init() during experimenting...

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

Re: Teensy 4.0 & 4.1

Post by RobH » Thu Jul 15, 2021 7:02 pm

Tried your mod of machine_i2c.c. The init(freq=...) is now accepted.
It looks like 'freq' (and 'drive') can be changed, but at least frequency does not really (and no warning):

Code: Select all

MicroPython v1.16-92-g98c570302-dirty on 2021-07-15; Teensy 4.0 with MIMXRT1062DVJ6A
Type "help()" for more information.
>>> from machine import I2C
>>> bus = I2C(0)
>>> print(bus)
I2C(0, freq=400000)
>>> bus.init(freq=100000)
>>> print(bus)
I2C(0, freq=400000)

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 » Thu Jul 15, 2021 7:24 pm

That might be just the display, where the change has not be noted back to the config. Did you look at the bus?

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 » Thu Jul 15, 2021 7:29 pm

File changed now to display the changed frequency.

androiddrew
Posts: 18
Joined: Sat Jan 23, 2021 7:24 pm

Re: Teensy 4.0 & 4.1

Post by androiddrew » Sat Jul 17, 2021 1:13 pm

So, as of 07/15 how ready for the world is a Mircropython running on Teensy 4.x? Does anyone have a built binary they could share with instructions on uploading it?

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 » Sat Jul 17, 2021 1:40 pm

After having stalled for a while, it is extended now. You can download actual builds from the MicroPython web site, at https://micropython.org/download/all/, which include quit a few of the machine class.

Code: Select all

>>> dir(machine)
['__class__', '__name__', 'ADC', 'I2C', 'LED', 'Pin', 'RTC', 'SDCard', 'SPI', 'Signal',
'SoftI2C', 'SoftSPI', 'Timer', 'UART', 'disable_irq', 'enable_irq', 'freq', 'idle', 'mem16',
'mem32', 'mem8', 'reset', 'time_pulse_us']
>>> help("modules")
__main__          machine           uasyncio/funcs    ujson
_boot             math              uasyncio/lock     uos
_onewire          micropython       uasyncio/stream   upysh
_uasyncio         mimxrt            ubinascii         urandom
bme280            onewire           ucollections      ure
builtins          pye_mp            uctypes           uselect
cmath             uarray            uerrno            ustruct
ds18x20           uasyncio/__init__ uftpd             usys
framebuf          uasyncio/core     uhashlib          utime
gc                uasyncio/event    uio               uzlib
Plus any modules on the filesystem
There is a PR for an initial documentation, which tell you which pins for which device, although that matches the Teensy Pin-Outs. I have a branch about to be submitted as PR for Ethernet support at https://github.com/robert-hh/micropytho ... mimxrt_lan. It is based on the current master. In order to us Ethernet with the Teensy 4.1, you have to connect a RJ45 jack to it. PJRC is offering a small Breakout for a few $.
There is support for the SD Card un der construction made by @alphaFred. You can get a copy of the actual branch at https://github.com/robert-hh/micropytho ... xrt_sdcard, which I use for testing with Teensy 4.1.
There is no combined branch for both SDCARD and Ethernet.
Not all options of MicroPython are yet enabled, but that's easy to add.

User avatar
mattyt
Posts: 410
Joined: Mon Jan 23, 2017 6:39 am

Re: Teensy 4.0 & 4.1

Post by mattyt » Sat Jul 17, 2021 3:15 pm

Thanks for all your efforts on the Teensy port Robert! Really appreciated. :)

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 » Sat Jul 17, 2021 3:25 pm

Cudos must go to @alphaFred, who started the effort. Without him I would not have considered working at that port, and would not have been able to do that. Being busy with his familiy and his daytime work, he might appear silent. But he is working on the port at every minute he can spare.

Shards
Posts: 39
Joined: Fri Jun 25, 2021 5:14 pm
Location: Milton Keynes, UK

Re: Teensy 4.0 & 4.1

Post by Shards » Sat Jul 17, 2021 7:12 pm

I can confirm both Teensy 4.0 and 4.1 both run micropython fine . I have been using both for the last couple of weeks and my standard UART (GPS) , i2C (display) SPI (mifare reader) programs all run fine with code just copied from pyboard or ESP versions. The boards are reasonably priced and seem well made. A small bonus is the nice printed pinout listing cards they come with.

I look forward to trying out the ethernet connection which should make the 4.1 ideal for a network connected hub application.

I've built the firmware from the micropython master with no issues, I use the teensy program provide by PJRC to upload the hex files, again without problems.

The 4.1 also has a USB host connection, any chance this will be supported in micropython?

Post Reply