mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-03 14:43:09 +08:00
update(cherryusb): update framework and bugfix
pkgs_test / change (push) Has been skipped
ToolsCI / Tools (push) Has been cancelled
AutoTestCI / components/cpp11 (push) Has been cancelled
AutoTestCI / kernel/atomic (push) Has been cancelled
AutoTestCI / kernel/atomic/riscv64 (push) Has been cancelled
AutoTestCI / kernel/atomic_c11 (push) Has been cancelled
AutoTestCI / kernel/atomic_c11/riscv64 (push) Has been cancelled
AutoTestCI / kernel/device (push) Has been cancelled
AutoTestCI / kernel/ipc (push) Has been cancelled
AutoTestCI / kernel/irq (push) Has been cancelled
AutoTestCI / kernel/mem (push) Has been cancelled
AutoTestCI / kernel/mem/riscv64 (push) Has been cancelled
AutoTestCI / kernel/thread (push) Has been cancelled
AutoTestCI / kernel/timer (push) Has been cancelled
AutoTestCI / rtsmart/aarch64 (push) Has been cancelled
AutoTestCI / rtsmart/arm (push) Has been cancelled
AutoTestCI / rtsmart/riscv64 (push) Has been cancelled
AutoTestCI / components/utest (push) Has been cancelled
RT-Thread BSP Static Build Check / 🔍 Summary of Git Diff Changes (push) Has been cancelled
RT-Thread BSP Static Build Check / ${{ matrix.legs.RTT_BSP }} (push) Has been cancelled
RT-Thread BSP Static Build Check / collect-artifacts (push) Has been cancelled
utest_auto_run / AARCH64-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64 :default.cfg (push) Has been cancelled
utest_auto_run / A9 :default.cfg (push) Has been cancelled
utest_auto_run / A9-smp :default.cfg (push) Has been cancelled
utest_auto_run / RISCV :default.cfg (push) Has been cancelled
pkgs_test / change (push) Has been skipped
ToolsCI / Tools (push) Has been cancelled
AutoTestCI / components/cpp11 (push) Has been cancelled
AutoTestCI / kernel/atomic (push) Has been cancelled
AutoTestCI / kernel/atomic/riscv64 (push) Has been cancelled
AutoTestCI / kernel/atomic_c11 (push) Has been cancelled
AutoTestCI / kernel/atomic_c11/riscv64 (push) Has been cancelled
AutoTestCI / kernel/device (push) Has been cancelled
AutoTestCI / kernel/ipc (push) Has been cancelled
AutoTestCI / kernel/irq (push) Has been cancelled
AutoTestCI / kernel/mem (push) Has been cancelled
AutoTestCI / kernel/mem/riscv64 (push) Has been cancelled
AutoTestCI / kernel/thread (push) Has been cancelled
AutoTestCI / kernel/timer (push) Has been cancelled
AutoTestCI / rtsmart/aarch64 (push) Has been cancelled
AutoTestCI / rtsmart/arm (push) Has been cancelled
AutoTestCI / rtsmart/riscv64 (push) Has been cancelled
AutoTestCI / components/utest (push) Has been cancelled
RT-Thread BSP Static Build Check / 🔍 Summary of Git Diff Changes (push) Has been cancelled
RT-Thread BSP Static Build Check / ${{ matrix.legs.RTT_BSP }} (push) Has been cancelled
RT-Thread BSP Static Build Check / collect-artifacts (push) Has been cancelled
utest_auto_run / AARCH64-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64 :default.cfg (push) Has been cancelled
utest_auto_run / A9 :default.cfg (push) Has been cancelled
utest_auto_run / A9-smp :default.cfg (push) Has been cancelled
utest_auto_run / RISCV :default.cfg (push) Has been cancelled
* update cdc_acm device framework * add host serial device framework * fix dfs read write return type * fix webusb desc len * fix dwc2 h7rs gccfg Signed-off-by: sakumisu <1203593632@qq.com>
This commit is contained in:
1 parent
e57605fa95
commit
61a5710664
18 files changed
+1972
-30
No files matched your search
@@ -123,16 +123,17 @@ if CHERRYUSB
|
||||
prompt "Enable usb mtp device, it is commercial charge"
|
||||
default n
|
||||
|
||||
config CHERRYUSB_DEVICE_DFU
|
||||
bool
|
||||
prompt "Enable usb dfu device"
|
||||
default n
|
||||
|
||||
config CHERRYUSB_DEVICE_ADB
|
||||
bool
|
||||
prompt "Enable usb adb device"
|
||||
default n
|
||||
|
||||
config CHERRYUSB_DEVICE_DFU
|
||||
bool
|
||||
prompt "Enable usb dfu device"
|
||||
default n
|
||||
|
||||
choice
|
||||
prompt "Select usb device template"
|
||||
default CHERRYUSB_DEVICE_TEMPLATE_NONE
|
||||
|
||||
@@ -125,11 +125,21 @@ if RT_USING_CHERRYUSB
|
||||
prompt "Enable usb mtp device, it is commercial charge"
|
||||
default n
|
||||
|
||||
config RT_CHERRYUSB_DEVICE_ADB
|
||||
bool
|
||||
prompt "Enable usb adb device"
|
||||
default n
|
||||
|
||||
config RT_CHERRYUSB_DEVICE_DFU
|
||||
bool
|
||||
prompt "Enable usb dfu device"
|
||||
default n
|
||||
|
||||
config RT_CHERRYUSB_DEVICE_CDC_ACM_CHARDEV
|
||||
bool
|
||||
prompt "Enable chardev for cdc acm device"
|
||||
default n
|
||||
|
||||
choice
|
||||
prompt "Select usb device template"
|
||||
default RT_CHERRYUSB_DEVICE_TEMPLATE_NONE
|
||||
@@ -169,6 +179,10 @@ if RT_USING_CHERRYUSB
|
||||
bool "winusbv2_cdc"
|
||||
config RT_CHERRYUSB_DEVICE_TEMPLATE_WINUSBV2_HID
|
||||
bool "winusbv2_hid"
|
||||
config RT_CHERRYUSB_DEVICE_TEMPLATE_ADB
|
||||
bool "adb"
|
||||
config RT_CHERRYUSB_DEVICE_TEMPLATE_CDC_ACM_CHARDEV
|
||||
bool "cdc_acm_chardev"
|
||||
endchoice
|
||||
|
||||
config CONFIG_USBDEV_MSC_BLOCK_DEV_NAME
|
||||
|
||||
@@ -124,11 +124,21 @@ if PKG_USING_CHERRYUSB
|
||||
prompt "Enable usb mtp device, it is commercial charge"
|
||||
default n
|
||||
|
||||
config PKG_CHERRYUSB_DEVICE_ADB
|
||||
bool
|
||||
prompt "Enable usb adb device"
|
||||
default n
|
||||
|
||||
config PKG_CHERRYUSB_DEVICE_DFU
|
||||
bool
|
||||
prompt "Enable usb dfu device"
|
||||
default n
|
||||
|
||||
config PKG_CHERRYUSB_DEVICE_CDC_ACM_CHARDEV
|
||||
bool
|
||||
prompt "Enable chardev for cdc acm device"
|
||||
default n
|
||||
|
||||
choice
|
||||
prompt "Select usb device template"
|
||||
default PKG_CHERRYUSB_DEVICE_TEMPLATE_NONE
|
||||
@@ -168,6 +178,10 @@ if PKG_USING_CHERRYUSB
|
||||
bool "winusbv2_cdc"
|
||||
config PKG_CHERRYUSB_DEVICE_TEMPLATE_WINUSBV2_HID
|
||||
bool "winusbv2_hid"
|
||||
config PKG_CHERRYUSB_DEVICE_TEMPLATE_ADB
|
||||
bool "adb"
|
||||
config PKG_CHERRYUSB_DEVICE_TEMPLATE_CDC_ACM_CHARDEV
|
||||
bool "cdc_acm_chardev"
|
||||
endchoice
|
||||
|
||||
config CONFIG_USBDEV_MSC_BLOCK_DEV_NAME
|
||||
|
||||
@@ -127,13 +127,17 @@ if GetDepend(['RT_CHERRYUSB_DEVICE']):
|
||||
src += Glob('class/cdc/usbd_cdc_ncm.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_DFU']):
|
||||
src += Glob('class/dfu/usbd_dfu.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_ADB']):
|
||||
src += Glob('class/adb/usbd_adb.c')
|
||||
src += Glob('platform/rtthread/usbd_adb_shell.c')
|
||||
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_CDC_ACM_CHARDEV']):
|
||||
src += Glob('platform/rtthread/usbd_serial.c')
|
||||
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_TEMPLATE_CDC_ACM']):
|
||||
src += Glob('demo/cdc_acm_template.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_TEMPLATE_MSC']):
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_TEMPLATE_MSC']) or GetDepend(['RT_CHERRYUSB_DEVICE_TEMPLATE_MSC_BLKDEV']):
|
||||
src += Glob('demo/msc_ram_template.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_TEMPLATE_MSC_BLKDEV']):
|
||||
src += Glob('platform/rtthread/usbd_msc_blkdev.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_TEMPLATE_HID_MOUSE']):
|
||||
src += Glob('demo/hid_mouse_template.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_TEMPLATE_HID_KEYBOARD']):
|
||||
@@ -162,6 +166,10 @@ if GetDepend(['RT_CHERRYUSB_DEVICE']):
|
||||
src += Glob('demo/winusb2.0_cdc_template.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_TEMPLATE_WINUSBV2_HID']):
|
||||
src += Glob('demo/winusb2.0_hid_template.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_TEMPLATE_ADB']):
|
||||
src += Glob('demo/adb/usbd_adb_template.c')
|
||||
if GetDepend(['RT_CHERRYUSB_DEVICE_TEMPLATE_CDC_ACM_CHARDEV']):
|
||||
src += Glob('demo/cdc_acm_rttchardev_template.c')
|
||||
|
||||
# USB HOST
|
||||
if GetDepend(['RT_CHERRYUSB_HOST']):
|
||||
@@ -285,6 +293,13 @@ if GetDepend(['RT_CHERRYUSB_HOST']):
|
||||
CPPDEFINES+=['TEST_USBH_MSC=0']
|
||||
src += Glob('demo/usb_host.c')
|
||||
|
||||
if GetDepend(['RT_CHERRYUSB_HOST_CDC_ACM']) \
|
||||
or GetDepend(['RT_CHERRYUSB_HOST_FTDI']) \
|
||||
or GetDepend(['RT_CHERRYUSB_HOST_CH34X']) \
|
||||
or GetDepend(['RT_CHERRYUSB_HOST_CP210X']) \
|
||||
or GetDepend(['RT_CHERRYUSB_HOST_PL2303']):
|
||||
src += Glob('platform/rtthread/usbh_serial.c')
|
||||
|
||||
if GetDepend('RT_USING_DFS') and GetDepend(['RT_CHERRYUSB_HOST_MSC']):
|
||||
src += Glob('platform/rtthread/usbh_dfs.c')
|
||||
|
||||
|
||||
@@ -350,6 +350,7 @@ static int usbh_ftdi_connect(struct usbh_hubport *hport, uint8_t intf)
|
||||
switch (version) {
|
||||
case 0x400:
|
||||
ftdi_class->chip_type = FT232B;
|
||||
break;
|
||||
case 0x500:
|
||||
ftdi_class->chip_type = FT2232C;
|
||||
break;
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 42 KiB |
@@ -164,7 +164,7 @@ static const char *string_descriptor_callback(uint8_t speed, uint8_t index)
|
||||
return string_descriptors[index];
|
||||
}
|
||||
|
||||
const struct usb_descriptor msc_bootuf2_descriptor = {
|
||||
const struct usb_descriptor adb_descriptor = {
|
||||
.device_descriptor_callback = device_descriptor_callback,
|
||||
.config_descriptor_callback = config_descriptor_callback,
|
||||
.device_quality_descriptor_callback = device_quality_descriptor_callback,
|
||||
@@ -274,9 +274,16 @@ static void usbd_event_handler(uint8_t busid, uint8_t event)
|
||||
|
||||
static struct usbd_interface intf0;
|
||||
|
||||
#ifdef RT_USING_MSH
|
||||
extern void usbd_adb_shell_init(uint8_t in_ep, uint8_t out_ep);
|
||||
#else
|
||||
extern int shell_init(bool need_login);
|
||||
#endif
|
||||
void cherryadb_init(uint8_t busid, uint32_t reg_base)
|
||||
{
|
||||
#ifdef RT_USING_MSH
|
||||
usbd_adb_shell_init(WINUSB_IN_EP, WINUSB_OUT_EP);
|
||||
#else
|
||||
/* default password is : 12345678 */
|
||||
/* shell_init() must be called in-task */
|
||||
if (0 != shell_init(false)) {
|
||||
@@ -286,7 +293,7 @@ void cherryadb_init(uint8_t busid, uint32_t reg_base)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef CONFIG_USBDEV_ADVANCE_DESC
|
||||
usbd_desc_register(busid, &adb_descriptor);
|
||||
#else
|
||||
@@ -297,4 +304,4 @@ void cherryadb_init(uint8_t busid, uint32_t reg_base)
|
||||
#endif
|
||||
usbd_add_interface(busid, usbd_adb_init_intf(busid, &intf0, WINUSB_IN_EP, WINUSB_OUT_EP));
|
||||
usbd_initialize(busid, reg_base, usbd_event_handler);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -135,7 +135,7 @@ uint8_t USBD_BinaryObjectStoreDescriptor[USBD_BOS_WTOTALLENGTH] = {
|
||||
struct usb_webusb_descriptor webusb_url_desc = {
|
||||
.vendor_code = USBD_WEBUSB_VENDOR_CODE,
|
||||
.string = USBD_WebUSBURLDescriptor,
|
||||
.string_len = USBD_WINUSB_DESC_SET_LEN
|
||||
.string_len = URL_DESCRIPTOR_LENGTH
|
||||
};
|
||||
|
||||
struct usb_msosv2_descriptor msosv2_desc = {
|
||||
|
||||
@@ -18,7 +18,8 @@ lwip support with usb host net class(cdc_ecm/cdc_ncm/cdc_rndis/asix/rtl8152/bl61
|
||||
- DFS support with usb host msc.
|
||||
- lwip support with usb host net class(cdc_ecm/cdc_ncm/cdc_rndis/asix/rtl8152/bl616_wifi).
|
||||
- msh support with lsusb
|
||||
|
||||
- device char support with host cdc_acm/ftdi/ch34x/cp210x/pl2303
|
||||
- shell support with adb
|
||||
|
||||
## Nuttx
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2022 ~ 2025, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "rtthread.h"
|
||||
#include "usb_config.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 2025, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_adb.h"
|
||||
|
||||
#ifndef CONFIG_USBDEV_SHELL_RX_BUFSIZE
|
||||
#define CONFIG_USBDEV_SHELL_RX_BUFSIZE (2048)
|
||||
#endif
|
||||
|
||||
struct usbd_adb_shell {
|
||||
struct rt_device parent;
|
||||
usb_osal_sem_t tx_done;
|
||||
struct rt_ringbuffer rx_rb;
|
||||
rt_uint8_t rx_rb_buffer[CONFIG_USBDEV_SHELL_RX_BUFSIZE];
|
||||
} g_usbd_adb_shell;
|
||||
|
||||
void usbd_adb_notify_shell_read(uint8_t *data, uint32_t len)
|
||||
{
|
||||
rt_ringbuffer_put(&g_usbd_adb_shell.rx_rb, data, len);
|
||||
|
||||
if (g_usbd_adb_shell.parent.rx_indicate) {
|
||||
g_usbd_adb_shell.parent.rx_indicate(&g_usbd_adb_shell.parent, len);
|
||||
}
|
||||
}
|
||||
|
||||
void usbd_adb_notify_write_done(void)
|
||||
{
|
||||
if (g_usbd_adb_shell.tx_done) {
|
||||
usb_osal_sem_give(g_usbd_adb_shell.tx_done);
|
||||
}
|
||||
}
|
||||
|
||||
static rt_err_t usbd_adb_shell_open(struct rt_device *dev, rt_uint16_t oflag)
|
||||
{
|
||||
while (!usb_device_is_configured(0)) {
|
||||
rt_thread_mdelay(10);
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t usbd_adb_shell_close(struct rt_device *dev)
|
||||
{
|
||||
if (g_usbd_adb_shell.tx_done) {
|
||||
usb_osal_sem_give(g_usbd_adb_shell.tx_done);
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_ssize_t usbd_adb_shell_read(struct rt_device *dev,
|
||||
rt_off_t pos,
|
||||
void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
return rt_ringbuffer_get(&g_usbd_adb_shell.rx_rb, (rt_uint8_t *)buffer, size);
|
||||
}
|
||||
|
||||
static rt_ssize_t usbd_adb_shell_write(struct rt_device *dev,
|
||||
rt_off_t pos,
|
||||
const void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
if (!usb_device_is_configured(0)) {
|
||||
return size;
|
||||
}
|
||||
|
||||
if (usbd_adb_can_write() && size) {
|
||||
usb_osal_sem_reset(g_usbd_adb_shell.tx_done);
|
||||
usbd_abd_write(ADB_SHELL_LOALID, buffer, size);
|
||||
usb_osal_sem_take(g_usbd_adb_shell.tx_done, 0xffffffff);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
const static struct rt_device_ops usbd_adb_shell_ops = {
|
||||
NULL,
|
||||
usbd_adb_shell_open,
|
||||
usbd_adb_shell_close,
|
||||
usbd_adb_shell_read,
|
||||
usbd_adb_shell_write,
|
||||
NULL
|
||||
};
|
||||
#endif
|
||||
|
||||
void usbd_adb_shell_init(uint8_t in_ep, uint8_t out_ep)
|
||||
{
|
||||
rt_err_t ret;
|
||||
struct rt_device *device;
|
||||
|
||||
device = &(g_usbd_adb_shell.parent);
|
||||
|
||||
device->type = RT_Device_Class_Char;
|
||||
device->rx_indicate = RT_NULL;
|
||||
device->tx_complete = RT_NULL;
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
device->ops = &usbd_adb_shell_ops;
|
||||
#else
|
||||
device->init = NULL;
|
||||
device->open = usbd_adb_shell_open;
|
||||
device->close = usbd_adb_shell_close;
|
||||
device->read = usbd_adb_shell_read;
|
||||
device->write = usbd_adb_shell_write;
|
||||
device->control = NULL;
|
||||
#endif
|
||||
device->user_data = NULL;
|
||||
|
||||
/* register a character device */
|
||||
ret = rt_device_register(device, "adb-sh", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE);
|
||||
|
||||
#ifdef RT_USING_POSIX_DEVIO
|
||||
/* set fops */
|
||||
device->fops = NULL;
|
||||
#endif
|
||||
|
||||
g_usbd_adb_shell.tx_done = usb_osal_sem_create(0);
|
||||
rt_ringbuffer_init(&g_usbd_adb_shell.rx_rb, g_usbd_adb_shell.rx_rb_buffer, sizeof(g_usbd_adb_shell.rx_rb_buffer));
|
||||
}
|
||||
|
||||
static int adb_enter(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
finsh_set_device("adb-sh");
|
||||
rt_console_set_device("adb-sh");
|
||||
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT(adb_enter, adb_enter);
|
||||
|
||||
static int adb_exit(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
usbd_adb_close(ADB_SHELL_LOALID);
|
||||
|
||||
finsh_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT(adb_exit, adb_exit);
|
||||
File diff suppressed because it is too large.
Load diff
@@ -30,15 +30,15 @@ static rt_err_t rt_udisk_init(rt_device_t dev)
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static ssize_t rt_udisk_read(rt_device_t dev, rt_off_t pos, void *buffer,
|
||||
rt_size_t size)
|
||||
static rt_ssize_t rt_udisk_read(rt_device_t dev, rt_off_t pos, void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
struct usbh_msc *msc_class = (struct usbh_msc *)dev->user_data;
|
||||
int ret;
|
||||
rt_uint8_t *align_buf;
|
||||
|
||||
align_buf = (rt_uint8_t *)buffer;
|
||||
#ifdef RT_USING_CACHE
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
if ((uint32_t)buffer & (CONFIG_USB_ALIGN_SIZE - 1)) {
|
||||
align_buf = rt_malloc_align(size * msc_class->blocksize, CONFIG_USB_ALIGN_SIZE);
|
||||
if (!align_buf) {
|
||||
@@ -53,7 +53,7 @@ static ssize_t rt_udisk_read(rt_device_t dev, rt_off_t pos, void *buffer,
|
||||
rt_kprintf("usb mass_storage read failed\n");
|
||||
return 0;
|
||||
}
|
||||
#ifdef RT_USING_CACHE
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
if ((uint32_t)buffer & (CONFIG_USB_ALIGN_SIZE - 1)) {
|
||||
usb_memcpy(buffer, align_buf, size * msc_class->blocksize);
|
||||
rt_free_align(align_buf);
|
||||
@@ -62,15 +62,15 @@ static ssize_t rt_udisk_read(rt_device_t dev, rt_off_t pos, void *buffer,
|
||||
return size;
|
||||
}
|
||||
|
||||
static ssize_t rt_udisk_write(rt_device_t dev, rt_off_t pos, const void *buffer,
|
||||
rt_size_t size)
|
||||
static rt_ssize_t rt_udisk_write(rt_device_t dev, rt_off_t pos, const void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
struct usbh_msc *msc_class = (struct usbh_msc *)dev->user_data;
|
||||
int ret;
|
||||
rt_uint8_t *align_buf;
|
||||
|
||||
align_buf = (rt_uint8_t *)buffer;
|
||||
#ifdef RT_USING_CACHE
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
if ((uint32_t)buffer & (CONFIG_USB_ALIGN_SIZE - 1)) {
|
||||
align_buf = rt_malloc_align(size * msc_class->blocksize, CONFIG_USB_ALIGN_SIZE);
|
||||
if (!align_buf) {
|
||||
@@ -86,7 +86,7 @@ static ssize_t rt_udisk_write(rt_device_t dev, rt_off_t pos, const void *buffer,
|
||||
rt_kprintf("usb mass_storage write failed\n");
|
||||
return 0;
|
||||
}
|
||||
#ifdef RT_USING_CACHE
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
if ((uint32_t)buffer & (CONFIG_USB_ALIGN_SIZE - 1)) {
|
||||
rt_free_align(align_buf);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -178,7 +178,7 @@ uint32_t usbd_get_dwc2_gccfg_conf(uint32_t reg_base)
|
||||
usb_hsphy_init(25000000U);
|
||||
return (1 << 23); /* Enable USB HS PHY USBx->GCCFG |= USB_OTG_GCCFG_PHYHSEN;*/
|
||||
#elif __has_include("stm32h7rsxx.h")
|
||||
return (1 << 21);
|
||||
return ((1 << 23) | (1 << 24));
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
@@ -205,6 +205,8 @@ uint32_t usbh_get_dwc2_gccfg_conf(uint32_t reg_base)
|
||||
USB_OTG_GLB->GCCFG = (1 << 23);
|
||||
usb_hsphy_init(25000000U);
|
||||
return (1 << 23); /* Enable USB HS PHY USBx->GCCFG |= USB_OTG_GCCFG_PHYHSEN;*/
|
||||
#elif __has_include("stm32h7rsxx.h")
|
||||
return (1 << 25);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
@@ -252,4 +254,4 @@ void usb_dcache_flush(uintptr_t addr, size_t size)
|
||||
{
|
||||
SCB_CleanInvalidateDCache_by_Addr((void *)addr, size);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -324,16 +324,11 @@ static inline void dwc2_chan_transfer(struct usbh_bus *bus, uint8_t ch_num, uint
|
||||
static void dwc2_halt(struct usbh_bus *bus, uint8_t ch_num)
|
||||
{
|
||||
volatile uint32_t ChannelEna = (USB_OTG_HC(ch_num)->HCCHAR & USB_OTG_HCCHAR_CHENA) >> 31;
|
||||
volatile uint32_t HcEpType = (USB_OTG_HC(ch_num)->HCCHAR & USB_OTG_HCCHAR_EPTYP) >> 18;
|
||||
volatile uint32_t SplitEna = (USB_OTG_HC(ch_num)->HCSPLT & USB_OTG_HCSPLT_SPLITEN) >> 31;
|
||||
volatile uint32_t count = 0U;
|
||||
volatile uint32_t value;
|
||||
|
||||
/* In buffer DMA, Channel disable must not be programmed for non-split periodic channels.
|
||||
At the end of the next uframe/frame (in the worst case), the core generates a channel halted
|
||||
and disables the channel automatically. */
|
||||
if ((((USB_OTG_GLB->GAHBCFG & USB_OTG_GAHBCFG_DMAEN) == USB_OTG_GAHBCFG_DMAEN) && (SplitEna == 0U)) &&
|
||||
((ChannelEna == 0U) || (((HcEpType == HCCHAR_ISOC) || (HcEpType == HCCHAR_INTR))))) {
|
||||
if (((USB_OTG_GLB->GAHBCFG & USB_OTG_GAHBCFG_DMAEN) == USB_OTG_GAHBCFG_DMAEN) &&
|
||||
(ChannelEna == 0U)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1397,4 +1392,4 @@ void USBH_IRQHandler(uint8_t busid)
|
||||
USB_OTG_GLB->GINTSTS = USB_OTG_GINTSTS_HCINT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user