Unexpected import problem RT1062 and SD card

Hi,

I am upgrading the Wifi RTSP example to provide some more functions. When importing machine(for IO) and socket (for NTP) and running in the IDE everything works fine. However if you save to openmv SD card the script then fails to get started (I have also added an LED step as the first thing to prove it)

To replicate simply take your sample WLAN RTSP and add these after the other imports:
import machine
import socket

Save to openmv with an SD card connected, restart the camera and the script will not start. The UI also starts behaving oddly with errors trying to connect to the camera.

Hi, I just did that and it’s working fine with the latest firmware.

Did you update to the latest? We released an emergency patch about a month ago that fixed a serious issue with the main.py script being saved to an SD card.

Also, potentially install the latest dev firmware.

Hi,

I was running 4.5.2. However, upgrading to latest has fixed it!

Thanks very much!

Hi,

I have more info as I tested again using the camera settings I need (HD 720P). I add an LED to indicate when the camera is ready to stream. The modified sample runs fine in the IDE with HD as the resolution, it runs fine when saved to the internal disk, but fails to run from the SD. No LED or stream. NB all works fine without the HD or without the LED. Occasionally it does work though. I guess it depends on the scene as to how much memory is needed.

rtsp_video_server_wlan_3.py (3.2 KB)

Yeah, I am getting the same error…

Not sure what’s wrong. However, this works instead and better. You should be able to do 30 FPS at 1280x720 from the OV5640:

Replace the sensor code with this:

sensor.set_pixformat(sensor.JPEG)
sensor.set_framesize(sensor.HD)
sensor.set_quality(80)

And use this binary for the RT1062.
firmware.zip (1.3 MB)

Once this PR is merged port/mimxrt: Improve Sensor Driver. by kwagyeman · Pull Request #2102 · openmv/openmv (github.com) JPEG support will be mainlined.

I can also start on eDMA offload support afterwards for the RT1062 which should bring the performance generally up to the STM32H7 when the system is loaded at larger resolutions. This will remove the CPU load from copying image lines to the frame buffer as the image streams in.

The issue may have been this: port/mimxrt: Improve Sensor Driver. by kwagyeman · Pull Request #2102 · openmv/openmv (github.com)

The Frame Buffer Memory sizes are set way too small.

Again, thanks very much for the alternative approach. Unfortunately I am overlaying text on the image, so compression must be by CPU. (1 FPS is enough for the application.)

Also, if it is a buffer size issue, why does the large frame size stream work in the ide? (And on the internal disk)

Mmm, it wouldn’t explain that.

Sorry, I am responding to the multiple threads you have at the same time. For VGA AprilTags we’d allocate 8-10x at minimum before the heap the amount of frame size in RAM. So, it would explain that running low on resources.

However, this is unrelated. Let me re-check with the new firmware if the issue still happens.

It works now with that PR compiled in.

It might be this: openmv/src/omv/ports/mimxrt/sensor.c at master · openmv/openmv (github.com)

I found a bug in the sensor driver that can lead to a null pointer deference that the PR fixes.

I noticed that when it crashed it was immediate which is usually a null pointer issue in the code since you get a bus fault when you do things like that which cause an instant reset.

…

The above null pointer issue would be triggered only in very particular cases. In triple buffer mode it wouldn’t be. But, it would happen in double buffer mode.

firmware.zip (1.3 MB)

New firmware with deepsleep fix.

Hi,

Thanks very for the deep sleep/wake fix. That’s now working again.

I am still getting a crash when using the SD card with the resolution set to VGA. I have cut my code down to a minimum (there is NTP, & timer based overlay and saving/retrieving stills to SD I have cut out) to follow for you.

IP CAMERA rtsp_video_server_wlan_1 min reproduction for sd.py (4.3 KB)

It goes into deep sleep when the client disconnects, so the next time it runs will be from the SD card. Now it does wake, but instantly crashes.

NB I was using double buffered initially, but that I commented out pretty early on yesterday in case it was a memory issue.

Hi, it’s working on my camera with the script you gave me. It handles going between off and on.

I would say though, it didn’t work initially. It appears my disk was corrupted slightly and windows needed to scan and fix it. So, you should probably mount the SD card on your laptop, scan and fix the drive. Then save the code to main.py there.

After I fixed the drive everything works as expected.

Avoid using double buffering. The system will triple buffer by default as long as it has RAM. And with the firmware above it’s hard to run out now given you have all 32MB enabled.

Ok I will try that in the morning. Thanks for the tip. Then assuming it works I will try the whole script.

Thanks again!

Hi, I tried the check disk. Still no joy. So I broke out a new SD card and all is well! (Oddly the PC seems OK with the original card. It must have a fault that the PC can’t/doesn’t report.) So all is well with the full version of the IP camera code too.

Thanks for the tip as it put me on the right track - faulty SD. And the wake fix.

1 Like