diff --git a/build/solution_kdp2_evb_verify/main_scpu/hw_test_i2c.c b/build/solution_kdp2_evb_verify/main_scpu/hw_test_i2c.c index 3b6b501..34e2a8b 100644 --- a/build/solution_kdp2_evb_verify/main_scpu/hw_test_i2c.c +++ b/build/solution_kdp2_evb_verify/main_scpu/hw_test_i2c.c @@ -6,6 +6,7 @@ #include "cmsis_os2.h" #include "kdrv_i2c.h" +#include "kdrv_gpio.h" #include "kdrv_pinmux.h" #include "kmdw_console.h" @@ -27,6 +28,14 @@ int hw_test_i2c_run(void) kmdw_printf("Starting I2C Bus Scan Test...\n"); + // Release Sensor Reset (PIO17) + kmdw_printf("Releasing Sensor Reset (PIO17 -> High)...\n"); + kdrv_pinmux_config(KDRV_PIN_LC_DATA_0, PIN_MODE_3, PIN_PULL_NONE, PIN_DRIVING_8MA); + kdrv_gpio_set_attribute(GPIO_PIN_11, GPIO_DIR_OUTPUT); + kdrv_gpio_write_pin(GPIO_PIN_11, 1); + + osDelay(10); // Wait for sensor to stabilize after reset release + // 1. Configure Pinmux for I2C0 kmdw_printf("Configuring pins for I2C0...\n"); kdrv_pinmux_config(KDRV_PIN_I2C0_SCL, PIN_MODE_0, PIN_PULL_NONE, PIN_DRIVING_8MA); @@ -116,19 +125,19 @@ int hw_test_i2c_run(void) } } -// kmdw_printf("---------------------------------------------------------\n"); -// kmdw_printf("Checking for VEYE-MIPI-IMX462 sensor at address 0x%02X...\n", VEYE_IMX462_I2C_ADDR); + kmdw_printf("---------------------------------------------------------\n"); + kmdw_printf("Checking for VEYE-MIPI-IMX462 sensor at address 0x%02X...\n", VEYE_IMX462_I2C_ADDR); -// // Probe for VEYE-MIPI-IMX462 -// // We use a 0-length write to check if the device ACKs the address. -// status = kdrv_i2c_write_register(KDRV_I2C_CTRL_0, VEYE_IMX462_I2C_ADDR, 0, 0, 0, NULL); + // Probe for VEYE-MIPI-IMX462 + // We use a 0-length write to check if the device ACKs the address. + status = kdrv_i2c_write_register(KDRV_I2C_CTRL_0, VEYE_IMX462_I2C_ADDR, 0, 0, 0, NULL); -// if (status == KDRV_STATUS_OK) { -// kmdw_printf(" VEYE-MIPI-IMX462 detected at 0x%02X! -> PASSED\n", VEYE_IMX462_I2C_ADDR); -// result = 0; // Passed if at least one supported sensor is found -// } else { -// kmdw_printf(" No response at 0x%02X. (Not connected or different address)\n", VEYE_IMX462_I2C_ADDR); -// } + if (status == KDRV_STATUS_OK) { + kmdw_printf(" VEYE-MIPI-IMX462 detected at 0x%02X! -> PASSED\n", VEYE_IMX462_I2C_ADDR); + result = 0; // Passed if at least one supported sensor is found + } else { + kmdw_printf(" No response at 0x%02X. (Not connected or different address)\n", VEYE_IMX462_I2C_ADDR); + } kmdw_printf("=========================================================\n"); kmdw_printf("Test finished. Returning to main menu...\n"); diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_ncpu/main.c b/build/solution_kdp2_hico_mipi_ARCI/main_ncpu/main.c new file mode 100644 index 0000000..fb0021a --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_ncpu/main.c @@ -0,0 +1,33 @@ +/* -------------------------------------------------------------------------- + * Copyright (c) 2018-2019 Kneron Inc. All rights reserved. + * + * Name: main.c + * Purpose: Kneron NCPU + * + *---------------------------------------------------------------------------*/ + + +#include "cmsis_os2.h" +#include "kdpio.h" + +extern void SystemCoreClockUpdate(void); + +/*---------------------------------------------------------------------------- + * Main: Initialize OS Kernel and NCPU SDK + *---------------------------------------------------------------------------*/ +int main(void) +{ + SystemCoreClockUpdate(); + osKernelInitialize(); + + /* init NCPU */ + kdpio_sdk_init(); + + if (osKernelGetState() == osKernelReady) + { + osKernelStart(); + } + + while (1) + ; +} diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_ncpu/model_ftr_table.c b/build/solution_kdp2_hico_mipi_ARCI/main_ncpu/model_ftr_table.c new file mode 100644 index 0000000..6f51916 --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_ncpu/model_ftr_table.c @@ -0,0 +1,48 @@ +/* -------------------------------------------------------------------------- + * Copyright (c) 2018-2020 Kneron Inc. All rights reserved. + * + * Name: ncpu_extend_ftr.c + * Purpose: Extend new features implementation + * + *---------------------------------------------------------------------------*/ + +#include "kdpio.h" +#include "model_type.h" +#include "model_ppp.h" + +/********************************************************************************* + Registered model pre-process features list + +only need to register functions for models that default builtin pre-proc can't support +*********************************************************************************/ +model_pre_post_func_t model_pre_proc_fns[MAX_MODEL_REGISTRATIONS] = { + /* < model type ID > < pre-process function > */ + /* -------------------------------------------------------------------------- */ + 0 // no pre-process function specified + + /* Put customized pre-process functions below: + { CUSTOMER_MODEL_1, preproc_customer_model_1 }, + { CUSTOMER_MODEL_2, preproc_customer_model_2 }, + { CUSTOMER_MODEL_3, preproc_customer_model_3 }, + */ +}; + +/********************************************************************************* + Registered model post-process features list +*********************************************************************************/ +model_pre_post_func_t model_post_proc_fns[MAX_MODEL_REGISTRATIONS] = { + /* < model type ID > < post-process function > */ + /* -------------------------------------------------------------------------- */ + + { TINY_YOLO_V3_224_224_3, post_yolov3_optimized }, + { TINY_YOLO_V3_416_416_3, post_yolov3_optimized }, + { TINY_YOLO_V3_608_608_3, post_yolov3_optimized }, + { KNERON_YOLOV5S_PersonBicycleCarMotorcycleBusTruckCatDog8_480_256_3, post_yolov5_optimized }, + + /* Put customized post-process functions below: + { CUSTOMER_MODEL_1, post_customer_model_1 }, + { CUSTOMER_MODEL_2, post_customer_model_2 }, + { CUSTOMER_MODEL_3, post_customer_model_3 }, + */ +}; + diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/application_init.c b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/application_init.c new file mode 100644 index 0000000..57928ec --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/application_init.c @@ -0,0 +1,82 @@ +/* + * Kneron Application initialization + * + * Copyright (C) 2022 Kneron, Inc. All rights reserved. + * + */ + +#include +#include "cmsis_os2.h" + +// power manager +#include "kmdw_power_manager.h" + +// inference core +#include "kp_struct.h" +#include "kmdw_console.h" +#include "kmdw_inference_app.h" + +// inference app +#include "kdp2_inf_app_yolo.h" + + +// inference client +extern int kdp2_hico_mipi_init(void); + +#define MAX_IMAGE_COUNT 10 /**< MAX inference input queue slot count */ +#define MAX_RESULT_COUNT 10 /**< MAX inference output queue slot count */ +//sync with kdp2_hico_mipi.c + +/** + * @brief To register AI applications + * @param[in] num_input_buf number of data inputs in list + * @param[in] inf_input_buf_list list of data input for inference task + * @return N/A + * @note Add a switch case item for a new inf_app application + */ +static void _app_func(int num_input_buf, void** inf_input_buf_list); + + +void _app_func(int num_input_buf, void** inf_input_buf_list) +{ + // check header stamp + if (0 >= num_input_buf) { + kmdw_printf("No input buffer for app function\n"); + return; + } + + kp_inference_header_stamp_t *header_stamp = (kp_inference_header_stamp_t *)inf_input_buf_list[0]; + uint32_t job_id = header_stamp->job_id; + + switch (header_stamp->job_id) + { + case KDP2_INF_ID_APP_YOLO: + kdp2_app_yolo_inference(job_id, num_input_buf, inf_input_buf_list); + break; + case KDP2_JOB_ID_APP_YOLO_CONFIG_POST_PROC: + kdp2_app_yolo_config_post_process_parameters(job_id, num_input_buf, inf_input_buf_list); + break; + default: + kmdw_inference_app_send_status_code(job_id, KP_FW_ERROR_UNKNOWN_APP); + break; + } +} + + +void app_initialize(void) +{ + info_msg(">> Start running KL520 KDP2 HICO MIPI mode ...\n"); + + // for shutdown command + kmdw_power_manager_init(); + + /* initialize inference app */ + /* register APP functions */ + /* specify depth of inference queues */ + kmdw_inference_app_init(_app_func, MAX_IMAGE_COUNT, MAX_RESULT_COUNT); + + /* HICO mode init */ + kdp2_hico_mipi_init(); + + return; +} diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/device_init.c b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/device_init.c new file mode 100644 index 0000000..72ff34c --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/device_init.c @@ -0,0 +1,25 @@ +/******************************************************************** + * Copyright (c) 2020 Kneron, Inc. All Rights Reserved. + * + * The information contained herein is property of Kneron, Inc. + * Terms and conditions of usage are described in detail in Kneron + * STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. + * NO WARRANTY of ANY KIND is provided. This heading must NOT be removed + * from the file. + ********************************************************************/ + //Include +#include "project.h" +#if defined(FLASH_TYPE) && (FLASH_TYPE == FLASH_TYPE_NULL) +#include "kdev_flash_null.h" +#else +#include "kdev_flash.h" +#endif + +//Function +void dev_initialize(void) +{ + kdev_flash_initialize(); +} + diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/display_init.c b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/display_init.c new file mode 100644 index 0000000..5862cbd --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/display_init.c @@ -0,0 +1,41 @@ +/* + * + * Copyright (C) 2020 Kneron, Inc. All rights reserved. + * + */ + + +#include +#include +#include "cmsis_os2.h" +#include "kmdw_display.h" + +#include "kmdw_console.h" + +static int display_inited = 0; + +void display_init(uint32_t input_fmt, uint16_t xres, uint16_t yres, uint8_t cam_idx) +{ + struct video_input_params params; + + if (display_inited == 0) { + params.input_fmt = input_fmt; + params.input_xres = xres; + params.input_yres = yres; + kmdw_video_renderer_open(¶ms); + kmdw_video_renderer_set_camera(cam_idx); + kmdw_display_set_pen_rgb565(BLACK, 1); + kmdw_video_renderer_buffer_initialize(¶ms); + kmdw_video_renderer_start(); + display_inited = 1; + kmdw_printf("input_fmt=0x%x, input_xres=%d, input_yres=%d, cam_idx=%d \n",params.input_fmt, params.input_xres, params.input_yres, cam_idx); + } +} + +void display_exit(void) +{ + if (display_inited == 1) { + kmdw_video_renderer_stop(); + display_inited = 0; + } +} diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/driver_init.c b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/driver_init.c new file mode 100644 index 0000000..c5c1068 --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/driver_init.c @@ -0,0 +1,47 @@ +/******************************************************************** + * Copyright (c) 2020 Kneron, Inc. All Rights Reserved. + * + * The information contained herein is property of Kneron, Inc. + * Terms and conditions of usage are described in detail in Kneron + * STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. + * NO WARRANTY of ANY KIND is provided. This heading must NOT be removed + * from the file. + ********************************************************************/ + +#include "project.h" + +#include "kdrv_uart.h" +#include "kdrv_ddr.h" +#include "kdrv_pinmux.h" +#include "kdrv_timer.h" +#include "kdrv_i2c.h" +#include "kdrv_gpio.h" +#include "kmdw_camera.h" + +static uint32_t pinmux_array[PIN_NUM] = PINMUX_ARRAY; + +void drv_initialize(void) +{ + kdrv_uart_initialize(); + kdrv_pinmux_initialize(PIN_NUM, pinmux_array); + + kdrv_ddr_system_init(DDR_INIT_ALL); // TODO, not 720 style + kdrv_i2c_initialize(KDRV_I2C_CTRL_0, KDRV_I2C_SPEED_400K); + //kdrv_gpio_initialize(GPIO_NUM, gpio_attr_ctx); + //kdrv_timer_initialize(); + //kdrv_timer_perf_measure_start(); + + /* Init these functions in kmdw_camera_init on 520 + for(uint32_t cam_id = 0; cam_id < CAM_ID_MAX ; cam_id++) + { + if(cam_ctx[cam_id].cam_input_type!= IMG_SRC_IN_PORT_NONE) + { + kdrv_csirx_initialize(cam_id); + kdrv_dpi2ahb_initialize(cam_id); + } + } + */ +} + diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/application_init.h b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/application_init.h new file mode 100644 index 0000000..980f71b --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/application_init.h @@ -0,0 +1,31 @@ +/******************************************************************** + * Copyright (c) 2022 Kneron, Inc. All Rights Reserved. + * + * The information contained herein is property of Kneron, Inc. + * Terms and conditions of usage are described in detail in Kneron + * STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. + * NO WARRANTY of ANY KIND is provided. This heading must NOT be removed + * from the file. + ********************************************************************/ + +/**@addtogroup APPLICATION_INIT + * @{ + * @brief Kneron application init + * @copyright Copyright (C) 2022 Kneron, Inc. All rights reserved. + */ +#ifndef __APPLICATION_INIT_H__ +#define __APPLICATION_INIT_H__ + +/** + * @brief app_initialize + * + * Add application layer initialization code + * + * @return void + */ +void app_initialize(void); +#endif + + diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/device_init.h b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/device_init.h new file mode 100644 index 0000000..9b1ae22 --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/device_init.h @@ -0,0 +1,29 @@ +/******************************************************************** + * Copyright (c) 2020 Kneron, Inc. All Rights Reserved. + * + * The information contained herein is property of Kneron, Inc. + * Terms and conditions of usage are described in detail in Kneron + * STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. + * NO WARRANTY of ANY KIND is provided. This heading must NOT be removed + * from the file. + ********************************************************************/ + +/**@addtogroup DEVICE_INIT + * @{ + * @brief Kneron device init + * @copyright Copyright (C) 2020 Kneron, Inc. All rights reserved. + */ +#ifndef __DEVICE_INIT_H__ +#define __DEVICE_INIT_H__ + +/** + * @brief dev_initialize + * + * @return void + */ +void dev_initialize(void); +#endif + + diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/driver_init.h b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/driver_init.h new file mode 100644 index 0000000..d564484 --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/driver_init.h @@ -0,0 +1,29 @@ +/******************************************************************** + * Copyright (c) 2020 Kneron, Inc. All Rights Reserved. + * + * The information contained herein is property of Kneron, Inc. + * Terms and conditions of usage are described in detail in Kneron + * STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. + * NO WARRANTY of ANY KIND is provided. This heading must NOT be removed + * from the file. + ********************************************************************/ + +/**@addtogroup SYSTEM_INIT + * @{ + * @brief Kneron System init + * @copyright Copyright (C) 2020 Kneron, Inc. All rights reserved. + */ +#ifndef __DRIVER_INIT_H__ +#define __DRIVER_INIT_H__ + +/** + * @brief drv_initialize + * + * @return void + */ +void drv_initialize(void); +#endif + + diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/hico_mipi.h b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/hico_mipi.h new file mode 100644 index 0000000..876da66 --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/hico_mipi.h @@ -0,0 +1,70 @@ +/** + * @file hico_mipi.h + * @brief macros and data structure for hico application of mipi camera + * @version 0.1 + * @date 2021-07-02 + * + * @copyright Copyright (c) 2021 Kneron Inc. All rights reserved. + */ + +#pragma once + +#define JID_START_HICO_MIPI 1000 // job ID to tell FW that this customized command attends to configure camera and hico mipi parameters + +#define JID_CAM_0_IMAGE 2000 // job ID for camera sensor 0 image +#define JID_CAM_1_IMAGE 2001 // job ID for camera sensor 1 image +#define JID_CAM_2_IMAGE 2002 // job ID for camera sensor 2 image +#define JID_CAM_3_IMAGE 2003 // job ID for camera sensor 3 image + +#define JID_CAM_0_INF_RESULT 3000 // job ID for camera sensor 0 inference result +#define JID_CAM_1_INF_RESULT 3001 // job ID for camera sensor 1 inference result +#define JID_CAM_2_INF_RESULT 3002 // job ID for camera sensor 2 inference result +#define JID_CAM_3_INF_RESULT 3003 // job ID for camera sensor 3 inference result + +#define KDP2_INF_ID_APP_YOLO 11 // job ID for configuring yolo application + +typedef enum +{ + // MODE_SELF_TEST = 0, add this one ? + MODE_NONE = 0, + MODE_LIVE_VIEW = 1, // only show image, not doing inference + MODE_LIVE_VIEW_INF = 2, // show image with the inference result +} hico_mode_t; + +typedef enum +{ + CAM_SENSOR_NONE = 0x0, + CAM_SENSOR_0 = 0x1, + CAM_SENSOR_1 = 0x2, + CAM_SENSOR_2 = 0x4, + CAM_SENSOR_3 = 0x8, +} sensor_selection_t; + +// FIXME: Add resolution and inference model type as the future work ?? +// need to know how to adjust the resolution of the camera +// currently model type is yolo v5s only +typedef struct +{ + /* header stamp is necessary for data transfer between host and device */ + kp_inference_header_stamp_t header_stamp; + uint32_t mode; // hico_mode_t + uint32_t sensor_sel; // sensor_selection_t bit fields + uint32_t app_job_id; // job id for application +} __attribute__((aligned(4))) hico_mipi_config_command_t; + +typedef struct +{ + uint32_t img_width; // in pixel + uint32_t img_height; // in pixel + uint32_t img_format; // kp_image_format_t +} __attribute__((aligned(4))) hico_mipi_camera_settings_t; + +#define MAX_NUM_SENSOR 4 + +typedef struct +{ + /* header stamp is necessary for data transfer between host and device */ + kp_inference_header_stamp_t header_stamp; + uint32_t num_cam_sensors; + hico_mipi_camera_settings_t cam_settings[MAX_NUM_SENSOR]; +} __attribute__((aligned(4))) hico_mipi_config_response_t; diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/middleware_init.h b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/middleware_init.h new file mode 100644 index 0000000..f86a89e --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/middleware_init.h @@ -0,0 +1,29 @@ +/******************************************************************** + * Copyright (c) 2020 Kneron, Inc. All Rights Reserved. + * + * The information contained herein is property of Kneron, Inc. + * Terms and conditions of usage are described in detail in Kneron + * STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. + * NO WARRANTY of ANY KIND is provided. This heading must NOT be removed + * from the file. + ********************************************************************/ + +/**@addtogroup MIDDLEWARE_INIT + * @{ + * @brief Kneron middleware init + * @copyright Copyright (C) 2020 Kneron, Inc. All rights reserved. + */ +#ifndef __MIDDLEWARE_INIT_H__ +#define __MIDDLEWARE_INIT_H__ + +/** + * @brief mdw_initialize + * + * @return void + */ +void mdw_initialize(void); +#endif + + diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/system_init.h b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/system_init.h new file mode 100644 index 0000000..32fe0c2 --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/system_init.h @@ -0,0 +1,28 @@ +/******************************************************************** + * Copyright (c) 2020 Kneron, Inc. All Rights Reserved. + * + * The information contained herein is property of Kneron, Inc. + * Terms and conditions of usage are described in detail in Kneron + * STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. + * NO WARRANTY of ANY KIND is provided. This heading must NOT be removed + * from the file. + ********************************************************************/ + +/**@addtogroup SYSTEM_INIT + * @{ + * @brief Kneron System init + * @copyright Copyright (C) 2020 Kneron, Inc. All rights reserved. + */ +#ifndef __SYSTEM_INIT_H__ +#define __SYSTEM_INIT_H__ + +/** + * @brief sys_initialize + * + * @return void + */ +void sys_initialize(void); +#endif + diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/task_handler.h b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/task_handler.h new file mode 100644 index 0000000..4bf449b --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/include/task_handler.h @@ -0,0 +1,89 @@ +/******************************************************************** + * Copyright (c) 2020 Kneron, Inc. All Rights Reserved. + * + * The information contained herein is property of Kneron, Inc. + * Terms and conditions of usage are described in detail in Kneron + * STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. + * NO WARRANTY of ANY KIND is provided. This heading must NOT be removed + * from the file. + ********************************************************************/ + +/**@addtogroup TASK_HANDLER + * @{ + * @brief Kneron System init + * @copyright Copyright (C) 2020 Kneron, Inc. All rights reserved. + */ +#ifndef _TASK_HANDLER_H +#define _TASK_HANDLER_H +#include "cmsis_os2.h" +// #include "project.h" +#define USB_HOST +/****************************************************************************** +Declaration of data structure +******************************************************************************/ +// Sec 5: structure, uniou, enum, linked list +typedef struct +{ + //parameters for creating tasks + const char caName[8]; //now, len=8 + + osThreadId_t *tTaskHandle; + osThreadFunc_t fpEntry; + const uint32_t dwStackSize; + osPriority_t dwPriority; + + //parameters for creating queue + osMessageQueueId_t *tQueueHandle; + const uint32_t tQmsg_count; + const uint32_t tQmsg_size; +}T_S_KneronTask; + +osThreadId_t task_log_handle; +osThreadId_t task_infdata_handle; +osThreadId_t task_infcb_handle; +osThreadId_t task_usb_cmd_handle; +osThreadId_t task_usb_image_handle; +osThreadId_t task_usb_result_handle; +osThreadId_t task_buf_mgr_handle; + +// put osMessageQueueId_t objects here for setting tQueueHandle + +extern void logger_thread(void *arg); +extern void kmdw_inference_image_dispatcher_thread(void *argument); +extern void kmdw_inference_result_handler_callback_thread(void *argument); +extern void kdp2_hico_mipi_usb_cmd_thread(void *arg); +extern void kdp2_hico_mipi_usb_img_send_back_thread(void *arg); +extern void kdp2_hico_mipi_usb_result_thread(void *arg); +extern void kdp2_fifoq_manager_enqueue_image_thread(void *arg); + +/****************************************************************************** +Declaration of Global Variables & Functions +******************************************************************************/ +// Sec 6: declaration of global variable +T_S_KneronTask g_atKneronTaskPool[]= +{ +// TaskName TaskHandle TaskFuncEntry TaskStack TaskPriority QueueHandle QueueMsgCount QueueMsgSize +//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + {"LogTask", &task_log_handle, logger_thread, 1024, osPriorityBelowNormal, NULL, 0, 0 }, + {"Infdata", &task_infdata_handle, kmdw_inference_image_dispatcher_thread, 2048, osPriorityNormal, NULL, 0, 0 }, + {"Infcb", &task_infcb_handle, kmdw_inference_result_handler_callback_thread, 1024, osPriorityNormal, NULL, 0, 0 }, + {"usbcmd", &task_usb_cmd_handle, kdp2_hico_mipi_usb_cmd_thread, 1024, osPriorityNormal, NULL, 0, 0 }, + {"usbimg", &task_usb_image_handle, kdp2_hico_mipi_usb_img_send_back_thread, 1024, osPriorityNormal, NULL, 0, 0 }, + {"usbrslt ", &task_usb_result_handle, kdp2_hico_mipi_usb_result_thread, 1024, osPriorityNormal, NULL, 0, 0 }, + {"buf_mgr", &task_buf_mgr_handle, kdp2_fifoq_manager_enqueue_image_thread, 1024, osPriorityHigh, NULL, 0, 0 }, + +// +//Follow above format to add your TASK here +// + + +//end of table, don't remove it +//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + {NULL,NULL,NULL,0,0,NULL,0,0} +//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +}; + +#endif + diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/kdev_sensor_imx462.c b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/kdev_sensor_imx462.c new file mode 100644 index 0000000..8e0cb0a --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/kdev_sensor_imx462.c @@ -0,0 +1,221 @@ +/* + * Kneron VEYE-MIPI-IMX462 sensor driver + * + * Copyright (C) 2023 Kneron, Inc. All rights reserved. + * + */ + +#include +#include "utility.h" +#include "board.h" +#include "kdev_sensor.h" +#include "kdrv_i2c.h" +#include "kdrv_gpio.h" +#include "kdrv_pinmux.h" +#include "cmsis_os2.h" +#include "kmdw_console.h" + +#define IMX462_DBG +#ifdef IMX462_DBG +#define sensor_msg(fmt, ...) kmdw_printf("[%s] " fmt, __func__, ##__VA_ARGS__) +#else +#define sensor_msg(fmt, ...) +#endif + +static const struct sensor_datafmt_info imx462_colour_fmts[] = { + { PIX_FMT_RGB565, COLORSPACE_RGB }, + { PIX_FMT_YCBCR, COLORSPACE_YUV }, + { PIX_FMT_RAW10, COLORSPACE_RAW }, + { PIX_FMT_RAW8, COLORSPACE_RAW }, +}; + +static struct sensor_device imx462_dev = { + .addr = 0x3B, +}; + +struct sensor_init_seq imx462_init_regs[] = { + /* + * VEYE-MIPI-IMX462 has an internal ISP that self-initializes. + * No complex init sequence is required. + * Refer to cs_mipi_i2c.sh for specific parameter configurations (WDR, Format, etc.) + * and add them here if needed. + */ + + // 範例:如果你想要一啟動就預設一些 VEYE 參數,可以加在這裡 + // {0x05, 0x00}, // Day/Night Mode: 0x00=Day(彩色), 0x01=Night(黑白), 0x02=Auto + // {0x0B, 0x01}, // WDR (寬動態): 0x00=Off, 0x01=On + // {0x09, 0x03}, // Image Flip/Mirror: 0x00=Normal, 0x01=Mirror, 0x02=Flip, 0x03=Mirror+Flip + + // 設定 YUV 輸出順序 (0x1E) + // 0x00 = UYVY, 0x01 = YUYV (KL520 預期接收 YUYV) + // {0x1E, 0x01}, + // {0x1B, 0x03}, + {0x00, 0x00}, +}; +static uint32_t kdev_sensor_get_dev_id(void); + +static uint32_t imx462_write_reg(struct sensor_device *sensor_dev, uint16_t reg, uint8_t data) +{ + uint32_t ret; + // VEYE ISP typically uses 8-bit register addresses (1 byte) + ret = kdrv_i2c_write_register(KDRV_I2C_CTRL_0, sensor_dev->addr, reg, 1, 1, &data); + if (ret != KDRV_STATUS_OK) { + sensor_msg("I2C write failed, reg: 0x%02X, ret: %d\n", reg, ret); + } + osDelay(5); // 給予相機內部的 MCU 緩衝時間處理寫入指令 + return ret; +} + +static uint32_t imx462_read_reg(struct sensor_device *sensor_dev, uint16_t reg, uint8_t *data) +{ + uint32_t ret; + + // VEYE ISP uses 8-bit register addresses. + // KL520 underlying I2C driver has been fixed to support perfect Repeated Start without Arbitration Lost. + ret = kdrv_i2c_read_register(KDRV_I2C_CTRL_0, sensor_dev->addr, reg, 1, 1, data); + + if (ret != KDRV_STATUS_OK) { + sensor_msg("I2C read failed, reg: 0x%02X, ret: %d\n", reg, ret); + } + return ret; +} + +uint32_t imx462_init(struct sensor_device *sensor_dev, struct sensor_init_seq *seq) +{ + struct sensor_device *dev = sensor_dev; + struct sensor_init_seq *init_fnc_ptr; + + // Release Sensor Reset (PIO17) before communicating + sensor_msg("Releasing Sensor Reset...\n"); + kdrv_pinmux_config(KDRV_PIN_LC_DATA_0, PIN_MODE_3, PIN_PULL_NONE, PIN_DRIVING_8MA); + kdrv_gpio_set_attribute(GPIO_PIN_11, GPIO_DIR_OUTPUT); + + // Assert Reset (Active Low) + kdrv_gpio_write_pin(GPIO_PIN_11, 0); + osDelay(100); + + // Release Reset + kdrv_gpio_write_pin(GPIO_PIN_11, 1); + osDelay(100); // Wait 0.1 second for ISP to fully boot up + + // Make sure I2C pins and speed are properly configured before communication + kdrv_pinmux_config(KDRV_PIN_I2C0_SCL, PIN_MODE_0, PIN_PULL_NONE, PIN_DRIVING_8MA); + kdrv_pinmux_config(KDRV_PIN_I2C0_SDA, PIN_MODE_0, PIN_PULL_NONE, PIN_DRIVING_8MA); + kdrv_i2c_initialize(KDRV_I2C_CTRL_0, KDRV_I2C_SPEED_100K); + + for (init_fnc_ptr = seq; ; ++init_fnc_ptr) + { + if(init_fnc_ptr->addr == 0 && init_fnc_ptr->value == 0) + break; + imx462_write_reg(dev, init_fnc_ptr->addr , (uint8_t)(init_fnc_ptr->value & 0xFF)); + } + + // uint32_t data = kdev_sensor_get_dev_id(); + // sensor_msg("imx462_init sensor id=%x\n", data); + return 0; +} + +static uint32_t imx462_set_params(struct sensor_device *sensor_dev) +{ + sensor_msg(" <%s>\n", __func__); + /* initialize the sensor with default settings */ + imx462_init(sensor_dev, imx462_init_regs); + return 0; +} + +static kdev_status_t kdev_sensor_power(uint32_t on) +{ + sensor_msg(" <%s>\n", __func__); + return KDEV_STATUS_OK; +} + +static kdev_status_t kdev_sensor_reset() +{ + sensor_msg(" <%s>\n", __func__); + return KDEV_STATUS_OK; +} + +static kdev_status_t kdev_sensor_stream(uint32_t enable) +{ + sensor_msg(" <%s>\n", __func__); + return KDEV_STATUS_OK; +} + +static kdev_status_t kdev_sensor_enum_fmt(uint32_t index, uint32_t *code) +{ + if (index >= ARRAY_SIZE(imx462_colour_fmts)) + return KDEV_STATUS_ERROR; + + sensor_msg(" <%s>\n", __func__); + *code = imx462_colour_fmts[index].fourcc; + return KDEV_STATUS_OK; +} + +static kdev_status_t kdev_sensor_get_fmt(struct cam_format *format) +{ + sensor_msg(" <%s>\n", __func__); + return KDEV_STATUS_OK; +} + +static kdev_status_t kdev_sensor_set_fmt(struct cam_format *fmt) +{ + sensor_msg(" <%s>\n", __func__); + return (kdev_status_t)imx462_set_params(&imx462_dev); +} + +static kdev_status_t kdev_sensor_set_aec(struct cam_sensor_aec *aec_p) +{ + sensor_msg(" <%s>\n", __func__); + // Implement AEC ROI setting if needed + return KDEV_STATUS_OK; +} + +static kdev_status_t kdev_sensor_get_lux(uint16_t *expo, uint8_t *pre_gain, uint8_t *post_gain, uint8_t* global_gain, uint8_t* y_average) +{ + sensor_msg(" <%s>\n", __func__); + // Implement Lux reading if needed + *expo = 0; + *pre_gain = 0; + *post_gain = 0; + *global_gain = 0; + *y_average = 0; + return KDEV_STATUS_OK; +} + +static uint32_t kdev_sensor_get_dev_id(void) +{ + uint8_t board_model = 0; + uint8_t device_id = 0; + uint8_t hdver = 0; + + imx462_read_reg(&imx462_dev, 0x01, &device_id); + imx462_read_reg(&imx462_dev, 0x00, &hdver); + imx462_read_reg(&imx462_dev, 0x25, &board_model); + + sensor_msg("VEYE ISP Info -> Board: 0x%02X, Dev ID: 0x%02X, HW Ver: 0x%02X\n", board_model, device_id, hdver); + + return device_id; + +} + +static struct sensor_ops imx462_ops = { + .s_power = kdev_sensor_power, + .reset = kdev_sensor_reset, + .s_stream = kdev_sensor_stream, + .enum_fmt = kdev_sensor_enum_fmt, + .get_fmt = kdev_sensor_get_fmt, + .set_fmt = kdev_sensor_set_fmt, + .set_gain = NULL, + .set_aec = kdev_sensor_set_aec, + .set_exp_time = NULL, + .get_lux = kdev_sensor_get_lux, + .led_switch = NULL, + .set_mirror = NULL, + .set_flip = NULL, + .get_dev_id = kdev_sensor_get_dev_id, +}; + +struct sensor_ops* kdev_sensor_imx462_get_ops(void) +{ + return &imx462_ops; +} diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/kdp2_hico_mipi.c b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/kdp2_hico_mipi.c new file mode 100644 index 0000000..c4b004e --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/kdp2_hico_mipi.c @@ -0,0 +1,612 @@ +//#define ENABLE_DBG_LOG + +#include +#include "cmsis_os2.h" +#include "kmdw_power_manager.h" + +#include "kmdw_console.h" +#include "kmdw_memory.h" +#include "kdrv_gdma.h" +#include "kdrv_power.h" +#include "kdrv_scu_ext.h" +#include "kdp_system.h" + +#include "usbd_hal.h" + +#include "model_type.h" + +#include "buffer_object.h" + +#include "kmdw_fifoq_manager.h" +#include "kdp2_ipc_cmd.h" +#include "kdp2_inf_app_yolo.h" +#include "kdp2_usb_companion.h" + +#include "kmdw_display.h" +// --- hico mipi include --- +#include "hico_mipi.h" + +#include "kmdw_camera.h" +#include "kdrv_timer.h" +#include "kdrv_i2c.h" +#include "project.h" + +extern uint32_t kdrv_efuse_get_kn_number(void); + +#define NUM_MIPI_INIT_BUFS 2 // 2 (ping-pong buffers) or 3 (triple-buffers for skipping frames) + +/* For 1920x1080, buffer size needs to be larger. + * YUYV (2 bytes/pixel): 1920 * 1080 * 2 = 4,147,200 bytes (~4MB). Let's use 5MB for safety. + * The number of buffers is reduced from 10 to 4 to avoid exhausting the 64MB DDR. + * 4 buffers * 5MB/buffer = 20MB. + */ +#define NUM_IMAGE_BUF 4 +#define IMAGE_BUF_SIZE (5 * 1024 * 1024) +#define NUM_RESULT_BUF 4 +#define RESULT_BUF_SIZE (400 * 1024) + +#if 0//KL720_Scott +#define JTAG_MAGIC_ADDRESS 0x1FFFFFFC +#define JTAG_MAGIC_VALUE 0xFEDCBA01 +#define USB_BOOT_MAGIC_HB 0xaabbccdd +#define USB_BOOT_MAGIC_LB 0x11223344 + +#else +#define JTAG_MAGIC_ADDRESS 0x10100000 +#define KDP2_BOOT_CONFIG_ADDRESS 0x10100100 + +#define JTAG_MAGIC_VALUE 0xFEDCBA01 +#define BOOT_FROM_FLASH 0xA +typedef struct +{ + uint32_t boot_type; // 0xA = flash-boot, others = usb-boot + uint8_t loader_ver[4]; // fw loader version numbers + uint8_t scpu_fw_ver[4]; // SCPU fw version numbers + uint8_t ncpu_fw_ver[4]; // NCPU fw version numbers +} kdp2_boot_config_t; +#endif + +//static osThreadId_t usb_img_tid = 0; +//#define SHOW_SENSOR_IMAGE_ON_LCD//debug purpose: show sensor image directly without inference on LCD + +#ifdef ENABLE_DBG_LOG +#define dbg_log(__format__, ...) kmdw_printf("[kp hico mipi]"__format__, ##__VA_ARGS__) +#else +#define dbg_log(__format__, ...) +#endif + +typedef struct +{ + uint32_t cam_idx; + uint32_t buf_addr; + uint32_t img_width; + uint32_t img_height; + uint32_t img_format; +} mipi_img_object_t; + +#define FLAG_WAIT_USB_CONNECTION 0x1 + +static osThreadId_t _usb_cmd_tid = NULL; +static osMessageQueueId_t _img_queue = NULL; +static uint32_t _hico_mode = MODE_LIVE_VIEW; + +//static osThreadId_t task_usb_cmd_handle = NULL; +//static osThreadId_t task_usb_image_handle = NULL; +//static osThreadId_t task_usb_result_handle = NULL; +extern void display_init(uint32_t input_fmt, uint16_t xres, uint16_t yres, uint8_t cam_idx); +extern void display_exit(void); + +extern uint32_t lcdc_kdp2_get_disp_idx(int *read_done_idx); +extern uint32_t lcdc_kdp2_set_disp_buf(uint32_t buf_addr, int write_done_idx); +extern uint32_t lcdc_kdp2_get_disp_buf(int cam_idx, int *disp_idx); + +static uint32_t _app_job_id = 0xFFFFFFFF; + +// usb link status notify +static void usb_user_link_status_callback(usbd_hal_link_status_t link_status) +{ + switch (link_status) + { + case USBD_STATUS_DISCONNECTED: + kmdw_printf("USB is disconnected\n"); + break; + + case USBD_STATUS_CONFIGURED: + kmdw_printf("USB is connected\n"); + osThreadFlagsSet(_usb_cmd_tid, FLAG_WAIT_USB_CONNECTION); + break; + } +} + +// vendor-specific control transfer setup packet notify +bool usb_user_control_callback(usbd_hal_setup_packet_t *setup) +{ + bool ret = false; + + dbg_log("control bRequest = 0x%x\n", setup->bRequest); + + switch (setup->bRequest) + { + case KDP2_CONTROL_REBOOT: + { + dbg_log("control reboot\n"); + kdrv_power_sw_reset(); + break; + } + case KDP2_CONTROL_SHUTDOWN: + { + dbg_log("control shutdown\n"); + kmdw_power_manager_shutdown(); + break; + } + case KDP2_CONTROL_FIFOQ_RESET: + { + dbg_log("control fifoq reset\n"); + + // FIXME + //kmdw_printf("wakeup USB cmd thread\n"); + //osThreadFlagsSet(_usb_cmd_tid, FLAG_WAIT_USB_CONNECTION); + //osThreadFlagsSet(image_thread_id, 0x1); + ret = true; + break; + } + + default: + ret = false; + break; + } + + return ret; +} + +//static cam_format _cams_fmt[2] = {0}; +static struct cam_format _cams_fmt[2] = {0}; +#include "kdrv_mipicsirx.h" +#include "kdrv_dpi2ahb.h" + +void check_mipi_d2a_registers(uint8_t cam_idx) +{ + uint32_t csirx_base = (cam_idx == 0) ? CSIRX_FTCSIRX100_PA_BASE : CSIRX_FTCSIRX100_1_PA_BASE; + uint32_t d2a_base = (cam_idx == 0) ? DPI2AHB_CSR_PA_BASE : DPI2AHB_CSR_1_PA_BASE; + uint32_t hpnr = inw(csirx_base + 0x20); // 讀取 HPNR + uint32_t dpisr = inw(csirx_base + 0x38); // 讀取 DPISR + + kmdw_printf("\n--- Cam %d MIPI/D2A Register Dump ---\n", cam_idx); + kmdw_printf("[CSIRX] HPNR (Horiz Pixels)= %d (Expected: %d)\n", hpnr, _cams_fmt[cam_idx].width); + kmdw_printf("[CSIRX] MCR (Data Type) = 0x%08X (Expected: 0x00000000)\n", inw(csirx_base + 0x1C)); + kmdw_printf("[CSIRX] DPISR(DPI Status) = 0x%08X (PNE:%d, DDE:%d)\n", dpisr, (dpisr >> 5) & 1, (dpisr >> 4) & 1); + kmdw_printf("[CSIRX] PFTR (PHY Settle)= 0x%08X (Expected: 0x00000000 or 0xF5)\n", inw(csirx_base + 0x50)); + kmdw_printf("[CSIRX] PECR (Lane En) = 0x%08X (Expected: 0x00000003 for 2 lanes)\n", inw(csirx_base + 0x28)); + kmdw_printf("[D2A] CTRL (Control) = 0x%08X (Expected: 0x00003008 or 0x3000)\n", inw(d2a_base + 0x00)); + kmdw_printf("[D2A] PT (Packet Type)= 0x%08X (Expected: 0x0000001E for YUV422)\n", inw(d2a_base + 0x1C)); + kmdw_printf("[D2A] P0A (Page0 Addr) = 0x%08X\n", inw(d2a_base + 0x08)); + kmdw_printf("[D2A] P1A (Page1 Addr) = 0x%08X\n", inw(d2a_base + 0x0C)); + kmdw_printf("--------------------------------------\n\n"); +} + +// image ISR callback +void image_coming_callback(uint32_t cam_idx, uint32_t img_buf, uint32_t *p_new_img) +{ + osStatus_t sts; + mipi_img_object_t img_obj; + uint32_t new_inf_buf; + int buf_size; + sts = kmdw_fifoq_manager_image_get_free_buffer(&new_inf_buf, &buf_size, 0, true); + if (sts != osOK) + { + sts = osMessageQueueGet(_img_queue, (void *)&img_obj, NULL, 0); + if (sts != osOK) + { + dbg_log("(ISR) error !! retrieving new buf failed, osMessageQueueGet() ret = %d\n", sts); + // Due to highest priority ISR has, + // image input is so fast that fifoq can't provide a free buffer even force_grab is set + *p_new_img = img_buf; + return; + } + + new_inf_buf = img_obj.buf_addr; + } + + // get inf_buf address by shift back by the size of XXX_inference_header_t + uint32_t inf_buf = img_buf - sizeof(kdp2_ipc_app_yolo_inf_header_t); + + img_obj.cam_idx = cam_idx; + img_obj.buf_addr = inf_buf; + img_obj.img_width = _cams_fmt[cam_idx].width; + img_obj.img_height = _cams_fmt[cam_idx].height; + if (_cams_fmt[cam_idx].pixelformat == IMG_FORMAT_RGB565) + img_obj.img_format = KP_IMAGE_FORMAT_RGB565; + else if (_cams_fmt[cam_idx].pixelformat == IMG_FORMAT_RAW8) + img_obj.img_format = KP_IMAGE_FORMAT_RAW8; + else if (_cams_fmt[cam_idx].pixelformat == IMG_FORMAT_YCBCR) + img_obj.img_format = KP_IMAGE_FORMAT_YUYV; +#ifdef SHOW_SENSOR_IMAGE_ON_LCD + if(cam_idx == 0) + lcdc_kdp2_set_disp_buf(img_buf,0);//show sensor image directly + //DSG("image_coming_callback, img_buf=0x%x, cam_idx=%d, pixelformat=0x%x, img_width=%d img_height=%d",img_buf, cam_idx, _cams_fmt[cam_idx].pixelformat, _cams_fmt[cam_idx].width, _cams_fmt[cam_idx].height); +#endif + sts = osMessageQueuePut(_img_queue, (const void *)&img_obj, 0U, 0); + if (sts != osOK) + { + dbg_log("(ISR) error !! osMessageQueuePut() failed, sts = %d\n", sts); + *p_new_img = img_buf; + return; + } + + *p_new_img = new_inf_buf + sizeof(kdp2_ipc_app_yolo_inf_header_t); + + return; +} + +uint32_t camera_start(uint8_t cam_idx, uint32_t width, uint32_t height, uint32_t pixelformat) +{ + uint32_t ret; + + struct cam_capability cap; + + _cams_fmt[cam_idx].width = width; + _cams_fmt[cam_idx].height = height; + _cams_fmt[cam_idx].pixelformat = pixelformat; + + char fmtstr[8]; + memset(&cap, 0, sizeof(cap)); + + if (0 != (ret = kmdw_camera_open(cam_idx))) + return ret; + + if (0 != (ret = kmdw_camera_get_device_info(cam_idx, &cap))) + return ret; + + if (0 != (ret = kmdw_camera_set_frame_format(cam_idx, &_cams_fmt[cam_idx])))//scpu: exception: code=1, object_id=0x102021d4 + return ret; + + if (0 != (ret = kmdw_camera_get_frame_format(cam_idx, &_cams_fmt[cam_idx]))) + return ret; + + memset(fmtstr, 0, 8); + memcpy(fmtstr, &_cams_fmt[cam_idx].pixelformat, 4); + + int buf_size; + uint32_t buf_addr[NUM_MIPI_INIT_BUFS] = {0}; + + // mipi needs some buffers at initialization + for (int i = 0; i < NUM_MIPI_INIT_BUFS; i++) + { + kmdw_fifoq_manager_image_get_free_buffer(&buf_addr[i], &buf_size, osWaitForever, false); + buf_addr[i] += sizeof(kdp2_ipc_app_yolo_inf_header_t); + } + + if (0 != (ret = kmdw_camera_buffer_init(cam_idx, buf_addr[0], buf_addr[1]))) + return ret; + + if (0 != (ret = kmdw_camera_start(cam_idx, image_coming_callback))) + return ret; + + // Dump registers after initialization to verify hardware state + //check_mipi_d2a_registers(cam_idx); + + return 0; +} + + +#define CMD_BUF_SIZE (1 * 1024) +//#define CMD_BUF_SIZE (1 * 1024 * 1024) + + +// this thread receive the command from host SW +void kdp2_hico_mipi_usb_cmd_thread(void *arg) +{ + kmdw_printf("[%s] start !\n", __FUNCTION__); + + _usb_cmd_tid = osThreadGetId(); + if (_usb_cmd_tid == NULL) + kmdw_printf("%s creation failed !\n", __FUNCTION__); + + // wait until usb connection is established + osThreadFlagsWait(FLAG_WAIT_USB_CONNECTION, osFlagsWaitAny, osWaitForever); + kmdw_printf("[%s] FLAG_WAIT_USB_CONNECTION OK !\n", __FUNCTION__); + + uint32_t cmd_buf = kmdw_ddr_reserve(CMD_BUF_SIZE); + + while (1) + { + uint32_t txLen = CMD_BUF_SIZE; + kdrv_status_t usb_sts = usbd_hal_bulk_receive(KDP2_USB_ENDPOINT_DATA_OUT, (void *)cmd_buf, &txLen, osWaitForever); + if (usb_sts != KDRV_STATUS_OK) // KDRV_STATUS_USBD_TRANSFER_TERMINATED or KDRV_STATUS_USBD_TRANSFER_DISCONNECTED + { + dbg_log("[%s] bulk receive is terminated, sts %d\n", __FUNCTION__, usb_sts); + continue; + } + + dbg_log("[%s] usb recv addr 0x%x len %d\n", __FUNCTION__, (void *)cmd_buf, txLen); + + kp_inference_header_stamp_t *header_stamp = (kp_inference_header_stamp_t *)cmd_buf; + + if (header_stamp->magic_type == KDP2_MAGIC_TYPE_COMMAND) // standard KDP2 commands + { + // borrow image fifo to handle KDP2 commands as well + dbg_log("[%s] handle kdp2 command = 0x%x\n", __FUNCTION__, header_stamp->job_id); + // handle kdp2 commands ... + kdp2_cmd_handle_kp_command(cmd_buf); + continue; + } + else if (header_stamp->magic_type == KDP2_MAGIC_TYPE_CUSTOMIZED) // customized commands + { + // customized command to configure mipi camera + if (header_stamp->job_id == JID_START_HICO_MIPI) + { + dbg_log("[%s] configuration command received\n", __FUNCTION__); + + hico_mipi_config_command_t *hico_mipi_cmd = (hico_mipi_config_command_t *)cmd_buf; + hico_mipi_config_response_t hico_mipi_resp; + + hico_mipi_resp.header_stamp.magic_type = KDP2_MAGIC_TYPE_CUSTOMIZED; + hico_mipi_resp.header_stamp.job_id = JID_START_HICO_MIPI; + hico_mipi_resp.header_stamp.status_code = KP_SUCCESS; + hico_mipi_resp.header_stamp.total_size = sizeof(hico_mipi_resp); + hico_mipi_resp.num_cam_sensors = 0; + + _hico_mode = hico_mipi_cmd->mode; + _app_job_id = hico_mipi_cmd->app_job_id; + + // Configure the mipi camera + if (hico_mipi_cmd->sensor_sel & CAM_SENSOR_0) + { + if (0 == camera_start(0, IMGSRC_0_WIDTH, IMGSRC_0_HEIGHT, IMGSRC_0_FORMAT)) + { + dbg_log("[%s] camera_start 0, ok\n",__FUNCTION__); + hico_mipi_resp.num_cam_sensors++; + hico_mipi_resp.cam_settings[0].img_width = IMGSRC_0_WIDTH; + hico_mipi_resp.cam_settings[0].img_height = IMGSRC_0_HEIGHT; +#if (IMGSRC_0_FORMAT == IMG_FORMAT_YCBCR) + hico_mipi_resp.cam_settings[0].img_format = KP_IMAGE_FORMAT_YUYV; +#else + hico_mipi_resp.cam_settings[0].img_format = KP_IMAGE_FORMAT_RGB565; +#endif + } + else + { + hico_mipi_resp.header_stamp.status_code = KP_ERROR_OTHER_99; // FIXME, give it a specific error code + } + } + + if (hico_mipi_cmd->sensor_sel & CAM_SENSOR_1) + { + dbg_log("[%s] camera_start 1, ok\n",__FUNCTION__); + + if (0 == camera_start(1, IMGSRC_1_WIDTH, IMGSRC_1_HEIGHT, IMGSRC_1_FORMAT)) + { + hico_mipi_resp.num_cam_sensors++; + hico_mipi_resp.cam_settings[1].img_width = IMGSRC_1_WIDTH; + hico_mipi_resp.cam_settings[1].img_height = IMGSRC_1_HEIGHT; + hico_mipi_resp.cam_settings[1].img_format = KP_IMAGE_FORMAT_RAW8; + } + else + { + hico_mipi_resp.header_stamp.status_code = KP_ERROR_OTHER_99; // FIXME, give it a specific error code + } + } + + kdrv_status_t usb_sts = usbd_hal_bulk_send(KDP2_USB_ENDPOINT_DATA_IN, (void *)&hico_mipi_resp, sizeof(hico_mipi_resp), 1000); + if (usb_sts != KDRV_STATUS_OK) // KDRV_STATUS_USBD_TRANSFER_TERMINATED or KDRV_STATUS_USBD_TRANSFER_DISCONNECTED + { + dbg_log("error ! usbd_hal_bulk_send() ret = %d\n", usb_sts); + //return; + } + } + else + { + dbg_log("error !!! wrong job_id = %d\n", __FUNCTION__, header_stamp->job_id); + } + } + else if ((header_stamp->magic_type & 0xFFFF) == KDP_MSG_HDR_CMD) // very speical case for old arch. fw update + { + // handle legendary kdp commands, should be as few as possible + dbg_log("[%s] handle legendary kdp command = 0x%x\n",__FUNCTION__, header_stamp->job_id); + kdp2_cmd_handle_legend_kdp_command(cmd_buf); + } + else + { + dbg_log("[%s] error ! buffer begin with incorrect magic_type 0x%x, txLen %d\n", __FUNCTION__, header_stamp->magic_type, txLen); + } + } +} + +// this thread sends inference result to host +void kdp2_hico_mipi_usb_result_thread(void *arg) +{ + kmdw_printf("[%s] start !\n", __FUNCTION__); + + while (1) + { + uint32_t result_buf_addr; + int result_buf_length; + + // get result data from result fifo queue with blocking wait + kmdw_fifoq_manager_result_dequeue(&result_buf_addr, &result_buf_length, osWaitForever); + dbg_log("[%s] result_buf_addr=0x%x, result_buf_length=%d\n", __FUNCTION__, result_buf_addr,result_buf_length); + // then send inference result + kdp2_ipc_app_yolo_result_t *yolo_result = (kdp2_ipc_app_yolo_result_t *)result_buf_addr; + + yolo_result->header_stamp.job_id = JID_CAM_0_INF_RESULT + yolo_result->inf_number; // for now it tells host SW that this is an inference result + + #if 1 + //yolo_result->header_stamp.total_size = result_buf_length; + #endif + // send result to the host SW, blocking wait + dbg_log("[%s] send usb data size %d\n", __FUNCTION__, yolo_result->header_stamp.total_size); + kdrv_status_t usb_sts = usbd_hal_bulk_send(KDP2_USB_ENDPOINT_DATA_IN, (void *)result_buf_addr, yolo_result->header_stamp.total_size, osWaitForever); + if (usb_sts != KDRV_STATUS_OK) // KDRV_STATUS_USBD_TRANSFER_TERMINATED or KDRV_STATUS_USBD_TRANSFER_DISCONNECTED + { + dbg_log("error ! usbd_hal_bulk_send() ret = %d \n", usb_sts); + } + + // return free buf back to queue + kmdw_fifoq_manager_result_put_free_buffer(result_buf_addr, result_buf_length, osWaitForever); + } +} + +// this thread sends raw image from image sensor to host SW (and also enqueues it to image fifo queue ?) +void kdp2_hico_mipi_usb_img_send_back_thread(void *arg) +{ + kmdw_printf("[%s] start !\n", __FUNCTION__); + + while (1) + { + mipi_img_object_t img_obj; + osMessageQueueGet(_img_queue, (void *)&img_obj, NULL, osWaitForever); + dbg_log("[%s] _hico_mode = %d\n",__FUNCTION__, _hico_mode); + dbg_log("[%s] got inf-buf (cam_idx %d buf_addr 0x%p img_width %d img_height %d img_format %d)\n", + __FUNCTION__,img_obj.cam_idx, img_obj.buf_addr, img_obj.img_width, img_obj.img_height, img_obj.img_format); + + kdp2_ipc_app_yolo_inf_header_t *inf_header = (kdp2_ipc_app_yolo_inf_header_t *)img_obj.buf_addr; + + int byte_ppix; + switch (img_obj.img_format) + { + case KP_IMAGE_FORMAT_RGB565: + case KP_IMAGE_FORMAT_YUYV: + byte_ppix = 2; + break; + case KP_IMAGE_FORMAT_RGBA8888: + byte_ppix = 3; + break; + case KP_IMAGE_FORMAT_RAW8: + byte_ppix = 1; + } + + inf_header->header_stamp.magic_type = KDP2_MAGIC_TYPE_INFERENCE; + inf_header->header_stamp.total_size = sizeof(kdp2_ipc_app_yolo_inf_header_t) + (img_obj.img_width * img_obj.img_height * byte_ppix); + inf_header->header_stamp.job_id = JID_CAM_0_IMAGE + img_obj.cam_idx; + inf_header->header_stamp.status_code = KP_SUCCESS; + + inf_header->inf_number = img_obj.cam_idx; + inf_header->width = img_obj.img_width; + inf_header->height = img_obj.img_height; + inf_header->channel = (img_obj.img_format == KP_IMAGE_FORMAT_RAW8) ? 1 : 3; + #if 0//KL720_Scott + inf_header->model_id = KNERON_YOLOV5S_COCO80_640_640_3;// + #else + inf_header->model_id = TINY_YOLO_V3_224_224_3; + #endif + inf_header->image_format = img_obj.img_format; + inf_header->model_normalize = KP_NORMALIZE_KNERON; + + dbg_log("[%s] send usb data size %d\n", __FUNCTION__, inf_header->header_stamp.total_size); + kdrv_status_t usb_sts = usbd_hal_bulk_send(KDP2_USB_ENDPOINT_DATA_IN, (void *)inf_header, inf_header->header_stamp.total_size, osWaitForever); + + if (usb_sts != KDRV_STATUS_OK) // KDRV_STATUS_USBD_TRANSFER_TERMINATED or KDRV_STATUS_USBD_TRANSFER_DISCONNECTED + { + dbg_log("error ! usbd_hal_bulk_send() ret = %d\n", usb_sts); + return; + } + + if (_hico_mode == MODE_LIVE_VIEW) + { + dbg_log("[%s] kmdw_fifoq_manager_image_put_free_buffer %d\n",__FUNCTION__); + kmdw_fifoq_manager_image_put_free_buffer((uint32_t)inf_header, IMAGE_BUF_SIZE, osWaitForever); + } + else // MODE_LIVE_VIEW_INF + { + dbg_log("[%s] kmdw_fifoq_manager_image_enqueue %d\n",__FUNCTION__); + inf_header->header_stamp.job_id = _app_job_id; + kmdw_fifoq_manager_image_enqueue(1, 0, (uint32_t)inf_header, IMAGE_BUF_SIZE, osWaitForever, false); + } + } +} + +//////////////////////////////////////////////////////////// +#define RECOVERY_MARK_POS (SdRAM_MEM_BASE + SdRAM_MEM_SIZE - 64) + +// KDP2 Inference Interface for HICO MIPI code +// image input +// image + inference output +int kdp2_hico_mipi_init() +{ + // retrieve real serial number here from efuse + // then convert it to hex string format + uint32_t uid = 0; + + uid = kdp_sys_get_kn_number(); + + int32_t sidx = 0; + uint8_t kn_num_string[32] = {0}; + for (int i = 7; i >= 0; i--) + { + uint32_t hex = (uid >> i * 4) & 0xF; + kn_num_string[sidx] = (hex < 10) ? '0' + hex : 'A' + (hex - 10); + sidx += 2; + } + + // HICO Mode + uint16_t bcdDevice = KP_KDP2_FW_HICO_MODE; + + if (*((uint32_t *)JTAG_MAGIC_ADDRESS) == JTAG_MAGIC_VALUE) + { + kmdw_printf("FW is running in JTAG mode\n"); + bcdDevice |= KP_KDP2_FW_JTAG_TYPE; + } + else + { + kdp2_boot_config_t *bConfig = (kdp2_boot_config_t *)KDP2_BOOT_CONFIG_ADDRESS; + if (bConfig->boot_type == BOOT_FROM_FLASH) + { + kmdw_printf("KDP2 FW is running in flash-boot mode\n"); + bcdDevice |= KP_KDP2_FW_FLASH_TYPE; + + kmdw_printf("boot ncpu fw from flash\n"); + SCU_EXTREG_CM4_NCPU_CTRL_SET_wakeup(1); // run ncpu + } + else + { + kmdw_printf("KDP2 FW is running in usb-boot mode\n"); + bcdDevice |= KP_KDP2_FW_USB_TYPE; + } + } + + // this is about recovery mode + *(uint32_t *)RECOVERY_MARK_POS = 0; + + usbd_hal_initialize(kn_num_string, bcdDevice, usb_user_link_status_callback, usb_user_control_callback); + + usbd_hal_set_enable(true); + + /* Allocate memory for image and result buffers */ + uint32_t buf_addr = kmdw_ddr_reserve(NUM_IMAGE_BUF * IMAGE_BUF_SIZE + NUM_RESULT_BUF * RESULT_BUF_SIZE); + if (buf_addr == 0) + { + dbg_log("error !!! kmdw_ddr_reserve() failed for image/result buffers\n"); + return -1; + } + + // queue buffers into image free-queue + for (uint32_t i = 0; i < NUM_IMAGE_BUF; i++) + { + kmdw_fifoq_manager_image_put_free_buffer(buf_addr, IMAGE_BUF_SIZE, osWaitForever); + buf_addr += IMAGE_BUF_SIZE; + } + + // queue buffers into result free-queue + for (uint32_t i = 0; i < NUM_RESULT_BUF; i++) + { + kmdw_fifoq_manager_result_put_free_buffer(buf_addr, RESULT_BUF_SIZE, osWaitForever); + buf_addr += RESULT_BUF_SIZE; + } + + // prepare an internal image queue between ISR callback and image-processing thread + _img_queue = osMessageQueueNew(NUM_IMAGE_BUF, sizeof(mipi_img_object_t), NULL); + if (_img_queue == NULL) + { + dbg_log("error !!! osMessageQueueNew() failed\n"); + } + + kmdw_fifoq_manager_store_fifoq_config(NUM_IMAGE_BUF, IMAGE_BUF_SIZE, NUM_RESULT_BUF, RESULT_BUF_SIZE); + + // wow ! fifoq can also handle command + kdp2_cmd_handler_initialize(); + +#ifdef SHOW_SENSOR_IMAGE_ON_LCD + display_init(V2K_PIX_FMT_RGB565, IMGSRC_0_WIDTH, IMGSRC_0_HEIGHT, 0); +#endif + return 0; +} diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/main.c b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/main.c new file mode 100644 index 0000000..017ab58 --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/main.c @@ -0,0 +1,57 @@ +/* + * Kneron Main Entry driver + * + * Copyright (C) 2020 Kneron, Inc. All rights reserved. + * + */ + +#include +#include "cmsis_os2.h" // ARM::CMSIS:RTOS2:Keil RTX5 + +#include "project.h" +#include "version.h" + +// Customized configuration and implementation +#include "system_init.h" +#include "driver_init.h" +#include "device_init.h" +#include "middleware_init.h" +#include "application_init.h" + +#include "kmdw_console.h" + +extern void task_initialize(void); + +/** + * @brief main, main function + */ +int main(void) +{ + osKernelInitialize(); // Initialize CMSIS-RTOS + sys_initialize(); + drv_initialize(); /* customize driver initialization, see driver_init.c */ + dev_initialize(); /* customize device initialization, see device_init.c */ + mdw_initialize(); /* customize middleware initialization, see middlewre_init.c */ + + + printf("SDK v%u.%u.%u-:build.%03u\n", + (uint8_t)(IMG_FW_MAJOR), + (uint8_t)(IMG_FW_MINOR), + (uint8_t)(IMG_FW_UPDATE), + (uint32_t)(IMG_FW_BUILD)); + + app_initialize(); /* customize application initialization, see application_init.c */ + + /* New task threads */ + task_initialize(); + + /* Start RTOS Kernel */ + if (osKernelGetState() == osKernelReady) + { + osKernelStart(); + } + + while (1) + { + } +} diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/middleware_init.c b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/middleware_init.c new file mode 100644 index 0000000..af0331b --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/middleware_init.c @@ -0,0 +1,34 @@ +/******************************************************************** + * Copyright (c) 2020 Kneron, Inc. All Rights Reserved. + * + * The information contained herein is property of Kneron, Inc. + * Terms and conditions of usage are described in detail in Kneron + * STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. + * NO WARRANTY of ANY KIND is provided. This heading must NOT be removed + * from the file. + ********************************************************************/ + +#include "project.h" + +#include "kmdw_memory.h" +#include "kmdw_model.h" +#include "kmdw_dfu.h" +#include "kmdw_camera.h" +#include "kmdw_display.h" +#include "kmdw_console.h" + +void mdw_initialize(void) +{ + kmdw_ddr_init(DDR_HEAP_BEGIN, DDR_HEAP_END); + kmdw_ddr_store_system_reserve(DDR_SYSTEM_RESERVED_BEGIN, DDR_SYSTEM_RESERVED_END); + kmdw_uart_console_init(MSG_PORT, MSG_PORT_BAUDRATE); // uart console + kmdw_dfu_init(NULL, NULL); + kmdw_model_init(); + + //load_ncpu_fw(1/*reset_flag*/); // (kmdw_system.h) load ncpu fw from flash + kmdw_camera_init(); // init cameras + kmdw_display_initialize(); // init display +} + diff --git a/build/solution_kdp2_hico_mipi_ARCI/main_scpu/system_init.c b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/system_init.c new file mode 100644 index 0000000..a89c8f3 --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/main_scpu/system_init.c @@ -0,0 +1,23 @@ +/******************************************************************** + * Copyright (c) 2020 Kneron, Inc. All Rights Reserved. + * + * The information contained herein is property of Kneron, Inc. + * Terms and conditions of usage are described in detail in Kneron + * STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. + * NO WARRANTY of ANY KIND is provided. This heading must NOT be removed + * from the file. + ********************************************************************/ + //Include +//#include "project.h" +#include "kdrv_system.h" + + + //Function +void sys_initialize(void) +{ + /* SDK main init for companion mode */ + kdrv_system_init(); + kdrv_system_init_ncpu(); +} diff --git a/build/solution_kdp2_hico_mipi_ARCI/sn52096/ncpu_keil/ncpu.sct b/build/solution_kdp2_hico_mipi_ARCI/sn52096/ncpu_keil/ncpu.sct new file mode 100644 index 0000000..7e4a57e --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/sn52096/ncpu_keil/ncpu.sct @@ -0,0 +1,19 @@ +#!armcc -E +#define DRAM_START 0x0FFF0000 +#define DRAM_SIZE 0x00010000 + +LR_IROM1 0x00000000 0x00010000 { ; load region size_region + ER_IROM1 0x00000000 0x00010000 { ; load address = execution address + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + } + RW_IRAM1 DRAM_START DRAM_SIZE-8 { ; RW data + .ANY (+RW +ZI) + } + + RW_IRAM2 AlignExpr(+0,8) { + .ANY (misc_data) + } +} + diff --git a/build/solution_kdp2_hico_mipi_ARCI/sn52096/ncpu_keil/ncpu.uvoptx b/build/solution_kdp2_hico_mipi_ARCI/sn52096/ncpu_keil/ncpu.uvoptx new file mode 100644 index 0000000..a458953 --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/sn52096/ncpu_keil/ncpu.uvoptx @@ -0,0 +1,552 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc; *.md + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + ncpu + 0x4 + ARM-ADS + + 250000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\Listings\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 0 + 0 + 1 + + 7 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 4 + + + + + + + + + + + Segger\JL2CM3.dll + + + + 0 + DLGUARM + + + + 0 + DLGDARM + (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0) + + + 0 + ULP2CM3 + -UAny -O905 -S0 -C0 -P00 -N00("ARM CoreSight JTAG-DP") -D00(4BA00477) -L00(4) -N01("ARM CoreSight JTAG-DP") -D01(4BA00477) -L01(4) -TO18 -TC10000000 -TP18 -TDX0 -TDD0 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO3 -FD20000000 -FC1000 -FN0 + + + 0 + ARMRTXEVENTFLAGS + -L70 -Z18 -C0 -M0 -T1 + + + 0 + DLGTARM + (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0) + + + 0 + ARMDBGFLAGS + -T0 + + + 0 + JL2CM3 + -U63610859 -O1 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST1 -N00("ARM CoreSight JTAG-DP") -D00(4BA00477) -L00(4) -N01("ARM CoreSight JTAG-DP") -D01(4BA00477) -L01(4) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO1 -FD20000000 -FC1000 -FN0 + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000) + + + + + 0 + 0 + 169 + 1 +
0
+ 0 + 0 + 0 + 0 + 0 + 0 + D:\3_code\mozart_sw_kdp2.git\scpu\project\companion_kdp2\main\main.c + + +
+
+ + + 1 + 2 + 0x30ff0140 + 0 + + + + + 2 + 2 + 0x61000000 + 0 + + + + + 3 + 2 + 0xa0000000 + 0 + + + + + 4 + 2 + 0 + 0 + + + + 0 + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + +
+
+ + + main + 0 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + ..\..\main_ncpu\main.c + main.c + 0 + 0 + + + 1 + 2 + 1 + 0 + 0 + 0 + ..\..\main_ncpu\model_ftr_table.c + model_ftr_table.c + 0 + 0 + + + + + libs + 0 + 0 + 0 + 0 + + 2 + 3 + 4 + 0 + 0 + 0 + ..\..\..\..\lib\kdp2_ncpu_sdk.lib + kdp2_ncpu_sdk.lib + 0 + 0 + + + 2 + 4 + 4 + 0 + 0 + 0 + ..\..\..\..\lib\kdp2_ncpu_model_ppp.lib + kdp2_ncpu_model_ppp.lib + 0 + 0 + + + + + rtx + 0 + 0 + 0 + 0 + + 3 + 5 + 2 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\irq_cm4f.s + irq_cm4f.s + 0 + 0 + + + 3 + 6 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\os_systick.c + os_systick.c + 0 + 0 + + + 3 + 7 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\RTX_Config.c + RTX_Config.c + 0 + 0 + + + 3 + 8 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_delay.c + rtx_delay.c + 0 + 0 + + + 3 + 9 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_evflags.c + rtx_evflags.c + 0 + 0 + + + 3 + 10 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_evr.c + rtx_evr.c + 0 + 0 + + + 3 + 11 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_kernel.c + rtx_kernel.c + 0 + 0 + + + 3 + 12 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_lib.c + rtx_lib.c + 0 + 0 + + + 3 + 13 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_memory.c + rtx_memory.c + 0 + 0 + + + 3 + 14 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_mempool.c + rtx_mempool.c + 0 + 0 + + + 3 + 15 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_msgqueue.c + rtx_msgqueue.c + 0 + 0 + + + 3 + 16 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_mutex.c + rtx_mutex.c + 0 + 0 + + + 3 + 17 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_semaphore.c + rtx_semaphore.c + 0 + 0 + + + 3 + 18 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_system.c + rtx_system.c + 0 + 0 + + + 3 + 19 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_thread.c + rtx_thread.c + 0 + 0 + + + 3 + 20 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_timer.c + rtx_timer.c + 0 + 0 + + + + + startup + 0 + 0 + 0 + 0 + + 4 + 21 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\startup\startup.c + startup.c + 0 + 0 + + + 4 + 22 + 2 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\ncpu\startup\startup_asm.s + startup_asm.s + 0 + 0 + + + +
diff --git a/build/solution_kdp2_hico_mipi_ARCI/sn52096/ncpu_keil/ncpu.uvprojx b/build/solution_kdp2_hico_mipi_ARCI/sn52096/ncpu_keil/ncpu.uvprojx new file mode 100644 index 0000000..61a8ba8 --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/sn52096/ncpu_keil/ncpu.uvprojx @@ -0,0 +1,548 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + ncpu + 0x4 + ARM-ADS + 5060960::V5.06 update 7 (build 960)::.\ARMCC + 0 + + + ARMCM4_FP + ARM + ARM.CMSIS.5.7.0 + http://www.keil.com/pack/ + IRAM(0x20000000,0x00020000) IROM(0x00000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000) + 0 + $$Device:ARMCM4_FP$Device\ARM\ARMCM4\Include\ARMCM4_FP.h + + + + + + + + + + $$Device:ARMCM4$Device\ARM\SVD\ARMCM4.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\Objects\ + Mozart_ncpu + 1 + 0 + 0 + 1 + 1 + .\Listings\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 1 + 1 + fromelf.exe --bin "!L" --output ".\Objects\fw_ncpu.bin" + post_build.bat fw_ncpu.bin + 0 + 0 + 0 + 0 + + 1 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + -MPU + DCM.DLL + -pCM4 + SARMCM3.DLL + -MPU + TCM.DLL + -pCM4 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + "Cortex-M4" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x20000 + + + 1 + 0x0 + 0x40000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x10000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0xfff0000 + 0x10000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 4 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + ARM_MATH_CM4, TARGET_NCPU, LOG_ENABLE, KL520 + + ..\..\..\..\platform\kl520\common;..\..\..\..\platform\kl520\ncpu\model_ppp\include;..\..\..\..\platform\kl520\ncpu\drv\include;..\..\..\..\platform\kl520\ncpu\rtos\rtx\include;..\..\..\..\include + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 13 + + --cpreproc + + + ..\..\..\..\include + + + + 0 + 0 + 0 + 0 + 0 + 0 + 0x00000000 + 0x20000000 + + ..\..\..\..\platform\kl520\ncpu\mozart_ncpu.sct + + + + + + + + + + + main + + + main.c + 1 + ..\..\main_ncpu\main.c + + + model_ftr_table.c + 1 + ..\..\main_ncpu\model_ftr_table.c + + + + + libs + + + kdp2_ncpu_sdk.lib + 4 + ..\..\..\..\lib\kdp2_ncpu_sdk.lib + + + kdp2_ncpu_model_ppp.lib + 4 + ..\..\..\..\lib\kdp2_ncpu_model_ppp.lib + + + + + rtx + + + irq_cm4f.s + 2 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\irq_cm4f.s + + + os_systick.c + 1 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\os_systick.c + + + RTX_Config.c + 1 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\RTX_Config.c + + + rtx_delay.c + 1 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_delay.c + + + rtx_evflags.c + 1 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_evflags.c + + + rtx_evr.c + 1 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_evr.c + + + rtx_kernel.c + 1 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_kernel.c + + + rtx_lib.c + 1 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_lib.c + + + rtx_memory.c + 1 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_memory.c + + + rtx_mempool.c + 1 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_mempool.c + + + rtx_msgqueue.c + 1 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_msgqueue.c + + + rtx_mutex.c + 1 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_mutex.c + + + rtx_semaphore.c + 1 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_semaphore.c + + + rtx_system.c + 1 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_system.c + + + rtx_thread.c + 1 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_thread.c + + + rtx_timer.c + 1 + ..\..\..\..\platform\kl520\ncpu\rtos\rtx\rtx_timer.c + + + + + startup + + + startup.c + 1 + ..\..\..\..\platform\kl520\ncpu\startup\startup.c + + + startup_asm.s + 2 + ..\..\..\..\platform\kl520\ncpu\startup\startup_asm.s + + + + + + + + + + + + + RTE\CMSIS\RTX_Config.c + + + + + + RTE\CMSIS\RTX_Config.h + + + + + + RTE\Device\ARMCM4_FP\startup_ARMCM4.s + + + + + + RTE\Device\ARMCM4_FP\system_ARMCM4.c + + + + + + + +
diff --git a/build/solution_kdp2_hico_mipi_ARCI/sn52096/ncpu_keil/post_build.bat b/build/solution_kdp2_hico_mipi_ARCI/sn52096/ncpu_keil/post_build.bat new file mode 100644 index 0000000..1ac5a9c --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/sn52096/ncpu_keil/post_build.bat @@ -0,0 +1,10 @@ +@ECHO OFF +REM SET BIN_IN=%1 +REM SET BIN_OUT=fw_ncpu.bin + +SET BIN_OUT=%1 + +SET UTILS_PATH=..\..\..\..\utils + +copy .\Objects\%BIN_OUT% %UTILS_PATH%\JLink_programmer\bin\ +copy .\Objects\%BIN_OUT% %UTILS_PATH%\bin_gen\flash_bin\ diff --git a/build/solution_kdp2_hico_mipi_ARCI/sn52096/proj.uvmpw b/build/solution_kdp2_hico_mipi_ARCI/sn52096/proj.uvmpw new file mode 100644 index 0000000..bc6b51a --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/sn52096/proj.uvmpw @@ -0,0 +1,20 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + WorkSpace + + + .\scpu_keil\scpu.uvprojx + 1 + 1 + + + + .\ncpu_keil\ncpu.uvprojx + + +
diff --git a/build/solution_kdp2_hico_mipi_ARCI/sn52096/project.h b/build/solution_kdp2_hico_mipi_ARCI/sn52096/project.h new file mode 100644 index 0000000..fe6f315 --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/sn52096/project.h @@ -0,0 +1,182 @@ +/* Copyright (c) 2020 Kneron, Inc. All Rights Reserved. + * + * The information contained herein is property of Kneron, Inc. + * Terms and conditions of usage are described in detail in Kneron + * STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. + * NO WARRANTY of ANY KIND is provided. This heading must NOT be removed + * from the file. + */ + +/****************************************************************************** +* Filename: +* --------- +* project.h +* +* Description: +* ------------ +* +* +******************************************************************************/ + +#ifndef _PROJECT_H_ +#define _PROJECT_H_ + + +/*============================================================================= +asic setting +=============================================================================*/ +#include "membase.h" + +/*============================================================================= +board setting +=============================================================================*/ +#include "board.h" + +#define FLASH_TYPE FLASH_TYPE_WINBOND_NOR +#define FLASH_SIZE FLASH_SIZE_256MBIT +#define FLASH_COMM FLASH_COMM_SPEED_25MHZ +#define FLASH_DRV FLASH_DRV_NORMAL_MODE + +/*============================================================================= +CAM setting +=============================================================================*/ +#define IMGSRC_0_FORMAT IMG_FORMAT_YCBCR//IMG_FORMAT_RGB565 +#define IMGSRC_0_TYPE IMG_TYPE_RGB +#define IMGSRC_0_RES SENSOR_RES_640_480 +#define IMGSRC_0_WIDTH 1920//640 +#define IMGSRC_0_HEIGHT 1080//480 +#define IMGSRC_0_TILE_AVG 0 +#define IMGSRC_0_MIPI_LANE 2 + +#define IMGSRC_1_FORMAT IMG_FORMAT_RAW8 +#define IMGSRC_1_TYPE IMG_TYPE_IR +#define IMGSRC_1_RES SENSOR_RES_480_640 +#define IMGSRC_1_WIDTH 480 +#define IMGSRC_1_HEIGHT 640 +#define IMGSRC_1_TILE_AVG 1 +#define IMGSRC_1_MIPI_LANE 2 + +/*============================================================================= +COMM setting +=============================================================================*/ +#define UART_NUM 1 +#define MSG_PORT COMM_PORT_ID_0 +#define MSG_PORT_BAUDRATE COMM_UART_BAUDRATE_115200 + +/*============================================================================= +Pinmux setting +=============================================================================*/ +#define PIN_NUM 38 +#define KDRV_PIN_SPI_WP_N_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_12MA << 6) //0x00000080 +#define KDRV_PIN_SPI_HOLD_N_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_12MA << 6) //0x00000080 +#define KDRV_PIN_JTAG_TRST_N_REG PIN_MODE_0 | (PIN_PULL_DOWN << 3) | (PIN_DRIVING_12MA << 6) //0x00000090 +#define KDRV_PIN_JTAG_TDI_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_12MA << 6) //0x00000080 +#define KDRV_PIN_JTAG_SWDITMS_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_12MA << 6) //0x00000080 +#define KDRV_PIN_JTAG_SWCLKTCK_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_12MA << 6) //0x00000080 +#define KDRV_PIN_JTAG_TDO_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_12MA << 6) //0x00000080 +#define KDRV_PIN_LC_PCLK_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_4MA << 6) //0x00000000 +#define KDRV_PIN_LC_VS_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_LC_HS_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_LC_DE_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_LC_DATA_0_REG PIN_MODE_3 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_4MA << 6) //0x00000000 +#define KDRV_PIN_LC_DATA_1_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_4MA << 6) //0x00000000 +#define KDRV_PIN_LC_DATA_2_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_4MA << 6) //0x00000000 +#define KDRV_PIN_LC_DATA_3_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_LC_DATA_4_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_LC_DATA_5_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_LC_DATA_6_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_LC_DATA_7_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_LC_DATA_8_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_LC_DATA_9_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_LC_DATA_10_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_LC_DATA_11_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_LC_DATA_12_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_LC_DATA_13_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_LC_DATA_14_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_LC_DATA_15_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_8MA << 6) //0x00000040 +#define KDRV_PIN_SD_CLK_REG PIN_MODE_1 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_12MA << 6) //0x00000081 +#define KDRV_PIN_SD_CMD_REG PIN_MODE_1 | (PIN_PULL_UP << 3) | (PIN_DRIVING_12MA << 6) //0x00000089 +#define KDRV_PIN_SD_DAT_0_REG PIN_MODE_0 | (PIN_PULL_UP << 3) | (PIN_DRIVING_4MA << 6) //0x00000008 +#define KDRV_PIN_SD_DAT_1_REG PIN_MODE_0 | (PIN_PULL_UP << 3) | (PIN_DRIVING_4MA << 6) //0x00000008 +#define KDRV_PIN_SD_DAT_2_REG PIN_MODE_0 | (PIN_PULL_UP << 3) | (PIN_DRIVING_4MA << 6) //0x00000008 +#define KDRV_PIN_SD_DAT_3_REG PIN_MODE_0 | (PIN_PULL_UP << 3) | (PIN_DRIVING_4MA << 6) //0x00000008 +#define KDRV_PIN_UART0_RX_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_12MA << 6) //0x00000080 +#define KDRV_PIN_UART0_TX_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_12MA << 6) //0x00000080 +#define KDRV_PIN_I2C0_SCL_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_4MA << 6) //0x00000000 +#define KDRV_PIN_I2C0_SDA_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_4MA << 6) //0x00000000 +#define KDRV_PIN_PWM0_REG PIN_MODE_0 | (PIN_PULL_NONE << 3) | (PIN_DRIVING_12MA << 6) //0x00000080 +#define PINMUX_ARRAY {KDRV_PIN_SPI_WP_N_REG, KDRV_PIN_SPI_HOLD_N_REG, KDRV_PIN_JTAG_TRST_N_REG, KDRV_PIN_JTAG_TDI_REG, KDRV_PIN_JTAG_SWDITMS_REG,\ + KDRV_PIN_JTAG_SWCLKTCK_REG, KDRV_PIN_JTAG_TDO_REG, KDRV_PIN_LC_PCLK_REG, KDRV_PIN_LC_VS_REG, KDRV_PIN_LC_HS_REG,\ + KDRV_PIN_LC_DE_REG, KDRV_PIN_LC_DATA_0_REG, KDRV_PIN_LC_DATA_1_REG, KDRV_PIN_LC_DATA_2_REG, KDRV_PIN_LC_DATA_3_REG,\ + KDRV_PIN_LC_DATA_4_REG, KDRV_PIN_LC_DATA_5_REG, KDRV_PIN_LC_DATA_6_REG, KDRV_PIN_LC_DATA_7_REG, KDRV_PIN_LC_DATA_8_REG,\ + KDRV_PIN_LC_DATA_9_REG, KDRV_PIN_LC_DATA_10_REG, KDRV_PIN_LC_DATA_11_REG, KDRV_PIN_LC_DATA_12_REG, KDRV_PIN_LC_DATA_13_REG,\ + KDRV_PIN_LC_DATA_14_REG, KDRV_PIN_LC_DATA_15_REG, KDRV_PIN_SD_CLK_REG, KDRV_PIN_SD_CMD_REG, KDRV_PIN_SD_DAT_0_REG,\ + KDRV_PIN_SD_DAT_1_REG, KDRV_PIN_SD_DAT_2_REG, KDRV_PIN_SD_DAT_3_REG, KDRV_PIN_UART0_RX_REG, KDRV_PIN_UART0_TX_REG,\ + KDRV_PIN_I2C0_SCL_REG, KDRV_PIN_I2C0_SDA_REG, KDRV_PIN_PWM0_REG}; + + +/*============================================================================= +fw setting +=============================================================================*/ +#define OS_DYNAMIC_MEM_SIZE (1024*32) /**< available memory size in RTX*/ + +/*============================================================================= +DDR configuration +=============================================================================*/ +/* DDR table */ +#define DDR_BEGIN DDR_MEM_BASE /**< = 0x60000000, definded in regbase.h*/ +#define DDR_END (DDR_MEM_BASE + DDR_MEM_SIZE - 1) /**< DDR end address */ + +/** Reserve for all_models.bin */ +#define DDR_MODEL_RESERVED_BEGIN KDP_DDR_BASE /**< space head for model data */ +#define DDR_MODEL_RESERVED_END 0x613FFFFF /**< space end for model data(initial boundary) */ + +/** Resseve for DDR heap. Allocation direction from END to BEGIN */ +#define DDR_HEAP_BEGIN 0x61400000 /**< space head for HEAP (initial boundary) */ +#define DDR_HEAP_END 0x63FCFFFF /**< space end for HEAP */ + +/** Reserve for system information, 188KB */ +#define DDR_SYSTEM_RESERVED_BEGIN 0x63FD0000 /**< space head for system info */ +#define DDR_SYSTEM_RESERVED_END 0x63FFEFFF /**< space end for system info */ + +/** Definition of snapshot image address and size, for kdrv_lcdc debug only*/ +#define KDP_DDR_SNAPSHOT_RGB_IMG_SIZE 0x96000 /* 640x480x2(RGB565) */ +#define KDP_DDR_SNAPSHOT_NIR_IMG_SIZE 0x4B000 /* 480x640x1(RAW8) */ +#define KDP_DDR_SNAPSHOT_RGB_IMG_ADDR DDR_MODEL_RESERVED_END +#define KDP_DDR_SNAPSHOT_NIR_IMG_ADDR (DDR_MODEL_RESERVED_END + KDP_DDR_SNAPSHOT_RGB_IMG_SIZE ) + +/*============================================================================= +Flash configuration +=============================================================================*/ +/* Flash table */ +#define FLASH_FW_SCPU0_ADDR 0x00002000 /**< fw_scpu.bin */ +#define FLASH_FW_NCPU0_ADDR 0x00018000 /**< fw_ncpu.bin */ +#define FLASH_FW_CFG0_ADDR 0x00028000 /**< boot_cfg0.bin */ +#define FLASH_FW_SCPU1_ADDR 0x00041000 /**< fw_scpu1.bin */ +#define FLASH_FW_NCPU1_ADDR 0x00057000 /**< fw_ncpu1.bin */ +#define FLASH_FW_CFG1_ADDR 0x00067000 /**< boot_cfg1.bin */ +#define FLASH_MODEL_FW_INFO_ADDR 0x00300000 /**< fw_info.bin */ +#define FLASH_MODEL_ALL_ADDR 0x00301000 /**< all_models.bin */ +#define FLASH_END_ADDR 0x01FFFFFF /**< end addr of 32MB flash */ + +#define FLASH_MINI_BLOCK_SIZE (4 * 1024) + +/*============================================================================= +mdw setting +=============================================================================*/ +/* scpu/ncpu image size */ +#define SCPU_IMAGE_SIZE (SiRAM_MEM_SIZE - 0x2000) +#define NCPU_IMAGE_SIZE NiRAM_MEM_SIZE + +/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +-->critical setting<-- +Below setting is for RD tuning or testing. +**Don't touch anything if you don't know what you are doing** +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ + + + + +#endif //_PROJECT_H_ diff --git a/build/solution_kdp2_hico_mipi_ARCI/sn52096/scpu_keil/kdp2_scpu_jlink.ini b/build/solution_kdp2_hico_mipi_ARCI/sn52096/scpu_keil/kdp2_scpu_jlink.ini new file mode 100644 index 0000000..d4099c3 --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/sn52096/scpu_keil/kdp2_scpu_jlink.ini @@ -0,0 +1,13 @@ +MEMSET(0x10200000, 0x18000, 0) +MEMSET(0x10210000, 0x08000, 0) + +// to let USB know this is running in JTAG mode +MEMSET(0x10100000, 1, 0x01) +MEMSET(0x10100001, 1, 0xBA) +MEMSET(0x10100002, 1, 0xDC) +MEMSET(0x10100003, 1, 0xFE) + +_WDWORD(0xE000ED08, 0x10102000); +SP=_RDWORD(0x10104000) // Set Stack Pointer +PC=_RDWORD(0x10104004) // Set Program Counter = Reset_Handler +BS main \ No newline at end of file diff --git a/build/solution_kdp2_hico_mipi_ARCI/sn52096/scpu_keil/post_build.bat b/build/solution_kdp2_hico_mipi_ARCI/sn52096/scpu_keil/post_build.bat new file mode 100644 index 0000000..f839167 --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/sn52096/scpu_keil/post_build.bat @@ -0,0 +1,12 @@ +@ECHO OFF +REM SET BIN_IN=%1 +REM SET BIN_OUT=fw_scpu.bin + +SET BIN_OUT=%1 + +SET UTILS_PATH=..\..\..\..\utils + +copy .\Objects\%BIN_OUT% %UTILS_PATH%\JLink_programmer\bin\ +copy .\Objects\%BIN_OUT% %UTILS_PATH%\bin_gen\flash_bin\ + + diff --git a/build/solution_kdp2_hico_mipi_ARCI/sn52096/scpu_keil/pre_build.bat b/build/solution_kdp2_hico_mipi_ARCI/sn52096/scpu_keil/pre_build.bat new file mode 100644 index 0000000..dba1dc6 --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/sn52096/scpu_keil/pre_build.bat @@ -0,0 +1 @@ +REM "prebuild script" diff --git a/build/solution_kdp2_hico_mipi_ARCI/sn52096/scpu_keil/scpu.uvoptx b/build/solution_kdp2_hico_mipi_ARCI/sn52096/scpu_keil/scpu.uvoptx new file mode 100644 index 0000000..d7edc7a --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/sn52096/scpu_keil/scpu.uvoptx @@ -0,0 +1,1242 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc; *.md + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + dev + 0x4 + ARM-ADS + + 200000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\Listings\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 7 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 4 + + + + + + + + + + .\kdp2_scpu_jlink.ini + Segger\JL2CM3.dll + + + + 0 + DLGUARM + + + + 0 + ARMRTXEVENTFLAGS + -L70 -Z18 -C0 -M0 -T1 + + + 0 + DLGTARM + (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0) + + + 0 + ARMDBGFLAGS + + + + 0 + JL2CM3 + -U59700618 -O64 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(4) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO5 -FD20000000 -FC1000 -FN0 + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000) + + + + + + 1 + 2 + 0 + 0 + + + + + 2 + 2 + 0x61000000 + 0 + + + + + 3 + 2 + 0xa0000000 + 0 + + + + + 4 + 2 + 0 + 0 + + + + ..\..\..\..\platform\kl520\scpu\scpu_common.scvd + + 1 + + + 0 + + + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + + + + main + 1 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + ..\..\main_scpu\main.c + main.c + 0 + 0 + + + 1 + 2 + 5 + 0 + 0 + 0 + ..\project.h + project.h + 0 + 0 + + + 1 + 3 + 1 + 0 + 0 + 0 + ..\..\main_scpu\application_init.c + application_init.c + 0 + 0 + + + 1 + 4 + 1 + 0 + 0 + 0 + ..\..\main_scpu\device_init.c + device_init.c + 0 + 0 + + + 1 + 5 + 1 + 0 + 0 + 0 + ..\..\main_scpu\driver_init.c + driver_init.c + 0 + 0 + + + 1 + 6 + 1 + 0 + 0 + 0 + ..\..\main_scpu\middleware_init.c + middleware_init.c + 0 + 0 + + + 1 + 7 + 1 + 0 + 0 + 0 + ..\..\main_scpu\system_init.c + system_init.c + 0 + 0 + + + 1 + 8 + 5 + 0 + 0 + 0 + ..\..\main_scpu\include\task_handler.h + task_handler.h + 0 + 0 + + + 1 + 9 + 1 + 0 + 0 + 0 + ..\..\main_scpu\display_init.c + display_init.c + 0 + 0 + + + 1 + 10 + 1 + 0 + 0 + 0 + ..\..\main_scpu\kdev_sensor_imx462.c + kdev_sensor_imx462.c + 0 + 0 + + + + + inf_app + 1 + 0 + 0 + 0 + + 2 + 11 + 1 + 0 + 0 + 0 + ..\..\..\..\app\demo_customize_inf_single_model.c + demo_customize_inf_single_model.c + 0 + 0 + + + 2 + 12 + 1 + 0 + 0 + 0 + ..\..\..\..\app\demo_customize_inf_multiple_models.c + demo_customize_inf_multiple_models.c + 0 + 0 + + + 2 + 13 + 1 + 0 + 0 + 0 + ..\..\..\..\app\kdp2_inf_app_yolo.c + kdp2_inf_app_yolo.c + 0 + 0 + + + + + inf_client + 1 + 0 + 0 + 0 + + 3 + 14 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\usb_companion\kdp2_cmd_handler_520.c + kdp2_cmd_handler_520.c + 0 + 0 + + + 3 + 15 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\usb_companion\usbd_hal_520.c + usbd_hal_520.c + 0 + 0 + + + 3 + 16 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\usb_companion\kdp2_usb_log.c + kdp2_usb_log.c + 0 + 0 + + + 3 + 17 + 1 + 0 + 0 + 0 + ..\..\main_scpu\kdp2_hico_mipi.c + kdp2_hico_mipi.c + 0 + 0 + + + + + middleware + 1 + 0 + 0 + 0 + + 4 + 18 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\memory\kmdw_memory.c + kmdw_memory.c + 0 + 0 + + + 4 + 19 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\flash\kmdw_memxfer.c + kmdw_memxfer.c + 0 + 0 + + + 4 + 20 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\console\kmdw_console.c + kmdw_console.c + 0 + 0 + + + 4 + 21 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\power\kmdw_power_manager.c + kmdw_power_manager.c + 0 + 0 + + + 4 + 22 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\dfu\kmdw_dfu.c + kmdw_dfu.c + 0 + 0 + + + 4 + 23 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\utils\kmdw_utils_crc.c + kdp_crc.c + 0 + 0 + + + 4 + 24 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\system\kmdw_system.c + kmdw_system.c + 0 + 0 + + + 4 + 25 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\ipc\kmdw_ipc.c + kmdw_ipc.c + 0 + 0 + + + 4 + 26 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\model\kmdw_model.c + kmdw_model.c + 0 + 0 + + + 4 + 27 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\inference\dual_fifo2.c + dual_fifo2.c + 0 + 0 + + + 4 + 28 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\inference\kdp2_inf_generic_raw.c + kdp2_inf_generic_raw.c + 0 + 0 + + + 4 + 29 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\inference\kmdw_inference_520.c + kmdw_inference_520.c + 0 + 0 + + + 4 + 30 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\camera\kmdw_camera.c + kmdw_camera.c + 0 + 0 + + + 4 + 31 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\camera\kmdw_camera_kl520.c + kmdw_camera_kl520.c + 0 + 0 + + + 4 + 32 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\camera\kmdw_sensor.c + kmdw_sensor.c + 0 + 0 + + + 4 + 33 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\display\kmdw_display.c + kmdw_display.c + 0 + 0 + + + 4 + 34 + 1 + 0 + 0 + 0 + ..\..\..\..\mdw\inference\kmdw_fifoq_manager.c + kmdw_fifoq_manager.c + 0 + 0 + + + + + device + 1 + 0 + 0 + 0 + + 5 + 35 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\dev\flash\kdev_flash_winbond.c + kdev_flash_winbond.c + 0 + 0 + + + 5 + 36 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\dev\sensor\kdev_sensor_gc2145.c + kdev_sensor_gc2145.c + 0 + 0 + + + 5 + 37 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\dev\sensor\kdev_sensor_sc132gs.c + kdev_sensor_sc132gs.c + 0 + 0 + + + 5 + 38 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\dev\panel\kdev_mzt_480x272.c + kdev_mzt_480x272.c + 0 + 0 + + + + + driver + 1 + 0 + 0 + 0 + + 6 + 39 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_pinmux.c + kdrv_pinmux.c + 0 + 0 + + + 6 + 40 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_gpio.c + kdrv_gpio.c + 0 + 0 + + + 6 + 41 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_spif.c + kdrv_spif.c + 0 + 0 + + + 6 + 42 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_uart.c + kdrv_uart.c + 0 + 0 + + + 6 + 43 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_ipc.c + kdrv_ipc.c + 0 + 0 + + + 6 + 44 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_usbd2.c + kdrv_usbd2.c + 0 + 0 + + + 6 + 45 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_usbd2v.c + kdrv_usbd2v.c + 0 + 0 + + + 6 + 46 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_clock.c + kdrv_clock.c + 0 + 0 + + + 6 + 47 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_mpu.c + kdrv_mpu.c + 0 + 0 + + + 6 + 48 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_ddr.c + kdrv_ddr.c + 0 + 0 + + + 6 + 49 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_power.c + kdrv_power.c + 0 + 0 + + + 6 + 50 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_system.c + kdrv_system.c + 0 + 0 + + + 6 + 51 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_wdt.c + kdrv_wdt.c + 0 + 0 + + + 6 + 52 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_gdma.c + kdrv_gdma.c + 0 + 0 + + + 6 + 53 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\rtc.c + rtc.c + 0 + 0 + + + 6 + 54 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_pwm.c + kdrv_pwm.c + 0 + 0 + + + 6 + 55 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_lcdc.c + kdrv_lcdc.c + 0 + 0 + + + 6 + 56 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_i2c.c + kdrv_i2c.c + 0 + 0 + + + 6 + 57 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_mipicsirx.c + kdrv_mipicsirx.c + 0 + 0 + + + 6 + 58 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_dpi2ahb.c + kdrv_dpi2ahb.c + 0 + 0 + + + + + rtx + 0 + 0 + 0 + 0 + + 7 + 59 + 2 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\irq_cm4f.s + irq_cm4f.s + 0 + 0 + + + 7 + 60 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\os_systick.c + os_systick.c + 0 + 0 + + + 7 + 61 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\RTX_Config.c + RTX_Config.c + 0 + 0 + + + 7 + 62 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_delay.c + rtx_delay.c + 0 + 0 + + + 7 + 63 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_evflags.c + rtx_evflags.c + 0 + 0 + + + 7 + 64 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_evr.c + rtx_evr.c + 0 + 0 + + + 7 + 65 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_kernel.c + rtx_kernel.c + 0 + 0 + + + 7 + 66 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_lib.c + rtx_lib.c + 0 + 0 + + + 7 + 67 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_memory.c + rtx_memory.c + 0 + 0 + + + 7 + 68 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_mempool.c + rtx_mempool.c + 0 + 0 + + + 7 + 69 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_msgqueue.c + rtx_msgqueue.c + 0 + 0 + + + 7 + 70 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_mutex.c + rtx_mutex.c + 0 + 0 + + + 7 + 71 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_semaphore.c + rtx_semaphore.c + 0 + 0 + + + 7 + 72 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_system.c + rtx_system.c + 0 + 0 + + + 7 + 73 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_thread.c + rtx_thread.c + 0 + 0 + + + 7 + 74 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_timer.c + rtx_timer.c + 0 + 0 + + + 7 + 75 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\task_handler.c + task_handler.c + 0 + 0 + + + + + startup + 1 + 0 + 0 + 0 + + 8 + 76 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\startup\startup.c + startup.c + 0 + 0 + + + 8 + 77 + 2 + 0 + 0 + 0 + ..\..\..\..\platform\kl520\scpu\startup\startup_asm.s + startup_asm.s + 0 + 0 + + + + + libs + 1 + 0 + 0 + 0 + + 9 + 78 + 4 + 0 + 0 + 0 + ..\..\..\..\lib\system_520.lib + system_520.lib + 0 + 0 + + + +
diff --git a/build/solution_kdp2_hico_mipi_ARCI/sn52096/scpu_keil/scpu.uvprojx b/build/solution_kdp2_hico_mipi_ARCI/sn52096/scpu_keil/scpu.uvprojx new file mode 100644 index 0000000..4214902 --- /dev/null +++ b/build/solution_kdp2_hico_mipi_ARCI/sn52096/scpu_keil/scpu.uvprojx @@ -0,0 +1,853 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + dev + 0x4 + ARM-ADS + 5060960::V5.06 update 7 (build 960)::.\ARMCC + 0 + + + ARMCM4_FP + ARM + ARM.CMSIS.5.7.0 + http://www.keil.com/pack/ + IRAM(0x20000000,0x00020000) IROM(0x00000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ESEL ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000) + 0 + $$Device:ARMCM4_FP$Device\ARM\ARMCM4\Include\ARMCM4_FP.h + + + + + + + + + + $$Device:ARMCM4_FP$Device\ARM\SVD\ARMCM4.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\Objects\ + scpu_fw + 1 + 0 + 0 + 1 + 1 + .\Listings\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 1 + 0 + pre_build.bat + + 0 + 0 + 0 + 0 + + + 1 + 1 + fromelf.exe --bin "!L" --output ".\Objects\fw_scpu.bin" + post_build.bat fw_scpu.bin + 0 + 0 + 0 + 0 + + 1 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + -MPU + DCM.DLL + -pCM4 + SARMCM3.DLL + -MPU + TCM.DLL + -pCM4 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 0 + 1 + 4099 + + 0 + Segger\JL2CM3.dll + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + "Cortex-M4" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x20000 + + + 1 + 0x0 + 0x40000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x10102000 + 0x16000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x10200000 + 0x16000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 4 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + --gnu + ARM_MATH_CM4, KL520, TARGET_SCPU, LOG_ENABLE, BOARD_96 + + ..\..\..\..\include;..\..\..\..\platform\kl520\common;..\..\..\..\platform\kl520\scpu\drv\include;..\..\..\..\platform\kl520\scpu\rtos\rtx\include;..\..\..\..\platform\board\board_sn52096;..\..\..\..\platform\dev\include;..\..\..\..\mdw\include;..\..\..\..\mdw\inference;..\..\..\..\app;..\..\main_scpu\include;..\;..\..\..\lib\system_520\main_scpu\include + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 4 + + --cpreproc + + + ..\..\sn52096;..\..\..\..\include;..\..\..\..\platform\kl520\common;..\..\..\..\platform\board\board_sn52096 + + + + 0 + 0 + 0 + 0 + 0 + 0 + 0x10100000 + 0x10200000 + + ..\..\..\..\platform\kl520\scpu\scatter_load.sct + + + + + + + + + + + main + + + main.c + 1 + ..\..\main_scpu\main.c + + + project.h + 5 + ..\project.h + + + application_init.c + 1 + ..\..\main_scpu\application_init.c + + + device_init.c + 1 + ..\..\main_scpu\device_init.c + + + driver_init.c + 1 + ..\..\main_scpu\driver_init.c + + + middleware_init.c + 1 + ..\..\main_scpu\middleware_init.c + + + system_init.c + 1 + ..\..\main_scpu\system_init.c + + + task_handler.h + 5 + ..\..\main_scpu\include\task_handler.h + + + display_init.c + 1 + ..\..\main_scpu\display_init.c + + + kdev_sensor_imx462.c + 1 + ..\..\main_scpu\kdev_sensor_imx462.c + + + + + inf_app + + + demo_customize_inf_single_model.c + 1 + ..\..\..\..\app\demo_customize_inf_single_model.c + + + demo_customize_inf_multiple_models.c + 1 + ..\..\..\..\app\demo_customize_inf_multiple_models.c + + + kdp2_inf_app_yolo.c + 1 + ..\..\..\..\app\kdp2_inf_app_yolo.c + + + + + inf_client + + + kdp2_cmd_handler_520.c + 1 + ..\..\..\..\mdw\usb_companion\kdp2_cmd_handler_520.c + + + usbd_hal_520.c + 1 + ..\..\..\..\mdw\usb_companion\usbd_hal_520.c + + + kdp2_usb_log.c + 1 + ..\..\..\..\mdw\usb_companion\kdp2_usb_log.c + + + kdp2_hico_mipi.c + 1 + ..\..\main_scpu\kdp2_hico_mipi.c + + + + + middleware + + + kmdw_memory.c + 1 + ..\..\..\..\mdw\memory\kmdw_memory.c + + + kmdw_memxfer.c + 1 + ..\..\..\..\mdw\flash\kmdw_memxfer.c + + + kmdw_console.c + 1 + ..\..\..\..\mdw\console\kmdw_console.c + + + kmdw_power_manager.c + 1 + ..\..\..\..\mdw\power\kmdw_power_manager.c + + + kmdw_dfu.c + 1 + ..\..\..\..\mdw\dfu\kmdw_dfu.c + + + kdp_crc.c + 1 + ..\..\..\..\mdw\utils\kmdw_utils_crc.c + + + kmdw_system.c + 1 + ..\..\..\..\mdw\system\kmdw_system.c + + + kmdw_ipc.c + 1 + ..\..\..\..\mdw\ipc\kmdw_ipc.c + + + kmdw_model.c + 1 + ..\..\..\..\mdw\model\kmdw_model.c + + + dual_fifo2.c + 1 + ..\..\..\..\mdw\inference\dual_fifo2.c + + + kdp2_inf_generic_raw.c + 1 + ..\..\..\..\mdw\inference\kdp2_inf_generic_raw.c + + + kmdw_inference_520.c + 1 + ..\..\..\..\mdw\inference\kmdw_inference_520.c + + + kmdw_camera.c + 1 + ..\..\..\..\mdw\camera\kmdw_camera.c + + + kmdw_camera_kl520.c + 1 + ..\..\..\..\mdw\camera\kmdw_camera_kl520.c + + + kmdw_sensor.c + 1 + ..\..\..\..\mdw\camera\kmdw_sensor.c + + + kmdw_display.c + 1 + ..\..\..\..\mdw\display\kmdw_display.c + + + kmdw_fifoq_manager.c + 1 + ..\..\..\..\mdw\inference\kmdw_fifoq_manager.c + + + + + device + + + kdev_flash_winbond.c + 1 + ..\..\..\..\platform\dev\flash\kdev_flash_winbond.c + + + kdev_sensor_gc2145.c + 1 + ..\..\..\..\platform\dev\sensor\kdev_sensor_gc2145.c + + + kdev_sensor_sc132gs.c + 1 + ..\..\..\..\platform\dev\sensor\kdev_sensor_sc132gs.c + + + kdev_mzt_480x272.c + 1 + ..\..\..\..\platform\dev\panel\kdev_mzt_480x272.c + + + + + driver + + + kdrv_pinmux.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_pinmux.c + + + kdrv_gpio.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_gpio.c + + + kdrv_spif.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_spif.c + + + kdrv_uart.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_uart.c + + + kdrv_ipc.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_ipc.c + + + kdrv_usbd2.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_usbd2.c + + + kdrv_usbd2v.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_usbd2v.c + + + kdrv_clock.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_clock.c + + + kdrv_mpu.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_mpu.c + + + kdrv_ddr.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_ddr.c + + + kdrv_power.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_power.c + + + kdrv_system.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_system.c + + + kdrv_wdt.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_wdt.c + + + kdrv_gdma.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_gdma.c + + + rtc.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\rtc.c + + + kdrv_pwm.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_pwm.c + + + kdrv_lcdc.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_lcdc.c + + + kdrv_i2c.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_i2c.c + + + kdrv_mipicsirx.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_mipicsirx.c + + + kdrv_dpi2ahb.c + 1 + ..\..\..\..\platform\kl520\scpu\drv\kdrv_dpi2ahb.c + + + + + rtx + + + irq_cm4f.s + 2 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\irq_cm4f.s + + + os_systick.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\os_systick.c + + + RTX_Config.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\RTX_Config.c + + + rtx_delay.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_delay.c + + + rtx_evflags.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_evflags.c + + + rtx_evr.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_evr.c + + + rtx_kernel.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_kernel.c + + + rtx_lib.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_lib.c + + + rtx_memory.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_memory.c + + + rtx_mempool.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_mempool.c + + + rtx_msgqueue.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_msgqueue.c + + + rtx_mutex.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_mutex.c + + + rtx_semaphore.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_semaphore.c + + + rtx_system.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_system.c + + + rtx_thread.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_thread.c + + + rtx_timer.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\rtx_timer.c + + + task_handler.c + 1 + ..\..\..\..\platform\kl520\scpu\rtos\rtx\task_handler.c + + + + + startup + + + startup.c + 1 + ..\..\..\..\platform\kl520\scpu\startup\startup.c + + + startup_asm.s + 2 + ..\..\..\..\platform\kl520\scpu\startup\startup_asm.s + + + + + libs + + + system_520.lib + 4 + ..\..\..\..\lib\system_520.lib + + + + + + + + + + + + + RTE\CMSIS\RTX_Config.c + + + + + + RTE\CMSIS\RTX_Config.h + + + + + + RTE\Device\ARMCM4_FP\startup_ARMCM4.s + + + + + + RTE\Device\ARMCM4_FP\system_ARMCM4.c + + + + + + + +
diff --git a/mdw/camera/kmdw_camera_kl520.c b/mdw/camera/kmdw_camera_kl520.c index a2dde0a..88e42db 100644 --- a/mdw/camera/kmdw_camera_kl520.c +++ b/mdw/camera/kmdw_camera_kl520.c @@ -78,7 +78,7 @@ static kmdw_status_t kmdw_cam_set_format(uint32_t cam_idx, struct cam_format *fo ctx->fmt = *format; - if (format->pixelformat == IMG_FORMAT_RGB565) + if (format->pixelformat == IMG_FORMAT_RGB565 || format->pixelformat == IMG_FORMAT_YCBCR) bpp = 2; else if (format->pixelformat == IMG_FORMAT_RAW8) { @@ -116,7 +116,7 @@ static kmdw_status_t kmdw_cam_buffer_init(uint32_t cam_idx, uint32_t buf_addr_0, struct kmdw_cam_context *ctx = &cam_ctx[cam_idx]; cam_msg("cam %d: size=%d\n", cam_idx, ctx->fmt.sizeimage); - + kdrv_dpi2ahb_buf_init(cam_idx, buf_addr_0, buf_addr_1); return KMDW_STATUS_OK; diff --git a/mdw/camera/kmdw_sensor.c b/mdw/camera/kmdw_sensor.c index 443bd55..e6c3a2f 100644 --- a/mdw/camera/kmdw_sensor.c +++ b/mdw/camera/kmdw_sensor.c @@ -13,6 +13,7 @@ #if defined(BOARD_96) || defined(BOARD_DVP_EXAMPLE) extern struct sensor_ops* kdev_sensor_gc2145_get_ops(void); +extern struct sensor_ops* kdev_sensor_imx462_get_ops(void); extern struct sensor_ops* kdev_sensor_sc132gs_get_ops(void); #endif @@ -190,6 +191,9 @@ struct sensor_ops * kmdw_sensor_get_ops(uint32_t sensor_idx) case SENSOR_ID_GC2145: pops = kdev_sensor_gc2145_get_ops(); break; + case SENSOR_ID_IMX462: + pops = kdev_sensor_imx462_get_ops(); + break; case SENSOR_ID_SC132GS: pops = kdev_sensor_sc132gs_get_ops(); break; diff --git a/platform/board/board_sn52096/board.h b/platform/board/board_sn52096/board.h index 3f22e2e..7115fa1 100644 --- a/platform/board/board_sn52096/board.h +++ b/platform/board/board_sn52096/board.h @@ -77,7 +77,8 @@ #define SENSOR_ID_HMXRICA 2 #define SENSOR_ID_GC2145 3 #define SENSOR_ID_SC132GS 4 -#define SENSOR_ID_MAX 5 +#define SENSOR_ID_IMX462 5 +#define SENSOR_ID_MAX 6 #define SENSOR_ID_EXTERN 0xFE #define SENSOR_ID_NONE 0xFF @@ -132,16 +133,16 @@ /* original board_kl520_96.h*/ #define IMGSRC_IN_0 YES -#define IMGSRC_IN_1 YES +#define IMGSRC_IN_1 NO #if (IMGSRC_IN_0 == YES) #define IMGSRC_IN_0_PORT IMGSRC_IN_PORT_MIPI -#define IMGSRC_0_SENSORID SENSOR_ID_GC2145 -#define IMGSRC_0_FORMAT IMG_FORMAT_RGB565 +#define IMGSRC_0_SENSORID SENSOR_ID_IMX462// SENSOR_ID_GC2145 +#define IMGSRC_0_FORMAT IMG_FORMAT_YCBCR #define IMGSRC_0_TYPE IMG_TYPE_RGB #define IMGSRC_0_RES SENSOR_RES_640_480 -#define IMGSRC_0_WIDTH 640 -#define IMGSRC_0_HEIGHT 480 +#define IMGSRC_0_WIDTH 1920//640 +#define IMGSRC_0_HEIGHT 1080//480 #define IMGSRC_0_TILE_AVG 0 #define IMGSRC_0_MIPI_LANE 2 #else @@ -222,12 +223,12 @@ #define PANEL_TYPE PANEL_MZT_480X272 #define DISPLAY_DEVICE DISPLAY_DEVICE_LCDC -#define CAM_CLK_MS 2 -#define CAM_CLK_NS 242 +#define CAM_CLK_MS 1 +#define CAM_CLK_NS 99 #define CAM_CLK_PS 2 -#define CSI0_TXESC 4 -#define CSI0_CSI 11 -#define CSI0_VC0 5 +#define CSI0_TXESC 3 +#define CSI0_CSI 7 +#define CSI0_VC0 3 #define CSI1_TXESC 4 #define CSI1_CSI 7 #define CSI1_VC0 1 diff --git a/platform/kl520/scpu/drv/kdrv_dpi2ahb.c b/platform/kl520/scpu/drv/kdrv_dpi2ahb.c index 5696bd2..99b3c89 100644 --- a/platform/kl520/scpu/drv/kdrv_dpi2ahb.c +++ b/platform/kl520/scpu/drv/kdrv_dpi2ahb.c @@ -86,6 +86,8 @@ Head Block of The File #if (IMGSRC_0_SENSORID == SENSOR_ID_HMX2056) || (IMGSRC_0_SENSORID == SENSOR_ID_SC132GS) #define D2A_REG_CTRL_0 0x3000 +#elif(IMGSRC_0_SENSORID == SENSOR_ID_IMX462) +#define D2A_REG_CTRL_0 0x5000 #elif(IMGSRC_0_SENSORID == SENSOR_ID_OV9286) || (IMGSRC_0_SENSORID == SENSOR_ID_HMXRICA) #define D2A_REG_CTRL_0 0x3008 #elif(IMGSRC_0_SENSORID == SENSOR_ID_GC2145) @@ -98,6 +100,8 @@ Head Block of The File #if (IMGSRC_1_SENSORID == SENSOR_ID_HMX2056) || (IMGSRC_1_SENSORID == SENSOR_ID_SC132GS) #define D2A_REG_CTRL_1 0x3000 +#elif(IMGSRC_1_SENSORID == SENSOR_ID_IMX462) +#define D2A_REG_CTRL_1 0x5000 #elif(IMGSRC_1_SENSORID == SENSOR_ID_OV9286) || (IMGSRC_1_SENSORID == SENSOR_ID_HMXRICA) #define D2A_REG_CTRL_1 0x3008 #elif(IMGSRC_1_SENSORID == SENSOR_ID_GC2145) @@ -276,7 +280,7 @@ void kdrv_dpi2ahb_irqhandler(uint32_t d2a_idx) if (ctx->page_done_num != sta_st) // 1: page 1 done 2: page 0 done { D2APageAddr = (sta_st == BIT0)? &d2a_base->dw.D2APage0Addr: &d2a_base->dw.D2APage1Addr; - + // hardware ping-pong buffers mechanism if (skip_next_count[d2a_idx] <= 0) { @@ -296,6 +300,11 @@ void kdrv_dpi2ahb_irqhandler(uint32_t d2a_idx) { // kmdw_printf("%d: cam %d error D2A_INT_AHB_TX_ERR\n", ++err_cnt, d2a_idx); // skip what ? + // // 寫入 1 觸發 D2A 硬體軟體重置 (Software Reset) + // d2a_base->dw.D2ACtrl |= 0x1; + + // // 輪詢等待硬體重置完成並自動清零 + // while (d2a_base->dw.D2ACtrl & 0x1); } if (sta_is & D2A_INT_FIFO_UF) diff --git a/platform/kl520/scpu/drv/kdrv_mipicsirx.c b/platform/kl520/scpu/drv/kdrv_mipicsirx.c index 3cdbb7f..4c2947f 100644 --- a/platform/kl520/scpu/drv/kdrv_mipicsirx.c +++ b/platform/kl520/scpu/drv/kdrv_mipicsirx.c @@ -273,6 +273,10 @@ kdrv_status_t kdrv_csi2rx_enable(uint32_t input_type, uint32_t cam_idx, uint32_t val = 245; outw(csirx_base + CSI2RX_REG_PFTR , val); break; + case SENSOR_ID_IMX462: + val = 0; + outw(csirx_base + CSI2RX_REG_PFTR , val); + break; case SENSOR_ID_GC2145: CSIRX_REG_VSCR_SET_VSTU0(csirx_base, 1); break;