Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 2 FirstFirst 1 2
Results 26 to 46 of 46

Thread: CircuitPython on Teensy 4!

  1. #26
    Junior Member
    Join Date
    Jul 2019
    Posts
    15
    Quote Originally Posted by PaulStoffregen View Post
    Though why Python can't give microsecond precision delay is also a good question. Arduino supports delayMicroseconds() on all boards. The slower boards usually have a minimum delay of several microseconds, so it's far from perfect, but certainly a lot better than 1 millisecond resolution.
    The delay could be more accurate but we run "background" stuff between Python byte codes. We may do mass storage writes, for example, that will mess up any precision timing. So, it's best to not rely on the timing of Python code execution.

    Quote Originally Posted by PaulStoffregen View Post
    Thank you!

  2. #27
    Junior Member
    Join Date
    Nov 2019
    Posts
    4
    Quote Originally Posted by tannewt View Post
    Thanks for finding those! Would you mind creating GitHub issues for them? That is how we keep track of things. Here is the url to do it: https://github.com/adafruit/circuitpython/issues/new
    Done (3rd one is a new issue) :
    - microcontroller.cpu.temperature doesn't work on Teensy 4.0 #2514;
    - REPL disconnects in paste mode with >= 4 lines on Teensy 4.0 #2515;
    - ampy doesn't work with Teensy 4.0 #2516.

  3. #28

  4. #29
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,494
    @tannewt
    I had a chance to install the .hex on the T4 the other day using the Teensy Loader to upload the file on a Windows10x64 PC. After upload Windows install it as a new drive and I was able to run Putty to access CircuitPython without have to unplug it and replug it back in - think you mentioned this in your first post. Tried TyCommander as well and no problem.

    As for adjust the clock and I can take a look if you point me in the right direction. Looks like its in mircrocontroller - clock.c file? In the Teensy 4 core there is a file clockspeed.c that probably has what is needed to be put into circuitpython.

  5. #30
    Junior Member
    Join Date
    Jul 2019
    Posts
    15
    Quote Originally Posted by mjs513 View Post
    @tannewt
    I had a chance to install the .hex on the T4 the other day using the Teensy Loader to upload the file on a Windows10x64 PC. After upload Windows install it as a new drive and I was able to run Putty to access CircuitPython without have to unplug it and replug it back in - think you mentioned this in your first post. Tried TyCommander as well and no problem.

    As for adjust the clock and I can take a look if you point me in the right direction. Looks like its in mircrocontroller - clock.c file? In the Teensy 4 core there is a file clockspeed.c that probably has what is needed to be put into circuitpython.
    Glad it worked well! Sounds like you found the right place. We already provide microcontroller.cpu.frequency as a read-only value. (The API is here: https://github.com/adafruit/circuitp...rocessor.c#L57 ) It'd be awesome to make it writable. Then the implementation can try to change the speed and either return the new value on the next read or the old value if it failed. The general file layout is documented here: https://circuitpython.readthedocs.io...ommon_hal.html and build instructions are here: https://learn.adafruit.com/building-circuitpython/

    Thanks!

  6. #31
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,296
    @tannewt
    I have successfully built circuitpython for STM32F405 (increased CPU clock to 168mhz) , but my build failed starting from your branch
    https://github.com/tannewt/circuitpython/tree/teensy4
    I followed the steps described at https://learn.adafruit.com/building-circuitpython
    but make BOARD=teensy40 fails with
    make: *** No rule to make target 'lib/tinyusb/src/portable/nxp/transdimension/dcd_transdimension.c'

    thoughts?

  7. #32
    Junior Member
    Join Date
    Jul 2019
    Posts
    15
    Quote Originally Posted by manitou View Post
    @tannewt
    I have successfully built circuitpython for STM32F405 (increased CPU clock to 168mhz) , but my build failed starting from your branch
    https://github.com/tannewt/circuitpython/tree/teensy4
    I followed the steps described at https://learn.adafruit.com/building-circuitpython
    but make BOARD=teensy40 fails with
    make: *** No rule to make target 'lib/tinyusb/src/portable/nxp/transdimension/dcd_transdimension.c'

    thoughts?
    I'm not sure the tip of my branch builds atm. I'm reworking the linking right now.

    That error sounds like the TinyUSB submodule isn't updated fully. Make sure to `git submodule sync` and `git submodule update --init .` when switching branches.

  8. #33
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,296
    OK, i did those git submodule, and that ends with
    Code:
    ...
    error: Server does not allow request for unadvertised object cf3acd6b6d47e3aaeb0ca29a70ca1339d415908b
    Fetched in submodule path 'ports/mimxrt10xx/sdk', but it did not contain cf3acd6b6d47e3aaeb0ca29a70ca1339d415908b. Direct fetching of that commit failed.
    then the make fails with

    Code:
    make BOARD=teensy40
    Use make V=1, make V=2 or set BUILD_VERBOSE similarly in your environment to increase build verbosity.
    Traceback (most recent call last):
      File "../../tools/gen_usb_descriptor.py", line 8, in <module>
        from adafruit_usb_descriptor import audio, audio10, cdc, hid, midi, msc, standard, util
    ModuleNotFoundError: No module named 'adafruit_usb_descriptor'
    ../../supervisor/supervisor.mk:185: recipe for target 'autogen_usb_descriptor.intermediate' failed
    make: *** [autogen_usb_descriptor.intermediate] Error 1

  9. #34
    Junior Member
    Join Date
    Jul 2019
    Posts
    15
    Try now. :-) I had a local commit of the SDK. We can also chat on Discord too if my response time is too slow. Link to join is https://adafru.it/discord

  10. #35
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,296
    Quote Originally Posted by tannewt View Post
    Try now. :-) I had a local commit of the SDK. We can also chat on Discord too if my response time is too slow. Link to join is https://adafru.it/discord
    so i should restart by cloning your branch again, and then doing all the submodule stuff?

  11. #36
    Junior Member
    Join Date
    Jul 2019
    Posts
    15
    Try the submodule update again. I pushed the commit it was looking for.

  12. #37
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,296
    Quote Originally Posted by tannewt View Post
    Try the submodule update again. I pushed the commit it was looking for.
    ok, i started over from cloning your teensy4 branch ... and the make worked.
    thanks

  13. #38
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,449
    I was watching thjis weeks Ask an Engineer (1/15/2020) from Adafruit, and they had a big mention about Circuit Python on the Teensy 4.0

    • https://www.facebook.com/adafruitind...5329442079046/
    • The main discussion starts at the 14 minutes, 10 seconds and goes through about 17 minutes and 30 seconds (with a little preview of a future feather that followed the Teensy stuff).
    • FWIW, there 10% off code for the day was IotTeensy.
    • I was amused the 2 issues Limor mentioned was the I2C and SPI buses were faster than the devices she was attaching.


    I know the Teensy 4.0++ will have places to solder flash memory on the chip. It may be useful in terms of sales particularly to some of the CircuitPython people if there was a version that has the flash memory soldered in (along with the pins being soldered).

    As an aside, the reason I was tuning in today was I'm on some electronics panels this weekend and one of my older projects is a simple Neopixel ring on a wooden bowtie. I've built it twice using the Teensy LC (due to the tri-state buffer for Neopixels). My main board stopped working due to broken solder joints. I tried to resolder the joints, and pulled off the copper on the prototype board. The second LC also was getting cranky in terms of solder joints and the layout wasn't the greatest.

    I discovered I no longer had any unsoldered LC's, but in thinking about it, I really wanted the on/off feature of the Teensy 4.0 (rather than hacking in an on/off switch), so the next board will have the Teensy 4.0 + Adafruit Feather (for the JST lipo battery charger). So, I'm ordering another Teensy 4.0. :-)
    Last edited by MichaelMeissner; 01-16-2020 at 03:35 AM.

  14. #39
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,296
    Quote Originally Posted by rcolistete View Post
    - CircuitPython halts after :
    Code:
    import microcontroller
    microcontroller.cpu.temperature
    likely TEMPMON fix described in github issue

    FYI, circuitpython T4 register settings:
    Code:
    SystemCoreClock 600000000  14:17:35 Jan 16 2020 ok
    
    AhbClk 600000000  kCLOCK_RtcClk 32768  kCLOCK_Usb1PllPfd0Clk 360000000  kCLOCK_IpgClk 150000000
    kCLOCK_Usb1PllClk 480000000  kCLOCK_OscClk 24000000 CoreSysClk 600000000 ARMPLL 1200000000
    XTALOSC24M->LOWPWR_CTRL 0x74f01
    XTALOSC24M->OSC_CONFIG0 0x4002040
    XTALOSC24M->OSC_CONFIG1 0x2ee
    XTALOSC24M->OSC_CONFIG2 0x800102e2
    SCB->ICIALLU 0x0
    SCB->CCR 0x60200
    SCB->CSSELR 0x0
    SCB->CCSIDR 0xf01fe019
    SCB->DCISW 0x0
    SCB->CCR 0x60200
    CCM->CBCDR 0xf8300
    SNVS->LPCR 0x21
    SNVS->LPSRTCMR 0x2f10
    SNVS->LPSRTCLR 0x3856f8ea
    CCM_ANALOG->MISC0 0x24008080
    SysTick->CTRL 0x7
    SysTick->LOAD 0x927be
    CCM->CCGR0 0xc0000fff
    CCM->CCGR1 0xfc0cc000
    CCM->CCGR2 0xc3fc033
    CCM->CCGR3 0xf00ff300
    CCM->CCGR4 0xffff
    CCM->CCGR5 0xf0033c33
    CCM->CCGR6 0xfc3fc3
    CCM->CMEOR 0x7fffffff
    SysTick->LOAD should really be 0x927bf
    Last edited by manitou; 01-17-2020 at 09:40 PM.

  15. #40
    @tannewt is there any CAN and CAN FD support on CircuitPython ?

  16. #41
    Junior Member
    Join Date
    Jul 2019
    Posts
    15
    Quote Originally Posted by skpang View Post
    @tannewt is there any CAN and CAN FD support on CircuitPython ?
    Not yet, no. I've heard interest before and started an issue for it here: https://github.com/adafruit/circuitpython/issues/2527

  17. #42
    Junior Member
    Join Date
    Jul 2019
    Posts
    15
    Hi all! I wanted to post an update. I spent all week heads down on rejiggering CircuitPython to take advantage of the TCM and caches better. It looks to be a 10ish times speedup for a very simple Python program.

    I've opened a pull request for Teensy 4.0 support here: https://github.com/adafruit/circuitpython/pull/2532

    I've also attached a new build. Please make sure and back up your files before updating with TeensyLoader! I'm not sure whether the files get wiped or not.

    Thanks!
    Attached Files Attached Files

  18. #43
    Senior Member
    Join Date
    May 2015
    Posts
    393
    Which files do we need to back up?

  19. #44
    Junior Member
    Join Date
    Jul 2019
    Posts
    15
    Everything on your CIRCUITPY drive.

  20. #45
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,296
    I tried your latest .hex. REPL prints a bunch of eeeeeeee's when it starts up. Also confirm REPL consumes the first character typed ? Strange behavior on a couple of py scripts that work fine with previous release. fact.py prints 0 seconds ? -- previous version reports 0.00488281s seconds, though your "speedup" could drive that to 0 with only millisecond resolution. llutm.py says syntax error, runs ok with previous .hex

    microcontroller.cpu.temperature still hangs -- there is a "fix" for that: https://github.com/adafruit/circuitpython/issues/2514

    toggle.py is faster 379khz, period 2.64 us (scope)

  21. #46
    Senior Member
    Join Date
    May 2015
    Posts
    393
    Ahh thank you. I thought you meant to get back to the basic Arduino environment. This would be my first try at Circuit Python so I have nothing to backup. If I ever get past ground zero I want to get good at Circuit Python to bang out a quick make it work prototype and then try to convert to Rust and save Arduino for when there is no drivers or libraries I need for the other two. At 800 mhz Circuit Python will probably faster than I need anyway.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •