/flash confused

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
beetle
Posts: 51
Joined: Sat Oct 16, 2021 11:35 am

/flash confused

Post by beetle » Fri Mar 11, 2022 4:17 pm

I put micropython on my Teensy 4.1 board (latest from a couple of weeks ago). Using Thonny I notice that the filesystem of the Teensy board starts at /flash. That is I can only download files and create directories from /flash. I cannot create a /lib dir - I can try but I do not end up with a /lib dir and the process does not give an error. I can create a /flash/lib directory but it does not appear to be searched as per a normal /lib dir. All the files I put in the /flash dir appear to work as normal, though I have not yet tried with a main.py file.

Is this by design, or perhaps something to do with the extra memory chip I soldered onto the board? All my other boards (rpi pico and Esp32 all have a file system that starts with /

Thanks

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

Re: /flash confused

Post by Roberthh » Fri Mar 11, 2022 6:23 pm

thanks for the note. that may be an oversight, that the search path does not contain /flash/lib. That can be changed. meanwhile you can change sys.path in boot.py or main.py, by using

import sys
sys,path.append("/flash/lib")

main.py and boot.py works as normal from /flash. And no, it is not caused by the extra memory chip, which is not (yet) supported by the firmware, except if you add your own drivers.

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

Re: /flash confused

Post by Roberthh » Sun Mar 13, 2022 7:38 am

Since the whole mounting happens in _boot.py, you can as well change it to / e.g. boot.py with the following script:

Code: Select all

import uos, sys
uos.umount("/flash")
uos.mount(vfs,"/")
sys.path.pop(-1)
sys.path.append("/")
sys.path.append("/lib")

User avatar
RetiredWizard
Posts: 4
Joined: Wed Apr 07, 2021 3:37 pm

Re: /flash confused

Post by RetiredWizard » Thu Jul 14, 2022 6:02 pm

Is there a reason for the un-writeable '/' folder with the flash mounted as /flash on the Teensy?

if I want to use the _boot.py option you've described, do I need to build a custom MP image with that file compiled in somewhere?

Probably related to the first question, but is this how the Teensy 4.1 flash will be supported going forward or is this just an artifact of the early stage of Teensy support?

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

Re: /flash confused

Post by Roberthh » Thu Jul 14, 2022 7:06 pm

Not all ports mount the flash file system at "/". Some, like the mimxrt port, mount it at "/flash", to be consistent with mounting the sd card at "/sdvard". I have no plans to change it. But to change it you do not have to re-compile the firmware. Just add the change to your boot.py:

Code: Select all

import uos, sys
uos.umount("/flash")
uos.mount(vfs,"/")
sys.path.pop(-1)
sys.path.pop(-1)
sys.path.append("/")
sys.path.append("/lib")
If you want to make a change in _boot.py, you have to recompile the firmware.

User avatar
RetiredWizard
Posts: 4
Joined: Wed Apr 07, 2021 3:37 pm

Re: /flash confused

Post by RetiredWizard » Thu Jul 14, 2022 7:29 pm

Thanks!!!

Post Reply