espressif / esp32-camera

Apache License 2.0
1.87k stars 635 forks source link

[ESP32-S3-DevKitC-1, OV5640, JPEG] Intermittent panic reboot, cam_hal: NO-SOI #431

Closed GTCLive closed 2 years ago

GTCLive commented 2 years ago

Regardless of any settings it is impossible to capture JPEG with the OV5640 sensor. Tried faster/slower clk speed, compression, high/low resolutions, all leads to panic crashes and/or NO-SOI, with extremely rare occurrences of a valid capture (1/100 type scenario). There is absolutely no problem capturing RGB565 frames though, this works perfectly fine. Only the JPEG capture fails,

The sensor JPEG Capture is confirmed functional and highly reliable onto a STM32H743VIT6 using the init registers below. However it is not functional using the ESP-IDF 4.4.1 and 5.0dev with the ESP32-Camera API.

`

{0x4300, 0x30}, // YUV 422, YUYV
{0x501f, 0x00}, // YUV 422

// Input clock = 24Mhz
{0x3035, 0x21}, // PLL
{0x3036, 0x69}, // PLL
{0x3c07, 0x07}, // lightmeter 1 threshold[7:0]
{0x3820, 0x46}, // flip
{0x3821, 0x20}, // mirror
{0x3814, 0x11}, // timing X inc
{0x3815, 0x11}, // timing Y inc
{0x3800, 0x00}, // HS
{0x3801, 0x00}, // HS
{0x3802, 0x00}, // VS
{0x3803, 0x00}, // VS
{0x3804, 0x0a}, // HW (HE)
{0x3805, 0x3f}, // HW (HE)
{0x3806, 0x07}, // VH (VE)
{0x3807, 0x9f}, // VH (VE)

{0x3808, 0x02}, // DVPHO
{0x3809, 0x80}, // DVPHO
{0x380a, 0x01}, // DVPVO
{0x380b, 0xe0}, // DVPVO

{0x380c, 0x0b}, // HTS
{0x380d, 0x1c}, // HTS
{0x380e, 0x07}, // VTS
{0x380f, 0xb0}, // VTS
{0x3813, 0x04}, // timing V offset   04
{0x3618, 0x04},
{0x3612, 0x2b},
{0x3709, 0x12},
{0x370c, 0x00},

{0x3a02, 0x02}, // 60Hz max exposure
{0x3a03, 0xe0}, // 60Hz max exposure
{0x3a14, 0x02}, // 50Hz max exposure
{0x3a15, 0xe0}, // 50Hz max exposure

{0x4004, 0x06}, // BLC line number
{0x3002, 0x00}, // enable JFIFO, SFIFO, JPG
{0x3006, 0xff}, // enable clock of JPEG2x, JPEG
{0x4713, 0x03}, // JPEG mode 3
{0x4407, 0x01}, // Quantization sacle
{0x460b, 0x35},
{0x460c, 0x22},
{0x4837, 0x16}, // MIPI global timing
{0x3824, 0x02}, // PCLK manual divider
{0x5001, 0xA3}, // SDE on, Scaling on, CMX on, AWB on
{0x3503, 0x00} // AEC/AGC on

`

GTCLive commented 2 years ago

define CAM_PIN_PWDN 2

define CAM_PIN_RESET 21

define CAM_PIN_XCLK 4

define CAM_PIN_SIOC 15

define CAM_PIN_SIOD 16

define CAM_PIN_D0 6

define CAM_PIN_D1 7

define CAM_PIN_D2 8

define CAM_PIN_D3 9

define CAM_PIN_D4 10

define CAM_PIN_D5 11

define CAM_PIN_D6 12

define CAM_PIN_D7 13

define CAM_PIN_VSYNC 5

define CAM_PIN_HREF 3

define CAM_PIN_PCLK 1

