Page 1 of 1

/flash confused

Posted: Fri Mar 11, 2022 4:17 pm
by beetle
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

Re: /flash confused

Posted: Fri Mar 11, 2022 6:23 pm
by Roberthh
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.

Re: /flash confused

Posted: Sun Mar 13, 2022 7:38 am
by Roberthh
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")

Re: /flash confused

Posted: Thu Jul 14, 2022 6:02 pm
by RetiredWizard
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?

Re: /flash confused

Posted: Thu Jul 14, 2022 7:06 pm
by Roberthh
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.

Re: /flash confused

Posted: Thu Jul 14, 2022 7:29 pm
by RetiredWizard
Thanks!!!