Add Custom Module to OpenMV firmware

Hey there you guys, I love what the engineers here have created, has helped me so much in my understanding of embedded systems and drastically expanded my prototyping skills.

I am here to ask your help on adding my own custom module to the firmware so that I can have the files burned to the device permanently.

At the moment I have a few .py files I have been dragging onto the board through the USB storage. This has worked super well; however, I am developing an IoT device powered by the sun which has created some complications due to the unreliable power source. A few of my boards have reset their file system and erased the files I have added, and reset the board to the original main.py file (with the blinking blue LED). This forces me to upload the files again from my computer. I would like to put my .py files on the firmware so that if it were to reset itself, that it would automatically load the .py files and hopefully eliminate my issue.

I have tried downloading VirtualBox and going through the firmware build instructions on GitHub to make the Openmv.dfu file for flashing, but have been unsuccessful due to some warnings regarding string truncation (I can upload the error log if needed). My original plan was to make the static C file from my python files and try to have those built into the .dfu file but have not succeeded.

Is there a better way of doing this?
Also any idea as to how I can get past the string truncation warnings?

  • I had to download the gcc-arm-none-ebai library from the ARM developer page because the apt repo is not working for me

Hi, if you build the firmware as normal and just drop your .py files in this folder: openmv/scripts/libraries at master · openmv/openmv · GitHub then they will be compiled into the firmware and available for main.py to use. Anything in the libraries directory is frozen and then linked with the main executable.

Regrading the build instructions. Sounds like you deviated from them… you should follow them exactly. I say what to do using the command line to install tools.

Thank you so much for the fast response, I will definitely add my files to the proper location.

I have tried following the commands exactly but have an issue on the following: sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa

This was the error from the command:
sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
This PPA is an alternative to toolchain released at GNU Arm Embedded Toolchain in Launchpad. The source codes for both are same. Currently supports Ubuntu 10.04/12.04/14.04/14.10 32 and 64 bit.

Detailed explanations to Launchpad PPA can be found at Packaging - Launchpad Help. That website explains how a PPA is set up and how to add existing PPA and install software from it.

Here are quick steps to install toolchain from this PPA on Ubuntu before 14.04:

Step1: Inside Ubuntu, open a terminal and input
“sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa”

Step2: Continue to input
“sudo apt-get update”

Step3: Continue to input to install toolchain
“sudo apt-get install gcc-arm-embedded”

To remove installed toolchain, just input “sudo apt-get remove gnu-arm-embedded”.
To update the toolchain, just repeat above step2 and step3.

If it reports error message of conflict to gcc-arm-none-eabi, which is likely if upgrading from 4.x to 5+, please uninstall it first with:
“sudo apt-get remove gcc-arm-none-eabi”

Questions should be asked at https://answers.launchpad.net/gcc-arm-embedded

Bug can be filed at https://bugs.launchpad.net/gcc-arm-embedded/+filebug. It is highly encouraged to ask question first before filing a bug.
More info: GNU Arm Embedded Toolchain : “GCC Arm Embedded Maintainers” team
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [107 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Ign:4 http://ppa.launchpad.net/team-gcc-arm-embedded/ppa/ubuntu focal InRelease
Get:5 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
Err:6 http://ppa.launchpad.net/team-gcc-arm-embedded/ppa/ubuntu focal Release
404 Not Found [IP: 91.189.95.83 80]
Get:7 http://us.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [122 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [235 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [149 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [6,960 B]
Get:11 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [124 kB]
Get:12 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [167 kB]
Get:13 http://us.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [532 B]
Get:14 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [21.2 kB]
Get:15 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [35.8 kB]
Reading package lists… Done
E: The repository ‘http://ppa.launchpad.net/team-gcc-arm-embedded/ppa/ubuntu focal Release’ does not have a Release file.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.



*** The steps listen in the error are leading me to believe its because of the version of Ubuntu I am running (18.04) but I am just hoping this isn’t the case. Should i download 14.04?**

Um, just try the steps that it says?

I haven’t run the command line script that I posted for building firmware in a while. It may be out of date. My VM I use to compile code has been running for years now.

I have tried the suggested ones, I was able to download the library from ARM developer page (GNU Toolchain | GNU Arm Embedded Toolchain Downloads – Arm Developer) but when running ‘make TARGET=OPENMV4’ in the /src/ directory, I get the string truncation warnings. I have removed the -Werror CFLAG from the makefile, this successfully builds the firmware but it does not successfully run the main.py file on the board after installing.

Your advice is super helpful and I’ll keep playing around with it to see if I can get something to work.

I only have 2 more questions:

  1. is TARGET=OPENMV4 used for STM32 boards?
  2. how can I overwrite the main.py file of the firmware?

actually ignore question #1, I believe I should be using OPENMV4 as the target. I am using STM32H743ZIT6

The main.py file is inside of the main.c file under omv/

It’s included as a string in the source. However, you could create a C file out of a python file string and then just extern that as the main.py file to link into the main application. This is easier than embedding the python file into the C file.

Alternatively, put all your code in the libraries directory and make main.py just execute a library immediately.

Awesome, I think I can make it all work with that info. I am still having some issues building a working version of the firmware.

What version of ubuntu are you running and what version of the GNU Arm Embedded Toolchain are you using? I am just gonna mimic that and see if I get past these string errors

for anyone with the issue regarding the GNU toolchain,

using Ubuntu 18.04, I was not able to download the repo from the command line. But after downgrading to Ubuntu 14.04, it worked out just fine

Ubuntu 16 LTS

I have added my module to the libraries directory but when I try to import it on the command line, it says the module does not exist. Anything else I should try?

And you flashed the firmware to the camera? the libraries folder gets compiled into the firmware image.

In the end I got the firmware to build! My main issue was using the wrong version of Ubuntu.

I fixed my issue by using Ubuntu 14.04

I got the firmware to build with VirtualBox using Ubuntu 14.04 but had a few issues with apt-get in regards to the GNU Arm Toolchain. Ultimately I had to download it from the ARM website.

I recommend spending the money to get VMWare Fusion as I had no problems installing any packages. The firmware guide worked perfectly every step of the way!