乐鑫技术交流
直播中

周臻庸

7年用户 853经验值
私信 关注
[问答]

esp camera无法重新配置初始化是怎么回事?

现在我要实现一个功能:

1. esp-camera默认配置为低分辨率的RGB565格式,然后将采集到的摄像头数据显示在屏幕上

2. 按下按键,摄像头配置为最大分辨率的JPEG格式,然后将采集到的图片保存在TF卡中

问题:当重新配置摄像头时,发生panic错误

报错信息:
Code: Select all
E (3464) gdma: gdma_disconnect(278): no peripheral is connected to the channelI (3465) s3 ll_cam: DMA Channel=1I (3465) cam_hal: cam init okI (3469) sccb: pin_sda 4 pin_scl 5I (3473) sccb: sccb_i2c_port=1I (3488) camera: Detected camera at address=0x30I (3491) camera: Detected OV2640 cameraI (3491) camera: Camera PID=0x26 VER=0x42 MIDL=0x7f MIDH=0xa2I (3567) cam_hal: buffer_size: 384000, half_buffer_size: 1024, node_buffer_size: 1024, node_cnt: 375, total_cnt: 375I (3568) cam_hal: Allocating 384016 Byte frame buffer in PSRAMI (3574) cam_hal: Frame[0]: Offset: 16, Addr: 0x3D807400I (3581) cam_hal: cam config okI (3584) ov2640: Set PLL: clk_2x: 0, clk_div: 0, pclk_auto: 0, pclk_div: 12I (3668) ov2640: Set PLL: clk_2x: 0, clk_div: 0, pclk_auto: 0, pclk_div: 8W (3669) cam_hal: NO-SOIW (3777) cam_hal: NO-SOIW (3802) cam_hal: NO-SOIW (3827) cam_hal: NO-SOIW (3852) cam_hal: NO-SOIW (3877) cam_hal: NO-SOIW (3902) cam_hal: NO-SOIW (3927) cam_hal: NO-SOIW (3952) cam_hal: NO-SOIW (3977) cam_hal: NO-SOIW (4002) cam_hal: NO-SOIW (4027) cam_hal: NO-SOIW (4052) cam_hal: NO-SOIW (4077) cam_hal: NO-SOIW (4102) cam_hal: NO-SOIW (4127) cam_hal: NO-SOIW (4152) cam_hal: NO-SOIW (4177) cam_hal: NO-SOIW (4202) cam_hal: NO-SOIW (4227) cam_hal: NO-SOIW (4252) cam_hal: NO-SOIW (4277) cam_hal: NO-SOIW (4302) cam_hal: NO-SOIW (4327) cam_hal: NO-SOIW (4352) cam_hal: NO-SOIW (4376) cam_hal: NO-SOIW (4401) cam_hal: NO-SOIW (4426) cam_hal: NO-SOIW (4451) cam_hal: NO-SOI***ERROR*** A stack overflow in task cam_task has been detected.Backtrace:0x40375c56:0x3fce91e00x40382089:0x3fce9200 0x4038501e:0x3fce9220 0x40383d9b:0x3fce92a0 0x40382144:0x3fce92c0 0x4038213a:0x00000000  |<-CORRUPTED0x40375c56: panic_abort at /home/don/esp/esp-idf/components/esp_system/panic.c:4020x40382089: esp_system_abort at /home/don/esp/esp-idf/components/esp_system/esp_system.c:1210x4038501e: vApplicationStackOverflowHook at /home/don/esp/esp-idf/components/freertos/port/xtensa/port.c:3940x40383d9b: vTaskSwitchContext at /home/don/esp/esp-idf/components/freertos/tasks.c:35540x40382144: _frxt_dispatch at /home/don/esp/esp-idf/components/freertos/port/xtensa/portasm.S:4360x4038213a: _frxt_int_exit at /home/don/esp/esp-idf/components/freertos/port/xtensa/portasm.S:231
出错代码:
Code: Select all
        // 按下按键,唤醒用于保存图像的task        if (xQueueReceive(queue_i, &key, 0))        {            camera_fb_t *jpg_fb = NULL;            xSemaphoreTake(fbmutex, portMAX_DELAY);            esp_camera_deinit();            camera_init(PIXFORMAT_JPEG, FRAMESIZE_UXGA, 1);            jpg_fb = esp_camera_fb_get();            // TODO: save_image(jpg_fb);            esp_camera_fb_return(jpg_fb);            esp_camera_deinit();            camera_init(PIXFORMAT_RGB565, FRAMESIZE_QVGA, 2);            xSemaphoreGive(fbmutex);        }
测试设备信息:
- idf v4.4
- OV2640
- esp-camera v2.0.8


是否是因为esp-camera目前不支持 重新在配置?
                                                                                                                                                                                                                        
               
            

回帖(1)

王强

2024-6-5 17:41:22
看起来您在使用ESP32-CAM时遇到了一些问题。根据您提供的错误信息,问题似乎与DMA通道有关。以下是一些建议来解决这个问题:

1. 确保您的ESP32-CAM模块是完好无损的,并且所有连接都是正确的。

2. 检查您的代码,确保您正确地初始化了ESP32-CAM模块和TF卡。您可以使用以下示例代码作为参考:

```c
#include
#include
#include

#define PWDN_GPIO_NUM     32
#define RESET_GPIO_NUM    -1
#define XCLK_GPIO_NUM      0
#define SIOD_GPIO_NUM     26
#define DIOD_GPIO_NUM     27

void setup() {
  Serial.begin(115200);
  Serial.setDebugOutput(true);
  esp_err_t ret = nvs_flash_init();
  if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
    ESP_ERROR_CHECK(nvs_flash_erase());
    ret = nvs_flash_init();
  }
  ESP_ERROR_CHECK(ret);

  // Initialize SD card
  sdmmc_host_t host = SDMMC_HOST_DEFAULT();
  sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();

  gpio_set_drive_capability(14, GPIO_DRIVE_CAP_4);
  gpio_set_drive_capability(13, GPIO_DRIVE_CAP_4);
  esp_vfs_fat_sdmmc_mount_config_t mount_config = {
      .format_if_mount_failed = false,
      .max_files = 5,
      .allocation_unit_size = 16 * 1024
  };
  sdmmc_card_t* card;
  esp_err_t card_init = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);

  if (card_init != ESP_OK) {
    Serial.printf("Failed to mount SD card VFAT filesystem. Error: %sn", esp_err_to_name(card_init));
    return;
  }

  // Initialize camera
  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 = DIOD_GPIO_NUM;
  config.pin_pwdn = PWDN_GPIO_NUM;
  config.pin_reset = RESET_GPIO_NUM;
  config.xclk_freq_hz = 20000000;
  config.pixel_format = PIXFORMAT_JPEG;

  esp_err_t cam_init = esp_camera_init(&config);
  if (cam_init != ESP_OK) {
    Serial.printf("Failed to initialize camera. Error: %sn", esp_err_to_name(cam_init));
    return;
  }
}

void loop() {
  // Your code here
}
```

3. 如果问题仍然存在,请尝试升级您的ESP-IDF框架到最新版本,因为新版本可能修复了一些已知问题。

4. 如果以上方法都无法解决问题,建议您在ESP32-CAM和ESP-IDF的GitHub仓库中查找类似问题的解决方案,或者在相关社区寻求帮助。
举报

更多回帖

发帖
×
20
完善资料,
赚取积分