Code Monkey home page Code Monkey logo

esp32-cam-demo's Introduction

NOTICE

This repository is archived, and no longer maintained. Please check https://github.com/espressif/esp32-camera for the ESP32 camera driver officially supported by Espressif.

Thanks to everyone who had contributed to this repository in the past.


ESP32 Camera Demo

Code provided in this repository gets the image from camera and prints it out as ASCII art to the serial port.

Build Status

Build Status

Table of Contents

Components

To make this code work, you need the following components:

  • This repository. It contains submodules, so make sure you clone it with --recursive option. If you have already cloned it without --recursive, run git submodule update --init.
  • ESP32 module
  • Camera module
  • PC with esp-idf

See the following sections for more details.

ESP32

Any ESP32 module should work, if it has sufficient number of GPIO pins available to interface with camera. See section Connect for more details.

If you are an owner of ESP-WROVER V1 (aka DevKitJ), then camera connector is already broken out.

Camera

This example has been tested with OV7725 camera module. Use it, if this is your first exposure to interfacing a microcontroller with a camera.

Other OV7xxx series should work as well, with some changes to camera configuration code. OV5xxx can work too, but it is advisable to choose the ones which support RGB or YUV 8-bit wide output bus. The ones which only output 10-bit raw data may be a bit harder to work with. Also choose the camera which can output a scaled down (QVGA or VGA) image. Use of larger frame buffers will require external SPI RAM.

ESP-IDF

Configure your PC according to ESP32 Documentation. Windows, Linux and Mac OS are supported. If this is you first exposure to ESP32 and esp-idf, then get familiar with 01_hello_world and 02_blink examples. Make them work and understand before proceeding further.

Quick Start

If you have your components ready, follow this section to connect the camera to ESP32 module, flash application to the ESP32 and finally shoot and display the image.

Connect

Specific pins used in this example to connect ESP32 and camera are shown in table below. Pinout can be adjusted to some extent in software. Table below provides two options of pin mapping (last two columns).

Interface Camera Pin Pin Mapping for ESP32 DevKitJ Alternate ESP32 Pin Mapping
SCCB Clock SIOC IO27 IO23
SCCB Data SIOD IO26 IO25
System Clock XCLK IO21 IO27
Vertical Sync VSYNC IO25 IO22
Horizontal Reference HREF IO23 IO26
Pixel Clock PCLK IO22 IO21
Pixel Data Bit 0 D2 IO4 IO35
Pixel Data Bit 1 D3 IO5 IO17
Pixel Data Bit 2 D4 IO18 IO34
Pixel Data Bit 3 D5 IO19 IO5
Pixel Data Bit 4 D6 IO36 IO39
Pixel Data Bit 5 D7 IO39 IO18
Pixel Data Bit 6 D8 IO34 IO36
Pixel Data Bit 7 D9 IO35 IO19
Camera Reset RESET IO2 IO15
Camera Power Down PWDN see Note 3 see Note 3
Power Supply 3.3V 3V3 3V3 3V3
Ground GND GND GND

Notes:

  1. Important: Make the connections short or you are likely to get noisy or even not legible images. More on that is discussed in section Showcase
  2. Camera pin column refers to pinout on OV7725 camera module
  3. Camera Power Down pin does not need to be connected to ESP32 GPIO. Instead it may be pulled down to ground with 10 kOhm resistor.
  4. OV7725 supports 10 bit image pixels. In this example the upper 8 bits are processed and saved. The pins corresponding with LSB are marked D0 and D1 and are left not connected.

If you have ESP-WROVER V1 (aka DevKitJ), then camera connector is already broken out and labeled Camera / JP4. Solder 2.54 mm / 0.1" double row, 18 pin socket in provided space and plug the camera module right into it. Line up 3V3 and GND pins on camera module and on ESP-WROVER. D0 and D1 should be left not connected outside the socket.

To connect the camera to Core Board V2 (aka DevKitC), consider alternate pin mapping (see the last column of table) that provides clean wiring layout shown below.

alt text

2.2uF capacitor conencted between GND and EN pins of ESP32module is added to resolve ESP32 Reset To Bootloader Issues on Windows #136.

Flash

Clone the code provided in this repository to your PC, compile with the latest esp-idf installed from GitHub and download to the module.

If all h/w components are connected properly you are likely to see the following message during download:

Krzysztof@tdk-kmb-op780 MSYS /esp/esp32-cam-demo
$ make flash
Flashing binaries to serial port com18 (app at offset 0x10000)...
esptool.py v2.0-dev
Connecting...

A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
make: *** [C:/msys32/esp-idf/components/esptool_py/Makefile.projbuild:48: flash] Error 2

This is due to a pullup on the camera reset line. It is stronger than the internal pull-down on GPIO2 of the ESP32, so the chip cannot go into programming mode.

There are couple of options how to resolve this issue:

  • If you are using ESP-WROVER V1 then connect GPIO2 to GND while flashing.
  • Power down the camera module by removing it from the socket (ESP-WROVER V1) or by uplugging 3.3V wire.
  • Map Camera Reset line to another GPIO pin on ESP32, for instance GPIO15.

Shoot

Once module is loaded with code, open a serial terminal.

Camera demo application will first configure XCLK output that is timing operation of the camera chip.

D (1527) camera: Enabling XCLK output
I (1527) ledc: LEDC_PWM CHANNEL 0|GPIO 21|Duty 0004|Time 0

This clock is also timing output of pixel data on camera output interface - see I2S and DMA described below.

Then SCCB interface is set up:

D (1527) camera: Initializing SSCB
I (1537) gpio: GPIO[26]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1537) gpio: GPIO[27]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1547) gpio: GPIO[26]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (1557) gpio: GPIO[27]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0

In next step the communication with camera should be established. ESP will retrieve camera's address and signature.

D (1567) camera: Resetting camera
D (1587) camera: Searching for camera address
D (1587) camera: Detected camera at address=0x21
D (1587) camera: Camera PID=0x77 VER=0x21 MIDL=0x7f MIDH=0xa2

If communication fails, the following message is shown:

E (1076) camera: Camera address not found
E (1076) camera_demo: Camera init failed with error = 131073

If communication with camera module is established, ESP will reset the camera sensor and reserve memory for video frame buffer:

D (1587) camera: Doing SW reset of sensor
D (1647) camera: Setting frame size at 320x240
D (1677) camera: Allocating frame buffer (320x240, 76800 bytes)

Image from camera is retrieved using I2S communication for all eight pixel bits at once and saved in memory line by line. Log below shows completion of initialization steps for I2S and DMA:

D (1677) camera: Initializing I2S and DMA
I (1677) gpio: GPIO[35]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1677) gpio: GPIO[34]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1687) gpio: GPIO[39]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1697) gpio: GPIO[36]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1707) gpio: GPIO[19]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1717) gpio: GPIO[18]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1727) gpio: GPIO[5]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1737) gpio: GPIO[4]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1747) gpio: GPIO[25]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1757) gpio: GPIO[23]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1767) gpio: GPIO[22]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
D (1777) intr_alloc: Connected src 32 to int 3 (cpu 0)
D (1777) camera: Allocating DMA buffer #0, size=1280
D (1787) camera: Allocating DMA buffer #1, size=1280
D (1817) camera: Init done

Finally ESP32 will retrieve image from camera and show it as ASCII art on serial terminal. Image will be retrieved in a loop once per second.

D (1817) camera: Waiting for positive edge on VSYNC
D (1847) camera: Got VSYNC
D (1847) camera: Waiting for frame
D (1887) camera: Frame done
D (1887) camera_demo: Done
|@@ ......... @@@@@@@@@@@@            .@@@@@@@@@@@@@ .. ....... @@@@@@@+. @@@@@@@|
|@@.    ... .+@@@@@@@@@@@@             @@@@@@@@@@@@@ ..      .. @@@@@@@@@@.:.  %@|
|@+         .@@@@@@@@@@@@@             @@@@@@@@@@@@@ ..       . @@@@@@@@@@@......|
|@           @@@@@@@@@@@@@             @@@@@@@@@@@@@.. .      ..@@@@@@@@@@@......|
|@           @@@@@@@@@@@@@             @@@@@@@@@@@@@-...       .@@@@@@@@@@@......|
|:@@@@@@@@@@@            =@@@@@@@@@@@@@             @@@@@@@%=.  @@@@@@@@@@@ .....|
|%@@@@@@@@@@@            %@@@@@@@@@@@@@            .@@@@@@@@@@@@@    .     @@*   |
|@@@@@@@@@@@@            @@@@@@@@@@@@@@             @@@@@@@@@@@@@        . @@@@@@|
|@@@@@@@@@@@%            @@@@@@@@@@@@@@             @@@@@@@@@@@@@          @@@@@@|
|@@@@@@@@@@@-            @@@@@@@@@@@@@@             @@@@@@@@@@@@@          @@@@@@|
|@@@@@@@@@@@             @@@@@@@@@@@@@@             @@@@@@@@@@@@@          @@@@@@|

How it Works

Software

The core of camera software is contained in camera folder and consists of the following files.

  • camera.c and include/camera.h - main file responsible for configuration of ESP32's GPIO, clock, I2S and DMA to interface with camera module. Once interface is established, it perfroms camera configuration to then retrieve image and save it in ESP32 memory. Access to camera is executed using lower level routines in the following files.

  • ov7725.c, ov7725.h, ov7725_regs.h and sensor.h - definition of registers of OV7725 to configure camera funcinality. Functions to set register groups to reset camera to default configuration and configure specific functionality like resolution or pixel format. Setting he registers is performed by lower level function in files below.

  • sccb.c and sccb.h - implementation of Serial Camera Control Bus (SCCB) protocol to set camera registers.

  • twi.c and twi.h - implementation of software I2C routines used by SCCB protocol.

  • wiring.c and wiring.h - the lowest level routines to set GPIO pin mode, set GPIO pin level and delay program execution by required number of ms.

  • component.mk - file used by C make command to access component during compilation.

  • Kconfig.projbuild - file used by make menuconfig that provides menu option to switch camera test pattern on / off.

