-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
Answers checklist.
- I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
- I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
- I have searched the issue tracker for a similar issue and not found a similar issue.
IDF version.
v5,3
Espressif SoC revision.
ESP32-S3 (QFN56) (revision v0.1)
Operating System used.
Windows
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
PowerShell
Development Kit.
ESP32-S3-DevKitC-1 v1.1
Power Supply used.
USB
What is the expected behavior?
Initializing both LCD using esp_lcd and then Camera using esp_camera should result in working LCD and Camera without errors during initialization.
What is the actual behavior?
After initializing the LCD using esp_lcd with 8-bit i8080 and then initializing esp_camera with an OV2640 a WDT Intrerrupt Timeout occurs. This happens when the ISR for camera VSYNC is installed in ll_cam_init_isr()
When running only the LCD it works and also when running only the camera it also works.
When initializing the camera first and then the LCD the WDT happens during initialzing the LCD.
Steps to reproduce.
The WDT happens during initialization of the periphials. The attached code should trigger the error during init_camera().
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_timer.h"
#include "esp_lcd_panel_io.h"
#include "esp_lcd_panel_vendor.h"
#include "esp_lcd_panel_ops.h"
#include "driver/gpio.h"
#include "esp_err.h"
#include "esp_log.h"
#include "esp_camera.h"
static const char *TAG = "esp32_i8080_camera";
#define LCD_PIXEL_CLOCK_HZ (2 * 1000 * 1000)
#define LCD_BK_LIGHT_ON_LEVEL 1
#define LCD_BK_LIGHT_OFF_LEVEL !LCD_BK_LIGHT_ON_LEVEL
#define LCD_PIN_NUM_DATA0 8
#define LCD_PIN_NUM_DATA1 3
#define LCD_PIN_NUM_DATA2 46
#define LCD_PIN_NUM_DATA3 9
#define LCD_PIN_NUM_DATA4 10
#define LCD_PIN_NUM_DATA5 11
#define LCD_PIN_NUM_DATA6 12
#define LCD_PIN_NUM_DATA7 13
#define LCD_PIN_NUM_RD -1
#define LCD_PIN_NUM_WR 17
#define LCD_PIN_NUM_CS -1
#define LCD_PIN_NUM_DC 16 // RS
#define LCD_PIN_NUM_RST 2
#define LCD_PIN_NUM_BK_LIGHT 1
#define CAM_PIN_PWDN -1 //power down is not used
#define CAM_PIN_RESET -1 //software reset will be performed
#define CAM_PIN_XCLK 15
#define CAM_PIN_SIOD 7
#define CAM_PIN_SIOC 6
#define CAM_PIN_D7 42
#define CAM_PIN_D6 41
#define CAM_PIN_D5 40
#define CAM_PIN_D4 39
#define CAM_PIN_D3 0
#define CAM_PIN_D2 45
#define CAM_PIN_D1 21
#define CAM_PIN_D0 17
#define CAM_PIN_VSYNC 48
#define CAM_PIN_HREF 47
#define CAM_PIN_PCLK 14
// The pixel number in horizontal and vertical
#define LCD_H_RES 800
#define LCD_V_RES 480
// Bit number used to represent command and parameter
#define LCD_CMD_BITS 16
#define LCD_PARAM_BITS 16
// Supported alignment: 16, 32, 64. A higher alignment can enables higher burst transfer size, thus a higher i80 bus throughput.
#define PSRAM_DATA_ALIGNMENT 64
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_freq_hz = 20000000,
.ledc_timer = LEDC_TIMER_0,
.ledc_channel = LEDC_CHANNEL_0,
.pixel_format = PIXFORMAT_JPEG, //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 = 12, //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,
};
static esp_err_t init_camera(void)
{
ESP_LOGI(TAG, "Camera Init");
esp_err_t err = esp_camera_init(&camera_config);
if (err != ESP_OK)
{
ESP_LOGE(TAG, "Camera Init Failed");
return err;
}
ESP_LOGI(TAG, "Camera Init OK");
return ESP_OK;
}
void app_main(void)
{
ESP_LOGI(TAG, "Turn off LCD backlight");
gpio_config_t bk_gpio_config = {
.mode = GPIO_MODE_OUTPUT,
.pin_bit_mask = 1ULL << LCD_PIN_NUM_BK_LIGHT
};
ESP_ERROR_CHECK(gpio_config(&bk_gpio_config));
gpio_set_level(LCD_PIN_NUM_BK_LIGHT, LCD_BK_LIGHT_OFF_LEVEL);
ESP_LOGI(TAG, "Initialize Intel 8080 bus");
esp_lcd_i80_bus_handle_t i80_bus = NULL;
esp_lcd_i80_bus_config_t bus_config = {
.clk_src = LCD_CLK_SRC_DEFAULT,
.dc_gpio_num = LCD_PIN_NUM_DC,
.wr_gpio_num = LCD_PIN_NUM_WR,
.data_gpio_nums = {
LCD_PIN_NUM_DATA0,
LCD_PIN_NUM_DATA1,
LCD_PIN_NUM_DATA2,
LCD_PIN_NUM_DATA3,
LCD_PIN_NUM_DATA4,
LCD_PIN_NUM_DATA5,
LCD_PIN_NUM_DATA6,
LCD_PIN_NUM_DATA7,
},
.bus_width = 8,
.max_transfer_bytes = LCD_H_RES * 100 * sizeof(uint16_t),
.psram_trans_align = PSRAM_DATA_ALIGNMENT,
.sram_trans_align = 4,
};
ESP_ERROR_CHECK(esp_lcd_new_i80_bus(&bus_config, &i80_bus));
esp_lcd_panel_io_handle_t io_handle = NULL;
esp_lcd_panel_io_i80_config_t io_config = {
.cs_gpio_num = LCD_PIN_NUM_CS,
.pclk_hz = LCD_PIXEL_CLOCK_HZ,
.trans_queue_depth = 10,
.dc_levels = {
.dc_idle_level = 0,
.dc_cmd_level = 0,
.dc_dummy_level = 0,
.dc_data_level = 1,
},
.flags = {
.swap_color_bytes = 0, // !LV_COLOR_16_SWAP, // Swap can be done in LvGL (default) or DMA
},
.lcd_cmd_bits = LCD_CMD_BITS,
.lcd_param_bits = LCD_PARAM_BITS,
};
ESP_ERROR_CHECK(esp_lcd_new_panel_io_i80(i80_bus, &io_config, &io_handle));
esp_lcd_panel_handle_t panel_handle = NULL;
ESP_LOGI(TAG, "Install LCD driver for nt35510");
esp_lcd_panel_dev_config_t panel_config = {
.reset_gpio_num = LCD_PIN_NUM_RST,
.rgb_endian = LCD_RGB_ENDIAN_RGB,
.bits_per_pixel = 16,
};
ESP_ERROR_CHECK(esp_lcd_new_panel_nt35510(io_handle, &panel_config, &panel_handle));
esp_lcd_panel_reset(panel_handle);
esp_lcd_panel_init(panel_handle);
// user can flush pre-defined pattern to the screen before we turn on the screen or backlight
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true));
ESP_LOGI(TAG, "Turn on LCD backlight");
gpio_set_level(LCD_PIN_NUM_BK_LIGHT, LCD_BK_LIGHT_ON_LEVEL);
if(ESP_OK != init_camera()) {
ESP_LOGI(TAG, "No camera");
}
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);
while (1) {
// raise the task priority of LVGL and/or reduce the handler period can improve the performance
vTaskDelay(pdMS_TO_TICKS(10));
}
}
Debug Logs.
I (1399) main_task: Calling app_main()
I (1409) esp32_i8080_camera: Turn off LCD backlight
I (1409) gpio: GPIO[1]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1419) esp32_i8080_camera: Initialize Intel 8080 bus
D (1429) intr_alloc: Connected src 24 to int 8 (cpu 0)
D (1429) gdma: new group (0) at 0x3fca6720
D (1439) gdma: new pair (0,0) at 0x3fca67ac
D (1439) gdma: new tx channel (0,0) at 0x3fca66e8
D (1449) lcd_panel.io.i80: new i80 bus(0) @0x3fca6460, 40 dma nodes
D (1449) lcd_panel.io.i80: new i80 lcd panel io @0x3c050b4c on bus(0)
I (1459) esp32_i8080_camera: Install LCD driver for nt35510
I (1469) gpio: GPIO[2]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
D (1479) lcd_panel.nt35510: new nt35510 panel @0x3fca68cc
I (1599) esp32_i8080_camera: Turn on LCD backlight
I (1599) esp32_i8080_camera: Camera Init
D (1599) gdma: new rx channel (0,0) at 0x3fca6978
I (1599) s3 ll_cam: DMA Channel=0
I (1599) cam_hal: cam init ok
D (1609) camera: Enabling XCLK output
D (1609) camera: Initializing SCCB
I (1609) sccb: pin_sda 7 pin_scl 6
I (1619) sccb: sccb_i2c_port=0
D (1619) intr_alloc: Connected src 42 to int 9 (cpu 0)
D (1629) camera: Searching for camera address
I (1639) camera: Detected camera at address=0x30
I (1639) camera: Detected OV2640 camera
D (1639) ov2640: OV2640 Attached
I (1639) camera: Camera PID=0x26 VER=0x42 MIDL=0x7f MIDH=0xa2
D (1649) camera: Doing SW reset of sensor
I (1729) cam_hal: buffer_size: 16384, half_buffer_size: 1024, node_buffer_size: 1024, node_cnt: 16, total_cnt: 15
I (1729) cam_hal: Allocating 15360 Byte frame buffer in PSRAM
D (1739) intr_alloc: Connected src 66 to int 8 (cpu 0)
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).
Core 0 register dump:
PC : 0x40376958 PS : 0x00060034 A0 : 0x4037798c A1 : 0x3fc96c10
0x40376958: shared_intr_isr at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/esp_hw_support/intr_alloc.c:442
0x4037798c: _xt_lowint1 at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/xtensa/xtensa_vectors.S:1240
A2 : 0x3fca66bc A3 : 0x00000008 A4 : 0x8037676c A5 : 0x4037daf2
0x4037daf2: _frxt_int_enter at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/portasm.S:140
A6 : 0x3fcaad0c A7 : 0x3fca66cc A8 : 0x00000002 A9 : 0x00000000
A10 : 0x00000001 A11 : 0xffffffff A12 : 0x8037673c A13 : 0x00060023
A14 : 0x3fcaad0c A15 : 0x0000cdcd SAR : 0x00000018 EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x400570e8 LEND : 0x400570f3 LCOUNT : 0x00000000
0x400570e8: memset in ROM
0x400570f3: memset in ROM
Core 0 was running in ISR context:
EPC1 : 0x42026d83 EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x40376958
0x42026d83: uart_hal_write_txfifo at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/hal/uart_hal_iram.c:27
0x40376958: shared_intr_isr at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/esp_hw_support/intr_alloc.c:442
Backtrace: 0x40376955:0x3fc96c10 0x40377989:0x3fc96c30 0x400559dd:0x3fc9cf40 0x4037da6b:0x3fc9cf50 0x42004d32:0x3fc9cf70 0x42016e77:0x3fc9cfc0 0x4200d1a8:0x3fc9cff0 0x4200c8af:0x3fc9d020 0x4200a4d3:0x3fc9d060 0x4200a6e3:0x3fc9d080 0x42029133:0x3fc9d160 0x4037d6c5:0x3fc9d190
0x40376955: vPortEnterCritical at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h:568
(inlined by) shared_intr_isr at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/esp_hw_support/intr_alloc.c:440
0x40377989: _xt_lowint1 at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/xtensa/xtensa_vectors.S:1240
0x400559dd: _xtos_set_intlevel in ROM
0x4037da6b: vPortClearInterruptMaskFromISR at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h:560
(inlined by) vPortExitCritical at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:504
0x42004d32: esp_intr_alloc_intrstatus at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/esp_hw_support/intr_alloc.c:650
0x42016e77: ll_cam_init_isr at C:/Code/embedded/esp/esp32_i8080_camera/managed_components/espressif__esp32-camera/target/esp32s3/ll_cam.c:412
0x4200d1a8: cam_config at C:/Code/embedded/esp/esp32_i8080_camera/managed_components/espressif__esp32-camera/driver/cam_hal.c:405
0x4200c8af: esp_camera_init at C:/Code/embedded/esp/esp32_i8080_camera/managed_components/espressif__esp32-camera/driver/esp_camera.c:302
0x4200a4d3: init_camera at C:/Code/embedded/esp/esp32_i8080_camera/main/main.c:107
0x4200a6e3: app_main at C:/Code/embedded/esp/esp32_i8080_camera/main/main.c:188
0x42029133: main_task at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/freertos/app_startup.c:208
0x4037d6c5: vPortTaskWrapper at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134
Core 1 register dump:
PC : 0x40378ff6 PS : 0x00060734 A0 : 0x82003b75 A1 : 0x3fc9dfe0
0x40378ff6: esp_cpu_wait_for_intr at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/esp_hw_support/cpu.c:64
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x3fc9c030 A5 : 0x3fc9c010
A6 : 0x4037619c A7 : 0x00000001 A8 : 0x820199be A9 : 0x3fc9dfa0
0x4037619c: ipc_task at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/esp_system/esp_ipc.c:53
A10 : 0x00000000 A11 : 0x00000000 A12 : 0x3fc9c010 A13 : 0x3fc9bff0
A14 : 0x00000001 A15 : 0x3fc9e1b0 SAR : 0x00000000 EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
Backtrace: 0x40378ff3:0x3fc9dfe0 0x42003b72:0x3fc9e000 0x4037e609:0x3fc9e020 0x4037d6c5:0x3fc9e040
0x40378ff3: xt_utils_wait_for_intr at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/xtensa/include/xt_utils.h:82
(inlined by) esp_cpu_wait_for_intr at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/esp_hw_support/cpu.c:55
0x42003b72: esp_vApplicationIdleHook at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/esp_system/freertos_hooks.c:58
0x4037e609: prvIdleTask at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:4344 (discriminator 1)
0x4037d6c5: vPortTaskWrapper at C:/Apps/Espressif/frameworks/v5.3/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134
More Information.
We have tried with different software and hardware setups with the same result, including standard devkits and a custom board.
The example used above is used with a ESP32-S3-DevkitC-1 v1.1, a NT35510 LCD driver in 8-bit i8080 mode and a OV2640 Camera connected via a ESP-LyraP-Cam v1.1 board (from a Kaluga kit).
We have also tried to run the LCD and Camera on different CPUs but with no difference.
I have traced the shard ISR handler and see different behavior with and without initializing the LCD before the camera.
The values in the log below are:
ISR Interrupt status register: Status register value - Status register mask - Shared interrupt enabled ## Triggered if Mask and Value matches.
Just initializing the camera (works):
I (2350) s3 ll_cam: Inter Alloc GDMA Reg 6003f00c, Mask 2
I (2360) s3 ll_cam: Inter Alloc CAM Reg 6004106c, Mask 4
...
ISR 6004106c: 4-4 - Enabled ## Triggered
ISR 6003f00c: 0-2 - Enabled
ISR 6004106c: 4-4 - Enabled ## Triggered
ISR 6003f00c: 0-2 - Enabled
ISR 6004106c: 0-4 - Enabled
ISR 6003f00c: 2-2 - Enabled ## Triggered
Initializing LCD first and then Camera (gives Interrupt WDT Timeout):
I (5680) lcd_panel.io.i80: Inter Alloc LCD Reg 6004106c, Mask 2
...
I (2350) s3 ll_cam: Inter Alloc GDMA Reg 6003f00c, Mask 2
I (2360) s3 ll_cam: Inter Alloc CAM Reg 6004106c, Mask 4
...
ISR 6004106c: 2-4 - Enabled
ISR 6003f00c: 0-2 - Enabled
ISR 6004106c: 2-2
ISR 6004106c: 2-4 - Enabled
ISR 6003f00c: 0-2 - Enabled
ISR 6004106c: 2-2
ISR 6004106c: 2-4 - Enabled
ISR 6003f00c: 0-2 - Enabled
ISR 6004106c: 2-2
ISR 6004106c: 2-4 - Enabled
ISR 6003f00c: 0-2 - Enabled
ISR 6004106c: 2-2
...
And then Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0)