From d093f48b6f04644e91f7576c7b4a4c984db8c695 Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Thu, 26 Jun 2025 15:02:10 -0700 Subject: [PATCH 1/4] drivers/sensors/lepton: Move lepton reset to config stage. The state of the auxilary flag has not resolved during reset(). During config() the state of the flag has been resolved. --- drivers/sensors/lepton.c | 62 +++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/drivers/sensors/lepton.c b/drivers/sensors/lepton.c index db3654982..ba35befd7 100644 --- a/drivers/sensors/lepton.c +++ b/drivers/sensors/lepton.c @@ -493,10 +493,42 @@ static int snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) { return 0; } +static int config(omv_csi_t *csi, omv_csi_config_t config) { + if (config == OMV_CSI_CONFIG_INIT) { + if (reset(csi) != 0) { + return -1; + } + + LEP_OEM_PART_NUMBER_T part; + if (LEP_GetOemFlirPartNumber(&lepton.port, &part) != LEP_OK) { + return OMV_CSI_ERROR_CSI_INIT_FAILED; + } + + // 500 == Lepton + // xxxx == Version + // 01/00 == Shutter/NoShutter + if (!strncmp(part.value, "500-0771", 8)) { + csi->chip_id = LEPTON_3_5; + } else if (!strncmp(part.value, "500-0726", 8)) { + csi->chip_id = LEPTON_3_0; + } else if (!strncmp(part.value, "500-0763", 8)) { + csi->chip_id = LEPTON_2_5; + } else if (!strncmp(part.value, "500-0659", 8)) { + csi->chip_id = LEPTON_2_0; + } else if (!strncmp(part.value, "500-0690", 8)) { + csi->chip_id = LEPTON_1_6; + } else if (!strncmp(part.value, "500-0643", 8)) { + csi->chip_id = LEPTON_1_5; + } + } + + return 0; +} + int lepton_init(omv_csi_t *csi) { csi->reset = reset; csi->sleep = sleep; - csi->config = NULL; + csi->config = config; csi->abort = NULL; csi->match = match; csi->snapshot = snapshot; @@ -529,34 +561,6 @@ int lepton_init(omv_csi_t *csi) { csi->frame_sync = 0; csi->mono_bpp = 1; - // Extra delay after power-on - mp_hal_delay_ms(1000); - - if (reset(csi) != 0) { - return OMV_CSI_ERROR_CSI_INIT_FAILED; - } - - LEP_OEM_PART_NUMBER_T part; - if (LEP_GetOemFlirPartNumber(&lepton.port, &part) != LEP_OK) { - return OMV_CSI_ERROR_CSI_INIT_FAILED; - } - - // 500 == Lepton - // xxxx == Version - // 01/00 == Shutter/NoShutter - if (!strncmp(part.value, "500-0771", 8)) { - csi->chip_id = LEPTON_3_5; - } else if (!strncmp(part.value, "500-0726", 8)) { - csi->chip_id = LEPTON_3_0; - } else if (!strncmp(part.value, "500-0763", 8)) { - csi->chip_id = LEPTON_2_5; - } else if (!strncmp(part.value, "500-0659", 8)) { - csi->chip_id = LEPTON_2_0; - } else if (!strncmp(part.value, "500-0690", 8)) { - csi->chip_id = LEPTON_1_6; - } else if (!strncmp(part.value, "500-0643", 8)) { - csi->chip_id = LEPTON_1_5; - } return 0; } #endif // (OMV_LEPTON_ENABLE == 1) From 7d2b334066bf3b0cddb3e3c99905dd61dad689d1 Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Fri, 27 Jun 2025 15:25:50 -0700 Subject: [PATCH 2/4] ports/stm32: Fix all sensor RGB565/GRAYSCALE/BAYER/YUV422 modes. Tested against all our supported sensors. Everything works. --- ports/stm32/omv_csi.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/ports/stm32/omv_csi.c b/ports/stm32/omv_csi.c index b5e90ec0b..3b2710c13 100644 --- a/ports/stm32/omv_csi.c +++ b/ports/stm32/omv_csi.c @@ -219,9 +219,14 @@ static int stm_csi_config(omv_csi_t *csi, omv_csi_config_t config) { scfg.Format = DCMIPP_FORMAT_RAW8; } else if (csi->pixformat == PIXFORMAT_RGB565) { scfg.Format = DCMIPP_FORMAT_RGB565; - scfg.SwapCycles = DCMIPP_SWAPCYCLES_ENABLE; + scfg.SwapCycles = (csi->rgb_swap == 1) ? DCMIPP_SWAPCYCLES_DISABLE : DCMIPP_SWAPCYCLES_ENABLE; } else if (csi->pixformat == PIXFORMAT_GRAYSCALE) { scfg.Format = (csi->mono_bpp == 1) ? DCMIPP_FORMAT_MONOCHROME_8B : DCMIPP_FORMAT_YUV422; + } else if (csi->pixformat == PIXFORMAT_YUV422) { + scfg.Format = DCMIPP_FORMAT_YUV422; + scfg.SwapCycles = (csi->yuv_swap == 1) ? DCMIPP_SWAPCYCLES_ENABLE : DCMIPP_SWAPCYCLES_DISABLE; + } else if (csi->pixformat == PIXFORMAT_BAYER) { + scfg.Format = DCMIPP_FORMAT_RAW8; } else { return OMV_CSI_ERROR_PIXFORMAT_UNSUPPORTED; } @@ -234,8 +239,10 @@ static int stm_csi_config(omv_csi_t *csi, omv_csi_config_t config) { DCMIPP_PipeConfTypeDef pcfg = { .FrameRate = DCMIPP_FRAME_RATE_ALL }; if (csi->pixformat == PIXFORMAT_RGB565) { pcfg.PixelPackerFormat = DCMIPP_PIXEL_PACKER_FORMAT_RGB565_1; - } else if (csi->pixformat == PIXFORMAT_GRAYSCALE) { + } else if (csi->pixformat == PIXFORMAT_GRAYSCALE || csi->pixformat == PIXFORMAT_BAYER) { pcfg.PixelPackerFormat = DCMIPP_PIXEL_PACKER_FORMAT_MONO_Y8_G8_1; + } else if (csi->pixformat == PIXFORMAT_YUV422) { + pcfg.PixelPackerFormat = DCMIPP_PIXEL_PACKER_FORMAT_YUV422_1; } else { return OMV_CSI_ERROR_PIXFORMAT_UNSUPPORTED; } @@ -243,15 +250,6 @@ static int stm_csi_config(omv_csi_t *csi, omv_csi_config_t config) { return OMV_CSI_ERROR_CSI_INIT_FAILED; } - // Swap RGB enabled. - if (csi->yuv_swap) { - HAL_DCMIPP_PIPE_EnableYUVSwap(&csi->dcmi, DCMIPP_PIPE); - } - // Swap YUV if enabled. - if (csi->rgb_swap) { - HAL_DCMIPP_PIPE_EnableRedBlueSwap(&csi->dcmi, DCMIPP_PIPE); - } - // Configure debayer. if (csi->raw_output && csi->pixformat != PIXFORMAT_BAYER) { DCMIPP_RawBayer2RGBConfTypeDef rawcfg = { From aa96e8837635bde8ba707a3a1f4dc7cb8d7dece3 Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Fri, 27 Jun 2025 18:11:13 -0700 Subject: [PATCH 3/4] drivers/sensors: Fix PAJ6100 on the OpenMV H7/P. When set_framesize is called it causes the DCMI hardware to lockup unless it's reconfigured. --- boards/OPENMV4/omv_boardconfig.h | 1 + boards/OPENMV4P/omv_boardconfig.h | 1 + drivers/sensors/paj6100.c | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/boards/OPENMV4/omv_boardconfig.h b/boards/OPENMV4/omv_boardconfig.h index 0f3eba915..c35f103fa 100644 --- a/boards/OPENMV4/omv_boardconfig.h +++ b/boards/OPENMV4/omv_boardconfig.h @@ -62,6 +62,7 @@ #define OMV_LEPTON_ENABLE (1) #define OMV_PAG7920_ENABLE (1) #define OMV_PAJ6100_ENABLE (1) +#define OMV_PAJ6100_GLITCH_RECONFIG (1) #define OMV_FROGEYE2020_ENABLE (1) // FIR drivers configuration. diff --git a/boards/OPENMV4P/omv_boardconfig.h b/boards/OPENMV4P/omv_boardconfig.h index 0a51fc880..e6acb55c3 100644 --- a/boards/OPENMV4P/omv_boardconfig.h +++ b/boards/OPENMV4P/omv_boardconfig.h @@ -48,6 +48,7 @@ #define OMV_LEPTON_ENABLE (1) #define OMV_PAG7920_ENABLE (1) #define OMV_PAJ6100_ENABLE (1) +#define OMV_PAJ6100_GLITCH_RECONFIG (1) #define OMV_FROGEYE2020_ENABLE (1) #define OMV_GENX320_EHC_ENABLE (1) diff --git a/drivers/sensors/paj6100.c b/drivers/sensors/paj6100.c index d1c842d10..d14efe592 100644 --- a/drivers/sensors/paj6100.c +++ b/drivers/sensors/paj6100.c @@ -446,6 +446,11 @@ static int set_framesize(omv_csi_t *csi, omv_csi_framesize_t framesize) { lt_lockrange_out_ubound = (L_TARGET + AE_LOCK_RANGE_OUT) * w * h; lt_lockrange_out_lbound = (L_TARGET - AE_LOCK_RANGE_OUT) * w * h; + // PAJ6100 crashes CSI hardware unless we recongfigure it. + #if (OMV_PAJ6100_GLITCH_RECONFIG == 1) + csi->config(csi, OMV_CSI_CONFIG_INIT); + #endif // (OMV_PAJ6100_GLITCH_RECONFIG == 1) + return 0; } From f6d22399244fc5d44e5257d328bbba04d86aea49 Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Fri, 27 Jun 2025 19:10:10 -0700 Subject: [PATCH 4/4] boards/OPENMV3: Fix default OV7725 clock freq. Was pushed way to fast. --- boards/OPENMV3/omv_boardconfig.h | 1 + 1 file changed, 1 insertion(+) diff --git a/boards/OPENMV3/omv_boardconfig.h b/boards/OPENMV3/omv_boardconfig.h index fd3541710..c767242c3 100644 --- a/boards/OPENMV3/omv_boardconfig.h +++ b/boards/OPENMV3/omv_boardconfig.h @@ -46,6 +46,7 @@ #define OMV_OV7725_ENABLE (1) #define OMV_OV7725_PLL_CONFIG (0x81) // x6 #define OMV_OV7725_BANDING (0x8F) +#define OMV_OV7725_CLK_FREQ (9000000) // FIR drivers configuration. #define OMV_FIR_MLX90621_ENABLE (1)