How to add some C-modules to omv's micropython?

Hey guys!

First of all, I need to send a big respect to the project’s authors.
I have one question, and I will be so glad to get even an any advice if not solution by anyone.

I need to have in omv’s micropython a few another python libraries. I won’t post them now 'cause it could be look not like a “please, explain” question but “give me step-by-step solution” question.

Them are C-modules for micropython, they doing smth that will be not so effectively to do on micropython/python by itself. For example, generating big QR-codes, for example - some cryptography (not implemented in native mpy, elliptic curves cryptography as example).

There are a few instructions how to compile mpy with C-modules, they can look like this:

compile mpy-cross with just make in mpy-cross directory
move to the needed port (ports/unix or ports/stm32) dir and do make USER_C_MODULES=dir/with/modules

No problems. But let’s see omv’s instructions how to compile the whole project (it will quote be from official github):

Work Flow

We recommend you use VS Code to edit the firmware. VS Code includes a code explorer, excellent code editor, and a built-in terminal. You should install VS Code on your Linux system.

Once you’ve installed VS Code please launch it and then go to File->Open Folder... and select your cloned openmv repository. Next, to compile firmware open a terminal inside VS Code and do:

cd src/micropython/mpy-cross
make

This will build the MicroPython Cross Compilier which we use to include frozen bytecode modules into the OpenMV Cam firmware. This only needs to be done once (or if mpy-cross changes). Next:

cd ../../
make

To build the latest OpenMV Cam firmware. You make target building the firmware for particular OpenMV Cam models by passing TARGET=OPENMV... to make:

make TARGET=OPENMV2 # To build the OpenMV Cam M4 Firmware
...

So what is my question, how to do it? Make for omv compiles micropython by itself? so why in this case I need to compile mpy-cross by myself? Do I need to compile mpy-cross, then compile ports/stm32/, and only after that compile openmv/ ?

It could be not any logical problem, it could be understanding not native lang problem - in this way I will be very appreciate if you can explain me what I misunderstood there. Big thanks to all and authors especially.

seeing this topic - How to compile cexample - #2 by kwagyeman . Am I missing smth else?


I’m not a C-programmer at all. I’m inventor. Trying to start big open source project based on omv. Want to try do myself or pass it to the outsource if I could not.
Should it be so easy as find in one of the Makefiles “make” string where I will place my USER_C_MODULE appending or should I search specialists? All my C-libs contains micropython.mk files so they’re prepared to be integrated in mpy with time less than coding directly into mpy.

Hi, you just run make from the top level per our README… not sure what else you need.

1 Like

We don’t use USER_C_MODULES to add built-in modules, had issues with it, we just add them directly to the port, but you should be able to use it to add your modules. I may change this and use USER_C_MODULES which should make it easier to add custom modules, but no promises.

1 Like

Thank you guys! I will try. In success case we will post our instructions - let open source be easier to everybody.

@tqatxm When this is merged you should be able to add a new module by just adding the .c file to omv/modules/

1 Like

merged, here’s an example:

1 Like

Huge thanks to you! We will mention your help on our project as a thanks if you won’t be against. By some reasons can’t describe project now. Will reask this question when we will deploy website and gh.

1 Like