All above are called esp-idf component and placed in components folder. Esp-idf framework provides components folder as a standard place to add modular functionality to a project.

Application starts and the top level control is executed from app_main.c file located in main folder.

Operation

Interconnections between application and h/w internals of ESP32 to acquire an image from the camera is shown on diagram below.

alt text

Troubleshooting

If you have issues to get the live image right, enable test pattern and see what is retrieved.

To do so, run make menuconfig, open Example Configuration menu option and check [ ] Enable test pattern on camera output.

Optionally change the following define in file camera.c:

# define ENABLE_TEST_PATTERN CONFIG_ENABLE_TEST_PATTERN

Camera sensor will then output test pattern instead of live image.

D (5692) camera: Waiting for positive edge on VSYNC
D (5722) camera: Got VSYNC
D (5722) camera: Waiting for frame
D (5752) camera: Frame done
D (5752) camera_demo: Done
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |

O nce test pattern is enabled, application will calculate standard variance of what is retrieved by ESP32 against pattern generated by the camera module. If there is noise on the lines or some pixels lines not connected or shortcut, this should be reported below displayed image.

Frames / mismatch : 4630 / 70 (1%), (6531449)

The value in brackets with % sign provides number of frames that differ from the test pattern. See code inline comments for more information on this functionality.

Showcase

This code has been tested with hardware presented below.

alt text alt text alt text
Core Board V2 (aka DevKitC) ESP-WROVER V1 (aka DevKitJ) OV7725 Camera module

Connections between camera and ESP32 should be made short or you are likely to get noisy images. In worst case you will not be able to retrieve any legible data from the camera. Using the above h/w it has been established, that connection length between OV7725 camera module header and ESP32 chip should not be longer than 90 mm.

In particular, if you are using ESP-WROVER V1 (aka DevKitJ), then camera module should be plugged right into socket soldered to the board. Attempt to use a cable header as shown below on left did not work. Image retrieved from camera was not legible. Test stand on right is showing ESP-WROVER V1 with a cable header. The chessboard test pattern retrieved in such set up is not legible. Module should be plugged right into the socket soldered on ESP-WROVER V1.

alt text alt text
Wiring of OV7725 to ESP-WROVER V1 - SUCH LONG WIRING DOES NOT WORK! Not legible chessboard test pattern for ESP-WROVER V1 with a cable header

To give you the idea of length of cable connection that does not cause issues with image retrieval, below is an example of wiring of Core Board V2 (aka DevKitC).

alt text alt text
Core Board V2 and camera on test stand Core Board V2 and camera wiring

A rigid test rig without any loose wires may be constructed using a proto-board and standard 2.54" sockets. It will work as a daughter board placed in-between Core Board V2 and camera module. Pictures below shows both sides of such rig wired according to alternate pin mapping.

alt text alt text
Daughter board - ESP32 Core Board V2 side Daughter board - OV7725 camera module side

Using short wires or a daughter board there are no problems with noise on the chessboard test pattern retrieved from the camera.

alt text

Next Steps

We are planning to test and compare images captured using:

  • ESP-WROVER V1 with camera module directly plugged in.
  • Core Board V2 and camera module interconnected with a daughter board instead of loose cables.

In longer perspective we plan the following:

  • Describe what's inside camera component
  • LCD support
  • QR Code reading
  • Web interface to control the camera
  • Camera component API development

Contribute

You are welcome to contribute to this repository by providing documentation to code, submitting issue reports, enhancement requests and pull requests. Contributions should follow Contributions Guide section of ESP32 Programming Guide.

Acknowledgments

This application is using code developed by:

  • OpenMV implementation for OV7725 by Ibrahim Abdelkader
  • Software I2C library for ESP31B by Hristo Gochkov

esp32-cam-demo's People

Contributors

esp32de avatar igrr avatar krzychb avatar oitzu avatar paccerdk avatar tuanpmt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp32-cam-demo's Issues

OV2640 eeserved registers

Hi,

In ov2640.c -->

static const uint8_t jpeg_regs[][2] = {
{ BANK_SEL, BANK_SEL_DSP },
{ RESET, RESET_DVP},
{ IMAGE_MODE, IMAGE_MODE_JPEG_EN|IMAGE_MODE_RGB565 },
{ 0xD7, 0x03 },
{ 0xE1, 0x77 },
{ QS, 0x0C },
{ RESET, 0x00 },
{0, 0},
};

But in OV2640 datasheet registers 0xD7 and 0xE1 appears as reserved.

Any help ?.

Regards.

How does s_dma_desc get advanced?

cur_buffer seems to be updated, but, i2s_fill_buf seems not to use the buffer info.

    SET_PERI_REG_BITS(I2S_IN_LINK_REG(0), I2S_INLINK_ADDR, ((uint32_t) &s_dma_desc), I2S_INLINK_ADDR_S);

Is this to be expected? Is there magic in the I2S subsystem to somehow select the right descriptor?

wifi send and camera data acquisition can not work at the same time?

When the camera output signal when the normal work of wifi data transmission will result in a high failure rate,if pull up the pin pwdn on the camera into the power off wifi send data can have a good effect.
Wifi send data when camera output signal will lead to wifi send problems?

Compile Error

Hi, I have a hard time. I do not know why compilation failed here because it's a well-known code. Maybe I have less configuration. I try to comment out this line of code, compiled successfully. Can be uploaded minicom display simply can not start the camera. I hope everyone can help me solve this problem. Thank you.

code:

/home/lee/work/12.11/esp32-cam-demo/components/camera/./xclk.c: In function 'camera_enable_out_clock':
/home/lee/work/12.11/esp32-cam-demo/components/camera/./xclk.c:14:15: error: 'ledc_timer_config_t {aka struct }' has no member named 'duty_resolution'
timer_conf.duty_resolution = 1;
^
/home/lee/esp-idf/make/component_wrapper.mk:242: recipe for target 'xclk.o' failed
make[1]: *** [xclk.o] Error 1
/home/lee/esp-idf//make/project.mk:448: recipe for target 'component-camera-build' failed

Update "sw-operation-diagram.png"

Due to some changes to support JPEG mode the diagram now doesn't exactly reflect the software structure... for example, the number of DMA buffers is calculated during initialization depending on resolution and other factors.

This issue is to get this diagram up to date.

Ref. #22 (comment)

OV7670 support

I have a WROVER and an OV7670 camera. I am using the ESP-IDF as of this post date. All compiles cleanly and when I flash/run, the application runs. However, I do not see any output (please see log at end). I have tried enabling the test pattern and there is no change. Here is the log of a run with zero changes having been made to the source:

D (633) camera: Enabling XCLK output
D (633) ledc: LEDC_PWM CHANNEL 0|GPIO 21|Duty 0004|Time 0
D (633) camera: Initializing SSCB
I (633) gpio: GPIO[26]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (633) gpio: GPIO[27]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (643) gpio: GPIO[26]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (653) gpio: GPIO[27]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
D (663) camera: Resetting camera
D (673) camera: Searching for camera address
D (673) camera: Detected camera at address=0x21
D (673) camera: Camera PID=0x76 VER=0x73 MIDL=0x7f MIDH=0xa2
D (683) camera: Doing SW reset of sensor
D (733) camera: Test pattern enabled
D (733) camera: Setting frame size at 320x240
D (763) camera: Allocating frame buffer (320x240, 76800 bytes)
D (763) camera: Initializing I2S and DMA
I (763) gpio: GPIO[35]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (763) gpio: GPIO[34]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (773) gpio: GPIO[39]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (783) gpio: GPIO[36]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (793) gpio: GPIO[19]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (793) gpio: GPIO[18]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (803) gpio: GPIO[5]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (813) gpio: GPIO[4]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (823) gpio: GPIO[25]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (833) gpio: GPIO[23]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (843) gpio: GPIO[22]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
D (843) camera: Allocating DMA buffer #0, size=1280
D (853) camera: Allocating DMA buffer #1, size=1280

ov2640 can not output test pattern

1.I'm trying to drive ov2640 and use openMV code(ov2640.c,ov2640.c,ov2640_reg.h),but I find that it can not output test pattern.I set the framesize which is QVGA.It should output 320x240 pixel,so I just need to change the code of camera init.I have not found the mistake of openMV code.Did you ever use Esp32 to drive ov2640,or I need to change i2s_fill_buf and line_filter_task.

D (1911) camera: Doing SW reset of sensor
D (1951) camera: Test pattern enabled
D (1951) camera: Setting frame size at 160x120
D (1981) camera: Allocating frame buffer (160x120, 19200 bytes)
D (1981) camera: Initializing I2S and DMA
I (1981) GPIO: GPIO[35]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (1981) GPIO: GPIO[34]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (1991) GPIO: GPIO[39]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (2001) GPIO: GPIO[36]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (2011) GPIO: GPIO[19]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (2021) GPIO: GPIO[18]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (2021) GPIO: GPIO[5]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (2031) GPIO: GPIO[4]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (2041) GPIO: GPIO[25]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (2051) GPIO: GPIO[23]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (2061) GPIO: GPIO[22]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
D (2071) camera: Allocating DMA buffer #0, size=640
D (2071) camera: Allocating DMA buffer #1, size=640
D (2081) camera: Init done
D (2081) camera: Waiting for VSYNC
D (2141) camera: Got VSYNC
D (2141) camera: Waiting for frame
D (2201) camera: Frame done
D (2201) camera_demo: Done
                                                                                
                       =                                        =               
                                 =                                        =     
  =.......                 .....................         ....                   
