Saving IDE Code as main.py failure

Hello. I have upgraded to OpenMV IDE 1.3.0 and my OpenMV Board to 2.0.0 via the IDE. I am not able to figure out how to save the IDE code in main.py despite many attempts. Using the TOOLS - Save open script to OpenMV Cam followed by a TOOLS - Reset OpenMV Cam does not seem to change my main.py. It is stuck as a zero byte file (as shown in the windows file explorer). I cannot delete it and replace using Windows file explorer before a new zero byte file appears (following the deletion). I am apparently missing a step somewhere here. The code I write in the IDE operates as intended. I am just unable to save it to main.py for use without the IDE. Can anyone enlighten me? Austin

Hi,

This behavior seems very weird. Are you using an SD card or the internal file system? As for the 0 byte being reported by Windows Explorer that seems to be a bug I’ve noticed with the MicroPython code but it doesn’t mater to get a script working.

Can you try saving main.py to an SD card and having one inserted with the system? Or maybe try another SD card if you are using one already?

It seems you are doing everything right BTW. So, the problem lies somewhere else. I can confirm that the newest firmware works correctly to do what you want.

I was using the internal file system and not an SD card. I have some time this afternoon so I’m going to try all of this again on another computer (one still using Win 7) and I’ll get an SD Card to try saving to it. Thanks for your suggestions. More later as I progress down this path. Austin

Using a 1GB SD card and the Win7 PC, I am able to save the main.py file and achieve Micro Python statement execution without the IDE. Upon editing the main.py using OpenMV IDE, the OpenMV board suddenly started flashing RED (indicating a syntax error, I assume) upon power up and would not execute my script. When I use one of my other boards (a Micro Python PYBLITEv1.0), I have to use Programmers Notepad (or another text editor) to edit and enter text into a main.py file. I loaded the main.py from the OpenMV board using Programmers Notepad and discovered an extra 4 spaces (almost like a TAB) before my last statement. I deleted the extra spaces and saved main.py using programmers notepad back to the OpenMV board and all was well. I’ll keep you updated on my trials here. I have been adapting many of the Micro Python 1.8 tutorials to the OpenMV board and find they work fine after I use the proper LED codes and other changed port differences. Thanks for the IDE and OpenMV board. I’m certain I will get my head around its subtle differences to the PYBLITEv1.0 - Austin

While use of the SD Card seems to solve my file save issues, I am still not able to use the internal file system. (Windows is now complaining the file structure is corrupt when I try to access the zero byte file) I searched the DOC’s for the factory reset process but I cannot find any links to that topic. May I know the process for factory reset and rebuilding of the main.py file) or can you point me to the DOC link?

Yes, so, disconnect the IDE from the cam. But, leave the cam plugged into the computer. The option in the tools menu to run the bootloader will be on then. Open the bootloader dialog and find the firmware.bin file for the OpenMV Cam which is in the /share/qtcreator/firmware/OMV2/firmware.bin.

Then, make sure to also select erase internal file system. This will factory reset everything except for the bootloader itself. If you want to do that then select the openmv.dfu file which will erase all sectors using DFU and load the factory firmware. You can also use OpenMV IDE to DFU upload pyboards.

I think I can get OpenMV IDE working for the PYBoard too. But, right now I’m going to focus on getting QRCode support working so I can make a demo and then get some more pre-orders for the M7 board. I should be able to get QRCode support working on the M4 too.

Thank you very much. The firmware.bin loaded as you said and I have a good main.py file now. I look forward to your future posts and I ordered a model 7 for when they are ready.