diff --git a/Ubiquitous/XiUOS/board/aiit-riscv64-board/Kconfig b/Ubiquitous/XiUOS/board/aiit-riscv64-board/Kconfig index 65db341b6..dce13fa31 100644 --- a/Ubiquitous/XiUOS/board/aiit-riscv64-board/Kconfig +++ b/Ubiquitous/XiUOS/board/aiit-riscv64-board/Kconfig @@ -58,6 +58,10 @@ menu "aiit-riscv64-board feature" bool "mount cd card" default n select BSP_USING_SDIO + config MOUNT_USB + bool "mount usb" + default n + select BSP_USING_USB endmenu endmenu diff --git a/Ubiquitous/XiUOS/board/aiit-riscv64-board/board.c b/Ubiquitous/XiUOS/board/aiit-riscv64-board/board.c index 17f15197c..18bab5060 100644 --- a/Ubiquitous/XiUOS/board/aiit-riscv64-board/board.c +++ b/Ubiquitous/XiUOS/board/aiit-riscv64-board/board.c @@ -64,13 +64,24 @@ extern int HwRtcInit(void); extern int HwTouchBusInit(void); extern int HwCh376Init(void); -#if defined(FS_VFS) && defined(MOUNT_SDCARD) +#ifdef FS_CH376 #include - +#ifdef MOUNT_USB /** - * @description: Mount SD card + * @description: Mount USB * @return 0 */ +int MountUSB(void) +{ + if (MountFilesystem(USB_BUS_NAME, USB_DEVICE_NAME, USB_DRIVER_NAME, FSTYPE_CH376, "/") == 0) + KPrintf("usb mount to '/'"); + else + KPrintf("usb mount to '/' failed!"); + + return 0; +} +#endif +#ifdef MOUNT_SDCARD /** * @description: Mount SD card * @return 0 @@ -85,6 +96,7 @@ int MountSDCard(void) return 0; } #endif +#endif void init_bss(void) { @@ -185,6 +197,9 @@ struct InitSequenceDesc _board_init[] = #ifdef BSP_USING_SDIO { "hw_sdio", HwCh376Init}, #endif +#ifdef BSP_USING_USB + { "hw_usb", HwCh376Init}, +#endif #ifdef BSP_USING_TOUCH { "hw_touch", HwTouchBusInit}, #endif diff --git a/Ubiquitous/XiUOS/kernel/include/xs_init.h b/Ubiquitous/XiUOS/kernel/include/xs_init.h index eb3af1e11..745377e91 100644 --- a/Ubiquitous/XiUOS/kernel/include/xs_init.h +++ b/Ubiquitous/XiUOS/kernel/include/xs_init.h @@ -43,6 +43,7 @@ extern int Ch376fsInit(void); extern int LibcSystemInit(void); extern int RtcNtpSyncInit(void); extern int MountSDCard(void); +extern int MountUSB(void); extern int DfsMountTable(void); extern int userShellInit(void); extern int STM32USBHostRegister(void); diff --git a/Ubiquitous/XiUOS/kernel/thread/init.c b/Ubiquitous/XiUOS/kernel/thread/init.c index af363f757..94a3d1881 100644 --- a/Ubiquitous/XiUOS/kernel/thread/init.c +++ b/Ubiquitous/XiUOS/kernel/thread/init.c @@ -109,6 +109,10 @@ struct InitSequenceDesc env_init[] = { "MountSDCard", MountSDCard }, #endif +#ifdef MOUNT_USB + { "MountUSB", MountUSB }, +#endif + #ifdef FS_VFS_MNTTABLE { "DfsMountTable", DfsMountTable }, #endif diff --git a/Ubiquitous/XiUOS/resources/include/usb_host.h b/Ubiquitous/XiUOS/resources/include/usb_host.h index 131b8370a..473b647fb 100644 --- a/Ubiquitous/XiUOS/resources/include/usb_host.h +++ b/Ubiquitous/XiUOS/resources/include/usb_host.h @@ -40,6 +40,12 @@ Modification: extern "C" { #endif +#ifdef ARCH_CPU_64BIT +typedef uint64 x_usb_format; +#else +typedef uint32 x_usb_format; +#endif + #define USB_MAX_DEVICE 0x20 #define USB_MAX_INTERFACE 0x08 #define USB_HUB_PORT_NUM 0x04 diff --git a/Ubiquitous/XiUOS/resources/usb/third_party_usb/usbhost/core/core.c b/Ubiquitous/XiUOS/resources/usb/third_party_usb/usbhost/core/core.c index 783a57e6f..26c594327 100644 --- a/Ubiquitous/XiUOS/resources/usb/third_party_usb/usbhost/core/core.c +++ b/Ubiquitous/XiUOS/resources/usb/third_party_usb/usbhost/core/core.c @@ -491,14 +491,14 @@ x_err_t UsbhClearFeature(UinstPointer device, int endpoint, int feature) x_err_t UsbhGetInterfaceDescriptor(UcfgDescPointer CfgDesc, int num, UintfDescPointer* IntfDesc) { - uint32 ptr, depth = 0; + x_usb_format ptr, depth = 0; UdescPointer desc; NULL_PARAM_CHECK(CfgDesc); - ptr = (uint32)CfgDesc + CfgDesc->bLength; - while(ptr < (uint32)CfgDesc + CfgDesc->wTotalLength) + ptr = (x_usb_format)CfgDesc + CfgDesc->bLength; + while(ptr < (x_usb_format)CfgDesc + CfgDesc->wTotalLength) { if(depth++ > 0x20) { @@ -517,7 +517,7 @@ x_err_t UsbhGetInterfaceDescriptor(UcfgDescPointer CfgDesc, int num, return EOK; } } - ptr = (uint32)desc + desc->bLength; + ptr = (x_usb_format)desc + desc->bLength; } KPrintf("usb_get_interface_descriptor %d failed\n", num); @@ -538,7 +538,7 @@ x_err_t UsbhGetEndpointDescriptor(UintfDescPointer IntfDesc, int num, UepDescPointer* EpDesc) { int count = 0, depth = 0; - uint32 ptr; + x_usb_format ptr; UdescPointer desc; @@ -546,7 +546,7 @@ x_err_t UsbhGetEndpointDescriptor(UintfDescPointer IntfDesc, int num, CHECK(num < IntfDesc->bNumEndpoints); *EpDesc = NONE; - ptr = (uint32)IntfDesc + IntfDesc->bLength; + ptr = (x_usb_format)IntfDesc + IntfDesc->bLength; while(count < IntfDesc->bNumEndpoints) { if(depth++ > 0x20) @@ -567,7 +567,7 @@ x_err_t UsbhGetEndpointDescriptor(UintfDescPointer IntfDesc, int num, } else count++; } - ptr = (uint32)desc + desc->bLength; + ptr = (x_usb_format)desc + desc->bLength; } KPrintf("usb_get_endpoint_descriptor %d failed\n", num); diff --git a/Ubiquitous/XiUOS/resources/usb/third_party_usb/usbhost/core/hub.c b/Ubiquitous/XiUOS/resources/usb/third_party_usb/usbhost/core/hub.c index e2b75cc45..52d2c8121 100644 --- a/Ubiquitous/XiUOS/resources/usb/third_party_usb/usbhost/core/hub.c +++ b/Ubiquitous/XiUOS/resources/usb/third_party_usb/usbhost/core/hub.c @@ -43,13 +43,13 @@ static x_err_t RootHubCtrl(struct uhcd *hcd, uint16 port, uint8 cmd, void *args) switch(cmd) { case RH_GET_PORT_STATUS: - (*(uint32 *)args) = hcd->roothub->PortStatus[port-1]; + (*(x_usb_format *)args) = hcd->roothub->PortStatus[port-1]; break; case RH_SET_PORT_STATUS: - hcd->roothub->PortStatus[port-1] = (*(uint32 *)args); + hcd->roothub->PortStatus[port-1] = (*(x_usb_format *)args); break; case RH_CLEAR_PORT_FEATURE: - switch(((uint32)args)) + switch(((x_usb_format)args)) { case PORT_FEAT_C_CONNECTION: hcd->roothub->PortStatus[port-1] &= ~PORT_CCSC; @@ -69,7 +69,7 @@ static x_err_t RootHubCtrl(struct uhcd *hcd, uint16 port, uint8 cmd, void *args) } break; case RH_SET_PORT_FEATURE: - switch((uint32)args) + switch((x_usb_format)args) { case PORT_FEAT_CONNECTION: hcd->roothub->PortStatus[port-1] |= PORT_CCSC; @@ -222,7 +222,7 @@ x_err_t UsbhHubClearPortFeature(UhubPointer hub, uint16 port, uint16 feature) if(hub->IsRoothub) { RootHubCtrl(hub->hcd, port, RH_CLEAR_PORT_FEATURE, - (void*)(uint32)feature); + (void*)(x_usb_format)feature); return EOK; } @@ -254,7 +254,7 @@ x_err_t UsbhHubSetPortFeature(UhubPointer hub, uint16 port, if(hub->IsRoothub) { RootHubCtrl(hub->hcd, port, RH_SET_PORT_FEATURE, - (void*)(uint32)feature); + (void*)(x_usb_format)feature); return EOK; }