...        .:-:.       ==...................  .     .:-:.       ==.............:
.......:::::::.   .....:::.       ==:..........::::::::::...    ..    ..........
..:-======-.   :..::::.....   =--..........-=======-.   ::.::::......  =--:.....
+--:.........:===+++++.  .::::..:--::::.=:--:.........:===+++++:  ..:::..:---:::
......-=====--+.::..... ....::-+++++++:.......:-=====--+..:........:.:::=++++++-
::::--=++==-:.......-========+...... ..::::::---+===-:.......-========+...... ..
   ::--::::------:.....  ..:=====--++....  .:---::::-----::..... ....-====--++..
..... .:-===-::::-::......  ..     .:---+...   .:-====:::::::.....   ..      .:-
...     .:--:       ==.   ..:-=====-:.......     .:-=-.      ==    ..:======-:..
::-=----:....        ..:.....::.  =    .::------::...        ...:::....::. =   .
...::------:...=   ..:::::::...          ..:--------::..=   ..::::::::::........
........           ..:--==---------++  .........            ..:--=----------++  
.::::---------::=   ......              .::------------::=  .......             
        ..:----::-::::::::+                     ...::---:::::::::::+            
                                    =                                        =  
                  =                                        =                    
                            =                                        =          
                                      =                                        =
                  ==                                       ==                   
                            ==                                       ==         
                                      ==                                       =
                   =                                        =                   
                             =                                        =         
                                       =                                        
                    +                                        =                  
                              =                                        =        

Porting of OpenMV

This is to open discussion how to port OpenMV to ESP32 and what it entails.

Initial ideas:

  1. Write shims for the STM32 DCMI peripheral functions, translating them into I2S calls
  2. Abstract away hardware-specific part of working with DCMI, using some generic API. Such an API could be implemented both for the ESP32 and STM32 targets. - #8 (comment)
  1. Initially we can start porting just the camera and image processing related parts of OpenMV - #9 (comment)

Basing on overview of DCMI, here is the list of DCMI features (add more if missing):

  1. From 8 to 14-bit parallel interface, data formats: 8/10/12/14-bit progressive scan; YCbCr 4:2:2 progressive scan; RGB 565 progressive video and compressed data: JPEG
  2. Continuous or snapshot capture mode
  3. Crop feature (except JPEG)
  4. DCMI_PIXCLK up to 54MHz
  5. AHB bus
  6. 8x32 (8-level) FIFO to accommodate for any DMA response latency
  7. H/W image format conversion by extracting specific bytes from FIFO
  8. Interrupts: IT_LINE, IT_FRAME, IT_OVR, IT_VSYNC and IT_ERR
  9. Low-power mode: Run, Sleep, Stop and Standby

Basing on my understanding of ESP32 internals, I would implement DCMI features in ESP32 as follows:

  1. All numbers of bits are supported by I2C. Potential limitations: not enough memory to store bigger or >8 bit images, GPIOs already used for other peripherals
  2. Snapshot is already implemented as camera_run function. I assume continuous capture shouldn't be an issue unless there are some perforce limitations of RTOS.
  3. Should be implemented in s/w as post processing of already captured image
  4. ESP32 supports up to 40MHz pixel clock
  5. I am not sure what of AHB bus may be replicated by ESP32 h/w and what should be supplemented by s/w. I think they key is data streaming over Wi-Fi / ethernet, LCD and SD card support
  6. There is no I2S documentation yet to say what intermediate storage is provided
  7. Should be implemented in s/w like already done line_filter_task
  8. IT_LINE, IT_FRAME, IT_VSYNC interrupts may be programmed for pins receiving these signals from camera. IT_OVR, IT_ERR may be replaced by s/w events
  9. I assume ESP32 can support these modes but did not check specific functionality.

How do you see replication of DCMI functionality in ESP32?

Pulling reset line low

Could it be that the camera resetting at the beginning of the camera_init() is not working correctly?
I couldn't observe any gpio level chances while it should reset.

I chanced the code to:

    gpio_config_t conf = {0};
    conf.pin_bit_mask = 1LL << s_config.pin_reset;
    conf.mode = GPIO_MODE_OUTPUT;
    gpio_config(&conf);
	
    gpio_pulldown_en(s_config.pin_reset);
    gpio_set_level(s_config.pin_reset, 0);
    delay(10);
    gpio_pulldown_dis(s_config.pin_reset);
    gpio_set_level(s_config.pin_reset, 1);
    delay(10);

and it works, but there are probably more clean ways to do this.

Some issues about DMA and I2S

Hi, I found that there is barely any document about the I2S on esp32 (its DMA operations and registers).

In camera.c

  1. why buf_size (and also the size and length of s_dma_desc) is initialized as line_width * 4? In ov7725, if using RGB565 format, the maximum bytes per line is only 2 * line_width. In mt9v034, only monochrome mode is supported, so bytes per line is just line_width.
  2. about SET_PERI_REG_BITS(I2S_RXEOF_NUM_REG(0), I2S_RX_EOF_NUM, (buf_line_width - 2)*2, I2S_RX_EOF_NUM_S); What is the meaning of magic -2 and *2?
  3. In line_filter_task, the following codes confused me
        if (line_count & 1) {
            uint8_t* psrc = s_fb + (line_count - 1) * buf_line_width;
            memcpy(pfb, psrc, buf_line_width);
        }
        else {
            const uint32_t* buf = s_dma_buf[buf_idx];
            for (int i = 0; i < buf_line_width; ++i) {
                uint32_t v = *buf;
                uint8_t comp = (v & 0xff0000) >> 16;
                *pfb = comp;
                ++buf;
                ++pfb;
            }
        }

where it process every even lines, extract only bit 23:16 from s_dma_buf for s_fb (why?), and copy previous even line to odd line..

How could I contribute to the documentation of I2S module ?

I can't see anything in http browser

Hi, the log seem to be ok but I can't see anything in the web browser (http://192.168.1.34/stream).

Any clue ?, Regards.

I (312) camera_demo: Detected OV2640 camera, using JPEG format
I (532) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (532) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (572) phy: phy_version: 359.0, e79c19d, Aug 31 2017, 17:06:07, 0, 0
I (582) camera_demo: Connecting to "emc2"
I (3022) event: ip: 192.168.1.34, mask: 255.255.255.0, gw: 192.168.1.1
I (3022) camera_demo: Connected
I (3022) camera_demo: Free heap: 152548
I (3022) camera_demo: Camera demo ready
I (3032) camera_demo: open http://192.168.1.34/get for single frame
I (3032) camera_demo: open http://192.168.1.34/stream for multipart/x-mixed-replace stream (use with JPEGs)
I (7082) camera: Frame 0 done in 152 ms
I (18752) camera: Frame 1 done in 153 ms
I (40262) camera: Frame 2 done in 152 ms
I (61292) camera: Frame 3 done in 157 ms
I (103442) camera: Frame 4 done in 83 ms
I (115512) camera: Frame 5 done in 150 ms
I (118712) camera: Frame 6 done in 148 ms
I (139102) camera: Frame 7 done in 149 ms
I (159812) camera: Frame 8 done in 155 ms
I (168132) camera: Frame 9 done in 134 ms
I (174772) camera: Frame 10 done in 103 ms
I (186842) camera: Frame 11 done in 139 ms

Skew for first lines of image grabbed from OV7725 camera

This is to carry over discussion and track issue from already closed pull request - #8 (review)

For the test pattern generated by OV7725 camera, the following skew of first image lines is observed.

D (691560) camera: Waiting for VSYNC
D (691560) camera: Got VSYNC
D (691560) camera: Waiting for frame
D (691560) camera: Frame done
D (691560) camera_demo: Done
 @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%#########@++++++++++==========:::::::::.
  @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%#########@++++++++++==========:::::::::.
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%**********++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%**********++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%**********++++++++++==========::::::::::
   @@@@@@@@@@@@@@@@@@@%%%%%%%%%%**********++++++++++==========::::::::::

Notes:

  1. For QVGA one ASCII character (like @ or space) is printed out for every forth pixel and every eight line.
  2. Similar issue is observed for live images but is harder to notice than for regular test pattern.
  3. Test pattern has been captured @40MHz XCLK. At this speed millisecond clock in some cases does not tick and in other ticks 10 milliseconds.
  4. Last 32 image lines have slightly different pattern between about 120th and 150th column. It is not yet verified whether this a feature of the test pattern or issue with image capture process .

Wrong values for a bit mask in i2s_conf_reset()?

While studying the code, I found the following:

static inline void i2s_conf_reset()
{
    const uint32_t lc_conf_reset_flags = I2S_IN_RST_S | I2S_AHBM_RST_S
            | I2S_AHBM_FIFO_RST_S;
    I2S0.lc_conf.val |= lc_conf_reset_flags;
    I2S0.lc_conf.val &= ~lc_conf_reset_flags;

    const uint32_t conf_reset_flags = I2S_RX_RESET_M | I2S_RX_FIFO_RESET_M
            | I2S_TX_RESET_M | I2S_TX_FIFO_RESET_M;
    I2S0.conf.val |= conf_reset_flags;
    I2S0.conf.val &= ~conf_reset_flags;
    while (I2S0.state.rx_fifo_reset_back) {
        ;
    }
}

I think we may be using the wrong reset flag macros in the first block (lc_conf_reset_flags). For a given bit field, the format seems to be:

<BIT_FIELD>_M - Bit mask
<BIT_FILED>_S - Bit number

It doesn't seem to make sense to or together bit numbers (as is done in the first part of the code) while it does make sense to or together masks as is done in the second part of the code. If I were to guess, I'd say that this line:

const uint32_t lc_conf_reset_flags = I2S_IN_RST_S | I2S_AHBM_RST_S | I2S_AHBM_FIFO_RST_S;

should be changed to:

const uint32_t lc_conf_reset_flags = I2S_IN_RST_M | I2S_AHBM_RST_M | I2S_AHBM_FIFO_RST_M;

Question on setting pd->length to same as pd->size

In the sample code in the function called dma_desc_init() we find the creation of the DMA descriptors in a linked list. In the initialization of an element of this list, we find that we are creating and populating instances of lldesc_t structures.

