ESP32-CAM

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
KJM
Posts: 158
Joined: Sun Nov 18, 2018 10:53 pm
Location: Sydney AU

ESP32-CAM

Post by KJM » Sun May 08, 2022 2:43 am

I'm trying upython on an ESP32-CAM, a board supposedly with 520k ram + 4Mb psram & 32Mb flash (with upython loaded it reports 2Mb ram & 1Mb flash available to the user).

I naively thought 2Mb free ram would solve my [Errno 12] ENOMEM problems from more resource constrained boards, sadly no. If I want to use urequests to upload a photo to a server I first have to camera.deinit() or urequests crashes with [Errno 12] ENOMEM.

If I want to use the camera after I've used requests it won't initialise (OSError: Camera Init Failed) & I can't deinit urequests to fix that issue.

Can someone explain why this is happening? The board still reports 2Mb of free ram if I try urequests without deinitialising the camera or try to initialise the camera after I've used urequests so I'm struggling to understand what resource I've run out of?

KJM
Posts: 158
Joined: Sun Nov 18, 2018 10:53 pm
Location: Sydney AU

Re: ESP32-CAM

Post by KJM » Sun May 08, 2022 8:03 am

I've tracked this down to https. If I use http for urequests uploads prior to using the camera the camera inits OK. It's only when I upload via https before hand that the camera won't init. So its prior ssl use that is preventing the camera initialising (http doesn't use ssl). How can I somehow clean out the ussl garbage after urequests? I tried gc.collect() but that never seems to work.

KJM
Posts: 158
Joined: Sun Nov 18, 2018 10:53 pm
Location: Sydney AU

Re: ESP32-CAM

Post by KJM » Mon May 09, 2022 5:05 am

I tried changing the 38k .py file to a 13k .mpy file but the camera still won't initialise if urquests has previously used ssl. Got further info on why the camera can't initialise though

Code: Select all

E (14790) cam_hal: cam_dma_config(296): DMA buffer 32768 Byte malloc failed, the current largest free block:20992 Byte
E (14800) cam_hal: cam_config(364): cam_dma_config failed
Looks like I'm still 32768-20992=12k short. Does anybody know why gc.collect() isn't cleaning up after ssl? Any tips on what else I could try?

I'm also very curious why running a .mpy in lieu of a .py yields the extra diagnostics on why the camera can't initialise. I don't understand why a precompiled file should behave differently when it comes to diagnostics output?

Post Reply