Micropython on Teensy 4.1

MrExplore

Member
Hi,

I'm trying to get Micropython code to run on a stand alone Teensy 4.1.

Why I say 'stand alone'? Well, I've got Micropython on it, wrote my code and it works as expected when started from within Thonny.
There is one thing though: booting on it's own.

I don't know if this is a question for the Teensy forum or the MicroPython forum.
It is about booting but I don't know if it's the Teensy or the MicroPython firmware controlling the boot.

I think the 'note to myself' below pretty much explains the situation.

So my question is: How can the Teensy be booted from the flash?
If you need more info, please let me know.

Thanks


My note to self:
Code:
Thonny shows :

MicroPython device/sdcard
MicroPython device/flash

== Whithout a 'boot.py' file nothing is run
   main.py is not booted at startup


boot.py WILL run startup if placed on the sd card
boot.py loads and runs main.py by the 'import main' statement inside boot.py

boot.py will NOT run at startup when it's inside the 'flash' directory


For developing:
- Place ALL code (boot.py, main.py, libraries, folders) in the 'flash directory'
- This because Thonny f's up and corrupts files when uploading/saving to the sd card
  and it's dead slow
- When you have a boot.py on the sd card when developing, Thonny cannot connect to the REPL
  rename it to boot.py.rename so it doesn't get booted

For deployment:
- Copy the contents of the 'flash' directory to your computer
- Take the sd card out of the teensy, put it in your card reader 
  and copy the contents of the flash directory onto the sd card.
- Put the sd card back in your teensy and it should boot: boot.py which loads main.py
 
Ok, I didn't post on the MicroPython forum but I got it working.

- On the Teensy's flash: main.py and all other code
- On the SD card: boot.py, webserver files and log files

boot.py has only one line of code: 'import main'. This loads and runs main.py from the flash.

When programming I have to remove or rename boot.py on the SD.
If not, Thonny can not connect to the Teensy over USB for programming.
 
Back
Top