Cannot find .c file

Ok, this might be a little weird.

I am working on a project involving the ESP32 Cam and want to edit the camera driver (camera.c).
I am unable to find the file though.
Nowhere on my hard drive can I locate the mentioned file.
The project miraculously works.
Also, the driver available on the Espressif git does not seem to work within the Arduino environment.
Am I missing a thing?
Any suggestions?

Thanks for your time!

Can you post a link to this file in the ESP-IDF folder or Arduino-ESP32 repo?

Thanks for your reply!
The link to the original driver:

For the Arduino-ESP32 core, the precompiled ESP-IDF core contains the libesp32-camera.a library file and header:

As you can see when opening the .a archive with an archive manager, the compiled .c files, aka the object files (.o), are contained therein.

(camera.o was created from camera.c once).

The ESP32-Camera driver is thus not compiled from source but included as a precompiled binary blob. That’s how it still works without there being the source C file.

If you wish to exchange the implementiation, you need to compile the new driver within the ESP-IDF framework + Arduino framework (example) and overwrite the libesp32-camera.a in the framework files (<home directory>\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib) with your own one.

When compiling with the ESP-IDF as target framework, you need to include GitHub - espressif/esp32-camera as a proper ESP-IDF component, like the docs tell you.

  1. you will have conflicts regarding double-definition of functions when you throw in the ESP32 camera driver definition source files with some changes
  2. I haven’t tried compilation myself, but it seems likely to me that it still needs the full ESP-IDF as a base? See Arduino+ESP-IDF example above (combination is possible). Otherwise I would need to see an error message and reproducable project.
1 Like

Oh, man! Thank you so much! This really helps!

Sorry to bother again, could you explain how you traced the file?

So we know that we are searching for a camera.c file that originally comes from an ESP-IDF component in the esp32-camera repository, and we also know that it compiles out of the box within Arduino IDE.

Searching for camera.c within the framework-arduinoespressif32 folder (aka GitHub - espressif/arduino-esp32: Arduino core for the ESP32) with the file explorer gives no results.Thus the file must either be in another source directory or be provided as a precompiled library. Since no other source files are compiled that are not from Arduino-ESP32 (can be checked from a compile log), the latter must be true. Now the compile file could be in any precompiled archive (.a) file, so we can search for all those in the explorer (*.a). We then see that Arduino-ESP32 has a list of precompiled SDK libraries (aka ESP-IDF and some commonly used components) concentrated in https://github.com/espressif/arduino-esp32/tree/master/tools/sdk/lib.

One is supsiciously named libesp32-camera, just like the repository name, and is the file we are looking for, after inspecting it with e.g. 7zip.

Alternatively, if it’s not directly identifiable, we can of course use the binary tools of the toolchain (toolchain-xtensa32), specifically xtensa-esp32-elf-nm. It can list symbols of an object and archive file. We can ask the platform-specifc nm tool to list the defined symbols of the libesp32-camera.a file and search for a camera.o object file (we know the camera.c should produce a camera.o object file after compilation). I’m doing the searching with GnuWin32 tools here so that I can use a unix-style grep.

C:\Users\Maxi\.platformio\packages\toolchain-xtensa32\bin>xtensa-esp32-elf-nm.exe --line-numbers --defined-only "C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib\libesp32-camera.a"  | grep -A30 "camera.o"
camera.o:
00000000 r __func__$6734
00000000 r __func__$6780
00000000 r __FUNCTION__$6755
00000000 r __FUNCTION__$6771
00000000 r __FUNCTION__$6834
00000000 r __FUNCTION__$6976
00000000 r __FUNCTION__$6983
00000000 r __FUNCTION__$6992
00000000 r __FUNCTION__$6999
00000000 t _gpio_get_level
00000000 t camera_fb_deinit
00000aac t camera_fb_done       /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/components/esp32-camera/driver/camera.c:920
00000000 t camera_fb_init
00000000 T camera_init
00000000 T camera_probe
00000000 t dma_desc_deinit
00000000 t dma_desc_init
00000034 t dma_filter_buffer
00000154 t dma_filter_grayscale
000001ac t dma_filter_grayscale_highspeed
000000fc t dma_filter_jpeg
000003b4 t dma_filter_rgb888
00000480 t dma_filter_rgb888_highspeed
00000d04 t dma_filter_task      /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/components/esp32-camera/driver/camera.c:357
0000022c t dma_filter_yuyv
000002cc t dma_filter_yuyv_highspeed
00000be4 t dma_finish_frame     /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/components/esp32-camera/driver/camera.c:454
00000000 T esp_camera_deinit
00000000 T esp_camera_fb_get
00000000 T esp_camera_fb_return

Alternatively with a Powershell, iterate through all *.a files with a small get-item gadget (and a select-string command instead of grep this time).

PS C:\Users\Maxi\.platformio\packages\toolchain-xtensa32\bin> .\xtensa-esp32-elf-nm.exe -A --line-numbers --defined-only (get-item C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib\*.a).FullName  | select-string -Pattern "camera\.o" -Context 0,30

> C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib\libesp32-camera.a:camera.o:00000000 r __func__$6734
> C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib\libesp32-camera.a:camera.o:00000000 r __func__$6780
> C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib\libesp32-camera.a:camera.o:00000000 r __FUNCTION__$6755
> C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib\libesp32-camera.a:camera.o:00000000 r __FUNCTION__$6771
> C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib\libesp32-camera.a:camera.o:00000000 r __FUNCTION__$6834
> C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib\libesp32-camera.a:camera.o:00000000 r __FUNCTION__$6976
> C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib\libesp32-camera.a:camera.o:00000000 r __FUNCTION__$6983
> C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib\libesp32-camera.a:camera.o:00000000 r __FUNCTION__$6992
> C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib\libesp32-camera.a:camera.o:00000000 r __FUNCTION__$6999
> C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib\libesp32-camera.a:camera.o:00000000 t _gpio_get_level
> C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib\libesp32-camera.a:camera.o:00000000 t camera_fb_deinit
> C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib\libesp32-camera.a:camera.o:00000aac t camera_fb_done
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/components/esp32-camera/driver/camera.c:920

And thus we get the same result, the path to the .a file and even the function names and symbols compliled in them.

The ar tool can also be used if no symbol information is required.

PS C:\Users\Maxi\.platformio\packages\toolchain-xtensa32\bin> .\xtensa-esp32-elf-ar t C:\Users\Maxi\.platformio\packages\framework-arduinoespressif32\tools\sdk\lib\libesp32-camera.a
sensor.o
twi.o
camera.o
xclk.o
sccb.o
esp_jpg_decode.o
to_bmp.o
yuv.o
ov2640.o
ov3660.o
ov7725.o
jpge.o
to_jpg.o
1 Like