Openmv H7 plus compiling files (not .py) with firmware

https://docs.openmv.io/openmvcam/tutorial/production.html

Hello. I am following the instructions linked above compiling the software locally. I would like to include files that are not .py scripts. I am using json , txt, .tflite and others. I am working with Build 4.5.5 as a basis since for my setup there are changes after that build that break my code. 1) Can I put all my files in the libraries directory and the compiled firmware will see them as if they were files on my flash / SD card?
2)With .py files I know that the if there is something on flash / SD those files take precedence over the ones compiled with the firmware. Is this true for all other file types as well?

Thanks.

Hi, the tflite files go here: openmv/src/lib/tflm/models at master · openmv/openmv (github.com)

Along with their .txt labels.

As for json, I’d just convert that into a python file using ChatGPT. Alternatively, you can modify the code that creates the default partition:

openmv/src/omv/common/mp_utils.c at master · openmv/openmv (github.com)

And then use xxd -i inputfile > outputfile.c to turn your JSON file into a C byte array and then write that in the above function as a file to the disk. Just converting your JSON array to python is easier. You can infact just add the JSON array to a python file as a string and then decode that into a dictionary to get the values.

Hi . Thanks for that. I have a couple of more questions I’d be glad if you could answer.
1)
If I were to have in my boot.py:
import XXX.py

where XXX.py is on the flash or SD drive , would that work or does boot.py run before mounting flash / SD?

  1. In your guide you say :

Edit the manifest.py file for your board type to include your scripts. If you just have one script then this should at minimum include you adding freeze ("$(OMV_LIB_DIR)/", "boot.py") to the manifest.py file.

I have multiple .py files in my project which I’d like to compile with firmware. Do I need to add a “freeze” statement for each one?

  1. You say

Additionally, any files on the internal flash or SD card will be overridden by what scripts you freeze that have the same name.

I think the opposite is meant. Any files that one freezes with the same name will be overidden by scripts on the internal flash or SD. I know this because in the manifest I find
freeze ("$(OMV_LIB_DIR)/", "rpc.py")
but if I have rpc.py on SD or flash it takes priority.
Can you confirm?

Thanks.

Yes filesystem paths take priority. To add new files to a fresh filesystem, you can edit mp_init_filesystem and create all the files you want. Note the filesystem is only created for the internal file-system, we don’t touch the SD card.

Yes… I need to update that documentation for imports.

However, frozen scripts are searched first by:

[openmv/src/omv/ports/stm32/main.c at master · openmv/openmv (github.com)](openmv/src/omv/ports/stm32/main.c at master · openmv/openmv · GitHub

So, a frozen boot.py or main.py will take control of the system over anything else.

Having scripts on the file system be searched first before built-in modules is a helpful feature for development.

If your app has many scripts that make up a library of functionality, you may wish to locate them in a new folder path that doesn’t appear as the same path on the disk.

You can also control how the disk is mounted and such from the boot.py/main.py.