Skip to content

Commit 8e1a003

Browse files
authored
Maintenance changes in the component, examples and readme (#597)
* maint(build): remove legacy GNU Make build system support * maint(example): move the example so that component manager finds it * maint(example): specify component dependency * maint(build): clean up legacy 'register_component' usage * maint(build): specify more fields in component manifest * doc(readme): simplify installation instructions See #596 * maint(ci): remove tests for EOL versions (v4.1, v4.2) * fix(build): add missing transitive dependency on driver component
1 parent 81cd88c commit 8e1a003

File tree

13 files changed

+55
-80
lines changed

13 files changed

+55
-80
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
idf_ver: ["release-v4.1", "release-v4.2", "release-v4.3"]
14+
idf_ver: ["release-v4.3"]
1515
idf_target: ["esp32", "esp32s2"]
16-
exclude:
17-
- idf_ver: "release-v4.1"
18-
idf_target: esp32s2 # ESP32S2 support started with version 4.2
1916
container: espressif/idf:${{ matrix.idf_ver }}
2017
steps:
2118
- uses: actions/checkout@v1
@@ -25,7 +22,7 @@ jobs:
2522
env:
2623
IDF_TARGET: ${{ matrix.idf_target }}
2724
shell: bash
28-
working-directory: examples
25+
working-directory: examples/camera_example
2926
run: |
3027
. ${IDF_PATH}/export.sh
3128
idf.py build
@@ -48,7 +45,7 @@ jobs:
4845
env:
4946
IDF_TARGET: ${{ matrix.idf_target }}
5047
shell: bash
51-
working-directory: examples
48+
working-directory: examples/camera_example
5249
run: |
5350
. ${IDF_PATH}/export.sh
5451
export PEDANTIC_FLAGS="-DIDF_CI_BUILD -Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function"

CMakeLists.txt

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
set(idf_version "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}")
33

44
# set conversion sources
5-
set(COMPONENT_SRCS
5+
set(srcs
66
conversions/yuv.c
77
conversions/to_jpg.cpp
88
conversions/to_bmp.c
99
conversions/jpge.cpp
1010
conversions/esp_jpg_decode.c
1111
)
1212

13-
set(COMPONENT_PRIV_INCLUDEDIRS
13+
set(priv_include_dirs
1414
conversions/private_include
1515
)
1616

17-
set(COMPONENT_ADD_INCLUDEDIRS
17+
set(include_dirs
1818
driver/include
1919
conversions/include
2020
)
@@ -23,7 +23,7 @@ set(COMPONENT_REQUIRES driver)
2323

2424
# set driver sources only for supported platforms
2525
if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET STREQUAL "esp32s3")
26-
list(APPEND COMPONENT_SRCS
26+
list(APPEND srcs
2727
driver/esp_camera.c
2828
driver/cam_hal.c
2929
driver/sccb.c
@@ -44,55 +44,61 @@ if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET ST
4444
sensors/sc031gs.c
4545
)
4646

47-
list(APPEND COMPONENT_PRIV_INCLUDEDIRS
47+
list(APPEND priv_include_dirs
4848
driver/private_include
4949
sensors/private_include
5050
target/private_include
5151
)
5252

5353
if(IDF_TARGET STREQUAL "esp32")
54-
list(APPEND COMPONENT_SRCS
54+
list(APPEND srcs
5555
target/xclk.c
5656
target/esp32/ll_cam.c
5757
)
5858
endif()
5959

6060
if(IDF_TARGET STREQUAL "esp32s2")
61-
list(APPEND COMPONENT_SRCS
61+
list(APPEND srcs
6262
target/xclk.c
6363
target/esp32s2/ll_cam.c
6464
target/tjpgd.c
6565
)
6666

67-
list(APPEND COMPONENT_PRIV_INCLUDEDIRS
67+
list(APPEND priv_include_dirs
6868
target/esp32s2/private_include
6969
)
7070
endif()
7171

7272
if(IDF_TARGET STREQUAL "esp32s3")
73-
list(APPEND COMPONENT_SRCS
73+
list(APPEND srcs
7474
target/esp32s3/ll_cam.c
7575
)
7676
endif()
7777

78-
set(COMPONENT_PRIV_REQUIRES freertos nvs_flash)
78+
set(priv_requires freertos nvs_flash)
7979

8080
set(min_version_for_esp_timer "4.2")
8181
if (idf_version VERSION_GREATER_EQUAL min_version_for_esp_timer)
82-
list(APPEND COMPONENT_PRIV_REQUIRES esp_timer)
82+
list(APPEND priv_requires esp_timer)
8383
endif()
8484

8585
endif()
8686

8787
# CONFIG_ESP_ROM_HAS_JPEG_DECODE is available from IDF v4.4 but
8888
# previous IDF supported chips already support JPEG decoder, hence okay to use this
8989
if(idf_version VERSION_GREATER_EQUAL "4.4" AND NOT CONFIG_ESP_ROM_HAS_JPEG_DECODE)
90-
list(APPEND COMPONENT_SRCS
90+
list(APPEND srcs
9191
target/tjpgd.c
9292
)
93-
list(APPEND COMPONENT_PRIV_INCLUDEDIRS
93+
list(APPEND priv_include_dirs
9494
target/jpeg_include/
9595
)
9696
endif()
9797

98-
register_component()
98+
idf_component_register(
99+
SRCS ${srcs}
100+
INCLUDE_DIRS ${include_dirs}
101+
PRIV_INCLUDE_DIRS ${priv_include_dirs}
102+
REQUIRES driver # due to include of driver/gpio.h in esp_camera.h
103+
PRIV_REQUIRES ${priv_requires}
104+
)

README.md

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,25 @@ This repository hosts ESP32 series Soc compatible driver for image sensors. Addi
4040
## Installation Instructions
4141

4242

43-
### Using esp-idf
43+
### Using with ESP-IDF
4444

45-
- Clone or download and extract the repository to the components folder of your ESP-IDF project
45+
- Add a dependency on `espressif/esp32-camera` component:
46+
```bash
47+
idf.py add-dependency "espressif/esp32-camera"
48+
```
49+
(or add it manually in idf_component.yml of your project)
4650
- Enable PSRAM in `menuconfig` (also set Flash and PSRAM frequiencies to 80MHz)
4751
- Include `esp_camera.h` in your code
4852

49-
### Using PlatformIO
53+
These instructions also work for PlatformIO, if you are using `framework=espidf`.
54+
55+
### Using with Arduino
56+
57+
#### Arduino IDE
58+
59+
If you are using the arduino-esp32 core in Arduino IDE, no installation is needed! You can use esp32-camera right away.
60+
61+
#### PlatformIO
5062

5163
The easy way -- on the `env` section of `platformio.ini`, add the following:
5264

@@ -68,41 +80,15 @@ Enable PSRAM on `menuconfig` or type it direclty on `sdkconfig`. Check the [offi
6880
CONFIG_ESP32_SPIRAM_SUPPORT=y
6981
```
7082

71-
***Arduino*** The easy-way (content above) only seems to work if you're using `framework=arduino` which seems to take a bunch of the guesswork out (thanks Arduino!) but also suck up a lot more memory and flash, almost crippling the performance. If you plan to use the `framework=espidf` then read the sections below carefully!!
72-
73-
## Platform.io lib/submodule (for framework=espidf)
83+
## Examples
7484

75-
It's probably easier to just skip the platform.io library registry version and link the git repo as a submodule. (i.e. using code outside the platform.io library management). In this example we will install this as a submodule inside the platform.io $project/lib folder:
76-
```
77-
cd $project\lib
78-
git submodule add -b master https://github.com/espressif/esp32-camera.git
79-
```
85+
This component comes with a basic example illustrating how to get frames from the camera. You can try out the example using the following command:
8086

81-
Then in `platformio.ini` file
8287
```
83-
build_flags =
84-
-I../lib/esp32-camera
88+
idf.py create-project-from-example "espressif/esp32-camera:camera_example"
8589
```
86-
After that `#include "esp_camera.h"` statement will be available. Now the module is included, and you're hopefully back to the same place as the easy-Arduino way.
87-
88-
**Warning about platform.io/espidf and fresh (not initialized) git repos**
89-
There is a sharp-edge on you'll discover in the platform.io build process (in espidf v3.3 & 4.0.1) where a project which has only had `git init` but nothing committed will crash platform.io build process with highly non-useful output. The cause is due to lack of a version (making you think you did something wrong, when you didn't at all) - the output is horribly non-descript. Solution: the devs want you to create a file called version.txt with a number in it, or simply commit any file to the projects git repo and use git. This happens because platform.io build process tries to be too clever and determine the build version number from the git repo - it's a sharp edge you'll only encounter if you're experimenting on a new project with no commits .. like wtf is my camera not working let's try a 'clean project'?! </rant>
9090

91-
## Platform.io Kconfig
92-
Kconfig is used by the platform.io menuconfig (accessed by running: `pio run -t menuconfig`) to interactively manage the various #ifdef statements throughout the espidf and supporting libraries (i.e. this repo: esp32-camera and arduino-esp32.git). The menuconfig process generates the `sdkconfig` file which is ultimately used behind the scenes by espidf compile+build process.
93-
94-
**Make sure to append or symlink** [this `Kconfig`](./Kconfig) content into the `Kconfig` of your project.
95-
96-
You symlink (or copy) the included Kconfig into your platform.io projects src directory. The file should be named `Kconfig.projbuild` in your projects src\ directory or you could also add the library path to a CMakefile.txt and hope the `Kconfig` (or `Kconfig.projbuild`) gets discovered by the menuconfig process, though this unpredictable for me.
97-
98-
The unpredictable wonky behavior in platform.io build process around Kconfig naming (Kconfig vs. Kconfig.projbuild) occurs between espidf versions 3.3 and 4.0 - but if you don't see "Camera configuration" in your `pio run -t menuconfig` then there is no point trying to test camera code (it may compile, but it probably won't work!) and it seems the platform.io devs (when they built their wrapper around the espidf menuconfig) didn't implement it properly. You've probably already figured out you can't use the espidf build tools since the files are in totally different locations and also different versions with sometimes different syntax. This is one of those times you might consider changing the `platformio.ini` from `platform=espressif32` to `platform=https://github.com/platformio/platform-espressif32.git#develop` to get a more recent version of the espidf 4.0 tools.
99-
100-
However with a bit of patience and experimenting you'll figure the Kconfig out. Once Kconfig (or Kconfig.projbuild) is working then you will be able to choose the configurations according to your setup or the camera libraries will be compiled. Although you might also need to delete your .pio/build directory before the options appear .. again, the `pio run -t menuconfig` doens't always notice the new Kconfig files!
101-
102-
If you miss-skip-ignore this critical step the camera module will compile but camera logic inside the library will be 'empty' because the Kconfig sets the proper #ifdef statements during the build process to initialize the selected cameras. It's very not optional!
103-
104-
105-
## Examples
91+
This command will download the example into `camera_example` directory. It comes already pre-configured with the correct settings in menuconfig.
10692

10793
### Initialization
10894

component.mk

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/Makefile

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/CMakeLists.txt renamed to examples/camera_example/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# CMakeLists in this exact order for cmake to work correctly
33
cmake_minimum_required(VERSION 3.5)
44

5-
set(EXTRA_COMPONENT_DIRS "../")
6-
7-
add_compile_options(-fdiagnostics-color=always)
5+
set(COMPONENTS main)
86
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
9-
project(camera_example)
7+
project(camera_example)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
idf_component_register(SRCS take_picture.c
2+
PRIV_INCLUDE_DIRS .
3+
PRIV_REQUIRES nvs_flash)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dependencies:
2+
espressif/esp32-camera:
3+
version: "*"
4+
override_path: "../../../"
5+

examples/main/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/main/component.mk

Lines changed: 0 additions & 5 deletions
This file was deleted.

idf_component.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
description: ESP32 compatible driver for OV2640, OV3660, OV5640, OV7670 and OV7725 image sensors.
22
url: https://github.com/espressif/esp32-camera
3+
issues: https://github.com/espressif/esp32-camera/issues
4+
documentation: https://github.com/espressif/esp32-camera/tree/main/README.md
5+
repository: https://github.com/espressif/esp32-camera.git

0 commit comments

Comments
 (0)