diff --git a/boards/shields/st_b_cams_omv_mb1683/Kconfig.shield b/boards/shields/st_b_cams_omv_mb1683/Kconfig.shield new file mode 100644 index 0000000000000..48bd6cd82492a --- /dev/null +++ b/boards/shields/st_b_cams_omv_mb1683/Kconfig.shield @@ -0,0 +1,5 @@ +# Copyright (c) 2025 Charles Dias +# SPDX-License-Identifier: Apache-2.0 + +config SHIELD_ST_B_CAMS_OMV_MB1683 + def_bool $(shields_list_contains,st_b_cams_omv_mb1683) diff --git a/boards/shields/st_b_cams_omv_mb1683/boards/stm32h7b3i_dk.overlay b/boards/shields/st_b_cams_omv_mb1683/boards/stm32h7b3i_dk.overlay new file mode 100644 index 0000000000000..c6e629d23425b --- /dev/null +++ b/boards/shields/st_b_cams_omv_mb1683/boards/stm32h7b3i_dk.overlay @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Charles Dias + * + * SPDX-License-Identifier: Apache-2.0 + * + */ + +&st_cam_i2c { + pinctrl-0 = <&i2c4_scl_pd12 &i2c4_sda_pd13>; + pinctrl-names = "default"; + status = "okay"; + clock-frequency = ; +}; + +&st_cam_dvp { + pinctrl-0 = <&dcmi_hsync_pa4 &dcmi_pixclk_pa6 &dcmi_vsync_pb7 + &dcmi_d0_pc6 &dcmi_d1_pc7 &dcmi_d2_pg10 &dcmi_d3_pc9 + &dcmi_d4_pc11 &dcmi_d5_pd3 &dcmi_d6_pb8 &dcmi_d7_pb9>; + pinctrl-names = "default"; + + dmas = <&dma1 0 75 (STM32_DMA_PERIPH_TO_MEMORY | STM32_DMA_PERIPH_NO_INC | + STM32_DMA_MEM_INC | STM32_DMA_PERIPH_8BITS | STM32_DMA_MEM_32BITS | + STM32_DMA_PRIORITY_HIGH) STM32_DMA_FIFO_1_4>; +}; + +&dma1 { + status = "okay"; +}; + +&dmamux1 { + status = "okay"; +}; diff --git a/boards/shields/st_b_cams_omv_mb1683/doc/index.rst b/boards/shields/st_b_cams_omv_mb1683/doc/index.rst new file mode 100644 index 0000000000000..754fbf2c9b7cb --- /dev/null +++ b/boards/shields/st_b_cams_omv_mb1683/doc/index.rst @@ -0,0 +1,153 @@ +.. _st_b_cams_omv_mb1683: + +ST B-CAMS-OMV-MB1683 +#################### + +Overview +******** + +The camera module bundle (B-CAMS-OMV) provides extension connectors +for the MB1379 STMicroelectronics camera module daughterboard or +third-party modules like OpenMV and Waveshare modules. It can be used +with the STM32 boards featuring a 1 x 30 pin ZIF connector for the +connection of multiple cameras to implement computer vision on STM32 +microcontrollers easily. + +The camera module bundle is compatible with all STM32 Discovery kits and +Evaluation boards featuring a ZIF connector, such as the STM32H747I-DISCO, +STM32H7B3I-DK, and 32L4R9IDISCOVERY Discovery kits. + +.. figure:: st_b_cams_omv.webp + :width: 600px + :align: center + :alt: B-CAMS-OMV-MB1683 + + B-CAMS-OMV MB1683 Image (Credit: STMicroelectronics.) + +The camera signals go into the shield from one of the supported input +connectors (CN1, CN2, CN4), and out of the shield towards Zephyr through +the output 30-pin ZIF connector CN5. + +Refer to the `User manual`_ for the pinout of CN1 and CN2. + +Waveshare camera board connector CN4 (camera input) +*************************************************** + ++------------+-----------------+------------+--------------+ +| Pin number | Description | Pin number | Description | ++============+=================+============+==============+ +| 1 | GND | 2 | VCAM | ++------------+-----------------+------------+--------------+ +| 3 | I2C_SDA | 4 | I2C_SCL | ++------------+-----------------+------------+--------------+ +| 5 | DCMI_HSYNC | 6 | DCMI_VSYNC | ++------------+-----------------+------------+--------------+ +| 7 | Camera_CLK | 8 | DCMI_PIXCLK | ++------------+-----------------+------------+--------------+ +| 9 | DCMI_D6 | 10 | DCMI_D7 | ++------------+-----------------+------------+--------------+ +| 11 | DCMI_D4 | 12 | DCMI_D5 | ++------------+-----------------+------------+--------------+ +| 13 | DCMI_D2 | 14 | DCMI_D3 | ++------------+-----------------+------------+--------------+ +| 15 | DCMI_D0 | 16 | DCMI_D1 | ++------------+-----------------+------------+--------------+ +| 17 | PWR_EN / LED1 | 18 | RESET# | ++------------+-----------------+------------+--------------+ + +ZIF connector CN5 (camera output) +********************************* + ++------------+-----------------+ +| Pin number | Description | ++============+=================+ +| 1 | 3V3 | ++------------+-----------------+ +| 2 | GND | ++------------+-----------------+ +| 3 | I2C_SCL | ++------------+-----------------+ +| 4 | I2C_SDA | ++------------+-----------------+ +| 5 | RESET# | ++------------+-----------------+ +| 6 | PWR_EN / LED1 | ++------------+-----------------+ +| 7 | SHUTTER | ++------------+-----------------+ +| 8 | GND | ++------------+-----------------+ +| 9 | PULLDOWN / LED2 | ++------------+-----------------+ +| 10 | Camera_CLK | ++------------+-----------------+ +| 11 | 3V3 | ++------------+-----------------+ +| 12 | DCMI_VSYNC | ++------------+-----------------+ +| 13 | 5V (RSU) | ++------------+-----------------+ +| 14 | DCMI_HSYNC | ++------------+-----------------+ +| 15 | GND | ++------------+-----------------+ +| 16 | DCMI_PIXCK | ++------------+-----------------+ +| 17 | GND | ++------------+-----------------+ +| 18 | SPI_MISO | ++------------+-----------------+ +| 19 | SPI_CS | ++------------+-----------------+ +| 20 | DCMI_D7 | ++------------+-----------------+ +| 21 | DCMI_D6 | ++------------+-----------------+ +| 22 | DCMI_D5 | ++------------+-----------------+ +| 23 | DCMI_D4 | ++------------+-----------------+ +| 24 | DCMI_D3 | ++------------+-----------------+ +| 25 | DCMI_D2 | ++------------+-----------------+ +| 26 | DCMI_D1 | ++------------+-----------------+ +| 27 | DCMI_D0 | ++------------+-----------------+ +| 28 | SPI_MOSI | ++------------+-----------------+ +| 29 | SPI_CLK | ++------------+-----------------+ +| 30 | GND | ++------------+-----------------+ + +Requirements +************ + +The camera module bundle is compatible with all STM32 Discovery kits and +Evaluation boards featuring a ZIF connector, such as the STM32H747I-DISCO, +STM32H7B3I-DK, and 32L4R9IDISCOVERY Discovery kits. + +Usage +***** + +The shield can be used in any application by setting ``SHIELD`` to +``_st_b_cams_omv_mb1683`` and adding the necessary device tree properties. + +Set ``--shield "st_b_cams_omv_mb1683"`` when you invoke ``west build``. For example: + +.. zephyr-app-commands:: + :zephyr-app: samples/drivers/video/capture_to_lvgl + :board: stm32h7b3i_dk + :shield: st_b_cams_omv_mb1683 + :goals: build + +References +********** + +- `Product page `_ + +- `Databrief `_ + +- `User manual `_ diff --git a/boards/shields/st_b_cams_omv_mb1683/doc/st_b_cams_omv.webp b/boards/shields/st_b_cams_omv_mb1683/doc/st_b_cams_omv.webp new file mode 100644 index 0000000000000..2060d43b2e421 Binary files /dev/null and b/boards/shields/st_b_cams_omv_mb1683/doc/st_b_cams_omv.webp differ diff --git a/boards/shields/st_b_cams_omv_mb1683/st_b_cams_omv_mb1683.overlay b/boards/shields/st_b_cams_omv_mb1683/st_b_cams_omv_mb1683.overlay new file mode 100644 index 0000000000000..0ffb5669dadfe --- /dev/null +++ b/boards/shields/st_b_cams_omv_mb1683/st_b_cams_omv_mb1683.overlay @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2025 Charles Dias + * + * SPDX-License-Identifier: Apache-2.0 + * + */ + +#include + +/ { + chosen { + zephyr,camera = &st_cam_dvp; + }; +}; + +&st_cam_i2c { + + ov5640: ov5640@3c { + compatible = "ovti,ov5640"; + reg = <0x3c>; + status = "okay"; + reset-gpios = <&dmci_camera_connector 5 GPIO_ACTIVE_LOW>; + powerdown-gpios = <&dmci_camera_connector 6 GPIO_ACTIVE_HIGH>; + + port { + ov5640_ep_out: endpoint { + remote-endpoint-label = "dcmi_ep_in"; + bus-type = ; + }; + }; + }; +}; + +&st_cam_dvp { + status = "okay"; + sensor = <&ov5640>; + + bus-width = <8>; + hsync-active = <0>; + vsync-active = <0>; + pixelclk-active = <1>; + capture-rate = <1>; + + port { + dcmi_ep_in: endpoint { + remote-endpoint-label = "ov5640_ep_out"; + }; + }; +}; diff --git a/boards/st/stm32h7b3i_dk/stm32h7b3i_dk.dts b/boards/st/stm32h7b3i_dk/stm32h7b3i_dk.dts index 7e4fe7f9c2d7f..23d71b056441a 100644 --- a/boards/st/stm32h7b3i_dk/stm32h7b3i_dk.dts +++ b/boards/st/stm32h7b3i_dk/stm32h7b3i_dk.dts @@ -75,6 +75,28 @@ #phy-cells = <0>; }; + dmci_camera_connector: connector_dcmi_camera { + compatible = "st,stm32-dcmi-camera-fpu-330zh"; + #gpio-cells = <2>; + gpio-map-mask = <0xffffffff 0xffffffc0>; + gpio-map-pass-thru = <0 0x3f>; + gpio-map = <3 0 &gpiod 12 0>, /* I2C4_SCL */ + <4 0 &gpiod 13 0>, /* I2C4_SDA */ + <5 0 &gpioa 0 0>, /* RESET# */ + <6 0 &gpioa 7 0>, /* PWDN_EN */ + <12 0 &gpiob 7 0>, /* DCMI_VSYNC */ + <14 0 &gpioa 4 0>, /* DCMI_HSYNC */ + <16 0 &gpioa 6 0>, /* DCMI_PIXCK */ + <20 0 &gpiob 9 0>, /* DCMI_D7 */ + <21 0 &gpiob 8 0>, /* DCMI_D6 */ + <22 0 &gpiod 3 0>, /* DCMI_D5 */ + <23 0 &gpioc 11 0>, /* DCMI_D4 */ + <24 0 &gpioc 9 0>, /* DCMI_D3 */ + <25 0 &gpiog 10 0>, /* DCMI_D2 */ + <26 0 &gpioc 7 0>, /* DCMI_D1 */ + <27 0 &gpioc 6 0>; /* DCMI_D0 */ + }; + aliases { led0 = &blue_led; led1 = &red_led; @@ -278,3 +300,7 @@ }; }; }; + +st_cam_i2c: &i2c4 {}; + +st_cam_dvp: &dcmi {}; diff --git a/dts/bindings/gpio/st,dcmi-camera-fpu-330zh.yaml b/dts/bindings/gpio/st,dcmi-camera-fpu-330zh.yaml new file mode 100644 index 0000000000000..e6b74dfd3d5dd --- /dev/null +++ b/dts/bindings/gpio/st,dcmi-camera-fpu-330zh.yaml @@ -0,0 +1,40 @@ +# Copyright (c) 2025 Charles Dias +# SPDX-License-Identifier: Apache-2.0 + +description: | + GPIO pins exposed on the 30-pin ZIF connector (CN5) of the B-CAMS-OMV. + Connector layout: + (1) 3V3 + (2) GND + (3) I2C_SCL + (4) I2C_SDA + (5) RESET# + (6) PWR_EN / LED1 + (7) SHUTTER + (8) GND + (9) PULLDOWN / LED2 + (10) Camera_CLK + (11) 3V3 + (12) DCMI_VSYNC + (13) 5V (RSU) + (14) DCMI_HSYNC + (15) GND + (16) DCMI_PIXCK + (17) GND + (18) SPI_MISO + (19) SPI_CS + (20) DCMI_D7 + (21) DCMI_D6 + (22) DCMI_D5 + (23) DCMI_D4 + (24) DCMI_D3 + (25) DCMI_D2 + (26) DCMI_D1 + (27) DCMI_D0 + (28) SPI_MOSI + (29) SPI_CLK + (30) GND + +compatible: "st,dcmi-camera-fpu-330zh" + +include: [gpio-nexus.yaml, base.yaml] diff --git a/samples/drivers/video/capture_to_lvgl/boards/stm32h7b3i_dk.conf b/samples/drivers/video/capture_to_lvgl/boards/stm32h7b3i_dk.conf new file mode 100644 index 0000000000000..bb4f8b12a920a --- /dev/null +++ b/samples/drivers/video/capture_to_lvgl/boards/stm32h7b3i_dk.conf @@ -0,0 +1,11 @@ +# +# Copyright (c) 2025 Charles Dias +# +# SPDX-License-Identifier: Apache-2.0 +# + +CONFIG_LOG_BUFFER_SIZE=2048 + +CONFIG_VIDEO_WIDTH=480 +CONFIG_VIDEO_HEIGHT=272 +CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=262144 diff --git a/samples/drivers/video/capture_to_lvgl/boards/stm32h7b3i_dk.overlay b/samples/drivers/video/capture_to_lvgl/boards/stm32h7b3i_dk.overlay new file mode 100644 index 0000000000000..b9e8ba05e9456 --- /dev/null +++ b/samples/drivers/video/capture_to_lvgl/boards/stm32h7b3i_dk.overlay @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2025 Charles Dias + * + * SPDX-License-Identifier: Apache-2.0 + * + */ + +/delete-node/ &sram1; +/delete-node/ &sram2; + +/* Increase the SRAM0 bank memory size to accommodate the VIDEO_BUFFER_POOL_SZ_MAX configuration. */ +&sram0 { + reg = <0x24000000 DT_SIZE_K(1024)>; +};