Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
A Custom MicroPython binaryIntroductionWe have already seen how to create a custom MicroPython binary when we integrated all the modules needed for the WEB server. In case of the camera driver things are even a bit more tricky. The driver integrated into esp-idf is written in C and we must get access to its functions through MicroPython. We therefore need a MicroPython to C interface. A simple example on how to do this, can be found this chapter![]() | ||||||||
Added: | ||||||||
> > | Creating a new port in MicroPython | |||||||
Changed: | ||||||||
< < | In addition to the diver itself we must enable the external psram needed to store the rather big image data. | |||||||
> > | In addition to the diver itself we must enable the external psram needed to store the rather big image data. You can see how this is done by looking at the esp32 port of MicroPython. In the boards sub-directory you will find folders for different board configurations:
#define MICROPY_HW_MCU_NAME "ESP32" #define MODULE_EXAMPLE_ENABLED (1) #define MODULE_ESP32_CAMERA_ENABLED (1)
SDKCONFIG += boards/sdkconfig.spiram SDKCONFIG += boards/sdkconfig.camera boards/sdconfig.camera contains the definitions needed for compilation of the camera driver: # ESP32-CAMERA CONFIG_CAMERA_SUPPORT=y CONFIG_OV2640_SUPPORT=y #CONFIG_OV7725_SUPPORT=y Finally we must modify the port's Makefile to include compilation of the camera driver. I have attached the modified Makefile to this page: https://afnog.iotworkshop.africa/pub/AFNOG/CustomNopMicropPython/Makefile First we have to specify the additional include files needed: ifeq ($(CONFIG_CAMERA_SUPPORT),y) INC_ESPCOMP += -I$(ESPCOMP)/esp32-camera/driver/include INC_ESPCOMP += -I$(ESPCOMP)/esp32-camera/driver/private_include INC_ESPCOMP += -I$(ESPCOMP)/esp32-camera/conversions/include INC_ESPCOMP += -I$(ESPCOMP)/esp32-camera/conversions/private_include INC_ESPCOMP += -I$(ESPCOMP)/esp32-camera/sensors/private_include endif Then we must add the additional C sources to be compiled: ifeq ($(CONFIG_CAMERA_SUPPORT),y) ESPIDF_CAMERA_O = $(patsubst %.c,%.o,\ $(wildcard $(ESPCOMP)/esp32-camera/driver/*.c) \ $(wildcard $(ESPCOMP)/esp32-camera/conversions/*.c) \ $(wildcard $(ESPCOMP)/esp32-camera/sensors/*.c) \ ) endif and finally we add the camera object files created this way. ifeq ($(CONFIG_CAMERA_SUPPORT),y) $(eval $(call gen_espidf_lib_rule,esp32_camera,$(ESPIDF_CAMERA_O))) endif The camera driver is not a standard component in esp-idf and must be added there. Go to the component directory of your esp32 development environment esp-idf and clone the driver into this place. You will find it on https://github.com/espressif/esp32-camera/tree/master/driver ![]() The MicroPython C module for the camera driverI based my MicroPython C module on work done by shariltumin: https://github.com/shariltumin/esp32-cam-micropython![]() # build Micropython with the integrated esp32-camera driver # make BOARD=ESP32_CAMERA ESPIDF=/opt/ucc/afnog/afnog-2020/esp32-cam/esp-idf-micropython clean make BOARD=ESP32_CAMERA ESPIDF=/opt/ucc/afnog/afnog-2020/esp32-cam/esp-idf-micropython USER_C_MODULES=../../../user_modules ESPIDF= ... specifies where to find the esp-idf and the camera driver. | |||||||
-- ![]() Comments | ||||||||
Added: | ||||||||
> > |
|
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Added: | ||||||||
> > |
A Custom MicroPython binaryIntroductionWe have already seen how to create a custom MicroPython binary when we integrated all the modules needed for the WEB server. In case of the camera driver things are even a bit more tricky. The driver integrated into esp-idf is written in C and we must get access to its functions through MicroPython. We therefore need a MicroPython to C interface. A simple example on how to do this, can be found this chapter![]() ![]() Comments |