乐鑫技术交流
直播中

刘辉

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

esp-camera报错cam_hal: FB-SIZE: 115200 != 129600的原因?

我在适配一个新的CIS,这颗输出的格式是raw,大小为480*270,所以dma node size 为2880,图片fb_size为129600,程序将它计算为9次拷贝,一次的大小为14400,我在esp32-camera的基础上修改了很多内容,目前的问题是出在cam_hal中的cam_task,程序期待的是有9次IN_SUC_EOF中断,但是每次只收到8次,也就是在came_task中只拷贝了8次,所以得到的大小为115200(离正确的129600差14400),测量过sensor的波形,其pclk为6.4MHZ,一共有270个行同步信号,每个行同步信号内有480个pclk信号.

我使用的是esp32s3-eye,主程序如下:

`extern "C" void app_main()

{

#if CONFIG_CAMERA_MODULE_ESP_EYE || CONFIG_CAMERA_MODULE_ESP32_CAM_BOARD

    /* IO13, IO14 is designed for JTAG by default,

     * to use it as generalized input,

     * firstly declair it as pullup input */

    gpio_config_t conf;

    conf.mode = GPIO_MODE_INPUT;

    conf.pull_up_en = GPIO_PULLUP_ENABLE;

    conf.pull_down_en = GPIO_PULLDOWN_DISABLE;

    conf.intr_type = GPIO_INTR_DISABLE;

    conf.pin_bit_mask = 1LL << 13;

    gpio_config(&conf);

    conf.pin_bit_mask = 1LL << 14;

    gpio_config(&conf);

#endif



    camera_config_t config;

    config.ledc_channel = LEDC_CHANNEL_0;

    config.ledc_timer = LEDC_TIMER_0;

    config.pin_d0 = CAMERA_PIN_D0;

    config.pin_d1 = CAMERA_PIN_D1;

    config.pin_d2 = CAMERA_PIN_D2;

    config.pin_d3 = CAMERA_PIN_D3;

    config.pin_d4 = CAMERA_PIN_D4;

    config.pin_d5 = CAMERA_PIN_D5;

    config.pin_d6 = CAMERA_PIN_D6;

    config.pin_d7 = CAMERA_PIN_D7;

    config.pin_xclk = CAMERA_PIN_XCLK;

    config.pin_pclk = CAMERA_PIN_PCLK;

    config.pin_vsync = CAMERA_PIN_VSYNC;

    config.pin_href = CAMERA_PIN_HREF;

    config.pin_sscb_sda = CAMERA_PIN_SIOD;

    config.pin_sscb_scl = CAMERA_PIN_SIOC;

    config.pin_pwdn = CAMERA_PIN_PWDN;

    config.pin_reset = CAMERA_PIN_RESET;

    config.xclk_freq_hz = 24000000;

    config.pixel_format = PIXFORMAT_GRAYSCALE;

    config.frame_size = FRAMESIZE_480X270;

    config.jpeg_quality = 12;

    config.fb_count = 2;

    config.fb_location = CAMERA_FB_IN_PSRAM;

    config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;



    // camera init

    esp_err_t err = esp_camera_init(&config);

    if (err != ESP_OK)

    {

        ESP_LOGE(TAG, "Camera init failed with error 0x%x", err);

        return;

    }

    vTaskDelay(2000 / portTICK_RATE_MS);

    while (1)

    {

        ESP_LOGW(TAG, "Taking picture...");

        camera_fb_t *pic = esp_camera_fb_get();

        ESP_LOGW(TAG, "pic addr: %p ", pic->buf);



        // use pic->buf to access the image

        ESP_LOGW(TAG, "Picture taken! Its size was: %zu bytes", pic->len);

        esp_camera_fb_return(pic);



        // vTaskDelay(5000 / portTICK_RATE_MS);

    }

}`



为了进一步调试,我修改了cam_hal中的buf_size检查,将尺寸不合规的frame的en也置为0,得到了如下输出:



I (00:00:09.711) cam_hal: FB-SIZE: 115200 != 129600

W (00:00:09.712) example:take_picture: pic addr: 0x3d8009c8

W (00:00:09.712) example:take_picture: Picture taken! Its size was: 115200 bytes

W (00:00:09.712) example:take_picture: Taking picture...

I (00:00:09.741) cam_hal: FB-SIZE: 115200 != 129600

W (00:00:09.741) example:take_picture: pic addr: 0x3d82040c

W (00:00:09.741) example:take_picture: Picture taken! Its size was: 115200 bytes

W (00:00:09.742) example:take_picture: Taking picture...

I (00:00:09.770) cam_hal: FB-SIZE: 115200 != 129600

W (00:00:09.770) example:take_picture: pic addr: 0x3d8009c8

W (00:00:09.771) example:take_picture: Picture taken! Its size was: 115200 bytes

W (00:00:09.771) example:take_picture: Taking picture...

I (00:00:09.799) cam_hal: FB-SIZE: 115200 != 129600



看起来像最后一个包的时候,程序还没来得及读到14400个字节,v信号就来了。实在想不出来问题出在哪。

当程序运行到这一行时的cam_obj:

` frame_buffer_event->len += ll_cam_memcpy(cam_obj,

                            &frame_buffer_event->buf[frame_buffer_event->len],

                            &cam_obj->dma_buffer[(cnt % cam_obj->dma_half_buffer_cnt) * cam_obj->dma_half_buffer_size],

                            cam_obj->dma_half_buffer_size);`

更多回帖

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