In this structure we set (among others):

  • buf - A pointer to a malloced RAM biffer of size=buf_size
  • size - We record the size of the buffer (=buf_size)
  • length - The sample code also sets this to be buf_size

This causes me to be puzzled. I understand that buf is the storage to be written into and I understand that size is the amount of storage that the DMA subsystem can write into. It is length that is causing me pause. I had understood that the value of this would be the length of data actually written into the buffer by DMA. At initialization time, I would thus have imagined that its value would be 0 as opposed to the size of the buffer itself. I would have thought that 0 would indicate that no bytes within the buffer have been utilized to store DMA retrieved data?

Why appeared reset problem after Multiply the camera clock ?

My project's idf is esp-idf-v2.0.
But it has some problems now.
If camera pclk is 10MHZ,and set i2s clkm_div_num = 2 ,it can normal work.
This is the set i2s mclk code,the camera's pclk was seen with a logic analyzer and is 10MHZ.
I2S0.clkm_conf.clkm_div_a = 1;
I2S0.clkm_conf.clkm_div_b = 0;
I2S0.clkm_conf.clkm_div_num = 2;
But if set camera pclk is 20MHZ,and set i2s clkm_div_num = 1,there are aproblem .It will print the following and reset .
Guru Meditation Error of type LoadProhibited occurred on core 0. Exception was unhandled.
Register dump:
PC : 0x400fcb8d PS : 0x00060f30 A0 : 0x800f1d74 A1 : 0x3ffd8390
A2 : 0x00000000 A3 : 0x3ffdfd88 A4 : 0x00000058 A5 : 0x3ffdfdb8
A6 : 0x3ff42000 A7 : 0x00000000 A8 : 0x800fcb6d A9 : 0x3ffd8376
A10 : 0x3ffdfdf0 A11 : 0x00000058 A12 : 0x00000058 A13 : 0x00000058
A14 : 0xdbefe9e9 A15 : 0x999f21a2 SAR : 0x0000001e EXCCAUSE: 0x0000001c
EXCVADDR: 0x999f21be LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000

Backtrace: 0x400fcb8d:0x3ffd8390 0x400f1d71:0x3ffd83c0 0x400f1ae2:0x3ffd83e0 0x400eb72a:0x3ffd8410 0x400ed3c0:0x3ffd8470 0x400efbcf:0x3ffd84b0 0x400efc4d:0x3ffd84d0 0x400edd14:0x3ffd84f0 0x400edd33:0x3ffd8530 0x400ef883:0x3ffd8550 0x400ef966:0x3ffd8570 0x400f86fb:0x3ffd8590
This is the set i2s mclk code,the camera's pclk was seen with a logic analyzer and is 20MHZ.
I2S0.clkm_conf.clkm_div_a = 1;
I2S0.clkm_conf.clkm_div_b = 0;
I2S0.clkm_conf.clkm_div_num = 1;

I don't why doubling the rate of both will cause problems ?
If i want to improve the camera's acquisition rate,How do I set up I2S ?

QR code decoding with quirc

Hi @igrr,

Basing on the includes I believe you were using https://github.com/dlbeer/quirc.
If so, did it work for you out of box or you had to tweak the code?

Waiting for the camera to arrive, I did dry run with quirc and could not make it work.
The code compiles and loads without any issues but num_codes = quirc_count(qr) does not find anything for s/w generated B&W QR images I provide.

Add button fuction but there is something wrong

Eh,I want to add a fuction that the camera take photo after pressing a button.I refer to esp-idf->peripherals->gpio demo and found that gpio_install_isr_service is incompatible with gpio_isr_register().So sad.
Do you have a plan to add a button function.

Support for ov9650

can you provide support for ov9650? That would be very grateful

thank you

OV2640 can not work right!

@igrr Here is verbose log! it is seem like work well ,but image is not right in the browser.
And could you update Readme about the Ov2640,thank you.
`
I (1222) cpu_start: Pro cpu up.
I (1234) cpu_start: Starting app cpu, entry point is 0x40080eb0
I (0) cpu_start: App cpu up.
I (1267) heap_alloc_caps: Initializing. RAM available for dynamic allocation:
I (1289) heap_alloc_caps: At 3FFAE2A0 len 00001D60 (7 KiB): DRAM
I (1310) heap_alloc_caps: At 3FFB79E8 len 00028618 (161 KiB): DRAM
I (1331) heap_alloc_caps: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (1352) heap_alloc_caps: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (1374) heap_alloc_caps: At 40093C7C len 0000C384 (48 KiB): IRAM
I (1395) cpu_start: Pro cpu start user code
I (1454) cpu_start: Starting scheduler on PRO CPU.
I (206) cpu_start: Starting scheduler on APP CPU.
D (206) nvs: nvs_flash_init_custom start=9 count=6
D (246) camera: Enabling XCLK output
D (246) ledc: LEDC_PWM CHANNEL 0|GPIO 21|Duty 0001|Time 0
D (246) camera: Initializing SSCB
D (246) camera: Resetting camera
D (266) camera: Searching for camera address
D (276) camera: Detected camera at address=0x30
D (286) camera: Camera PID=0x26 VER=0x42 MIDL=0x7f MIDH=0xa2
D (286) camera: Doing SW reset of sensor
I (326) camera_demo: Detected OV2640 camera, using JPEG format
D (366) camera: Setting frame size to 640x480
D (426) camera: Test pattern enabled
D (426) camera: in_bpp: 2, fb_bpp: 2, fb_size: 61440, mode: 0, width: 640 height: 480
D (426) camera: Allocating frame buffer (61440 bytes)
D (426) camera: Initializing I2S and DMA
D (436) camera: Line width (for DMA): 5120 bytes
D (436) camera: DMA buffer size: 2560, DMA buffers per line: 2
D (446) camera: DMA buffer count: 8
D (446) camera: Allocating DMA buffer #0, size=2560
D (446) camera: Allocating DMA buffer #1, size=2560
D (456) camera: Allocating DMA buffer #2, size=2560
D (456) camera: Allocating DMA buffer #3, size=2560
D (466) camera: Allocating DMA buffer #4, size=2560
D (466) camera: Allocating DMA buffer #5, size=2560
D (476) camera: Allocating DMA buffer #6, size=2560
D (476) camera: Allocating DMA buffer #7, size=2560
D (486) camera: Initializing GPIO interrupts
D (576) camera: Init done
D (576) nvs: nvs_open misc 1
D (576) nvs: nvs_get_str_or_blob log
I (576) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (576) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
D (586) nvs: nvs_open nvs.net80211 1
D (596) nvs: nvs_get opmode 1
D (596) nvs: nvs_get country 1
D (596) nvs: nvs_get_str_or_blob sta.ssid
D (606) nvs: nvs_get_str_or_blob sta.mac
D (606) nvs: nvs_get sta.authmode 1
D (616) nvs: nvs_get_str_or_blob sta.pswd
D (616) nvs: nvs_get_str_or_blob sta.pmk
D (616) nvs: nvs_get sta.chan 1
D (626) nvs: nvs_get auto.conn 1
D (626) nvs: nvs_get bssid.set 1
D (626) nvs: nvs_get_str_or_blob sta.bssid
D (636) nvs: nvs_get sta.phym 1
D (636) nvs: nvs_get sta.phybw 1
D (636) nvs: nvs_get_str_or_blob sta.apsw
D (646) nvs: nvs_get_str_or_blob sta.apinfo
D (646) nvs: nvs_get_str_or_blob ap.ssid
D (656) nvs: nvs_get_str_or_blob ap.mac
D (656) nvs: nvs_get_str_or_blob ap.passwd
D (666) nvs: nvs_get_str_or_blob ap.pmk
D (666) nvs: nvs_get ap.chan 1
D (666) nvs: nvs_get ap.authmode 1
D (676) nvs: nvs_get ap.hidden 1
D (676) nvs: nvs_get ap.max.conn 1
D (676) nvs: nvs_get bcn.interval 2
D (686) nvs: nvs_get ap.phym 1
D (686) nvs: nvs_get ap.phybw 1
D (686) nvs: nvs_get ap.sndchan 1
D (696) nvs: nvs_set_blob sta.mac 6
D (696) nvs: nvs_set_blob ap.mac 6
D (706) nvs: nvs_open phy 0
D (706) nvs: nvs_get cal_version 4
D (706) nvs: nvs_get_str_or_blob cal_mac
D (706) nvs: nvs_get_str_or_blob cal_data
D (716) nvs: nvs_close 3
I (736) phy: phy_version: 350, Mar 22 2017, 15:02:06, 0, 0
I (736) camera_demo: Connecting to "CHQJ_DEV"
D (736) tcpip_adapter: check: local, if=0 fn=0x4010d644

D (736) tcpip_adapter: call api in lwip: ret=0x0, give sem
D (746) tcpip_adapter: check: remote, if=0 fn=0x4010d644

D (3096) tcpip_adapter: check: local, if=0 fn=0x4010d820

D (3096) tcpip_adapter: call api in lwip: ret=0x0, give sem
D (3096) tcpip_adapter: check: remote, if=0 fn=0x4010d820

D (3106) tcpip_adapter: check: local, if=0 fn=0x4010db9c

D (3116) tcpip_adapter: dhcp client init ip/mask/gw to all-0
D (3116) tcpip_adapter: dhcp client start successfully
D (3126) tcpip_adapter: call api in lwip: ret=0x0, give sem
D (3126) tcpip_adapter: check: remote, if=0 fn=0x4010db9c

I (4116) event: ip: 192.168.0.100, mask: 255.255.255.0, gw: 192.168.0.1
I (4116) camera_demo: Connected
I (4116) camera_demo: Free heap: 153896
I (4116) camera_demo: Camera demo ready
I (4116) camera_demo: open http://192.168.0.100/get for single frame
I (4126) camera_demo: open http://192.168.0.100/stream for multipart/x-mixed-replace stream (use with JPEGs)
D (10766) camera_demo: Image requested.
D (10766) camera: Waiting for positive edge on VSYNC
D (10806) camera: Got VSYNC
V (10806) camera: gpio isr, cnt=0
D (10806) camera: Waiting for frame
V (10816) camera: isr, cnt=1
V (10816) camera: isr, cnt=2
V (10826) camera: isr, cnt=3
V (10836) camera: isr, cnt=4
V (10836) camera: isr, cnt=5
V (10846) camera: isr, cnt=6
V (10856) camera: isr, cnt=7
V (10856) camera: isr, cnt=8
V (10866) camera: isr, cnt=9
V (10866) camera: isr, cnt=10
V (10876) camera: isr, cnt=11
V (10886) camera: isr, cnt=12
V (10886) camera: isr, cnt=13
V (10896) camera: isr, cnt=14
V (10896) camera: gpio isr, cnt=14
I (10896) camera: Frame 0 done in 135 ms
D (10896) camera_demo: Done
D (13956) camera_demo: Image requested.`
image