static camera_config_t camera_config = { .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   = 16000000,
.ledc_timer     = LEDC_TIMER_0,
.ledc_channel   = LEDC_CHANNEL_0,
.pixel_format   = PIXFORMAT_JPEG,
.frame_size     = FRAMESIZE_QVGA,
.jpeg_quality   = 11,
.fb_count       = 2,
.fb_location    = CAMERA_FB_IN_PSRAM,
.grab_mode      = CAMERA_GRAB_LATEST
GTCLive commented 2 years ago

ELF file SHA256: b9b9992ca878d66d

Rebooting... ESP-ROM:esp32s3-20210327 Build:Mar 27 2021 rst:0x3 (RTC_SW_SYS_RST),boot:0x2b (SPI_FAST_FLASH_BOOT) Saved PC:0x4037591d 0x4037591d: esp_restart_noos_dig at D:/IDEs/Eclipse/Expressif/idf/master/esp-idf/components/esp_system/esp_system.c:46 (discriminator 1)

SPIWP:0xee mode:DIO, clock div:1 load:0x3fce3810,len:0x1494 load:0x403c9700,len:0xe54 load:0x403cc700,len:0x2e70 entry 0x403c992c I (24) boot: ESP-IDF v5.0-dev-4379-g36f49f361 2nd stage bootloader I (24) boot: compile time 03:26:35 I (24) boot: chip revision: V001 I (25) boot_comm: chip revision: 1, min. bootloader chip revision: 0 I (31) qio_mode: Enabling default flash chip QIO I (35) boot.esp32s3: Boot SPI Speed : 80MHz I (39) boot.esp32s3: SPI Mode : QIO I (43) boot.esp32s3: SPI Flash Size : 8MB I (46) boot: Enabling RNG early entropy source... I (51) boot: Partition Table: I (54) boot: ## Label Usage Type ST Offset Length I (60) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (66) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (73) boot: 2 factory factory app 00 00 00010000 00100000 I (79) boot: End of partition table I (83) boot_comm: chip revision: 1, min. application chip revision: 0 I (89) esp_image: segment 0: paddr=00010020 vaddr=3c030020 size=0b348h ( 45896) map I (103) esp_image: segment 1: paddr=0001b370 vaddr=3fc93900 size=03234h ( 12852) load I (106) esp_image: segment 2: paddr=0001e5ac vaddr=40374000 size=01a6ch ( 6764) load I (113) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=209d4h (133588) map I (139) esp_image: segment 4: paddr=000409fc vaddr=40375a6c size=0ddf8h ( 56824) load I (150) esp_image: segment 5: paddr=0004e7fc vaddr=50000000 size=00010h ( 16) load I (157) boot: Loaded app from partition at offset 0x10000 I (157) boot: Disabling RNG early entropy source... I (159) octal_psram: vendor id : 0x0d (AP) I (161) octal_psram: dev id : 0x02 (generation 3) I (165) octal_psram: density : 0x03 (64 Mbit) I (170) octal_psram: good-die : 0x01 (Pass) I (174) octal_psram: Latency : 0x01 (Fixed) I (179) octal_psram: VCC : 0x01 (3V) I (183) octal_psram: SRF : 0x01 (Fast Refresh) I (188) octal_psram: BurstType : 0x01 (Hybrid Wrap) I (192) octal_psram: BurstLen : 0x01 (32 Byte) I (197) octal_psram: Readlatency : 0x02 (10 cycles@Fixed) I (202) octal_psram: DriveStrength: 0x00 (1/1) W (206) PSRAM: DO NOT USE FOR MASS PRODUCTION! Timing parameters will be updated in future IDF version. I (216) esp_psram: Found 8MB SPI RAM device I (219) esp_psram: Speed: 80MHz I (222) cpu_start: Pro cpu up. I (225) cpu_start: Starting app cpu, entry point is 0x40375450 0x40375450: call_start_cpu1 at D:/IDEs/Eclipse/Expressif/idf/master/esp-idf/components/esp_system/port/cpu_start.c:154

I (0) cpu_start: App cpu up. I (650) esp_psram: SPI SRAM memory test OK I (659) cpu_start: Pro cpu start user code I (659) cpu_start: cpu freq: 240000000 Hz I (660) cpu_start: Application information: I (660) cpu_start: Project name: test I (660) cpu_start: App version: 1 I (660) cpu_start: Compile time: Aug 1 2022 03:26:21 I (661) cpu_start: ELF file SHA256: b9b9992ca878d66d... I (661) cpu_start: ESP-IDF: v5.0-dev-4379-g36f49f361 I (661) heap_init: Initializing. RAM available for dynamic allocation: I (661) heap_init: At 3FCBCDC0 len 00023240 (140 KiB): D/IRAM I (662) heap_init: At 3FCE0000 len 0000EE34 (59 KiB): STACK/DRAM I (662) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM I (662) heap_init: At 600FE010 len 00001FF0 (7 KiB): RTCRAM I (662) esp_psram: Adding pool of 8192K of external SPI memory to heap allocator I (663) spi_flash: detected chip: generic I (664) spi_flash: flash io: qio I (665) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. I (665) esp_psram: Reserving pool of 32K of internal memory for DMA/internal allocations I (665) s3 ll_cam: DMA Channel=4 I (665) cam_hal: cam init ok I (665) sccb: pin_sda 16 pin_scl 15 I (665) gpio: GPIO[2]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 I (685) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 I (715) camera: Detected camera at address=0x3c I (715) camera: Detected OV5640 camera I (715) camera: Camera PID=0x5640 VER=0x00 MIDL=0x00 MIDH=0x00 I (1365) cam_hal: buffer_size: 16384, half_buffer_size: 1024, node_buffer_size: 1024, node_cnt: 16, total_cnt: 960 I (1365) cam_hal: Allocating 983040 Byte frame buffer in PSRAM I (1365) cam_hal: Allocating 983040 Byte frame buffer in PSRAM I (1365) cam_hal: cam config ok I (1365) ov5640: Set PLL: bypass: 0, multiplier: 200, sys_div: 4, pre_div: 2, root_2x: 0, pclk_root_div: 2, pclk_manual: 1, pclk_div: 4 I (1365) ov5640: Calculated XVCLK: 10000000 Hz, REFIN: 5000000 Hz, VCO: 1000000000 Hz, PLL_CLK: 100000000 Hz, SYSCLK: 25000000 Hz, PCLK: 6250000 Hz W (1375) cam_hal: NO-SOI W (1385) cam_hal: NO-SOI W (1395) cam_hal: NO-SOI W (1405) cam_hal: NO-SOI Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited). Exception was unhandled.

