Web Analytics

System API

System API is for system control, init/deinit system, and update firmware and models.

Init

int kdp_lib_init();

Start

int kdp_lib_start();

De Init

int kdp_lib_de_init();

Init Log

int kdp_init_log(const char* dir, const char* name);

 

Scan Devices

int kdp_scan_usb_devices(kdp_device_info_list_t **list)

enum kdp_usb_speed
{
    KDP_USB_SPEED_UNKNOWN = 0,
    KDP_USB_SPEED_LOW = 1,
    KDP_USB_SPEED_FULL = 2,
    KDP_USB_SPEED_HIGH = 3,
    KDP_USB_SPEED_SUPER = 4,
};

enum kdp_product_id
{
    KDP_DEVICE_KL520 = 0x100,
    KDP_DEVICE_KL720 = 0x200,
};

typedef struct
{
    int scan_index;             // scanned order index, can be used by kdp_connect_usb_device()
    bool isConnectable;         // indicate if this device is connectable
    unsigned short vendor_id;   // supposed to be 0x3231
    unsigned short product_id;  // enum kdp_product_id
    int link_speed;             // enum kdp_usb_speed
    unsigned int serial_number; // KN number
    char device_path[20];       // "bus-hub_port-device_port", ex: "1-2-3", means bus 1 - (hub) port 2 - (device) port 3
} kdp_device_info_t;

typedef struct
{
    int num_dev;
    kdp_device_info_t kdevice[1]; // real index range from 0 ~ (num_dev-1)
} kdp_device_info_list_t;
kdp_device_info_list_t *list = NULL;
kdp_scan_usb_devices(&list);

for (int i = 0; i < list->num_dev; i++)
{
    /* reading the content of list->kdevice[i] for whatever wanted */
}

free(list);

 

Connect To USB Device

int kdp_connect_usb_device(int scan_index)

int dev_idx = kdp_connect_usb_device(1);

/* then invoke other APIs with dev_idx as input */

 

kdp_device_info_list_t *list = NULL;
kdp_scan_usb_devices(&list);

int dev_idx[10];

for (int i = 0; i < list->num_dev; i++)
{
    int sidx = list->kdevice[i].scan_index
    dev_idx[i] = kdp_connect_usb_device(sidx);
}

free(list);

/* then invoke other APIs with dev_idx[i] as input */

 

Add Device (Deprecated)

int kdp_add_dev(int type, const char* name);

 

System Reset

int kdp_reset_sys(int dev_idx, uint32_t reset_mode);

System Status

int kdp_report_sys_status(int dev_idx, uint32_t* sfw_id, uint32_t* sbuild_id, uint16_t* sys_status, uint16_t* app_status, uint32_t* nfw_id, uint32_t* nbuild_id);

Get KN Number

int kdp_get_kn_number(int dev_idx, uint32_t *kn_num);

Get Model Info

int kdp_get_model_info(int dev_idx, int from_ddr, char *data_buf);

Update Firmware

int kdp_update_fw(int dev_idx, uint32_t* module_id, char* img_buf, int buf_len);

Update Model

int kdp_update_model(int dev_idx, uint32_t* model_id, uint32_t model_size, char* img_buf, int buf_len);

Update SPL

int kdp_update_spl(int dev_idx, uint32_t mode, uint16_t auth_type, uint16_t spl_size, uint8_t* auth_key, char* spl_buf, uint32_t* rsp_code, uint32_t* spl_id, uint32_t* spl_build);