Send out through wifi after a row of data has been collected.Every sendto API has been called,but almost half of udp packet is missing.

The demand of my project is to collect the data of camera by ESP32, and then send it to PC in real time by wifi. LAN transmission.It is similar to demand for real-time monitoring.
My design is(modify line_filter_task to udp_thread) :ESP32 collects camera data through I2S protocol.I set the I2S DMA ping-pang buffer.When a buffer is full, I2S interrupt will occuer.In the ISR, let the camera data fill into another buffer, and then notify the UDP thread to send the data from the DMA buffer which has just been filled to PC through wifi.
Here is my i2s_isr code:
CODE: SELECT ALL
static void IRAM_ATTR i2s_isr(void* arg)
{
   I2S0.conf.rx_start = 0;
   I2S0.int_clr.val = I2S0.int_raw.val;       
   /switch buffer to let camera data fill*********/             
       s_cur_buffer = !s_cur_buffer;
     if (s_isr_count == 239)
   {
      i2s_stop();
       }
   else
       {
          ++s_isr_count;
   }
   i2s_fill_buf(s_cur_buffer);
   BaseType_t xHigherPriorityTaskWoken;
   /notify udp_thread*********/     
       xSemaphoreGiveFromISR(s_data_ready, &xHigherPriorityTaskWoken);
       if (xHigherPriorityTaskWoken != pdFALSE)
   {     
           portYIELD_FROM_ISR();
       }
}

