Teensy 3.5 & 3.6 support

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: 352
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Re: Teensy 3.5 & 3.6 support

Post by rcolistete » Mon Nov 21, 2016 11:58 am

rcolistete wrote:Could you post some MicroPython firmware files for Teensy 3.2, Teensy 3.5 and Teensy 3.6 ?

Just flashing with teensy_loader_cli seems a lot easier than to have the build environment of MicroPython for Teensy.
Ok, after some incompatibilities between ARM toolchain from Arduino/Teensyduino and MicroPython, I've succeded with the GNU ARM Embedded Toolchain.
Here are the MicroPython 1.8.6 firmware from dhylands's dev-build for :
* Teensy 3.1/3.2;
* Teensy 3.5;
* Teensy 3.6.

Some benchmarks and comparisons with Teensy 3.2, 3.5, 3.6 and other MicroPython boards :
Free RAM on MicroPython boards
Benchmark comparison of MicroPython boards
ADC performance of MicroPython boards

The Teensy 3.x 16 bits ADC has different speed with respect resolution, e.g., on Teensy 3.6, in ksamples/s :
- 13, 14, 15, 16 bits :106;
- 11, 12 bits : 148;
- 9, 10 bits : 153.
- 8 bits: 158.

So Teensy 3.6 is the fastest MicroPython board for MicroPython/calculations processing and for ADC reading inside a loop.

Thanks, dhylands, MicroPython for Teensy 3.x is already very useful (for reading sensors, datalogging, etc), despite not being complete (no time, DAC, etc modules).
Last edited by rcolistete on Tue Nov 22, 2016 12:19 am, edited 1 time in total.
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Teensy 3.5 & 3.6 support

Post by dhylands » Mon Nov 21, 2016 8:38 pm

I've just been adding enough support so that rshell will work on the Teensy. This allows you to copy files to/from the sd card without having to remove it from the Teensy.

Once I test everything again, I'll check my hex files into my branch and also put a copy on Dropbox for anybody who want to grab one.

And a nice side-effect is that Control-C will work to interrupt the running program.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Teensy 3.5 & 3.6 support

Post by dhylands » Tue Nov 22, 2016 5:43 am

Here are some slightly newer vesions of MicroPython for Teensy.
https://github.com/dhylands/micropython ... /hex-files

built from: https://github.com/dhylands/micropython/tree/teensy-usb

This version allows rshell (and hence pyboard.py) to work with the Teensy.

rshell allows you to copy files onto and off of the Teensy's sdcard (sorry 3.5 & 3.6 only).

You can use pyboard.py to execute a script on your local computer on the Teensy. For example, with a file called heartbeat.py:

Code: Select all

import pyb

tick = 0
led = pyb.LED(1)
while True:
    if tick <= 3:
        led.toggle()
    tick = (tick + 1) % 10
    pyb.delay(100)
on your local computer, you can run pyboard.py:

Code: Select all

pyboard.py heartbeat.py
and it will run heartbeat.py on the teensy.

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

Re: Teensy 3.5 & 3.6 support

Post by Roberthh » Mon Nov 28, 2016 6:45 am

Good morning @dhylands, thank you again for making the teensy ports. These are a good platform for micropython, and with it's larger RAM (and maybe the Ethernet port sometime) they can be used where PyBoard may be too limited. Whenever you are going to work on it the next time, may I ask you to add a definition for sys.platform in one of the mp... header files, like:

Code: Select all

#define MICROPY_PY_SYS_PLATFORM "teensy"
or specific ones for each board variant. That allows a script to tell which platform it's on. That did not seem to be required for teensy 3.1/3.2, but the new teensy's are more powerful and definitely play in the league of the other devices.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Teensy 3.5 & 3.6 support

Post by dhylands » Mon Nov 28, 2016 6:26 pm

I've added them here: https://github.com/dhylands/micropython/tree/teensy-usb.

I rebased to the latest master, so it now shows as 1.8.6

I updated the hex-files as well.

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

Re: Teensy 3.5 & 3.6 support

Post by Roberthh » Mon Nov 28, 2016 9:17 pm

Hi @dhylands, thanks a lot. That works, but I noticed a change. With the previous version, I could use rshell or ampy. With this one, ampy times out and rshell has some issues.

Code: Select all

MicroPython v1.8.6-107-gab7e019 on 2016-11-28; Teensy-3.6 with MK66FX1M0
rshell is version 0.0.6, freshly cloned from your git site. I open rshell with

Code: Select all

rshell -p /dev/ttyACM0
The boards command tells:

Code: Select all

