ESP32 Cam cannot initialize after restart

MV-Fabian
Posts: 1
Joined: Mon May 09, 2022 3:09 pm

ESP32 Cam cannot initialize after restart

Postby MV-Fabian » Mon May 09, 2022 3:30 pm

Hello,

we use our ESP32-CAM in combination with a SIM800L module to transmit images to a server. Therefore, we need two operating modes: one for recording images, and one for transmitting them. We use ESP.restart() to reboot and read the requested operating mode from the SD Card.

The camera can successfully be initialized exactly once. After every following reboot, the camera cannot be initialized with this error message:

Code: Select all

E (2243) cam_hal: cam_dma_config(280): frame buffer malloc failed
E (2244) cam_hal: cam_config(364): cam_dma_config failed
E (2244) camera: Camera config failed with error 0xffffffff
If we restart the module by removing and re-applying power, the camera initializes fine each time. Therefore, we suspect that ESP.restart() is the culprit.

This log may further illustrate the problem:

Code: Select all

SDMMC initialization: successful!
[GSM] Serial Connection started
[GSM] Modem initialized: 1
[GSM] Current SIM status: 1
[GSM] Sim Ready!
GSM initialization: successful!
KEF Device state:
        Device mode:            Transmitting Mode
        SD initialized:          1
        GSM initialized:         1
        Cam initialized:         0
[GSM] Transmit dummy
�R��fgR

RESTART

SDMMC initialization: successful!
Camera initialization: successful!
KEF Device state:
        Device mode:            Record Mode
        SD initialized:          1
        GSM initialized:         0
        Cam initialized:         1
[CAM] Taking pigtu�en..�
/1268.jpg
[CAM] File saved: /1268.jpg
[CAM] �akyng(picture/..
/4793.jpg
[CAM] File saved: /4793.jpg
[CAM] taki�g �icture...
/8357.jpg
[CAM] File saved: /8357.jpg
[CCM] Taking picture�.�
/11926.jpg
[CAM] File saved: /11926.jpg
[CAM] Taoing qicuuse...
/15487.jpg
[CAM] File saved: /15487.jpg
[CAM] Taking picture...
/19048.jpg
[CAM] File saved: /19048.jpg
[CAM] Taking picture...
/22610.jpg
[CAM] File saved: /22610.jpg
[SAMW��aokn�$pkcture...
/26171.jpg
[CAM] File saved: /26171.jpg
{CAM] Takinw pictuze...
/29733.jpg
[CAM] File saved: /29733.jpg
�R��fgR

RESTART

SDMMC initialization: successful!
[GSM] Serial Connection started
[GSM] Modem initialized: 1
[GSM] Current SIM status: 1
[GSM] Sim Ready!
GSM initialization: successful!
KEF Device state:
        Device mode:            Transmitting Mode
        SD initialized:          1
        GSM initialized:         1
        Cam initialized:         0
[GSM] Transmit dummy
�R��fgR��c�o�oo

RESTART

SDMMC initialization: successful!
E (2243) cam_hal: cam_dma_config(280): frame buffer malloc failed
E (2244) cam_hal: cam_config(364): cam_dma_config failed
E (2244) camera: Camera config failed with error 0xffffffff
[CAM] Camera init failed with error 0xffffffff
Camera initialization: failed!
Error number = -1
KEF Device state:
        Device mode:            Record Mode
        SD initialized:          1
        GSM initialized:         0
        Cam initialized:         0
[CAM] Not initialized
�R��fgR��c�o�oo

RESTART

SDMMC initialization: successful!
[GSM] Serial Connection started
[GSM] Modem initialized: 1
[GSM] Current SIM status: 1
[GSM] Sim Ready!
GSM initialization: successful!
KEF Device state:
        Device mode:            Transmitting Mode
        SD initialized:          1
        GSM initialized:         1
        Cam initialized:         0
[GSM] Transmit dummy
�R��fgR��c�o�oo

RESTART

SDMMC initialization: successful!
E (2243) cam_hal: cam_dma_config(280): frame buffer malloc failed
E (2244) cam_hal: cam_config(364): cam_dma_config failed
E (2244) camera: Camera config failed with error 0xffffffff
[CAM] Camera init failed with error 0xffffffff
Camera initialization: failed!
Error number = -1
KEF Device state:
        Device mode:            Record Mode
        SD initialized:          1
        GSM initialized:         0
        Cam initialized:         0
[CAM] Not initialized
We initialize the camera like so:

Code: Select all

esp_err_t init_camera()
{   
    pinMode(led_gpio, OUTPUT);

    config.ledc_channel = LEDC_CHANNEL_0;
    config.ledc_timer = LEDC_TIMER_0;
    config.pin_d0 = Y2_GPIO_NUM;
    config.pin_d1 = Y3_GPIO_NUM;
    config.pin_d2 = Y4_GPIO_NUM;
    config.pin_d3 = Y5_GPIO_NUM;
    config.pin_d4 = Y6_GPIO_NUM;
    config.pin_d5 = Y7_GPIO_NUM;
    config.pin_d6 = Y8_GPIO_NUM;
    config.pin_d7 = Y9_GPIO_NUM;
    config.pin_xclk = XCLK_GPIO_NUM;
    config.pin_pclk = PCLK_GPIO_NUM;
    config.pin_vsync = VSYNC_GPIO_NUM;
    config.pin_href = HREF_GPIO_NUM;
    config.pin_sscb_sda = SIOD_GPIO_NUM;
    config.pin_sscb_scl = SIOC_GPIO_NUM;
    config.pin_pwdn = PWDN_GPIO_NUM;
    config.pin_reset = RESET_GPIO_NUM;
    config.xclk_freq_hz = 20000000;
    config.pixel_format = PIXFORMAT_JPEG;

    if (psramFound())
    {
        config.frame_size = FRAMESIZE_QVGA; // FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA
        config.jpeg_quality = 10;
        config.fb_count = 2;
    }
    else
    {
        config.frame_size = FRAMESIZE_SVGA;
        config.jpeg_quality = 12;
        config.fb_count = 1;
    }

    cam_err = esp_camera_init(&config);

    if (cam_err == ESP_OK)
    {
        camera_initialized = true;
    }
    else
    {
        Serial.printf("[CAM] Camera init failed with error 0x%x", cam_err);
    }

    return cam_err;
}
We suspect that maybe some register or memory is not cleared correctly. Did anybody experience similar problems and can maybe even provide a solution? Thanks in advance!

Best Regards

icepick
Posts: 3
Joined: Thu May 18, 2023 1:58 pm

Re: ESP32 Cam cannot initialize after restart

Postby icepick » Thu May 18, 2023 2:00 pm

Did you ever find a solution to this problem? I am having the same issue.

Who is online

Users browsing this forum: Bing [Bot] and 84 guests