Core 0 register dump: PC : 0x00000000 PS : 0x00060033 A0 : 0x40377110 A1 : 0x3fc94740 0x40377110: _xt_lowint1 at D:/IDEs/Eclipse/Expressif/idf/master/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/xtensa_vectors.S:1117

A2 : 0x494f532d A3 : 0x00000001 A4 : 0x00000001 A5 : 0x4037b67a 0x4037b67a: _frxt_int_enter at D:/IDEs/Eclipse/Expressif/idf/master/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/portasm.S:101

A6 : 0x00060423 A7 : 0x3fcf0fa8 A8 : 0x80376464 A9 : 0x3fc94700 A10 : 0x00000000 A11 : 0x3fc96da4 A12 : 0x00060021 A13 : 0xffffffff A14 : 0x00000001 A15 : 0x00000001 SAR : 0x00000004 EXCCAUSE: 0x00000014 EXCVADDR: 0x00000000 LBEG : 0x400556d5 LEND : 0x400556e5 LCOUNT : 0xfffffffd

Backtrace: 0xfffffffd:0x3fc94740 0x4037710d:0x3fc94760 0x400559dd:0x3fce0f40 |<-CORRUPTED 0x4037710d: _xt_lowint1 at D:/IDEs/Eclipse/Expressif/idf/master/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/xtensa_vectors.S:1117

........................... ............... ........................ ........................... ............... ........................ ........................... ............... ........................

github-actions[bot] commented 2 years ago

This issue appears to be stale. Please close it if its no longer valid.