system/fastboot: Support USB boardctl

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This commit is contained in:
wangjianyu3 2023-12-15 12:08:40 +08:00 committed by Xiang Xiao
parent 1752726479
commit 4d0b9d61de
2 changed files with 43 additions and 0 deletions

View File

@ -24,4 +24,11 @@ config SYSTEM_FASTBOOTD_DOWNLOAD_MAX
int "USB-fastboot download buffer size"
default 40960
config FASTBOOTD_USB_BOARDCTL
bool "USB Board Control"
depends on BOARDCTL
depends on BOARDCTL_USBDEVCTRL
---help---
Connect usbdev before running fastboot daemon.
endif # SYSTEM_FASTBOOTD

View File

@ -623,6 +623,42 @@ int main(int argc, FAR char **argv)
char usbdev[32];
int ret = OK;
#ifdef CONFIG_FASTBOOTD_USB_BOARDCTL
struct boardioc_usbdev_ctrl_s ctrl;
# ifdef CONFIG_USBDEV_COMPOSITE
uint8_t dev = BOARDIOC_USBDEV_COMPOSITE;
# else
uint8_t dev = BOARDIOC_USBDEV_FASTBOOT;
# endif
FAR void *handle;
ctrl.usbdev = dev;
ctrl.action = BOARDIOC_USBDEV_INITIALIZE;
ctrl.instance = 0;
ctrl.config = 0;
ctrl.handle = NULL;
ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl);
if (ret < 0)
{
printf("boardctl(BOARDIOC_USBDEV_CONTROL) failed: %d\n", ret);
return ret;
}
ctrl.usbdev = dev;
ctrl.action = BOARDIOC_USBDEV_CONNECT;
ctrl.instance = 0;
ctrl.config = 0;
ctrl.handle = &handle;
ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl);
if (ret < 0)
{
printf("boardctl(BOARDIOC_USBDEV_CONTROL) failed: %d\n", ret);
return ret;
}
#endif /* FASTBOOTD_USB_BOARDCTL */
buffer = malloc(CONFIG_SYSTEM_FASTBOOTD_DOWNLOAD_MAX);
if (buffer == NULL)
{