Skip to content

video/esp32s3: add GC0308 DVP camera support for lckfb-szpi-esp32s3#18542

Merged
acassis merged 5 commits intoapache:masterfrom
JianyuWang0623:camera_gc0308_lckfb-szpi_0
Mar 16, 2026
Merged

video/esp32s3: add GC0308 DVP camera support for lckfb-szpi-esp32s3#18542
acassis merged 5 commits intoapache:masterfrom
JianyuWang0623:camera_gc0308_lckfb-szpi_0

Conversation

@JianyuWang0623
Copy link
Contributor

@JianyuWang0623 JianyuWang0623 commented Mar 16, 2026

Note: Please adhere to Contributing Guidelines.

Summary

Add GC0308 DVP camera support for the ESP32-S3 platform, including the full V4L2 video pipeline from pixel format definition to board-level configuration.

This PR contains 5 patches:

  1. video: add V4L2_PIX_FMT_RGB565X pixel format support — Add big-endian RGB565 (RGB565X) format to imgdata.h, imgsensor.h, and v4l2_cap.c. This is needed by 8-bit DVP camera sensors that output RGB565 in big-endian byte order (high byte first on the data bus).

  2. drivers/video: add GC0308 VGA CMOS image sensor driver — Add a NuttX imgsensor driver for the GalaxyCore GC0308 VGA CMOS sensor. Supports VGA (640x480), QVGA (320x240), and QQVGA (160x120) resolutions via Kconfig. Output format is RGB565X.

  3. arch/xtensa/esp32s3: add CAM DVP imgdata driver — Add an ESP32-S3 CAM controller driver implementing the NuttX imgdata interface. Supports 8-bit DVP input with DMA-based frame capture, VSYNC interrupt handling, and PSRAM frame buffer allocation. The driver is sensor-agnostic: resolution and pixel format are negotiated at runtime through the V4L2 pipeline.

  4. boards/lckfb-szpi-esp32s3: add camera defconfig — Add a full camera configuration for the lckfb-szpi-esp32s3 board with GC0308 on DVP interface. Includes board-level camera initialization, DVP GPIO pin mapping, V4L2 video pipeline setup, ADB, SDMMC, LCD, and PSRAM.

  5. boards/lckfb-szpi-esp32s3: add gc0308 minimal defconfig — Add a minimal GC0308 camera configuration based on nsh. Only enables the GC0308 DVP camera driver (I2C, PCA9557, LEDC, CAM, VIDEO) without ADB, SDMMC, LCD, PSRAM or other peripherals.

Impact

  • New pixel format V4L2_PIX_FMT_RGB565X added to the V4L2 pipeline — no impact on existing formats.
  • New driver drivers/video/gc0308.c — only compiled when CONFIG_VIDEO_GC0308=y.
  • New arch driver arch/xtensa/src/esp32s3/esp32s3_cam.c — only compiled when CONFIG_ESP32S3_CAM=y.
  • New board configurations camera and gc0308 for lckfb-szpi-esp32s3 — no impact on existing configs.
  • Documentation updated in Documentation/platforms/xtensa/esp32s3/boards/lckfb-szpi-esp32s3/index.rst.

Testing

Host: Ubuntu x86_64
Board: LCKFB SZPI ESP32-S3 (ESP32-S3-WROOM-1-N16R8) + GC0308 DVP camera module

Build & flash (gc0308 minimal config):

$ ./tools/configure.sh lckfb-szpi-esp32s3:gc0308
$ make flash -j8 ESPTOOL_PORT=/dev/ttyUSB0

Build & flash (camera full config):

$ ./tools/configure.sh lckfb-szpi-esp32s3:camera
$ make flash -j8 ESPTOOL_PORT=/dev/ttyUSB0

Both configurations build and flash successfully. Camera frame capture verified on hardware — GC0308 outputs 320x240 RGB565X frames (153600 bytes) via the V4L2 pipeline.

Test app - camcap: JianyuWang0623/nuttx-apps@4aeadf2 (TEMPORARY)

adb -s 1234 shell camcap
adb -s 1234 pull /tmp/cap.rgb /tmp/cap.rgb

python3 -c "
import struct
from PIL import Image
raw = open('/tmp/cap.rgb', 'rb').read()
w, h = 320, 240
img = Image.new('RGB', (w, h))
pixels = []
for i in range(0, len(raw), 2):
    val = struct.unpack('>H', raw[i:i+2])[0]  # BE RGB565
    r = ((val >> 11) & 0x1F) << 3
    g = ((val >> 5)  & 0x3F) << 2
    b = (val & 0x1F) << 3
    pixels.append((r, g, b))
img.putdata(pixels)
img.save('/tmp/cap.png')
print('Saved: /tmp/cap.png')
"
cap_su7u

Add big-endian RGB565 (RGB565X) pixel format throughout the V4L2
video pipeline:
- IMGDATA_PIX_FMT_RGB565X in imgdata.h
- IMGSENSOR_PIX_FMT_RGB565X in imgsensor.h
- Format conversion and buffer size handling in v4l2_cap.c

This is needed by 8-bit DVP camera sensors that output RGB565 in
big-endian byte order (high byte first on the data bus).

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
@github-actions github-actions bot added Area: Documentation Improvements or additions to documentation Arch: xtensa Issues related to the Xtensa architecture Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. Board: xtensa labels Mar 16, 2026
@JianyuWang0623 JianyuWang0623 force-pushed the camera_gc0308_lckfb-szpi_0 branch from 72e0488 to 50138cd Compare March 16, 2026 07:25
Copy link
Contributor

