rtt更新

This commit is contained in:
2025-01-18 13:25:25 +08:00
parent c6a7554b51
commit d6009a0773
726 changed files with 103376 additions and 6270 deletions

View File

@@ -1,17 +1,13 @@
#include "rtthread.h"
#ifdef PKG_CHERRYUSB_HOST
#ifdef RT_CHERRYUSB_HOST
#ifndef RT_USING_TIMER_SOFT
#error must enable RT_USING_TIMER_SOFT to support timer callback in thread
#endif
#if IDLE_THREAD_STACK_SIZE < 2048
#error "IDLE_THREAD_STACK_SIZE must be greater than 2048"
#endif
#if RT_TIMER_THREAD_STACK_SIZE < 2048
#error "RT_TIMER_THREAD_STACK_SIZE must be greater than 2048"
#error "RT_TIMER_THREAD_STACK_SIZE must be >= 2048"
#endif
#endif

View File

@@ -9,7 +9,7 @@
#include "rtthread.h"
#include <dfs_fs.h>
#define DEV_FORMAT "/sd%c"
#define DEV_FORMAT "/dev/sd%c"
#ifndef CONFIG_USB_DFS_MOUNT_POINT
#define CONFIG_USB_DFS_MOUNT_POINT "/"
@@ -36,17 +36,6 @@ void rt_hw_cpu_dcache_ops(int ops, void *addr, int size)
bflb_l1c_dcache_invalidate_range(addr, size);
}
}
#elif defined(SOC_HPM5000) || defined(SOC_HPM6000)
#include "hpm_l1c_drv.h"
void rt_hw_cpu_dcache_ops(int ops, void *addr, int size)
{
if (ops == RT_HW_CACHE_FLUSH) {
l1c_dc_flush((uint32_t)addr, size);
} else {
l1c_dc_invalidate((uint32_t)addr, size);
}
}
#endif
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t msc_sector[512];
@@ -57,7 +46,7 @@ static rt_err_t rt_udisk_init(rt_device_t dev)
}
static ssize_t rt_udisk_read(rt_device_t dev, rt_off_t pos, void *buffer,
rt_size_t size)
rt_size_t size)
{
struct usbh_msc *msc_class = (struct usbh_msc *)dev->user_data;
int ret;
@@ -96,7 +85,7 @@ static ssize_t rt_udisk_read(rt_device_t dev, rt_off_t pos, void *buffer,
}
static ssize_t rt_udisk_write(rt_device_t dev, rt_off_t pos, const void *buffer,
rt_size_t size)
rt_size_t size)
{
struct usbh_msc *msc_class = (struct usbh_msc *)dev->user_data;
int ret;
@@ -186,15 +175,17 @@ int udisk_init(struct usbh_msc *msc_class)
ret = usbh_msc_scsi_read10(msc_class, 0, msc_sector, 1);
if (ret != RT_EOK) {
rt_kprintf("usb mass_storage read failed\n");
rt_free(dev);
return ret;
}
for (i = 0; i < 16; i++) {
for (i = 0; i < 4; i++) {
/* Get the first partition */
ret = dfs_filesystem_get_partition(&part0, msc_sector, i);
if (ret == RT_EOK) {
rt_kprintf("Found partition %d: type = %d, offet=0x%x, size=0x%x\n",
i, part0.type, part0.offset, part0.size);
break;
} else {
break;
}
@@ -230,6 +221,8 @@ void usbh_msc_run(struct usbh_msc *msc_class)
void usbh_msc_stop(struct usbh_msc *msc_class)
{
struct rt_device *dev;
char name[CONFIG_USBHOST_DEV_NAMELEN];
char mount_point[CONFIG_USBHOST_DEV_NAMELEN];
@@ -237,5 +230,9 @@ void usbh_msc_stop(struct usbh_msc *msc_class)
snprintf(mount_point, CONFIG_USBHOST_DEV_NAMELEN, CONFIG_USB_DFS_MOUNT_POINT, msc_class->sdchar);
dfs_unmount(mount_point);
rt_device_unregister(rt_device_find(name));
dev = rt_device_find(name);
if (dev) {
rt_device_unregister(dev);
rt_free(dev);
}
}

View File

@@ -44,6 +44,10 @@
#error PBUF_POOL_BUFSIZE must be larger than 1600
#endif
#if RT_LWIP_TCPTHREAD_STACKSIZE < 2048
#error RT_LWIP_TCPTHREAD_STACKSIZE must be >= 2048
#endif
// #define CONFIG_USBHOST_PLATFORM_CDC_ECM
// #define CONFIG_USBHOST_PLATFORM_CDC_RNDIS
// #define CONFIG_USBHOST_PLATFORM_CDC_NCM
@@ -118,6 +122,7 @@ static rt_err_t rt_usbh_cdc_ecm_control(rt_device_t dev, int cmd, void *args)
static rt_err_t rt_usbh_cdc_ecm_eth_tx(rt_device_t dev, struct pbuf *p)
{
int ret;
(void)dev;
usbh_lwip_eth_output_common(p, usbh_cdc_ecm_get_eth_txbuf());
ret = usbh_cdc_ecm_eth_output(p->tot_len);
@@ -150,6 +155,8 @@ void usbh_cdc_ecm_run(struct usbh_cdc_ecm *cdc_ecm_class)
void usbh_cdc_ecm_stop(struct usbh_cdc_ecm *cdc_ecm_class)
{
(void)cdc_ecm_class;
eth_device_deinit(&g_cdc_ecm_dev);
}
#endif
@@ -204,6 +211,7 @@ static rt_err_t rt_usbh_rndis_control(rt_device_t dev, int cmd, void *args)
static rt_err_t rt_usbh_rndis_eth_tx(rt_device_t dev, struct pbuf *p)
{
int ret;
(void)dev;
usbh_lwip_eth_output_common(p, usbh_rndis_get_eth_txbuf());
ret = usbh_rndis_eth_output(p->tot_len);
@@ -237,6 +245,8 @@ void usbh_rndis_run(struct usbh_rndis *rndis_class)
void usbh_rndis_stop(struct usbh_rndis *rndis_class)
{
(void)rndis_class;
eth_device_deinit(&g_rndis_dev);
// rt_timer_stop(keep_timer);
// rt_timer_delete(keep_timer);
@@ -273,6 +283,7 @@ static rt_err_t rt_usbh_cdc_ncm_control(rt_device_t dev, int cmd, void *args)
static rt_err_t rt_usbh_cdc_ncm_eth_tx(rt_device_t dev, struct pbuf *p)
{
int ret;
(void)dev;
usbh_lwip_eth_output_common(p, usbh_cdc_ncm_get_eth_txbuf());
ret = usbh_cdc_ncm_eth_output(p->tot_len);
@@ -305,6 +316,8 @@ void usbh_cdc_ncm_run(struct usbh_cdc_ncm *cdc_ncm_class)
void usbh_cdc_ncm_stop(struct usbh_cdc_ncm *cdc_ncm_class)
{
(void)cdc_ncm_class;
eth_device_deinit(&g_cdc_ncm_dev);
}
#endif
@@ -339,6 +352,7 @@ static rt_err_t rt_usbh_asix_control(rt_device_t dev, int cmd, void *args)
static rt_err_t rt_usbh_asix_eth_tx(rt_device_t dev, struct pbuf *p)
{
int ret;
(void)dev;
usbh_lwip_eth_output_common(p, usbh_asix_get_eth_txbuf());
ret = usbh_asix_eth_output(p->tot_len);
@@ -371,6 +385,8 @@ void usbh_asix_run(struct usbh_asix *asix_class)
void usbh_asix_stop(struct usbh_asix *asix_class)
{
(void)asix_class;
eth_device_deinit(&g_asix_dev);
}
#endif
@@ -405,6 +421,7 @@ static rt_err_t rt_usbh_rtl8152_control(rt_device_t dev, int cmd, void *args)
static rt_err_t rt_usbh_rtl8152_eth_tx(rt_device_t dev, struct pbuf *p)
{
int ret;
(void)dev;
usbh_lwip_eth_output_common(p, usbh_rtl8152_get_eth_txbuf());
ret = usbh_rtl8152_eth_output(p->tot_len);
@@ -437,6 +454,8 @@ void usbh_rtl8152_run(struct usbh_rtl8152 *rtl8152_class)
void usbh_rtl8152_stop(struct usbh_rtl8152 *rtl8152_class)
{
(void)rtl8152_class;
eth_device_deinit(&g_rtl8152_dev);
}
#endif