Notice for UNITCAM users, IDF and Arduino IDE



  • Hi, just want to address users of the M5Stack UNITCAM which are trying or want to try the Arduino IDE Framework, or the ESP-IDP Framework.

    There is a bug introduced somewhere this year (2021) in the "ESP32-camera" Software, which causes all ESP32 CAMERA DEVICES WITHOUT PSRAM to fail when executing the camera initialization code...
    The problem is created during the compilation procedure, where PSRAM is ALWAYS selected, independent of the setup that the user does, and independent if the device has or do not have PSRAM...
    So, the binary code ALWAYS try to use PSRAM, causing a CRASH in the execution...
    Which may produce an error message like this:

    [error message]

    E (127) cam_hal: cam_dma_config(280): frame buffer malloc failed
    E (127) cam_hal: cam_config(364): cam_dma_config failed
    E (127) camera: Camera config failed with error 0xffffffff
    Camera init failed with error 0xffffffff 
    

    This problem is reported here on the ESP32-Camera Github development website:

    [issue on GitHub]
    https://github.com/espressif/esp32-camera/issues/334

    In the beginning, after trying several different samples, and all of them giving the same error message, I started to think that my unit has a hardware problem with the camera... but, then I saw the Github issue report, which makes perfect sense for my case...

    I then downloaded older versions of the ESP32-Camera software and test with success in the first attempt.
    First I did with ESP-IDF Programming Framework, success!

    Then, I search on how to use older soft/libraries with the Arduino IDE, found the information on the Espressif website and tried old version (about the same time/day of the IDF code I had selected), and it WORKED OK!

    [How to install esp32 on Arduino - Espressif site]
    https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html

    So, a temporary solution for the problem is:
    DOWNLOAD AN OLD VERSION (COMMIT) OF THE ESP32-CAM, it was working OK in the past...
    I did not check WHEN, exactly, the bug was introduced, which I think is somewhere between FEBRUARY and AUGUST of 2021...
    For me, 2021/FEB/22 versions works OK...

    This problem seems very simple and easy to correct, so we must expect that in few days a solution is announced on the ESP32-Camera Github development website...

    I am writing 2 little texts explaining how to use old version of the ESP32-Camera.
    The first is about ESP-IDF Framework, the second Arduino IDE, and I will post/publish here...

    Knowing how to use different versions of the code is VERY helpful in many circumstances, and can give the user another level of understanding when using code samples or when trying to create/modify code, so I think that it is worth to know about.
    There are thousands of good projects/samples/tutorials on Internet, and many of them will work fine and well, ONLY when we use old versions of some software components, so, learning how to use old versions (or different) can be interesting...

    In this present post I just want to inform UNICAM users that, for ESP-IDF and Arduino IDE, using the camera may return errors like the one in the top of this post, and what the reason is... so there is an easy solution, which is: USE OLD VERSIONS OF THE CODE!

    Next posts I will explain the details about using old versions (also called commits) of the code, for IDF and for Arduino IDE.

    Regard all,
    Valter



  • This text uses Google Translate.

    I use UNIT CAMERA DIY KIT.
    I tested it with the latest cameraWebServer sample program.
    I got the same error, so I checked the source program.
    I found the following description in the comment of esp_camera.h.

    typedef enum {
    CAMERA_FB_IN_PSRAM, / *! <Frame buffer is placed in external PSRAM * /
    CAMERA_FB_IN_DRAM / *! <Frame buffer is placed in internal DRAM * /
    } camera_fb_location_t;

    I added one line to the cameraWebServer program as a trial.

    // if PSRAM IC present, init with UXGA resolution and higher JPEG quality
    // for larger pre-allocated frame buffer.
    if (psramFound ()) {
    config.frame_size = FRAMESIZE_UXGA;
    config.jpeg_quality = 10;
    config.fb_count = 2;
    } else {
    config.frame_size = FRAMESIZE_SVGA;
    config.jpeg_quality = 12;
    config.fb_count = 1;
    config.fb_location = CAMERA_FB_IN_DRAM; // add 2021-12-09
    }

    I checked the operation of UNIT CAM.

    12: 48: 08.541-> ets Jul 29 2019 12:21:46
    12: 48: 08.541->
    12: 48: 08.541-> rst: 0x1 (POWERON_RESET), boot: 0x13 (SPI_FAST_FLASH_BOOT)
    12: 48: 08.541-> configsip: 0, SPIWP: 0xee
    12: 48: 08.541-> clk_drv: 0x00, q_drv: 0x00, d_drv: 0x00, cs0_drv: 0x00, hd_drv: 0x00, wp_drv: 0x00
    12: 48: 08.541-> mode: DIO, clock div: 1
    12: 48: 08.541-> load: 0x3fff0030, len: 1420
    12: 48: 08.587-> ho 0 tail 12 room 4
    12: 48: 08.587-> load: 0x40078000, len: 13540
    12: 48: 08.587-> load: 0x40080400, len: 3604
    12: 48: 08.587-> entry 0x400805f0
    12: 48: 08.821->
    12: 48: 09.675-> ...........
    12: 48: 14.695-> WiFi connected
    12: 48: 14.695-> Camera Ready! Use'http://192.168.1.220' to connect

    3_1639047929018_スクリーンショット (675).png 2_1639047929018_スクリーンショット (676).png 1_1639047929018_スクリーンショット (677).png 0_1639047929017_スクリーンショット (678).png