1、fix third_party_usb data format bugs; 2、feat riscv64 usb mount file system function.

it is OK
This commit is contained in:
xuedongliang 2021-12-07 09:52:09 +08:00
commit 1dfb44a706
7 changed files with 46 additions and 16 deletions

View File

@ -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

View File

@ -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 <iot-vfs.h>
#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

View File

@ -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);

View File

@ -109,6 +109,10 @@ struct InitSequenceDesc env_init[] =
{ "MountSDCard", MountSDCard },
#endif
#ifdef MOUNT_USB
{ "MountUSB", MountUSB },
#endif
#ifdef FS_VFS_MNTTABLE
{ "DfsMountTable", DfsMountTable },
#endif

View File

@ -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

View File

@ -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);

View File

@ -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;
}