rshell> boards
pyboard @ /dev/ttyACM0 connected Dirs: /sd /pyboard/sd
rshell> ls /pyboard
sd/
But:

Code: Select all

rshell> ls /pyboard/sd
Traceback (most recent call last):
  File "/usr/local/bin/rshell", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.4/dist-packages/rshell/command_line.py", line 4, in main
    rshell.main.main()
  File "/usr/local/lib/python3.4/dist-packages/rshell/main.py", line 2386, in main
    real_main()
  File "/usr/local/lib/python3.4/dist-packages/rshell/main.py", line 2369, in real_main
    shell.cmdloop(cmd_line)
  File "/usr/local/lib/python3.4/dist-packages/rshell/main.py", line 1390, in cmdloop
    cmd.Cmd.cmdloop(self)
  File "/usr/lib/python3.4/cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/usr/local/lib/python3.4/dist-packages/rshell/main.py", line 1420, in onecmd
    self.onecmd_exec("".join(group))
  File "/usr/local/lib/python3.4/dist-packages/rshell/main.py", line 1431, in onecmd_exec
    return cmd.Cmd.onecmd(self, line)
  File "/usr/lib/python3.4/cmd.py", line 217, in onecmd
    return func(arg)
  File "/usr/local/lib/python3.4/dist-packages/rshell/main.py", line 1957, in do_ls
    for filename, stat in sorted(auto(listdir_stat, filename),
  File "/usr/local/lib/python3.4/dist-packages/rshell/main.py", line 444, in auto
    return dev.remote_eval(func, dev_filename, *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/rshell/main.py", line 1198, in remote_eval
    return eval(self.remote(func, *args, **kwargs))
  File "<string>", line 1
    (('allstars', (32768, 0, 0, 0, 0, 0, 11701, 1446673538, 1446673538, 1446673538)), ('analogread.py', (32768, 0, 0, 0, 0, 0, 602, 1443870640, 1443870640, 1443870640)), ('boot.py', (32768, 0, 0, 0, 0, 0, 244, 321926400, 321926400, 321926400)), ('vttest.py', (32768, 0, 0, 0, 0, 0, 2578, 1453229372, 1453229372, 1453229372)), ('font7mono.py', (32768, 0, 0, 0, 0, 0, 6020, 1462433996, 1462433996, 1462433996)), ('vt100.py', (32768, 0, 0, 0, 0, 0, 15638, 1462433836, 1462433836, 1462433836)), ('data_7', (32768, 0, 0, 0, 0, 0, 59930, 946686238, 946686238, 946686238)), ('eatmem.py', (32768, 0, 0, 0, 0, 0, 392, 1388534996, 1388534996, 1388534996)), ('getfile.py', (32768, 0, 0, 0, 0, 0, 362, 1446673532, 1446673532, 1446673532)), ('font10.py', (32768, 0, 0, 0, 0, 0, 7940, 1462013212, 1462013212, 1462013212)), ('main.py', (32768, 0, 0, 0, 0, 0, 65, 321926400, 321926400, 321926400)), ('test_isr.py', (32768, 0, 0, 0, 0, 0, 1510, 1478623238, 1478623238, 1478623238)), ('readch.py', (32768, 0, 0, 0, 0, 0, 844, 1420070432, 1420070432, 1420070432)), ('ranger.py', (32768, 0, 0, 0, 0, 0, 504, 1466228400, 1466228400, 1466228400)), ('reload.py', (32768, 0, 0, 0, 0, 0, 511, 946684800, 946684800, 946684800)), ('logo50.raw', (32768, 0, 0, 0, 0, 0, 5000, 1456332344, 1456332344, 1456332344)), ('foto.data', (32768, 0, 0, 0, 0, 0, 391680, 1456586368, 1456586368, 1456586368)), ('F0010.jpg', (32768, 0, 0, 0, 0, 0, 64789, 1456595468, 1456595468, 1456595468)), ('data_1', (32768, 0, 0, 0, 0, 0, 30000, 1420071292, 1420071292, 1420071292)), ('alloctest.py', (32768, 0, 0, 0, 0, 0, 432, 1420071850, 1420071850, 1420071850)), ('toggle.py', (32768, 0, 0, 0, 0, 0, 1027, 1420070474, 1420070474, 1420070474)), ('F0020_8.bmp', (32768, 0, 0, 0, 0, 0, 131706, 1461869008, 1461869008, 1461869008)), ('ssimul.py', (32768, 0, 0, 0, 0, 0, 2580, 1388546970, 1388546970, 1388546970)), ('test16.py', (32768, 0, 0, 0, 0, 0, 9714, 1462896124, 1462896124, 1462896124)), ('test.py', (32768, 0, 0, 0, 0, 0, 289, 1460061424, 1460061424, 1460061424)), ('getrandom.py', (32768, 0, 0, 0, 0, 0, 173, 1420070586, 1420070586, 1420070586)), ('F0012.jpg', (32768, 0, 0, 0, 0, 0, 64789, 1456595468, 1456595468, 1456595468)), ('counter.py', (32768, 0, 0, 0, 0, 0, 650, 1454846430, 1454846430, 1454846430)), ('toggle.py', (32768, 0, 0, 0, 0, 0, 1027, 1420070474, 1420070474, 1420070474)), ('loop.py', (32768, 0, 0, 0, 0, 0, 857, 1462818616, 1462818616, 1462818616)), ('counter2.py', (32768, 0, 0, 0, 0, 0, 1783, 1454532264, 1454532264, 1454532264)), ('F0013.jpg', (32768, 0, 0, 0, 0, 0, 76261, 1456596104, 1456596104, 1456596104)), ('loop2.py', (32768, 0, 0, 0, 0, 0, 500, 1454876302, 1454876302, 1454876302)), ('loop3.py', (32768, 0, 0, 0, 0, 0, 1189, 1454931716, 1454931716, 1454931716)), ('readf.py', (32768, 0, 0, 0, 0, 0, 371, 946684800, 946684800, 946684800)), ('sample.py', (32768, 0, 0, 0, 0, 0, 170, 1455443462, 1455443462, 1455443462)), ('loop5.py', (32768, 0, 0, 0, 0, 0, 1257, 1454946844, 1454946844, 1454946844)), ('F0010.raw', (32768, 0, 0, 0, 0, 0, 259200, 1447090974, 1447090974, 1447090974)), ('tft_test.py', (32768, 0, 0, 0, 0, 0, 9997, 1475297296, 1475297296, 1475297296)), ('dsb.py', (32768, 0, 0, 0, 0, 0, 65, 1455731124, 1455731124, 1455731124)), ('foto.jpg', (32768, 0, 0, 0, 0, 0, 63358, 1456586336, 1456586336, 1456586336)), ('inspect.py', (32768, 0, 0, 0, 0, 0, 922, 1455778962, 1455778962, 1455778962)), ('burst.py', (32768, 0, 0, 0, 0, 0, 950, 1455824474, 1455824474, 1455824474)), ('P0001.raw', (32768, 0, 0, 0, 0, 0, 110976, 1447005344, 1447005344, 1447005344)), ('slides_4.py', (32768, 0, 0, 0, 0, 0, 10439, 1478020008, 1478020008, 1478020008)), ('font12.py', (32768, 0, 0, 0, 0, 0, 10760, 1460306032, 1460306032, 1460306032)), ('F0011.raw', (32768, 0, 0, 0, 0, 0, 259200, 1447090992, 1447090992, 1447090992)), ('F0012.bmp', (32768, 0, 0, 0, 0, 0, 261258, 1456941690, 1456941690, 1456941690)), ('logo50_3.raw', (32768, 0, 0, 0, 0, 0, 7500, 1456938656, 1456938656, 1456938656)), ('F0013.data', (32768, 0, 0, 0, 0, 0, 391680, 1456596748, 1456596748, 1456596748)), ('F0012.data', (32768, 0, 0, 0, 0, 0, 391680, 1456596768, 1456596768, 1456596768)), ('F0010.data', (32768, 0, 0, 0, 0, 0, 391680, 1456596780, 1456596780, 1456596780)), ('img_480x800', (16384, 0, 0, 0, 0, 0, 0, 1471790754, 1471790754, 1471790754)), ('font14.py', (32768, 0, 0, 0, 0, 0, 13848, 1462013212, 1462013212, 1462013212)), ('foto.bmp', (32768, 0, 0, 0, 0, 0, 261258, 1456864020, 1456864020, 1456864020)), ('F0020_4.bmp', (32768, 0, 0, 0, 0, 0, 65466, 1461869068, 1461869068, 1461869068)), ('touch.py', (32768, 0, 0, 0, 0, 0, 12018, 1462945248, 1462945248, 1462945248)), ('seek_n_read.py', (32768, 0, 0, 0, 0, 0, 126, 1456938000, 1456938000, 1456938000)), ('count.py', (32768, 0, 0, 0, 0, 0, 262, 1456937678, 1456937678, 1456937678)), ('F0020_1.bmp', (32768, 0, 0, 0, 0, 0, 16450, 1461869104, 1461869104, 1461869104)), ('data_2', (32768, 0, 0, 0, 0, 0, 30000, 1420072572, 1420072572, 1420072572)), ('slides.py', (32768, 0, 0, 0, 0, 0, 10439, 1478018860, 1478018860, 1478018860)), ('fonts.py', (32768, 0, 0, 0, 0, 0, 24297, 1459967618, 1459967618, 1459967618)), ('font20.py', (32768, 0, 0, 0, 0, 0, 25624, 1460306032, 1460306032, 1460306032)), ('calibrate.py', (32768, 0, 0, 0, 0, 0, 3279, 1460738868, 1460738868, 1460738868)), ('logo.jpg', (32768, 0, 0, 0, 0, 0, 93381, 1456328654, 1456328654, 1456328654)), ('logo.raw', (32768, 0, 0, 0, 0, 0, 223112, 1456332392, 1456332392, 1456332392)), ('logo50.jpg', (32768, 0, 0, 0, 0, 0, 8233, 1456331970, 1456331970, 1456331970)), ('font7hex.py', (32768, 0, 0, 0, 0, 0, 8093, 1460306088, 1460306088, 1460306088)), ('font6mono.py', (32768, 0, 0, 0, 0, 0, 3819, 1460306032, 1460306032, 1460306032)), ('peteensy.py', (32768, 0, 0, 0, 0, 0, 24538, 1479843422, 1479843422, 1479843422)), ('touchtest.py', (32768, 0, 0, 0, 0, 0, 4612, 1461266434, 1461266434, 1461266434)), ('terminal7hex.py', (32768, 0, 0, 0, 0, 0, 10171, 1459970540, 1459970540, 1459970540)), ('terminal7ctrl.py', (32768, 0, 0, 0, 0, 0, 10178, 1459970550, 1459970550, 1459970550)), ('font7ctrl.py', (32768, 0, 0, 0, 0, 0, 8100, 1460306084, 1460306084, 1460306084)), ('font8mono.py', (32768, 0, 0, 0, 0, 0, 6892, 1460306032, 1460306032, 1460306032)), ('tft.py', (32768, 0, 0, 0, 0, 0, 32207, 1463809802, 1463809802, 1463809802)), ('font9mono.py', (32768, 0, 0, 0, 0, 0, 6892, 1460306032, 1460306032, 1460306032)), ('font10mono.py', (32768, 0, 0, 0, 0, 0, 9204, 1460306030, 1460306030, 1460306030)), ('font24num_mono.py', (32768, 0, 0, 0, 0, 0, 3824, 1460306032, 1460306032, 1460306032)), ('font36num_mono.py', (32768, 0, 0, 0, 0, 0, 8844, 1460306068, 1460306068, 1460306068)), ('speed.py', (32768, 0, 0, 0, 0, 0, 416, 1460276684, 1460276684, 1460276684)), ('dejavu10.py', (32768, 0, 0, 0, 0, 0, 9982, 1461403008, 1461403008, 1461403liberation8mono.py', (32768, 0, 0, 0, 0, 0, 7318, 1460391878, 1460391878, 1460391878)), ('sevensegnumfont.py', (32768, 0, 0, 0, 0, 0, 9204, 1460392150, 1460392150, 1460392150)), ('liberation10mono.py', (32768, 0, 0, 0, 0, 0, 10398, 1460391878, 1460391878, 1460391878)), ('F0020.jpg', (32768, 0, 0, 0, 0, 0, 72406, 1460820810, 1460820810, 1460820810)), ('F0013.bmp', (32768, 0, 0, 0, 0, 0, 388922, 1460796310, 1460796310, 1460796310)), ('F0020.bmp', (32768, 0, 0, 0, 0, 0, 261258, 1460820848, 1460820848, 1460820848)), ('TFT_io.py', (32768, 0, 0, 0, 0, 0, 22073, 1462549502, 1462549502, 1462549502)), ('README.md', (32768, 0, 0, 0, 0, 0, 7014, 1462013212, 1462013212, 1462013212)), ('F0020_2.bmp', (32768, 0, 0, 0, 0, 0, 65418, 1461909590, 1461909590, 1461909590)), ('delay.py', (32768, 0, 0, 0, 0, 0, 1912, 1462013212, 1462013212, 1462013212)), ('hst.py', (32768, 0, 0, 0, 0, 0, 4522, 1462013212, 1462013212, 1462013212)), ('knobtest.py', (32768, 0, 0, 0, 0, 0, 1498, 1462013212, 1462013212, 1462013212)), ('ugui.py', (32768, 0, 0, 0, 0, 0, 31469, 1462013212, 1462013212, 1462013212)), ('usched.py', (32768, 0, 0, 0, 0, 0, 10951, 1462013212, 1462013212, 1462013212)), ('vst.py', (32768, 0, 0, 0, 0, 0, 4130, 1462013212, 1462013212, 1462013212)), ('get_rng.py', (32768, 0, 0, 0, 0, 0, 367, 1470229022, 1470229022, 1470229022)), ('sliderhandle.py', (32768, 0, 0, 0, 0, 0, 6611, 1462887998, 1462887998, 1462887998)), ('checkbox.py', (32768, 0, 0, 0, 0, 0, 7706, 1462888000, 1462888000, 1462888000)), ('icontest.py', (32768, 0, 0, 0, 0, 0, 1260, 1463400548, 1463400548, 1463400548)), ('radiobutton.py', (32768, 0, 0, 0, 0, 0, 5394, 1462887998, 1462887998, 1462887998)), ('switch.py', (32768, 0, 0, 0, 0, 0, 6195, 1462888000, 1462888000, 1462888000)), ('sliderpath.py', (32768, 0, 0, 0, 0, 0, 20944, 1462887996, 1462887996, 1462887996)), ('bmp_to_icon.py', (32768, 0, 0, 0, 0, 0, 10816, 1462894490, 1462894490, 1462894490)), ('test24.py', (32768, 0, 0, 0, 0, 0, 14322, 1462896132, 1462896132, 1462896132)), ('touch_python.py', (32768, 0, 0, 0, 0, 0, 11631, 1462559594, 1462559594, 1462559594)), ('Flat_UI.py', (32768, 0, 0, 0, 0, 0, 55130, 1462981918, 1462981918, 1462981918)), ('mdesign.py', (32768, 0, 0, 0, 0, 0, 5724, 1463309436, 1463309436, 1463309436)), ('blink.py', (32768, 0, 0, 0, 0, 0, 117, 1463168422, 1463168422, 1463168422)), ('media.py', (32768, 0, 0, 0, 0, 0, 6901, 1463392818, 1463392818, 1463392818)), ('__pycache__', (16384, 0, 0, 0, 0, 0, 0, 1463309962, 1463309962, 1463309962)), ('globals.py', (32768, 0, 0, 0, 0, 0, 47, 1463309846, 1463309846, 1463309846)), ('check_boxes.py', (32768, 0, 0, 0, 0, 0, 9220, 1463385434, 1463385434, 1463385434)), ('thin_arrow.py', (32768, 0, 0, 0, 0, 0, 2903, 1463385438, 1463385438, 1463385438)), ('switch_4c.py', (32768, 0, 0, 0, 0, 0, 5149, 1463400470, 1463400470, 1463400470)), ('slides_old.py', (32768, 0, 0, 0, 0, 0, 7871, 1462039456, 1462039456, 1462039456)), ('img_272x480', (16384, 0, 0, 0, 0, 0, 0, 1471790884, 1471790884, 1471790884)), ('.Trash-1000', (16384, 0, 0, 0, 0, 0, 0, 1471790898, 1471790898, 1471790898)))

^
SyntaxError: invalid syntax
If I run the ls command for a single file only or an sd cards with fewer files, it works. So it may be a problem of the number of files.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Teensy 3.5 & 3.6 support

Post by dhylands » Mon Nov 28, 2016 11:41 pm

Thanks for the report. It looks like some data loss in the middle of the buffer.

I see:

Code: Select all

...1461403008, 1461403liberation8mono.py', (32768,...
so at least a few characters got dropped.

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

Re: Teensy 3.5 & 3.6 support

Post by Roberthh » Tue Nov 29, 2016 6:22 am

Hello Dave. Do you see the data loss on the teensy (sending) side or the PC (receiving) side?

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Teensy 3.5 & 3.6 support

Post by dhylands » Tue Nov 29, 2016 8:16 am

Hey Robert,

I was just looking at the log info you posted, which would have been on the host side. My guess is that the response is bigger than the USB buffer on the teensy side and that's causing the problem. rshell has some flow control management for sending files, but not for sending the typical responses. So I'll need to look into breaking up large responses into chunks and just send a chunk at a time.

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

Re: Teensy 3.5 & 3.6 support

Post by Roberthh » Tue Nov 29, 2016 12:03 pm

Hello Dave, I do not know whether you send on teensy with your own code, but I ran into that problem with my little editor, and had to use this kind of code (just to explain the principle):

Code: Select all

     ns = 0
     while ns < len(s): # complicated but needed, since USB_VCP.write() has issues
          res = pyb.USB_VCP.write(s[ns:])
          if res != None:
              ns += res

Post Reply