diff --git a/.gitignore b/.gitignore index 2e0d4e7..41af108 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ __pycache__ # lvgl build files micropython/port/lextab.py micropython/port/yacctab.py + +.clangd +compile_commands.json diff --git a/.gitmodules b/.gitmodules index ad27db0..21eba93 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,15 +1,19 @@ [submodule "micropython"] path = micropython/micropython url = https://github.com/micropython/micropython.git + ignore = dirty [submodule "k230_sdk"] path = k230_sdk url = https://github.com/kendryte/k230_sdk.git [submodule "micropython_port/lvgl/lv_binding_micropython"] path = micropython/port/3d-party/lvgl/lv_binding_micropython url = https://github.com/lvgl/lv_binding_micropython.git + ignore = dirty [submodule "micropython_port/3d-party/freetype/freetype"] path = micropython/port/3d-party/freetype/freetype url = https://github.com/freetype/freetype.git + ignore = dirty [submodule "micropython_port/3d-party/wrap/micropython-wrap"] path = micropython/port/3d-party/wrap/micropython-wrap url = https://github.com/stinos/micropython-wrap.git + ignore = dirty diff --git a/Makefile b/Makefile index 412eead..366cd3a 100644 --- a/Makefile +++ b/Makefile @@ -102,6 +102,7 @@ k230_sdk_build: .sync_overlay .PHONY: micropython micropython_freetype: .sync_overlay + @rm -rf $(K230_CANMV_BUILD_DIR)/images/res/font/ @mkdir -p $(K230_CANMV_BUILD_DIR)/images/res/font/ @cp -f fs_resource/font/SourceHanSansSC-Normal-Min.ttf $(K230_CANMV_BUILD_DIR)/images/res/font @cp -f fs_resource/font/LICENSE.txt $(K230_CANMV_BUILD_DIR)/images/res/font/LICENSE.txt @@ -115,6 +116,7 @@ micropython_freetype_clean: .sync_overlay .PHONY: micropython micropython: k230_sdk_build micropython_freetype @make -C micropython/port + @rm -rf $(K230_CANMV_BUILD_DIR)/images/app/ @mkdir -p $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel/ @cp -f $(K230_CANMV_BUILD_DIR)/micropython/micropython $(K230_CANMV_BUILD_DIR)/images/app diff --git a/k230_sdk_overlay/src/big/mpp/include/comm/k_board_config_comm.h b/k230_sdk_overlay/src/big/mpp/include/comm/k_board_config_comm.h new file mode 100644 index 0000000..fa76362 --- /dev/null +++ b/k230_sdk_overlay/src/big/mpp/include/comm/k_board_config_comm.h @@ -0,0 +1,247 @@ +/** +* @file k_ao_comm.h +* @author +* @sxp +* @version 1.0 +* @date 2022-10-21 +* +* @copyright +* Copyright (c) 2023, Canaan Bright Sight Co., Ltd +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#ifndef __K_BOARD_CONFIG_COMM_H__ +#define __K_BOARD_CONFIG_COMM_H__ + + +#include "k_autoconf_comm.h" + +#ifdef __cplusplus +extern "C" { +#endif /* End of #ifdef __cplusplus */ + + +// sip gpio board config +#if defined(CONFIG_BOARD_K230D) +// display gpio +#define DISPLAY_LCD_RST_GPIO 21 +#define DISPLAY_LCD_BACKLIGHT_EN 20 + +// imx335 gpio config +#define VICAP_IMX335_RST_GPIO 37 +#define VICAP_IMX335_MASTER_GPIO 33 +//OV9286 gpio cinfig +#define VICAP_OV9286_RST_GPIO 35 +#define OV5647_IIC "i2c1" +#define OV5647_CAM_PIN 20 +#define OV5647_CAM_PIN_CSI2 (24) +#define OV5647_CAM_PIN_CSI1 (23) + +#define OV5647_CSI2_IIC "i2c1" +#define OV5647_CSI1_IIC "i2c0" +#define OV9732_RST_PIN (28) + +#define LT9611_RESET_GPIO 42 +#define LT9611_SLAVE_ADDR 0x3b +#define LT9611_I2C_BUS "i2c4" + +#elif defined(CONFIG_BOARD_K230_EVB) +// usip evb gpio config +// display gpio +#define DISPLAY_LCD_RST_GPIO 9 +#define DISPLAY_LCD_BACKLIGHT_EN 31 + +// imx335 gpio config +#define VICAP_IMX335_RST_GPIO 46 +#define VICAP_IMX335_MASTER_GPIO 28 +//OV9286 gpio cinfig +#define VICAP_OV9286_RST_GPIO 49 +#define OV5647_IIC "i2c1" +#define OV5647_CAM_PIN 20 +#define OV5647_CAM_PIN_CSI2 (24) +#define OV5647_CAM_PIN_CSI1 (23) + +#define OV5647_CSI2_IIC "i2c1" +#define OV5647_CSI1_IIC "i2c0" +#define OV9732_RST_PIN (28) + +#define LT9611_RESET_GPIO 42 +#define LT9611_SLAVE_ADDR 0x3b +#define LT9611_I2C_BUS "i2c4" + +#elif defined(CONFIG_BOARD_K230_CANMV) +// usip evb gpio config +// display gpio +#define DISPLAY_LCD_RST_GPIO 20 +#define DISPLAY_LCD_BACKLIGHT_EN 25 + +// imx335 gpio config +#define VICAP_IMX335_RST_GPIO 46 +#define VICAP_IMX335_MASTER_GPIO 28 +//OV9286 gpio cinfig +#define VICAP_OV9286_RST_GPIO 23 +#define OV5647_IIC "i2c3" +#define OV5647_CAM_PIN 0 +#define OV5647_CAM_PIN_CSI2 (24) +#define OV5647_CAM_PIN_CSI1 (23) + +#define OV5647_CSI2_IIC "i2c1" +#define OV5647_CSI1_IIC "i2c0" +#define OV9732_RST_PIN (24) + +#define LT9611_RESET_GPIO 42 +#define LT9611_SLAVE_ADDR 0x3b +#define LT9611_I2C_BUS "i2c4" + +#elif defined(CONFIG_BOARD_K230D_CANMV) +// usip evb gpio config +// display gpio +#define DISPLAY_LCD_RST_GPIO 24 +#define DISPLAY_LCD_BACKLIGHT_EN 25 + +// imx335 gpio config +#define VICAP_IMX335_RST_GPIO 46 +#define VICAP_IMX335_MASTER_GPIO 28 +//OV9286 gpio cinfig +#define VICAP_OV9286_RST_GPIO 20 +#define OV5647_IIC "i2c1" +#define OV5647_CAM_PIN 20 +#define OV5647_CAM_PIN_CSI2 (24) +#define OV5647_CAM_PIN_CSI1 (23) +#define OV9732_RST_PIN (24) + +#define OV5647_CSI2_IIC "i2c4" +#define OV5647_CSI1_IIC "i2c0" + + +#define LT9611_RESET_GPIO 42 +#define LT9611_SLAVE_ADDR 0x3b +#define LT9611_I2C_BUS "i2c3" + +#elif defined(CONFIG_BOARD_K230_CANMV_01STUDIO) +// usip evb gpio config +// display gpio +#define DISPLAY_LCD_RST_GPIO 24 +#define DISPLAY_LCD_BACKLIGHT_EN 25 + +// imx335 gpio config +#define VICAP_IMX335_RST_GPIO 46 +#define VICAP_IMX335_MASTER_GPIO 28 +//OV9286 gpio cinfig +#define VICAP_OV9286_RST_GPIO 20 +#define OV5647_CSI2_IIC "i2c4" +#define OV5647_CSI1_IIC "i2c1" +#define OV5647_IIC "i2c0" +#define OV5647_CAM_PIN 45 +#define OV5647_CAM_PIN_CSI2 (62) +#define OV5647_CAM_PIN_CSI1 (10) +#define OV9732_RST_PIN (28) + + +#define LT9611_RESET_GPIO 22 +#define LT9611_SLAVE_ADDR 0x3b +#define LT9611_I2C_BUS "i2c3" + +#elif defined(CONFIG_BOARD_K230_CANMV_V2) +// usip evb gpio config +// display gpio +#define DISPLAY_LCD_RST_GPIO 22 +#define DISPLAY_LCD_BACKLIGHT_EN 25 + +// imx335 gpio config +#define VICAP_IMX335_RST_GPIO 46 +#define VICAP_IMX335_MASTER_GPIO 28 +//OV9286 gpio cinfig +#define VICAP_OV9286_RST_GPIO 20 + +#define OV5647_IIC "i2c0" +#define OV5647_CAM_PIN 61 + +#define OV5647_CSI1_IIC "i2c1" +#define OV5647_CSI2_IIC "i2c4" + +#define OV5647_CAM_PIN_CSI2 (21) +#define OV5647_CAM_PIN_CSI1 (60) + +#define OV9732_RST_PIN (28) + +#define LT9611_RESET_GPIO 24 //42 +#define LT9611_SLAVE_ADDR 0x3b +#define LT9611_I2C_BUS "i2c3"//"i2c4" + +#elif defined(CONFIG_BOARD_K230_CANMV_DONGSHANPI) +// usip evb gpio config +// display gpio +#define DISPLAY_LCD_RST_GPIO 22 +#define DISPLAY_LCD_BACKLIGHT_EN 25 + +// imx335 gpio config +#define VICAP_IMX335_RST_GPIO 46 +#define VICAP_IMX335_MASTER_GPIO 28 +//OV9286 gpio cinfig +#define VICAP_OV9286_RST_GPIO 20 + +#define OV5647_IIC "i2c0" +#define OV5647_CAM_PIN 61 + +#define OV5647_CSI1_IIC "i2c1" +#define OV5647_CSI2_IIC "i2c4" + +#define OV5647_CAM_PIN_CSI2 (21) +#define OV5647_CAM_PIN_CSI1 (60) + +#define OV9732_RST_PIN (28) + +#define LT9611_RESET_GPIO 24 //42 +#define LT9611_SLAVE_ADDR 0x3b +#define LT9611_I2C_BUS "i2c3"//"i2c4" + +#else + +#define DISPLAY_LCD_RST_GPIO 9 +#define DISPLAY_LCD_BACKLIGHT_EN 31 + +// imx335 gpio config +#define VICAP_IMX335_RST_GPIO 46 +#define VICAP_IMX335_MASTER_GPIO 28 +//OV9286 gpio cinfig +#define VICAP_OV9286_RST_GPIO 49 +#define OV5647_IIC "i2c1" +#define OV5647_CAM_PIN 20 +#define OV5647_CSI2_IIC "i2c1" +#define OV5647_CSI1_IIC "i2c0" +#define OV5647_CAM_PIN_CSI2 (24) +#define OV5647_CAM_PIN_CSI1 (23) +#define OV9732_RST_PIN (24) + +#define LT9611_RESET_GPIO 42 +#define LT9611_SLAVE_ADDR 0x3b +#define LT9611_I2C_BUS "i2c4" + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/k230_sdk_overlay/src/big/mpp/kernel/sensor/src/ov5647_csi2_drv.c b/k230_sdk_overlay/src/big/mpp/kernel/sensor/src/ov5647_csi2_drv.c index bd96216..e5e4176 100755 --- a/k230_sdk_overlay/src/big/mpp/kernel/sensor/src/ov5647_csi2_drv.c +++ b/k230_sdk_overlay/src/big/mpp/kernel/sensor/src/ov5647_csi2_drv.c @@ -754,7 +754,20 @@ static k_sensor_mode ov5647_mode_info[] = { .data_type = 0x2B, //RAW10 }, .reg_list = ov5647_640x480_10bpp, - .mclk_setting = {{K_FALSE}, {K_FALSE}, {K_FALSE}}, +#if defined(CONFIG_BOARD_K230_CANMV) || defined(CONFIG_BOARD_K230D_CANMV) + .mclk_setting = {{K_FALSE}, {K_FALSE}, {K_FALSE}}, +#else + .mclk_setting = { + { + .mclk_setting_en = K_TRUE, + .setting.id = SENSOR_MCLK2, + .setting.mclk_sel = SENSOR_PLL0_CLK_DIV4, + .setting.mclk_div = 16, + }, + {K_FALSE}, + {K_FALSE}, + }, +#endif }, { .index = 3, @@ -852,13 +865,13 @@ static k_sensor_mode ov5647_mode_info[] = { .data_type = 0x2B, //RAW10 }, .reg_list = mode_1280x720_60fps, //mode_1280x720_60fps, -#if defined(CONFIG_BOARD_K230_CANMV) +#if defined(CONFIG_BOARD_K230_CANMV) || defined(CONFIG_BOARD_K230D_CANMV) .mclk_setting = {{K_FALSE}, {K_FALSE}, {K_FALSE}}, #else .mclk_setting = { { .mclk_setting_en = K_TRUE, - .setting.id = SENSOR_MCLK0, + .setting.id = SENSOR_MCLK2, .setting.mclk_sel = SENSOR_PLL0_CLK_DIV4, .setting.mclk_div = 16, }, @@ -888,14 +901,14 @@ static k_sensor_mode ov5647_mode_info[] = { .data_type = 0x2B, //RAW10 }, .reg_list = ov5647_1280x960p30_10bpp, //mode_1280x720_60fps, -#if defined(CONFIG_BOARD_K230_CANMV) +#if defined(CONFIG_BOARD_K230_CANMV) || defined(CONFIG_BOARD_K230D_CANMV) .mclk_setting = {{K_FALSE}, {K_FALSE}, {K_FALSE}}, #else .mclk_setting = { { .mclk_setting_en = K_TRUE, - .setting.id = SENSOR_MCLK0, + .setting.id = SENSOR_MCLK2, .setting.mclk_sel = SENSOR_PLL0_CLK_DIV4, .setting.mclk_div = 16, }, diff --git a/k230_sdk_overlay/src/big/mpp/userapps/src/sensor/mpi_sensor.c b/k230_sdk_overlay/src/big/mpp/userapps/src/sensor/mpi_sensor.c index ca3f85f..602440f 100755 --- a/k230_sdk_overlay/src/big/mpp/userapps/src/sensor/mpi_sensor.c +++ b/k230_sdk_overlay/src/big/mpp/userapps/src/sensor/mpi_sensor.c @@ -206,6 +206,7 @@ static const k_vicap_sensor_info sensor_info_list[] = { VICAP_FLASH_FOLLOW_STROBE, VICAP_VI_FIRST_FRAME_FS_TR0, 0, + 30, OV_OV9286_MIPI_1280X720_30FPS_10BIT_LINEAR_IR }, { @@ -481,7 +482,7 @@ static const k_vicap_sensor_info sensor_info_list[] = { OV_OV9286_MIPI_1280X720_60FPS_10BIT_LINEAR_SPECKLE }, { - "ov5647", + "ov5647_csi2", 1920, 1080, VICAP_CSI2, diff --git a/k230_sdk_overlay/src/little/uboot/arch/riscv/dts/k230d_canmv.dts b/k230_sdk_overlay/src/little/uboot/arch/riscv/dts/k230d_canmv.dts new file mode 100644 index 0000000..b604134 --- /dev/null +++ b/k230_sdk_overlay/src/little/uboot/arch/riscv/dts/k230d_canmv.dts @@ -0,0 +1,164 @@ +/* Copyright (c) 2023, Canaan Bright Sight Co., Ltd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/dts-v1/; +#include +#define BANK_VOLTAGE_IO0_IO1 K230_MSC_1V8 // FIXED +#define BANK_VOLTAGE_IO2_IO13 K230_MSC_3V3 +#define BANK_VOLTAGE_IO14_IO25 K230_MSC_3V3 +#define BANK_VOLTAGE_IO26_IO37 K230_MSC_3V3 +#define BANK_VOLTAGE_IO38_IO49 K230_MSC_3V3 +#define BANK_VOLTAGE_IO50_IO61 K230_MSC_3V3 +#define BANK_VOLTAGE_IO62_IO63 K230_MSC_3V3 +#include "k230d.dtsi" + +/ { + model = "kendryte k230d canmv"; + compatible = "kendryte,k230d_canmv"; + + memory@0 { + device_type = "memory"; + reg = < + 0x0 0 0x0 0x8000000 + >; + }; +}; + +&mmc0 { + status = "okay"; +}; + +&mmc1 { + status = "okay"; +}; + +&usbotg0 { + status = "okay"; +}; + +&iomux { + pinctrl-names = "default"; + pinctrl-0 = <&drop_pins &pins>; + +// Please pay attention to the bank voltage! will damage the chip. + pins: iomux_pins { + u-boot,dm-pre-reloc; + pinctrl-single,pins = < + + // SW3 KEY + (IO0 ) ( 0< CAM0 + (IO7 ) ( 2< TP + (IO36) ( 1< CAM + (IO40) ( 2< CAM + (IO48) ( 1< // JP1-PIN21 + (IO62) ( 1< // JP1-PIN22 + (IO63) ( 1<; + }; +}; \ No newline at end of file