espressif / esp32-camera

Apache License 2.0
1.91k stars 640 forks source link

BF3005(BYD3005) support not working... #537

Closed PCossu93 closed 1 year ago

PCossu93 commented 1 year ago

Hi, I'm trying the camera BF3005(BYD3005) but i can't even get the picture with take_picture example. This is the main.c:

include

include

include <sys/param.h>

include

include "freertos/FreeRTOS.h"

include "freertos/task.h"

// support IDF 5.x

ifndef portTICK_RATE_MS

define portTICK_RATE_MS portTICK_PERIOD_MS

endif

include "esp_camera.h"

define BOARD_ESP32CAM_AITHINKER 1

// ESP32Cam (AiThinker) PIN Map

ifdef BOARD_ESP32CAM_AITHINKER

define CAM_PIN_PWDN 32

define CAM_PIN_RESET -1 //software reset will be performed

define CAM_PIN_XCLK 0

define CAM_PIN_SIOD 26

define CAM_PIN_SIOC 27

define CAM_PIN_D7 35

define CAM_PIN_D6 34

define CAM_PIN_D5 39

define CAM_PIN_D4 36

define CAM_PIN_D3 21

define CAM_PIN_D2 19

define CAM_PIN_D1 18

define CAM_PIN_D0 5

define CAM_PIN_VSYNC 25

define CAM_PIN_HREF 23

define CAM_PIN_PCLK 22

endif

static const char *TAG = "example:take_picture";

if ESP_CAMERA_SUPPORTED

static camera_config_t camera_config = { .pin_pwdn = CAM_PIN_PWDN, .pin_reset = CAM_PIN_RESET, .pin_xclk = CAM_PIN_XCLK, .pin_sccb_sda = CAM_PIN_SIOD, .pin_sccb_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 20MHz or 10MHz for OV2640 double FPS (Experimental)
.xclk_freq_hz = 10000000,
.ledc_timer = LEDC_TIMER_0,
.ledc_channel = LEDC_CHANNEL_0,

.pixel_format = PIXFORMAT_RGB565, //YUV422,GRAYSCALE,RGB565,JPEG
.frame_size = FRAMESIZE_QVGA,    //QQVGA-UXGA, For ESP32, do not use sizes above QVGA when not JPEG. The performance of the ESP32-S series has improved a lot, but JPEG mode always gives better frame rates.

.jpeg_quality = 10, //0-63, for OV series camera sensors, lower number means higher quality
.fb_count = 1,       //When jpeg mode is used, if fb_count more than one, the driver will work in continuous mode.
.fb_location = CAMERA_FB_IN_PSRAM,
.grab_mode = CAMERA_GRAB_WHEN_EMPTY,
.sccb_i2c_port = 1,

};

static esp_err_t init_camera(void) { //initialize the camera esp_err_t err = esp_camera_init(&camera_config); if (err != ESP_OK) { ESP_LOGE(TAG, "Camera Init Failed"); return err; }

return ESP_OK;

}

endif

void app_main(void) {

if ESP_CAMERA_SUPPORTED

if(ESP_OK != init_camera()) {
    return;
}

while (1)
{
    ESP_LOGI(TAG, "Taking picture...");
    camera_fb_t *pic = esp_camera_fb_get();

    // use pic->buf to access the image
    ESP_LOGI(TAG, "Picture taken! Its size was: %zu bytes", pic->len);
    esp_camera_fb_return(pic);

    vTaskDelay(2000 / portTICK_RATE_MS);
}

else

ESP_LOGE(TAG, "Camera support is not available for this chip");
return;

endif

}

and this is the monitor log:

rst:0x1 (POWERON_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0030,len:6660 load:0x40078000,len:14876 load:0x40080400,len:3792 0x40080400: _init at ??:?

entry 0x40080694 I (27) boot: ESP-IDF v4.4.2 2nd stage bootloader I (27) boot: compile time 21:58:13 I (27) boot: chip revision: 3 I (32) boot.esp32: SPI Speed : 80MHz I (35) boot.esp32: SPI Mode : DIO I (39) boot.esp32: SPI Flash Size : 4MB I (44) boot: Enabling RNG early entropy source... I (49) boot: Partition Table: I (53) boot: ## Label Usage Type ST Offset Length I (60) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (68) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (75) boot: 2 factory factory app 00 00 00010000 00100000 I (83) boot: End of partition table I (87) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=0c524h ( 50468) map I (110) esp_image: segment 1: paddr=0001c54c vaddr=3ffb0000 size=0243ch ( 9276) load I (114) esp_image: segment 2: paddr=0001e990 vaddr=40080000 size=01688h ( 5768) load I (118) esp_image: segment 3: paddr=00020020 vaddr=400d0020 size=1e4b4h (124084) map I (162) esp_image: segment 4: paddr=0003e4dc vaddr=40081688 size=0d1fch ( 53756) load I (181) esp_image: segment 5: paddr=0004b6e0 vaddr=50000000 size=00010h ( 16) load I (189) boot: Loaded app from partition at offset 0x10000 I (189) boot: Disabling RNG early entropy source... I (202) psram: This chip is ESP32-D0WD I (202) spiram: Found 64MBit SPI RAM device I (202) spiram: SPI RAM mode: flash 80m sram 80m I (207) spiram: PSRAM initialized, cache is in low/high (2-core) mode. I (214) cpu_start: Pro cpu up. I (218) cpu_start: Starting app cpu, entry point is 0x40081310 0x40081310: call_start_cpu1 at C:/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/port/cpu_start.c:160

I (0) cpu_start: App cpu up. I (721) spiram: SPI SRAM memory test OK I (729) cpu_start: Pro cpu start user code I (729) cpu_start: cpu freq: 240000000 I (729) cpu_start: Application information: I (731) cpu_start: Project name: template-app I (737) cpu_start: App version: 1 I (741) cpu_start: Compile time: May 24 2023 21:57:59 I (747) cpu_start: ELF file SHA256: 033aa767dfc04846... I (753) cpu_start: ESP-IDF: v4.4.2 I (758) heap_init: Initializing. RAM available for dynamic allocation: I (765) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM I (771) heap_init: At 3FFB2E18 len 0002D1E8 (180 KiB): DRAM I (778) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM I (784) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM I (790) heap_init: At 4008E884 len 0001177C (69 KiB): IRAM I (797) spiram: Adding pool of 4095K of external SPI memory to heap allocator I (805) spi_flash: detected chip: gd I (809) spi_flash: flash io: dio I (814) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. I (823) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations I (833) gpio: GPIO[25]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:2 I (843) cam_hal: cam init ok I (843) sccb: pin_sda 26 pin_scl 27 I (853) sccb: sccb_i2c_port=1 I (853) gpio: GPIO[32]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 I (893) camera: Detected camera at address=0x6e I (893) camera: Detected BF3005 camera I (893) camera: Camera PID=0x30 VER=0x03 MIDL=0x03 MIDH=0x30 I (953) esp32 ll_cam: node_size: 3840, nodes_per_line: 1, lines_per_node: 3, dma_half_buffer_min: 3840, dma_half_buffer: 15360,lines_per_half_buffer: 12, dma_buffer_size: 30720, image_size: 153600 I (953) cam_hal: buffer_size: 30720, half_buffer_size: 15360, node_buffer_size: 3840, node_cnt: 8, total_cnt: 10 I (963) cam_hal: Allocating 153600 Byte frame buffer in PSRAM I (973) cam_hal: cam config ok set_framesize 274 set_framesize 277 I (1043) example:take_picture: Taking picture... cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF cam_hal: EV-EOF-OVF W (5043) cam_hal: Failed to get the frame on time! Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Core 0 register dump: PC : 0x400d60c7 PS : 0x00060130 A0 : 0x800ee2f2 A1 : 0x3ffb5f30 0x400d60c7: app_main at C:/Espressif/workspace/template-app/main/main.c:127 (discriminator 13)

A2 : 0x3f403704 A3 : 0x00000000 A4 : 0x00000001 A5 : 0x00000001 A6 : 0x007b1218 A7 : 0x003fffff A8 : 0x800d60c7 A9 : 0x3ffb5f10 A10 : 0x000013b3 A11 : 0x3f403704 A12 : 0x3f403748 A13 : 0x00000413 A14 : 0x3f403704 A15 : 0x00000001 SAR : 0x00000004 EXCCAUSE: 0x0000001c EXCVADDR: 0x00000004 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffd

Backtrace:0x400d60c4:0x3ffb5f300x400ee2ef:0x3ffb5f50 0x4008a669:0x3ffb5f70 0x400d60c4: app_main at C:/Espressif/workspace/template-app/main/main.c:127 (discriminator 13)

0x400ee2ef: main_task at C:/Espressif/frameworks/esp-idf-v4.4.2/components/freertos/port/port_common.c:141 (discriminator 2)

0x4008a669: vPortTaskWrapper at C:/Espressif/frameworks/esp-idf-v4.4.2/components/freertos/port/xtensa/port.c:131

Can you help me with that?

AthenasArch commented 1 year ago

Can someone help me, I have the camera initialization problem.

the software returns that the camera is not supported:

ESP-ROM: esp32s3-20210327 Build: Mar 27 2021 rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT) SPIWP:0xee mode:DIO, clock div:1 load:0x3fce3808,len:0x44c load:0x403c9700,len:0xbe4 load:0x403cc700,len:0x2a38 entry 0x403c98d4

E (33) camera: Detected camera not supported. E (33) camera: Camera probe failed with error 0x106(ESP_ERR_NOT_SUPPORTED) Camera init failed with error 0x106

ESP32-S3


#include 
#include "esp_camera.h"
#include 

// ===================
// Select camera model
// ===================
//#define CAMERA_MODEL_WROVER_KIT // Has PSRAM
//#define CAMERA_MODEL_ESP_EYE // Has PSRAM
#define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM
//#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
//#define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM
//#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
//#define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM
//#define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM
//#define CAMERA_MODEL_AI_THINKER // Has PSRAM
//#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM
// ** Espressif Internal Boards **
//#define CAMERA_MODEL_ESP32_CAM_BOARD
//#define CAMERA_MODEL_ESP32S2_CAM_BOARD
//#define CAMERA_MODEL_ESP32S3_CAM_LCD

#include "camera_pins.h"

#define USE_OV2640 0

// ===========================
// Enter your WiFi credentials
// ===========================
const char* ssid     = "Athenas 2.4G";
const char* password = "HILGEMBERG";

sensor_t * s;

void startCameraServer();
void camera_ini(void);

void setup() {
    Serial.begin(115200);
    Serial.setDebugOutput(true);
    Serial.println();
    // camera_ini();

    camera_config_t config;
    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;
#if USE_OV2640
    config.xclk_freq_hz = 20000000;
    config.frame_size = FRAMESIZE_UXGA;
    config.pixel_format = PIXFORMAT_JPEG; // for streaming
    config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
    config.fb_location = CAMERA_FB_IN_PSRAM;
    config.jpeg_quality = 12;
    config.fb_count = 1;
#else 
    config.xclk_freq_hz = 10000000;
    config.frame_size = FRAMESIZE_VGA;
    config.pixel_format = PIXFORMAT_RGB565; // for streaming
    config.grab_mode = CAMERA_GRAB_LATEST;
    config.fb_location = CAMERA_FB_IN_PSRAM;
    config.jpeg_quality = 6;
    config.fb_count = 2;
#endif
    // if PSRAM IC present, init with UXGA resolution and higher JPEG quality
    // for larger pre-allocated frame buffer.
    if(psramFound()){
        config.jpeg_quality = 10;
        config.fb_count = 2;
        config.grab_mode = CAMERA_GRAB_LATEST;
    } else {
        // Limit the frame size when PSRAM is not available
        config.frame_size = FRAMESIZE_SVGA;
        config.fb_location = CAMERA_FB_IN_DRAM;
    }

    // camera init
    esp_err_t err = esp_camera_init(&config);
    if (err != ESP_OK) {
        Serial.printf("Camera init failed with error 0x%x", err);
        return;
    }

    sensor_t * s = esp_camera_sensor_get();
    // initial sensors are flipped vertically and colors are a bit saturated
    s->set_vflip(s, 1); // flip it back
    s->set_brightness(s, 1); // up the brightness just a bit
    s->set_saturation(s, 0); // lower the saturation

    WiFi.begin(ssid, password);
    WiFi.setSleep(false);

    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }
    Serial.println("");
    Serial.println("WiFi connected");

    startCameraServer();

    Serial.print("Camera Ready! Use 'http://");
    Serial.print(WiFi.localIP());
    Serial.println("' to connect");
}

void loop() {
  // Do nothing. Everything is done in another task by the web server
  delay(10000);
}