@eren-terzioglu eren-terzioglu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

Nice work, congrats

@simbit18
Copy link
Contributor

simbit18 commented Mar 16, 2026

Hi @JianyuWang0623, Please align CMakeLists.txt with Make.defs (drivers/video)

https://github.com/JianyuWang0623/nuttx/blob/50138cdd2baaf050dee2bdd3a25825388da73000/drivers/video/CMakeLists.txt#L52

    if(CONFIG_VIDEO_GC0308)
      list(APPEND SRCS gc0308.c)
    endif()

@simbit18 simbit18 requested review from acassis, linguini1 and liuguo09 and removed request for liuguo09 March 16, 2026 09:01
@JianyuWang0623 JianyuWang0623 force-pushed the camera_gc0308_lckfb-szpi_0 branch from 50138cd to 1832a92 Compare March 16, 2026 09:09
simbit18
simbit18 previously approved these changes Mar 16, 2026
acassis
acassis previously approved these changes Mar 16, 2026
Copy link
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JianyuWang0623 that is amazing!!! Thank you very much! I bought a device and I'm looking forward to test it!

@JianyuWang0623 JianyuWang0623 dismissed stale reviews from acassis and simbit18 via 6208696 March 16, 2026 12:15
@JianyuWang0623 JianyuWang0623 requested a review from Donny9 as a code owner March 16, 2026 12:15
@simbit18
Copy link
Contributor

Hi @JianyuWang0623, please fix

../nuttx/tools/checkpatch.sh -c -u -m -g  11b4125170deee18458883441e0034fc1c310db3..HEAD
❌ Missing Signed-off-by
Used config files:
    1: .codespellrc
Error: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:174:18: error: Left bracket not on separate line
Error: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:179:18: error: Left bracket not on separate line
Error: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:180:18: error: Left bracket not on separate line
Warning: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:180:56: warning: Wrong column position of comment right of code
Error: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:181:18: error: Left bracket not on separate line
Error: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:211:78: error: Long line found
Warning: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:258:37: warning: Wrong column position of comment right of code
Warning: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:259:37: warning: Wrong column position of comment right of code
Warning: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:276:37: warning: Wrong column position of comment right of code
Warning: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:295:37: warning: Wrong column position of comment right of code
Error: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:345:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:367:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:370:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:373:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:379:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:385:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:391:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:399:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:449:80: error: Long line found
Error: /home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:792:1: error: Missing blank line before comment found
/home/runner/work/nuttx/nuttx/nuttx/drivers/usbdev/uvc.c:370: wHeight ==> weight, height
Some checks failed. For contributing guidelines, see:
  https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md
Error: Process completed with exit code 1.

@JianyuWang0623 JianyuWang0623 force-pushed the camera_gc0308_lckfb-szpi_0 branch from 6208696 to caa8876 Compare March 16, 2026 12:26
@JianyuWang0623
Copy link
Contributor Author

depends on: apache/nuttx-apps#3425

@JianyuWang0623 JianyuWang0623 force-pushed the camera_gc0308_lckfb-szpi_0 branch from caa8876 to 5c02755 Compare March 16, 2026 13:42
acassis
acassis previously approved these changes Mar 16, 2026
Add support for the GalaxyCore GC0308 VGA CMOS image sensor.
The driver implements the NuttX imgsensor interface and supports
VGA (640x480), QVGA (320x240), and QQVGA (160x120) resolutions
via Kconfig selection. Output format is RGB565X (big-endian).

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Add ESP32-S3 CAM controller driver implementing the NuttX imgdata
interface. Supports 8-bit DVP camera input with DMA-based frame
capture, VSYNC interrupt handling, and PSRAM frame buffer allocation.

The driver is sensor-agnostic: resolution and pixel format are
negotiated at runtime through the V4L2 pipeline. XCLK output
(24 MHz) is started during initialization for sensor communication.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Add camera configuration for lckfb-szpi-esp32s3 board with GC0308
sensor on DVP interface. Includes board-level camera initialization,
DVP GPIO pin mapping, and V4L2 video pipeline setup.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
@JianyuWang0623 JianyuWang0623 marked this pull request as draft March 16, 2026 15:05
@JianyuWang0623
Copy link
Contributor Author

Set as draft until dependency apache/nuttx-apps#3425 is merged.

@simbit18
Copy link
Contributor

Hi @JianyuWang0623, PR apache/nuttx-apps#3425 merged

Add a minimal GC0308 camera configuration based on nsh. Unlike the
full camera config, this only enables the GC0308 DVP camera driver
(I2C, PCA9557, LEDC, CAM, VIDEO) and camcap example, without ADB,
SDMMC, LCD, PSRAM or other peripherals.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
@JianyuWang0623 JianyuWang0623 force-pushed the camera_gc0308_lckfb-szpi_0 branch from 184ff0a to 5abe378 Compare March 16, 2026 17:02
@JianyuWang0623 JianyuWang0623 marked this pull request as ready for review March 16, 2026 17:02
@acassis acassis merged commit 9e55df4 into apache:master Mar 16, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: xtensa Issues related to the Xtensa architecture Area: Documentation Improvements or additions to documentation Board: xtensa Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants