I’m using lib_deps=esp32-camera
But whenever I initialize camera with esp_init_camera
, It gave me error linker.
I read previous old topic that say C and C++ include is not compatible each other, but still it gave me no clue what to do. I have stuck with this error for 24 hours with no result:
Here is what is my code, just focus to app_main
if you lazy to read.
#include <stdio.h>
#include "driver/gpio.h"
#include "driver/uart.h"
#include "esp_camera.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "sdkconfig.h"
// LED BUILT-IN
#define BUILT_IN_LED 33
// UART PIN
#define UART_PIN_TXD GPIO_NUM_1
#define UART_PIN_RXD GPIO_NUM_3
#define UART_PIN_RTS UART_PIN_NO_CHANGE
#define UART_PIN_CTS UART_PIN_NO_CHANGE
#define UART_BUF_SIZE 1024
// CAMERA PIN
#define CAM_PIN_PWDN GPIO_NUM_32 // power down is not used
#define CAM_PIN_RESET -1 // software reset will be performed
#define CAM_PIN_XCLK GPIO_NUM_0
#define CAM_PIN_SIOD GPIO_NUM_26
#define CAM_PIN_SIOC GPIO_NUM_27
#define CAM_PIN_D7 GPIO_NUM_35
#define CAM_PIN_D6 GPIO_NUM_34
#define CAM_PIN_D5 GPIO_NUM_39
#define CAM_PIN_D4 GPIO_NUM_36
#define CAM_PIN_D3 GPIO_NUM_21
#define CAM_PIN_D2 GPIO_NUM_19
#define CAM_PIN_D1 GPIO_NUM_18
#define CAM_PIN_D0 GPIO_NUM_5
#define CAM_PIN_VSYNC GPIO_NUM_25
#define CAM_PIN_HREF GPIO_NUM_23
#define CAM_PIN_PCLK GPIO_NUM_22
static uart_config_t konfig_uart = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.source_clk = UART_SCLK_APB,
};
static camera_config_t konfig_kamera = {
.pin_pwdn = CAM_PIN_PWDN,
.pin_reset = CAM_PIN_RESET,
.pin_xclk = CAM_PIN_XCLK,
.pin_sscb_sda = CAM_PIN_SIOD,
.pin_sscb_scl = CAM_PIN_SIOC,
.pin_d7 = CAM_PIN_D7,
.pin_d6 = CAM_PIN_D6,
.pin_d5 = CAM_PIN_D5,
.pin_d4 = CAM_PIN_D4,
.pin_d3 = CAM_PIN_D3,
.pin_d2 = CAM_PIN_D2,
.pin_d1 = CAM_PIN_D1,
.pin_d0 = CAM_PIN_D0,
.pin_vsync = CAM_PIN_VSYNC,
.pin_href = CAM_PIN_HREF,
.pin_pclk = CAM_PIN_PCLK,
.xclk_freq_hz = 20000000, // EXPERIMENTAL: Set to 16MHz on ESP32-S2 or
// ESP32-S3 to enable EDMA mode
.ledc_timer = LEDC_TIMER_0,
.ledc_channel = LEDC_CHANNEL_0,
.pixel_format = PIXFORMAT_JPEG, // YUV422,GRAYSCALE,RGB565,JPEG
.frame_size =
FRAMESIZE_UXGA, // QQVGA-QXGA Do not use sizes above QVGA when not JPEG
.jpeg_quality = 12, // 0-63 lower number means higher quality
.fb_count =
1, // if more than one, i2s runs in continuous mode. Use only with JPEG
.grab_mode = CAMERA_GRAB_WHEN_EMPTY // CAMERA_GRAB_LATEST. Sets when
// buffers should be filled
};
esp_err_t mulai_uart() {
esp_err_t err =
uart_driver_install(UART_NUM_1, UART_BUF_SIZE * 2, 0, 0, NULL, 0);
if (err == ESP_OK) {
uart_param_config(UART_NUM_1, &konfig_uart);
uart_set_pin(UART_NUM_1, UART_PIN_TXD, UART_PIN_RXD, UART_PIN_RTS,
UART_PIN_CTS);
}
return err;
}
esp_err_t mulai_kamera() {
// initialize the camera
esp_err_t err = esp_camera_init(&konfig_kamera);
if (err != ESP_OK) {
return err;
}
return ESP_OK;
}
esp_err_t mulai_led() {
gpio_pad_select_gpio(BUILT_IN_LED);
return gpio_set_direction(BUILT_IN_LED, GPIO_MODE_OUTPUT);
}
void app_main() {
mulai_kamera();
mulai_led();
mulai_uart();
uint8_t i = 0;
while (1) {
char teks[2];
sprintf(teks, "%d", i % 2);
teks[1] = '\n';
uart_write_bytes(UART_NUM_1, &teks, sizeof(teks));
gpio_set_level(BUILT_IN_LED, i % 2);
vTaskDelay(3000 / portTICK_RATE_MS);
i++;
}
}
And this is error linker message when build
Processing esp32cam (platform: espressif32; board: esp32cam; fram
ework: espidf)
-----------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif3
2/esp32cam.html
PLATFORM: Espressif 32 (5.0.0+sha.e66e12c) > AI Thinker ESP32-CAM
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-p
rog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-
arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
- framework-espidf @ 3.40401.0 (4.4.1)
- tool-cmake @ 3.16.4
- tool-esptoolpy @ 1.30300.0 (3.3.0)
- tool-idf @ 1.0.1
- tool-mconf @ 1.4060000.20190628 (406.0.0)
- tool-ninja @ 1.9.0
- toolchain-esp32ulp @ 1.22851.191205 (2.28.51)
- toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
Reading CMake configuration...
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ld
f
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 1 compatible libraries
Scanning dependencies...
Dependency Graph
|-- esp32-camera @ 2.0.0
Building in release mode
Compiling .pio\build\esp32cam\src\main.o
Linking .pio\build\esp32cam\firmware.elf
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(ov2640.o):(.l
iteral.set_xclk+0x4): undefined reference to `xclk_timer_conf'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(ov2640.o): in
function `set_xclk':
C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pio/libde
ps/esp32cam/esp32-camera/sensors/ov2640.c:502: undefined referenc
e to `xclk_timer_conf'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(esp_camera.o)
:(.literal.camera_probe+0x1c): undefined reference to `camera_ena
ble_out_clock'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(esp_camera.o)
:(.literal.camera_probe+0x20): undefined reference to `camera_dis
able_out_clock'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(esp_camera.o)
: in function `camera_probe':
C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pio/libde
ps/esp32cam/esp32-camera/driver/esp_camera.c:138: undefined refer
ence to `camera_enable_out_clock'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pi
o/libdeps/esp32cam/esp32-camera/driver/esp_camera.c:169: undefine
d reference to `camera_disable_out_clock'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pi
o/libdeps/esp32cam/esp32-camera/driver/esp_camera.c:198: undefine
d reference to `camera_disable_out_clock'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(esp_camera.o)
: in function `esp_camera_deinit':
C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pio/libde
ps/esp32cam/esp32-camera/driver/esp_camera.c:211: undefined refer
ence to `camera_disable_out_clock'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o):(.
literal.cam_start_frame+0x4): undefined reference to `ll_cam_star
t'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o):(.
literal.cam_start_frame+0x8): undefined reference to `ll_cam_do_v
sync'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o):(.
literal.cam_dma_config+0x38): undefined reference to `ll_cam_dma_
sizes'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o):(.
literal.cam_dma_config+0x3c): undefined reference to `ll_cam_get_
dma_align'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o):(.
literal.cam_init+0x14): undefined reference to `ll_cam_set_pin'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o):(.
literal.cam_init+0x18): undefined reference to `ll_cam_config'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o):(.
literal.cam_stop+0x0): undefined reference to `ll_cam_vsync_intr_
enable'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o):(.
literal.cam_stop+0x4): undefined reference to `ll_cam_stop'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o):(.
literal.cam_deinit+0x0): undefined reference to `ll_cam_deinit'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o):(.
literal.cam_config+0x24): undefined reference to `ll_cam_set_samp
le_mode'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o):(.
literal.cam_config+0x28): undefined reference to `ll_cam_init_isr
'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o):(.
literal.cam_task+0x10): undefined reference to `ll_cam_memcpy'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o): i
n function `cam_start_frame':
C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pio/libde
ps/esp32cam/esp32-camera/driver/cam_hal.c:79: undefined reference
to `ll_cam_start'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pi
o/libdeps/esp32cam/esp32-camera/driver/cam_hal.c:81: undefined re
ference to `ll_cam_do_vsync'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o): i
n function `cam_dma_config':
C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pio/libde
ps/esp32cam/esp32-camera/driver/cam_hal.c:240: undefined referenc
e to `ll_cam_dma_sizes'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pi
o/libdeps/esp32cam/esp32-camera/driver/cam_hal.c:255: undefined r
eference to `ll_cam_get_dma_align'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o): i
n function `cam_init':
C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pio/libde
ps/esp32cam/esp32-camera/driver/cam_hal.c:315: undefined referenc
e to `ll_cam_set_pin'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pi
o/libdeps/esp32cam/esp32-camera/driver/cam_hal.c:317: undefined r
eference to `ll_cam_config'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o): i
n function `cam_stop':
C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pio/libde
ps/esp32cam/esp32-camera/driver/cam_hal.c:329: undefined referenc
e to `ll_cam_vsync_intr_enable'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pi
o/libdeps/esp32cam/esp32-camera/driver/cam_hal.c:329: undefined r
eference to `ll_cam_stop'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o): i
n function `cam_deinit':
C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pio/libde
ps/esp32cam/esp32-camera/driver/cam_hal.c:425: undefined referenc
e to `ll_cam_deinit'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o): i
n function `cam_config':
C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pio/libde
ps/esp32cam/esp32-camera/driver/cam_hal.c:343: undefined referenc
e to `ll_cam_set_sample_mode'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pi
o/libdeps/esp32cam/esp32-camera/driver/cam_hal.c:374: undefined r
eference to `ll_cam_init_isr'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o): i
n function `cam_start':
C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pio/libde
ps/esp32cam/esp32-camera/driver/cam_hal.c:381: undefined referenc
e to `ll_cam_vsync_intr_enable'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: .pio\build\esp32cam\lib3e4\libesp32-camera.a(cam_hal.o): i
n function `cam_task':
C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pio/libde
ps/esp32cam/esp32-camera/driver/cam_hal.c:134: undefined referenc
e to `ll_cam_stop'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pi
o/libdeps/esp32cam/esp32-camera/driver/cam_hal.c:141: undefined r
eference to `ll_cam_memcpy'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pi
o/libdeps/esp32cam/esp32-camera/driver/cam_hal.c:145: undefined r
eference to `ll_cam_stop'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pi
o/libdeps/esp32cam/esp32-camera/driver/cam_hal.c:147: undefined r
eference to `ll_cam_stop'
c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../
lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/l
d.exe: C:\Users\User\Documents\PlatformIO\Projects\cek-kamera/.pi
o/libdeps/esp32cam/esp32-camera/driver/cam_hal.c:160: undefined r
eference to `ll_cam_memcpy'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\esp32cam\firmware.elf] Error 1
================== [FAILED] Took 39.57 seconds ==================
* The terminal process "C:\Users\User\.platformio\penv\Scripts\
platformio.exe 'run'" terminated with exit code: 1.
My platformio.ini
is no proble I think:
`
[env]
lib_deps =
esp32-camera
[env:esp32cam]
platform = espressif32
board = esp32cam
framework = espidf
monitor_speed = 115200
As you see If I call mulai_kamera()
it will throw error like above, but my another code part is working fine IF i didn’t call mulai_kamera
.
`