/lib/ folder in /frozen/base
We're working on getting SecureBoot and Encryption working and we have come quite long so far - everything compiles nicely except one core part of our code - the libraries. The internal libraries we have are put in a directory relative to flash,
/flash/lib. They are included in the build under
...esp32/frozen/Base. I'm wondering if this is the right way to put it though, as it doesn't seem to work. Running the compiled code on the device, we get "Module not found" errors.
See the REPL output when connected to an encrypted device:
>>> os.listdir("/flash/lib/")  >>>
This makes me think that there could be some kind of conflict. The building of the firmware indicates that the lib/ folder at least is being built:
MPY frozen/base/lib/filename1.py MPY frozen/base/lib/dirname1/filename2.py
I see there are multiple folders where you can put things, but they are not documented more thoroughly. For example, the
Custom/directory's README talks about "custom user scripts", but what does "custom user scripts" even mean? Therefore, I can't determine where I should put the
lib/folder or what I'm doing wrong.
@robert-hh Okay! Thanks a lot for that clarification and a fast answer.
robert-hh last edited by
@techykermit Actually there is no fix for that. The set of frozen files is not contained in a file-system-like structure. So you have to name the lib files in a appropriate manner.
@robert-hh Hi, sorry for a little late response. I had to get hold of the test unit :)
Thanks for the command suggestion! Running it, I see that my libraries all show up, but they do show up in the list with
lib/in front of their import name. See below, where
lib3are the internal libraries that have been frozen:
lib/lib1 select uqueue hashlib lib/lib2 socket ure json lib/lib3
All our previous code relies on not using
libin front of the library when importing it (for example,
lib2is imported with the line
import lib2instead of
from lib import lib2in our source code. While the line
import lib.lib2works (so thanks a lot for pointing me to this function and figuring out that the libraries are there!), is there anything we can do to not have to change all our import statements to import from
lib/(is there anything to do so we can import the libraries from
lib/using a prefix like
robert-hh last edited by
@techykermit You can check with help("modules"), whether and under which name the frozen modules were included.
@jcaron I try to load them as you can do "normally" (when not building your custom firmware):
for example we do:
when we want to import the
logmodule that is under lib.
This gives a
Traceback (most recent call last): File "main.py", line 1, in <module> ModuleNotFoundError: No module named 'log'
@techykermit frozen files are not present as actual files in the filesystem, so it’s normal you can’t list them. They should be available for import directly.
How do you import them and what error do you get?
Don-iot last edited by