Micropython autoboot boot.py


Can you make a sub thread called Portenta-micropython. A fair number of people have micropython questions. My first questions would be, how do we get a boot.py file onto our board. Everything works fine connected to the IDE, but when I choose to dave the program to my drive, it does not work when running on a cell phone battery pack. Any I don’t see a boot.py file on the drive. My main.py file is there.

Our firmware just runs the main.py file. However, if there’s a boot.py file we will run that first, then the main.py.

Use Tools->Save Script to OpenMV Cam, to save the script to the OpenMV Cam.



Do you have a boot.py script that we could try. Just running main.py without your IDE does not work for me.

I found this on an adafruit site. Is tht all that is needed in a boot.py file?

boot.py – run on boot-up

can run arbitrary Python, but best to keep it minimal

import pyb
#pyb.main(‘main.py’) # main script to run after this one
#pyb.usb_mode(‘CDC+MSC’) # act as a serial and a storage device
#pyb.usb_mode(‘CDC+HID’) # act as a serial device and a mouse

Curious in the above file if # is a comment or not. Kind of looks like # with a space is a comment but #No space is a special command

Did you save a main.py script to the camera? And then reset the camera. And what output do you expect it to generate?


Quick question, since my installation may have some issues, does your portenta with camera work when disconnected from the IDE. Say just powered with a usb battery? Mine doesn’t, just curious if yours does.

Let me check.

I tested saving a script to the camera and it works as expected.

Save the script to OpenMV Cam under Tools.
Then reset the camera with the reset OpenMV Cam option under Tools.

Yes, but your test has you still connected to the IDE, I want to know if fully away from the computer, only powered by a usb charger the script can run. The only reset capable is a single push on the Portenta button, or just plugging in the usb charger.

Yeah, I saved a script on the camera and just had it plugged in via a USB C cable to a power only port and it was blinking the LED onboard. I programmed it to blink the red led versus the blue one.

That is interesting, because I thought I did have that working a week ago (around the time my Vision Shield was working), but I can’t reproduce it now. Since my Camera is also not working perhaps somehow I have a software issue. I will try to see if I can get that part of micropython working again. Thanks for doing that little test. That is very helpful.

Thanks so much for your help Nyamekye. I thought a video would help. Is it possible you have some software installed that we don’t.

See video in the attachments.

This is a fresh install of OpenMV version 2.6.5
bootfail010001-1348.mp4 (5.78 MB)

This is also really interesting. I got a brand new Portenta today. Installed v21 Portenta Bootloader using version 1.3.0 MBED. Ran it on OpenMV IDE and it did not install into the folder the .openmv_disk file which somehow helps the menu commands

Tools → Open OpenMV cam Drive folder
→ Configure…
→ save open script …

So I can’t even test if this Portenta auto boots unless I drag main.py to the folder.

Also tried the Vision Shield and it went into panic flashing white mode.

Hope this info helps.

Hi, can you run the Tools->Reset OpenMV Cam command after saving the script with the IDE?

I think what you might be running into is the fact that the internal disk size is small enough that the OS treats it as FAT12 and doesn’t flush writes immediately but caches them. What’s the disk size when you plug the device in?

Wait, just watched the video.

Mmm, okay, that’s definitely odd, that was the exact procedure I just did. I also unplugged and plugged the device in too, but, otherwise it worked.

Um, can you install this firmware here on the Portenta? Release v3.6.9 · openmv/openmv · GitHub

Install the Portenta/firmware.bin using Run Bootloader under tools.

Awesome. New Release fixes the autoboot ability. Thank you so much. Both my personal Portentas are now autobooting. I will see what that has done to my ability to use the Vision Shield.

Any idea when this new version will be released? I want to make a video about micropython to add to my Portenta playlist https://www.youtube.com/watch?v=DHXquGNvXUQ&list=PL57Dnr1H_egtm0pi-okmG0iE_X5dROaLw&index=24 but don’t want to explain how to install the future release.

Has it already been released?

I just need to get the Mac IDE to compile and I can release. I’ll try to get this done next week.

There’s a lot on my plate however.

No rush, this works so it is the least of my worries.

I’m working on redoing our lcd code base right now.

After the commit is in… the display port out on the Portenta should work allowing you to display what the camera sees on screen.

Better yet, it will display it using a triple buffer architecture so no updates to the screen ever block. And… you’ll have scaling support.

The same code update will also make the SPI LCD screen support a lot better along with giving us better 24-bit parallel LCD support for platforms with large touch screen LCDs.