Here is my UDP_thread code:
CODE: SELECT ALL
void udp_thread(void p)
{
      int prev_buf = -1;
      int sock;
      struct sockaddr_in toAddr;
      LWIP_UNUSED_ARG(p);
      sock = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
      if(sock < 0)
      {
         ESP_LOGI(TAG, "socket err");
      }
      memset(&toAddr,0,sizeof(toAddr));
      toAddr.sin_family=AF_INET;
      toAddr.sin_addr.s_addr=inet_addr("192.168.23.1");
      toAddr.sin_port = htons(REMOTE_PORT);
      while (true)
      {
                        /waiting notification from udp_i2s_isr
********/     
         xSemaphoreTake(s_data_ready, portMAX_DELAY);
                        FD_ZERO(&rdfds);
         FD_SET(sock,&rdfds);
         usertimeout.tv_sec=0;
         usertimeout.tv_usec=1000;
                        /******buf_idx is the buffer which has just been filled fully /   
         int buf_idx = !s_cur_buffer;
         if (prev_buf != -1 && prev_buf == buf_idx)
         {    
            ets_printf("! %d\n", s_line_count);
         }
                        const uint32_t
buf = s_dma_buf[buf_idx];
         prev_buf = buf_idx;
                        /A frame has been collected fully from  camera

         if (!s_i2s_running)
         {
            prev_buf = -1;
            s_frame_count++;
                                /frame_end tells the receiver that this is the end of this frame
/   
            sendto(sock,frame_end,SEND_END_LEN ,0,(struct sockaddr
)&toAddr,sizeof(toAddr));
                                /new fram collect
/
            i2s_run(s_fb_w, s_fb_h);
                               /frame_start tells the receiver that this is the start of this frame
/   
            sendto(sock,frame_start,SEND_START_LEN ,0,(struct sockaddr
)&toAddr,sizeof(toAddr));
            continue;
         }
         ret=select(sock+1,NULL,&rdfds,NULL,&usertimeout);

         if(ret < 0)
         {
            perror("select error\n");
         }
         else if(ret == 0)
         {
            printf("time out\n");
         }
         else
         {
                 if(FD_ISSET(sock,&rdfds))   
            {
            /send the part of centent of frame.********
               sendto(sock,buf,960,0,(struct sockaddr
)&toAddr,sizeof(toAddr));
                                        ++s_line_count;
            }
              
                   }
         }
            close(sock);
            vTaskDelete(NULL);
}

My problem is:According to my debugging,every sendto API that should be called has been called.But From my observation on Wireshark,more than half of the UDP package is missing.The time that sento API needs to run is more than sufficient.
From my guess,wiFi task hasn't finished yet,but new data coming in.So these data cannot be sent out.I don't know the detail about wifi stack in ESP32.
Can you share your opinion about it.I will be appreciate it very much.

LEDC: div param err and GPIO interrupt type error for GPIO 26 and 27

Hi @igrr,

I have connected the camera to ESP32_DevKitJ_V1 and flashed esp32-cam-demo application.
Compilation was done using the latest esp-idf release.

I have observed two issues:

  1. On start up LEDC as well as GPIO 26 and 27 interrupt type errors were reported:
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x1a (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0x00
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3ffc0008,len:0
load:0x3ffc0008,len:3592
load:0x40078000,len:5264
load:0x40080000,len:260
entry 0x40080034
I (26) boot: Espressif ESP32 2nd stage bootloader v. V0.1
I (34) boot: compile time 21:10:59
D (38) esp_image: reading image header @ 0x1000
D (45) boot: magic e9
D (48) boot: segments 04
D (51) boot: spi_mode 02
D (54) boot: spi_speed 00
D (58) boot: spi_size 01
I (61) boot: SPI Speed      : 40MHz
I (66) boot: SPI Mode       : DIO
I (71) boot: SPI Flash Size : 2MB
I (76) boot: Partition Table:
I (80) boot: ## Label            Usage          Type ST Offset   Length
D (89) bootloader_flash: mmu set paddr=00000000 count=1
D (97) boot: mapped partition table 0x8000 at 0x3f408000
D (104) boot: load partition table entry 0x3f408000
D (111) boot: type=1 subtype=2
I (115) boot:  0 nvs              WiFi data        01 02 00009000 00006000
D (125) boot: load partition table entry 0x3f408020
D (132) boot: type=1 subtype=1
I (136) boot:  1 phy_init         RF data          01 01 0000f000 00001000
D (146) boot: load partition table entry 0x3f408040
D (153) boot: type=0 subtype=0
I (158) boot:  2 factory          factory app      00 00 00010000 00100000
D (168) boot: load partition table entry 0x3f408060
D (174) boot: type=ff subtype=ff
I (179) boot: End of partition table
I (184) boot: Loading app partition at offset 00010000
D (191) esp_image: reading image header @ 0x10000
D (198) esp_image: reading 9 image segments
V (204) esp_image: loading segment header 0 at offset 0x10018
V (212) esp_image: segment data length 0xffe8 data starts 0x10020
D (221) bootloader_flash: mmu set paddr=00010000 count=2
V (296) esp_image: loading segment header 0 at offset 0x10018
V (297) esp_image: segment data length 0xffe8 data starts 0x10020
V (297) esp_image: loading segment header 1 at offset 0x20008
V (305) esp_image: segment data length 0x455c data starts 0x20010
D (314) bootloader_flash: mmu set paddr=00020000 count=1
V (340) esp_image: loading segment header 0 at offset 0x10018
V (340) esp_image: segment data length 0xffe8 data starts 0x10020
V (342) esp_image: loading segment header 1 at offset 0x20008
V (350) esp_image: segment data length 0x455c data starts 0x20010
V (359) esp_image: loading segment header 2 at offset 0x2456c
V (367) esp_image: segment data length 0x1a7c data starts 0x24574
D (376) bootloader_flash: mmu set paddr=00020000 count=1
V (390) esp_image: loading segment header 0 at offset 0x10018
V (392) esp_image: segment data length 0xffe8 data starts 0x10020
V (400) esp_image: loading segment header 1 at offset 0x20008
V (409) esp_image: segment data length 0x455c data starts 0x20010
V (417) esp_image: loading segment header 2 at offset 0x2456c
V (426) esp_image: segment data length 0x1a7c data starts 0x24574
V (434) esp_image: loading segment header 3 at offset 0x25ff0
V (443) esp_image: segment data length 0x400 data starts 0x25ff8
D (451) bootloader_flash: mmu set paddr=00020000 count=1
V (460) esp_image: loading segment header 0 at offset 0x10018
V (467) esp_image: segment data length 0xffe8 data starts 0x10020
V (476) esp_image: loading segment header 1 at offset 0x20008
V (484) esp_image: segment data length 0x455c data starts 0x20010
V (493) esp_image: loading segment header 2 at offset 0x2456c
V (501) esp_image: segment data length 0x1a7c data starts 0x24574
V (510) esp_image: loading segment header 3 at offset 0x25ff0
V (518) esp_image: segment data length 0x400 data starts 0x25ff8
V (527) esp_image: loading segment header 4 at offset 0x263f8
V (535) esp_image: segment data length 0x12948 data starts 0x26400
D (544) bootloader_flash: mmu set paddr=00020000 count=2
V (631) esp_image: loading segment header 0 at offset 0x10018
V (631) esp_image: segment data length 0xffe8 data starts 0x10020
V (631) esp_image: loading segment header 1 at offset 0x20008
V (639) esp_image: segment data length 0x455c data starts 0x20010
V (648) esp_image: loading segment header 2 at offset 0x2456c
V (656) esp_image: segment data length 0x1a7c data starts 0x24574
V (665) esp_image: loading segment header 3 at offset 0x25ff0
V (673) esp_image: segment data length 0x400 data starts 0x25ff8
V (682) esp_image: loading segment header 4 at offset 0x263f8
V (690) esp_image: segment data length 0x12948 data starts 0x26400
V (699) esp_image: loading segment header 5 at offset 0x38d48
V (707) esp_image: segment data length 0x0 data starts 0x38d50
D (715) bootloader_flash: mmu set paddr=00030000 count=1
V (723) esp_image: loading segment header 0 at offset 0x10018
V (731) esp_image: segment data length 0xffe8 data starts 0x10020
V (740) esp_image: loading segment header 1 at offset 0x20008
V (748) esp_image: segment data length 0x455c data starts 0x20010
V (757) esp_image: loading segment header 2 at offset 0x2456c
V (765) esp_image: segment data length 0x1a7c data starts 0x24574
V (774) esp_image: loading segment header 3 at offset 0x25ff0
V (783) esp_image: segment data length 0x400 data starts 0x25ff8
V (791) esp_image: loading segment header 4 at offset 0x263f8
V (799) esp_image: segment data length 0x12948 data starts 0x26400
V (808) esp_image: loading segment header 5 at offset 0x38d48
V (817) esp_image: segment data length 0x0 data starts 0x38d50
V (825) esp_image: loading segment header 6 at offset 0x38d50
V (833) esp_image: segment data length 0x72b8 data starts 0x38d58
D (842) bootloader_flash: mmu set paddr=00030000 count=2
V (880) esp_image: loading segment header 0 at offset 0x10018
V (881) esp_image: segment data length 0xffe8 data starts 0x10020
V (881) esp_image: loading segment header 1 at offset 0x20008
V (889) esp_image: segment data length 0x455c data starts 0x20010
V (897) esp_image: loading segment header 2 at offset 0x2456c
V (906) esp_image: segment data length 0x1a7c data starts 0x24574
V (914) esp_image: loading segment header 3 at offset 0x25ff0
V (923) esp_image: segment data length 0x400 data starts 0x25ff8
V (931) esp_image: loading segment header 4 at offset 0x263f8
V (940) esp_image: segment data length 0x12948 data starts 0x26400
V (948) esp_image: loading segment header 5 at offset 0x38d48
V (957) esp_image: segment data length 0x0 data starts 0x38d50
V (965) esp_image: loading segment header 6 at offset 0x38d50
V (973) esp_image: segment data length 0x72b8 data starts 0x38d58
V (982) esp_image: loading segment header 7 at offset 0x40010
V (990) esp_image: segment data length 0xf7c0 data starts 0x40018
D (999) bootloader_flash: mmu set paddr=00040000 count=1
V (1072) esp_image: loading segment header 0 at offset 0x10018
V (1073) esp_image: segment data length 0xffe8 data starts 0x10020
V (1073) esp_image: loading segment header 1 at offset 0x20008
V (1081) esp_image: segment data length 0x455c data starts 0x20010
V (1090) esp_image: loading segment header 2 at offset 0x2456c
V (1099) esp_image: segment data length 0x1a7c data starts 0x24574
V (1107) esp_image: loading segment header 3 at offset 0x25ff0
V (1116) esp_image: segment data length 0x400 data starts 0x25ff8
V (1125) esp_image: loading segment header 4 at offset 0x263f8
V (1133) esp_image: segment data length 0x12948 data starts 0x26400
V (1142) esp_image: loading segment header 5 at offset 0x38d48
V (1151) esp_image: segment data length 0x0 data starts 0x38d50
V (1159) esp_image: loading segment header 6 at offset 0x38d50
V (1167) esp_image: segment data length 0x72b8 data starts 0x38d58
V (1176) esp_image: loading segment header 7 at offset 0x40010
V (1185) esp_image: segment data length 0xf7c0 data starts 0x40018
V (1194) esp_image: loading segment header 8 at offset 0x4f7d8
V (1202) esp_image: segment data length 0x8 data starts 0x4f7e0
D (1211) bootloader_flash: mmu set paddr=00040000 count=1
V (1218) esp_image: unpadded image length 0x3f7e8
V (1225) esp_image: padded image length 0x3f7f0
D (1231) esp_image: reading checksum block at 0x4f7e0
D (1239) esp_image: reading image header @ 0x10000
D (1245) boot: bin_header: 233 9 2 1 400808fc
V (1252) esp_image: loading segment header 0 at offset 0x10018
V (1260) esp_image: segment data length 0xffe8 data starts 0x10020
I (1269) boot: segment 0: paddr=0x00010018 vaddr=0x00000000 size=0x0ffe8 ( 65512)
V (1280) esp_image: loading segment header 0 at offset 0x10018
V (1288) esp_image: segment data length 0xffe8 data starts 0x10020
V (1297) esp_image: loading segment header 1 at offset 0x20008
V (1306) esp_image: segment data length 0x455c data starts 0x20010
D (1315) boot: found drom segment, map from 00020010 to 3f400010
I (1323) boot: segment 1: paddr=0x00020008 vaddr=0x3f400010 size=0x0455c ( 17756) map
V (1335) esp_image: loading segment header 0 at offset 0x10018
V (1343) esp_image: segment data length 0xffe8 data starts 0x10020
V (1352) esp_image: loading segment header 1 at offset 0x20008
V (1360) esp_image: segment data length 0x455c data starts 0x20010
V (1369) esp_image: loading segment header 2 at offset 0x2456c
V (1378) esp_image: segment data length 0x1a7c data starts 0x24574
I (1387) boot: segment 2: paddr=0x0002456c vaddr=0x3ffb2c30 size=0x01a7c (  6780) load
D (1398) bootloader_flash: mmu set paddr=00020000 count=1
V (1409) esp_image: loading segment header 0 at offset 0x10018
V (1414) esp_image: segment data length 0xffe8 data starts 0x10020
V (1423) esp_image: loading segment header 1 at offset 0x20008
V (1432) esp_image: segment data length 0x455c data starts 0x20010
V (1440) esp_image: loading segment header 2 at offset 0x2456c
V (1449) esp_image: segment data length 0x1a7c data starts 0x24574
V (1458) esp_image: loading segment header 3 at offset 0x25ff0
V (1466) esp_image: segment data length 0x400 data starts 0x25ff8
I (1475) boot: segment 3: paddr=0x00025ff0 vaddr=0x40080000 size=0x00400 (  1024) load
D (1487) bootloader_flash: mmu set paddr=00020000 count=1
V (1495) esp_image: loading segment header 0 at offset 0x10018
V (1503) esp_image: segment data length 0xffe8 data starts 0x10020
V (1512) esp_image: loading segment header 1 at offset 0x20008
V (1520) esp_image: segment data length 0x455c data starts 0x20010
V (1529) esp_image: loading segment header 2 at offset 0x2456c
V (1537) esp_image: segment data length 0x1a7c data starts 0x24574
V (1546) esp_image: loading segment header 3 at offset 0x25ff0
V (1555) esp_image: segment data length 0x400 data starts 0x25ff8
V (1563) esp_image: loading segment header 4 at offset 0x263f8
V (1572) esp_image: segment data length 0x12948 data starts 0x26400
I (1581) boot: segment 4: paddr=0x000263f8 vaddr=0x40080400 size=0x12948 ( 76104) load
D (1592) bootloader_flash: mmu set paddr=00020000 count=2
V (1636) esp_image: loading segment header 0 at offset 0x10018
V (1637) esp_image: segment data length 0xffe8 data starts 0x10020
V (1637) esp_image: loading segment header 1 at offset 0x20008
V (1645) esp_image: segment data length 0x455c data starts 0x20010
V (1654) esp_image: loading segment header 2 at offset 0x2456c
V (1663) esp_image: segment data length 0x1a7c data starts 0x24574
V (1671) esp_image: loading segment header 3 at offset 0x25ff0
V (1680) esp_image: segment data length 0x400 data starts 0x25ff8
V (1689) esp_image: loading segment header 4 at offset 0x263f8
V (1697) esp_image: segment data length 0x12948 data starts 0x26400
V (1706) esp_image: loading segment header 5 at offset 0x38d48
V (1714) esp_image: segment data length 0x0 data starts 0x38d50
I (1723) boot: segment 5: paddr=0x00038d48 vaddr=0x400c0000 size=0x00000 (     0) load
D (1734) bootloader_flash: mmu set paddr=00030000 count=1
V (1742) esp_image: loading segment header 0 at offset 0x10018
V (1751) esp_image: segment data length 0xffe8 data starts 0x10020
V (1759) esp_image: loading segment header 1 at offset 0x20008
V (1768) esp_image: segment data length 0x455c data starts 0x20010
V (1777) esp_image: loading segment header 2 at offset 0x2456c
V (1785) esp_image: segment data length 0x1a7c data starts 0x24574
V (1794) esp_image: loading segment header 3 at offset 0x25ff0
V (1803) esp_image: segment data length 0x400 data starts 0x25ff8
V (1811) esp_image: loading segment header 4 at offset 0x263f8
V (1820) esp_image: segment data length 0x12948 data starts 0x26400
V (1829) esp_image: loading segment header 5 at offset 0x38d48
V (1837) esp_image: segment data length 0x0 data starts 0x38d50
V (1846) esp_image: loading segment header 6 at offset 0x38d50
V (1854) esp_image: segment data length 0x72b8 data starts 0x38d58
I (1863) boot: segment 6: paddr=0x00038d50 vaddr=0x00000000 size=0x072b8 ( 29368)
V (1874) esp_image: loading segment header 0 at offset 0x10018
V (1882) esp_image: segment data length 0xffe8 data starts 0x10020
V (1891) esp_image: loading segment header 1 at offset 0x20008
V (1900) esp_image: segment data length 0x455c data starts 0x20010
V (1909) esp_image: loading segment header 2 at offset 0x2456c
V (1917) esp_image: segment data length 0x1a7c data starts 0x24574
V (1926) esp_image: loading segment header 3 at offset 0x25ff0
V (1934) esp_image: segment data length 0x400 data starts 0x25ff8
V (1943) esp_image: loading segment header 4 at offset 0x263f8
V (1952) esp_image: segment data length 0x12948 data starts 0x26400
V (1961) esp_image: loading segment header 5 at offset 0x38d48
V (1969) esp_image: segment data length 0x0 data starts 0x38d50
V (1977) esp_image: loading segment header 6 at offset 0x38d50
V (1986) esp_image: segment data length 0x72b8 data starts 0x38d58
V (1995) esp_image: loading segment header 7 at offset 0x40010
V (2003) esp_image: segment data length 0xf7c0 data starts 0x40018
D (2012) boot: found irom segment, map from 00040018 to 400d0018
I (2021) boot: segment 7: paddr=0x00040010 vaddr=0x400d0018 size=0x0f7c0 ( 63424) map
V (2032) esp_image: loading segment header 0 at offset 0x10018
V (2041) esp_image: segment data length 0xffe8 data starts 0x10020
V (2049) esp_image: loading segment header 1 at offset 0x20008
V (2058) esp_image: segment data length 0x455c data starts 0x20010
V (2067) esp_image: loading segment header 2 at offset 0x2456c
V (2075) esp_image: segment data length 0x1a7c data starts 0x24574
V (2084) esp_image: loading segment header 3 at offset 0x25ff0
V (2093) esp_image: segment data length 0x400 data starts 0x25ff8
V (2101) esp_image: loading segment header 4 at offset 0x263f8
V (2110) esp_image: segment data length 0x12948 data starts 0x26400
V (2119) esp_image: loading segment header 5 at offset 0x38d48
V (2127) esp_image: segment data length 0x0 data starts 0x38d50
V (2136) esp_image: loading segment header 6 at offset 0x38d50
V (2144) esp_image: segment data length 0x72b8 data starts 0x38d58
V (2153) esp_image: loading segment header 7 at offset 0x40010
V (2161) esp_image: segment data length 0xf7c0 data starts 0x40018
V (2170) esp_image: loading segment header 8 at offset 0x4f7d8
V (2179) esp_image: segment data length 0x8 data starts 0x4f7e0
I (2187) boot: segment 8: paddr=0x0004f7d8 vaddr=0x50000000 size=0x00008 (     8) load
D (2199) bootloader_flash: mmu set paddr=00040000 count=1
D (2207) boot: configure drom and irom and start
V (2213) boot: d mmu set paddr=00020000 vaddr=3f400000 size=17764 n=1
V (2222) boot: rc=0
V (2225) boot: rc=0
V (2228) boot: i mmu set paddr=00040000 vaddr=400d0000 size=63432 n=1
V (2237) boot: rc=0
V (2240) boot: rc=0
D (2243) boot: start: 0x400808fc
I (2248) heap_alloc_caps: Initializing heap allocator:
I (2255) heap_alloc_caps: Region 19: 3FFB46AC len 0002B954 tag 0
I (2263) heap_alloc_caps: Region 25: 3FFE8000 len 00018000 tag 1
I (2272) cpu_start: Pro cpu up.
I (2276) cpu_start: Single core mode
I (2281) cpu_start: Pro cpu start user code
rtc v134 Oct 20 2016 12:36:18
XTAL 40M
D (2320) nvs: nvs_flash_init_custom start=9 count=6
D (2404) phy_init: loading PHY init data from application binary
D (2405) nvs: nvs_open phy 0
D (2406) nvs: nvs_get cal_version 4
D (2409) nvs: nvs_get_str_or_blob cal_mac
D (2444) nvs: nvs_get_str_or_blob cal_data
D (2487) nvs: nvs_close 1
I (2627) phy: phy_version: 246, Nov 18 2016, 17:30:07, 0, 0

D (2628) nvs: nvs_open phy 1
D (2628) nvs: nvs_set cal_version 4 1
D (2634) nvs: nvs_set_blob cal_mac 6
D (2664) nvs: nvs_set_blob cal_data 1904
D (2750) nvs: nvs_close 2
I (2751) cpu_start: Starting scheduler on PRO CPU.
D (2759) camera: Enabling XCLK output
E (2759) LEDC: div param err,div_param=3
E (2759) camera: ledc_timer_config failed, rc=ffffffff
I (2769) LEDC: LEDC_PWM CHANNEL 0|GPIO 21|Duty 0004|Time 0
D (2769) camera: Initializing SSCB
I (2779) GPIO: GPIO[26]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 1| Intr:12
E (2779) GPIO: C:/msys32/esp-idf/components/driver/./gpio.c:143 (gpio_set_intr_type):GPIO interrupt type error
I (2789) GPIO: GPIO[27]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 1| Intr:12
E (2799) GPIO: C:/msys32/esp-idf/components/driver/./gpio.c:143 (gpio_set_intr_type):GPIO interrupt type error
I (2809) GPIO: GPIO[26]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:12
E (2819) GPIO: C:/msys32/esp-idf/components/driver/./gpio.c:143 (gpio_set_intr_type):GPIO interrupt type error
I (2829) GPIO: GPIO[27]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:12
E (2839) GPIO: C:/msys32/esp-idf/components/driver/./gpio.c:143 (gpio_set_intr_type):GPIO interrupt type error
D (2849) camera: Resetting camera
D (2859) camera: Searching for camera address
E (2859) camera: Camera address not found
E (2859) camera_demo: Camera init failed with error = 131073
  1. To be able to flash the code I have to power down the camera. Otherwise the following error is reported:
Krzysztof@tdk-kmb-op780 MSYS /esp/esp32-cam-demo
$ make flash
Flashing binaries to serial port com18 (app at offset 0x10000)...
esptool.py v2.0-dev
Connecting...

A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
make: *** [C:/msys32/esp-idf/components/esptool_py/Makefile.projbuild:48: flash] Error 2

This error shows up no matter if I power up the board and camera using USB power supply or external power supply.

After fixing Issue #11, OV7725 is unable to operate @ 20MHz XCLK

After increasing XCLK from 10 to 20MHz, output of test pattern of OV7725 looks as follows:

D (1693434) camera: Waiting for positive edge on VSYNC
D (1693444) camera: Got VSYNC
D (1693444) camera: Waiting for frame
D (1693454) camera: Frame done
D (1693454) camera_demo: Done
|@++++++++++          **********          @@@@@@@@@@----------@@@@@@@@@@+++++++++|
|@===-:::::::::          ++++++++++          **********          @@@@@@@@@@------|
|@+          **********          @@@@@@@@@@----------@@@@@@@@@@++++++++++@@@@@@@@|
|:+++++++@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::  |
|@*****          @@@@@@@@@@----------@@@@@@@@@@++++++++++@@@@@@@@@@@@@@@@@@@@%%%%|
|+++++++++++**********                    @@@@@@@@@@@@@@@@@@@@+---------+++++++++|
|#@@@@@@@@@----------@@@@@@@@@@++++++++++@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########|
|+++++++++++*********=                   .@@@@@@@@@@@@@@@@@@@@---------=+++++++++|
|+---@@@@@@@@@@++++++++++@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++======|
|@+          **********          @@@@@@@@@@----------@@@@@@@@@@++++++++++@@@@@@@@|
|:+++++++@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::  |
|@*****          @@@@@@@@@@----------@@@@@@@@@@++++++++++@@@@@@@@@@@@@@@@@@@@%%%%|
|+++++++++++**********                    @@@@@@@@@@@@@@@@@@@@+---------+++++++++|
|#@@@@@@@@@----------@@@@@@@@@@++++++++++@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########|
|+++++++++++*********=                   .@@@@@@@@@@@@@@@@@@@@---------=+++++++++|
|+---@@@@@@@@@@++++++++++@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++======|
|@+          **********          @@@@@@@@@@----------@@@@@@@@@@++++++++++@@@@@@@@|
|:+++++++@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::  |
|@*****          @@@@@@@@@@----------@@@@@@@@@@++++++++++@@@@@@@@@@@@@@@@@@@@%%%%|
|+++++++++++**********                    @@@@@@@@@@@@@@@@@@@@+---------+++++++++|
|#@@@@@@@@@----------@@@@@@@@@@++++++++++@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########|
|+++++++++++*********=                   .@@@@@@@@@@@@@@@@@@@@---------=+++++++++|
|+---@@@@@@@@@@++++++++++@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++======|
|@+          **********          @@@@@@@@@@----------@@@@@@@@@@++++++++++@@@@@@@@|
|:+++++++@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%**********++++++++++==========::::::::::  |
|@*****          @@@@@@@@@@----------@@@@@@@@@@++++++++++@@@@@@@@@@@@@@@@@@@@%%%%|
|+++++++++++**********                    @@@@@@@@@@@@@@@@@@@@+---------+++++++++|
|*@@@@@@@@@----------@@@@@@@@@@++++++++++@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%**********|
|+++++++++++*********=                   .@@@@@@@@@@@@@@@@@@@@---------=+++++++++|
|+---@@@@@@@@@@++++++++++@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++======|
Variance from pattern = 1316374459

It is possible to get legible test pattern by reversing fix of issue #11 applied in 442ca8a

D (13968) camera: Waiting for positive edge on VSYNC
D (13978) camera: Got VSYNC
D (13978) camera: Waiting for frame
D (13988) camera: Frame done
D (13988) camera_demo: Done
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%#########@++++++++++==========:::::::::.         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%##########++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%**********++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%**********++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%**********++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%**********++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%**********++++++++++==========::::::::::         |
| @@@@@@@@@@@@@@@@@@@@%%%%%%%%%%**********++++++++++==========::::::::::         |
Variance from pattern = 69561395

The test pattern with XCLK at 10MHz with fix applied looks as follows::

D (5652) camera: Waiting for positive edge on VSYNC
D (5682) camera: Got VSYNC
D (5682) camera: Waiting for frame
D (5712) camera: Frame done
D (5712) camera_demo: Done
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%########## +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%********** +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%********** +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%********** +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%********** +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%********** +++++++++==========-:::::::::          |
|@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%********** +++++++++==========-:::::::::          |
Variance from pattern = 6531449

Is it possible to have have #11 fixed and be able to operate OV7725 camera at 20MHz?

Application to test application in various scenarios including fix reversal is available under https://github.com/krzychb/esp32-cam-demo

More or less a pixel randomly occured when wifi is connecting.

Wifi is connecting,according my investigation,when esp32 collects data from camera ,more or less a pixel occured randomly.It lead to data of the line shift.So this line will be wrong.If this issue cann't be avoided,what measures should be taken on the software?
5

Using default sdkconfig is causing application to get stuck on random basis waiting for a frame

Application gets stuck on the following step:

D (2825) camera: Waiting for frame

This happens on random basis, after reset and (always) successfully displaying the first frame.
Then, in two out of three cases, application gets stuck on the second frame.
If second frame is displayed successfully, then application continue to operate normally.

To replicate this issue use settings as on the left below.
Settings on the right do not cause any issues and are as used so far in this repository.

image

To change settings go to Component config > ESP32-specific config > Task watchdog

I have discovered this issue when checking generation of default sdkconfig file with make defconfig.
By default "Wathdog task" is enabled.

analog video input

Hi.
Is it possible to connect analog video encoder like saa7113h/ADV7181 to esp32?

saa7113h system clock out 27MHz, is esp32 can handle it ?
Thanks.

image

Read frame data

Hello!

Very cool project! Thanks for making this.

I have tried the demo, but the code seems updated, the question is how to read the data downloaded from http://192.168.0.104/get

I have tried to rename the file from http://192.168.0.104/pgm to pgm.pgm, and open it with a tool called openseeit, it is very grey rough image. This is a problem of the camera or what could be?
pgmpgm

Better embedded web server?

Embedded web server is definitely a nice feature which enables quicker iterations when debugging the code, and also reduces the effort of setting up and running this example.
Camera configuration, which is mostly hard-coded now, could be exposed in a web page, making it easier to experiment with support for new cameras. Playing with SCCB on the fly, poking registers, maybe even changing DMA filter code somehow? That would be cool. On the other hand, all this feature creep moves this project from being something bigger than just a camera demo.

With regards to the embedded web server, here are the options we have

  • ureq. Pros: really small and easy to integrate. Cons: doesn't have a way of sending (part of) the data in NETCONN_NOCOPY mode, which is essential when streaming bit chunks of framebuffer. Might be an easy feature to add though.
  • civetweb (MIT-licensed fork of Mongoose) Pros: nice and fully-featured solution. Cons: might take more time to integrate.
  • libesphttpd. Pros: already an ESP-IDF component. Cons: also doesn't support NETCONN_NOCOPY.
  • Port ESP8266WebServer from Arduino? Pros: has all the features, somewhat proven. Cons: depends on Arduino String type heavily, might be difficult to switch to std::string.
  • Keep rolling our own?
  • Any other options?

Limitations of pin-mappings?

I was looking into etching some board for my testrig and was wondering are there some limitation about the pin-mappings i can do?
Documentation just states "Pinout can be adjusted to some extent in software.", but not the limits of these.

SCCB Pull-ups?

Hi, do I need to use pull-up resistors on the SCCB lines?

Do we need sdkconfig file in this repository?

As we keep development sdkconfig will soon contain:

CONFIG_WIFI_SSID=
CONFIG_WIFI_PASSWORD=

With ESP8266 development this was one of my problems to remember to remove these setting from code before posting on GitHub.

Now once we can detach user settings we should do it.

The only argument I see for keeping this file are potentially some application required settings like mentioned in #19.

Apart of strictly user specific ssid/pass, sdkconfig also contains Serial flasher config settings that are unlikely to be useful to other users. Anybody besides the author of last commit would need to change them anyway after cloning this repository.

Overall I believe we should remove it.

JPEG mode

Forked from #11 to not go off-topic.

I also need to see the waveforms for JPEG case and check with hardware folks if this is something that I2S can support (although this is not something directly related to this specific issue).

I will do this, as soon as i get the cam. (Feels like taking forever)

Ov2640 reset eroor on soft reboots

Why ov2640 reset eroor on soft reboots.I use logic analyzer to catch signal,it seems that the camera don't respose ack after soft reboots.And how to fix it.

Getting an error during i2c check of camera:
D (1843) camera: Detected camera at address=0x30
D (1853) camera: Camera PID=0x00 VER=0x00 MIDL=0x00 MIDH=0x00

OV2640 JPEG data

Hi, only a question,

Is OV2640 JPEG data d[7:0] or d[9:2] ?.

Thanks in advance and regards.

Failed to allocate frame buffer

Can get the maximum resolution of 220x160 and then a little more memory application failed
How to get resolution of 640x480

Using socket to send image to a server, unsure if complete data is sent.

Hello,
Iam working on adding a function to send the image data (camera_get_fb() pointer data) to a remote LAMP server. I am using socket example to send the image data using write(socket,dataptr,size) function call. Using this method, I get only 40 characters sent at a time when I set dataptr to camera_get_fb() and size to camera_get_data_size(). No error is being invoked and it is being sent successfully, yet when I echo the POST variable sent from the ESP32 , I only receive 40 characters.When I sent the 41st character onwards, it sent around 80. I am not sure if it is indeed sending the complete image or is getting stuck at some point due to a unparsable character or maybe it is an error on the PHP side.
camera_client_xfer
Following is a link to my code , the only changes to the esp32-cam-demo I made for the client mode is in the app_main.c file
https://github.com/Serpent999/esp32-cam-demo

How to set OV7725 to get RGB565 picture

I set the OV7725 register for the RGB565 mode but the BMP picture data is still gray data, please explain the source of s_fb data
I’d appreciate your help

Display bitmap image over http

I've added httpd server and sent the captured bitmap file over http, some modified:

  • RGB555 format: COM7_RES_VGA | COM7_FMT_RGB555 | COM7_FMT_RGB, FRAMESIZE_HQVGA
  • line_filter_task:
uint32_t rgb = *buf;
rgb >>= 16; //remove 2Bytes i2s overhead
uint32_t red =       (rgb & 0b111110000000000) >> (10);
*pfb = red << 3;
pfb++;
// // // Set target pointer 8 bit forward
uint32_t green =     (rgb & 0b000001111100000) >> (5);
*pfb = green << 3;
pfb++;
uint32_t blue =      (rgb & 0b000000000011111);
*pfb = blue << 3;
pfb++;
buf ++;
  • s_fb_size = s_fb_w * s_fb_h * 3;

But it seems the data I received was not what I expected:

screen shot 2017-06-03 at 12 59 58 pm

Could you please take a look at this:
https://github.com/tuanpmt/esp32-cam-demo

Thanks.,

Multi camera support

Hoi,
i spent a couple of hours the last days trying to understand the code in order to reimplement a few of the original OpenMV features in https://github.com/Oitzu/esp32-camera.

Now, i'm kinda questioning myself if it wouldn't be better to modify the esp32-cam-demo to support multiple cameras and the gone camera settings.

Question: Would you approve such pull requests?

Documentation on ESP32 DMA I2S Camera mode

Two status questions if I may:

  • Is the ESP32 Technical Reference Manual as it relates to I2S Camera DMA considered complete?
  • Is the ESP-IDF support of ESP32 camera mode considered complete?

The back story:
I have been studying the Camera support and this excellent sample on and off for a few months now and I'm making very slow progress. I study the code and contrast that against the documentation in the Technical Reference and then examine the data structures in the ESP-IDF ... but after a day or two I get frustrated and walk away to another area of the ESP32. I seem to find that the Technical Reference Manual is the briefest of summaries and while it may be technically accurate I'm afraid I have to say that is consumer unfriendly. Obviously, there is the opportunity for this just to be my lack of comprehension of what I am reading ... so if there other community members who feel they have a grasp off it, I'd dearly love to spend time with you.

Another thought I had was that this area is still being baked ... and hence this issue/question ... what is the state of I2S Camera DMA documentation and support? Is this component still "cooking" or is it considered complete? If complete, then we'll see how we can improve. If still being developed, then I'll back away until such time as it is in a more consumable state.

The second question, the one relating to ESP-IDF. It seems that the camera samples are "poking around" at the I2S registers which feels much lower level compared to the other ESP-IDF functions. Are there plans to encapsulate I2S camera DMA into higher level ESP-IDF functions?

Only getting 4MHz period on the XCLK pin ...

I decided to put a signal analyzer on the XCLCK and PCLK pins and what I find is that the frequency is 4MHZ (using the code in this project).

I think I had expected 20MHz based on the logic within. Has anyone else measured the clock rate on the pins and have either the same or different results?

2017-07-22_22-49-53

Missing esp_intr_alloc.h

With commit cf5d8a1 I am getting the following error:

C:/msys32/esp/esp32-cam-demo/components/camera/camera.c:44:28: fatal error: esp_intr_alloc.h: No such file or directory
#include "esp_intr_alloc.h"
^
compilation terminated.

When esp32 sets up modem sleep, i2s's isr is in a mess。

The IDF version I use is the rc2.0 version. Network environment is WiFi lan.
I use esp32+camera to do network real-time video transmission. When esp32 grab a frame of data from camera, it sends out a frame of data through the wifi. When the esp32's WiFi finished transimission of one frame , it goes into modem sleep. If I set modem sleep mode, the i2s's isr becomes abnormal after the system has been running for some time. But if I don't set modem sleep mode, the system will work normal all the time.
Here is a log of logic analyser.How to fix it?Thank you!
i2s_isr in a mess

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.