update(cherryusb): add config for hpm6750 usbdev and usbhost

This commit is contained in:
sakumisu 2024-09-01 11:02:53 +08:00 committed by Meco Man
parent 9511e4bd19
commit f7de9de7dd
8 changed files with 102 additions and 224 deletions

View File

@ -128,7 +128,6 @@ CONFIG_RT_USING_DFS_DEVFS=y
# CONFIG_RT_USING_DFS_RAMFS is not set
# CONFIG_RT_USING_DFS_TMPFS is not set
# CONFIG_RT_USING_DFS_MQUEUE is not set
# CONFIG_RT_USING_DFS_NFS is not set
# end of DFS: device virtual file system
# CONFIG_RT_USING_FAL is not set
@ -179,41 +178,7 @@ CONFIG_RT_USING_RTC=y
CONFIG_RT_USING_PIN=y
# CONFIG_RT_USING_KTIME is not set
# CONFIG_RT_USING_HWTIMER is not set
CONFIG_RT_USING_CHERRYUSB=y
# CONFIG_RT_CHERRYUSB_DEVICE is not set
CONFIG_RT_CHERRYUSB_HOST=y
# CONFIG_RT_CHERRYUSB_HOST_CUSTOM is not set
# CONFIG_RT_CHERRYUSB_HOST_EHCI_BL is not set
CONFIG_RT_CHERRYUSB_HOST_EHCI_HPM=y
# CONFIG_RT_CHERRYUSB_HOST_EHCI_AIC is not set
# CONFIG_RT_CHERRYUSB_HOST_EHCI_NUVOTON_NUC980 is not set
# CONFIG_RT_CHERRYUSB_HOST_EHCI_NUVOTON_MA35D0 is not set
# CONFIG_RT_CHERRYUSB_HOST_EHCI_CUSTOM is not set
# CONFIG_RT_CHERRYUSB_HOST_DWC2_ST is not set
# CONFIG_RT_CHERRYUSB_HOST_DWC2_ESP is not set
# CONFIG_RT_CHERRYUSB_HOST_DWC2_CUSTOM is not set
# CONFIG_RT_CHERRYUSB_HOST_MUSB_ES is not set
# CONFIG_RT_CHERRYUSB_HOST_MUSB_SUNXI is not set
# CONFIG_RT_CHERRYUSB_HOST_MUSB_BK is not set
# CONFIG_RT_CHERRYUSB_HOST_MUSB_CUSTOM is not set
# CONFIG_RT_CHERRYUSB_HOST_PUSB2 is not set
# CONFIG_RT_CHERRYUSB_HOST_XHCI is not set
CONFIG_RT_CHERRYUSB_HOST_CDC_ACM=y
CONFIG_RT_CHERRYUSB_HOST_HID=y
# CONFIG_RT_CHERRYUSB_HOST_MSC is not set
# CONFIG_RT_CHERRYUSB_HOST_CDC_ECM is not set
# CONFIG_RT_CHERRYUSB_HOST_CDC_RNDIS is not set
# CONFIG_RT_CHERRYUSB_HOST_CDC_NCM is not set
# CONFIG_RT_CHERRYUSB_HOST_VIDEO is not set
# CONFIG_RT_CHERRYUSB_HOST_AUDIO is not set
# CONFIG_RT_CHERRYUSB_HOST_BLUETOOTH is not set
# CONFIG_RT_CHERRYUSB_HOST_ASIX is not set
# CONFIG_RT_CHERRYUSB_HOST_RTL8152 is not set
# CONFIG_RT_CHERRYUSB_HOST_FTDI is not set
# CONFIG_RT_CHERRYUSB_HOST_CH34X is not set
# CONFIG_RT_CHERRYUSB_HOST_CP210X is not set
# CONFIG_RT_CHERRYUSB_HOST_PL2303 is not set
# CONFIG_CHERRYUSB_HOST_TEMPLATE is not set
# CONFIG_RT_USING_CHERRYUSB is not set
# end of Device Drivers
#
@ -242,10 +207,10 @@ CONFIG_RT_USING_POSIX_FS=y
# CONFIG_RT_USING_POSIX_DEVIO is not set
# CONFIG_RT_USING_POSIX_STDIO is not set
CONFIG_RT_USING_POSIX_POLL=y
CONFIG_RT_USING_POSIX_SELECT=y
# CONFIG_RT_USING_POSIX_SELECT is not set
# CONFIG_RT_USING_POSIX_EVENTFD is not set
# CONFIG_RT_USING_POSIX_TIMERFD is not set
CONFIG_RT_USING_POSIX_SOCKET=y
# CONFIG_RT_USING_POSIX_SOCKET is not set
# CONFIG_RT_USING_POSIX_TERMIOS is not set
# CONFIG_RT_USING_POSIX_AIO is not set
# CONFIG_RT_USING_POSIX_MMAN is not set
@ -274,88 +239,9 @@ CONFIG_RT_USING_POSIX_SOCKET=y
#
# Network
#
CONFIG_RT_USING_SAL=y
CONFIG_SAL_INTERNET_CHECK=y
#
# Docking with protocol stacks
#
CONFIG_SAL_USING_LWIP=y
# CONFIG_SAL_USING_AT is not set
# CONFIG_SAL_USING_TLS is not set
# end of Docking with protocol stacks
CONFIG_SAL_USING_POSIX=y
CONFIG_RT_USING_NETDEV=y
CONFIG_NETDEV_USING_IFCONFIG=y
CONFIG_NETDEV_USING_PING=y
CONFIG_NETDEV_USING_NETSTAT=y
CONFIG_NETDEV_USING_AUTO_DEFAULT=y
# CONFIG_NETDEV_USING_LINK_STATUS_CALLBACK is not set
# CONFIG_NETDEV_USING_IPV6 is not set
CONFIG_NETDEV_IPV4=1
CONFIG_NETDEV_IPV6=0
CONFIG_RT_USING_LWIP=y
# CONFIG_RT_USING_LWIP_LOCAL_VERSION is not set
# CONFIG_RT_USING_LWIP141 is not set
# CONFIG_RT_USING_LWIP203 is not set
CONFIG_RT_USING_LWIP212=y
# CONFIG_RT_USING_LWIP_LATEST is not set
CONFIG_RT_USING_LWIP_VER_NUM=0x20102
# CONFIG_RT_USING_LWIP_IPV6 is not set
CONFIG_RT_LWIP_MEM_ALIGNMENT=4
CONFIG_RT_LWIP_IGMP=y
CONFIG_RT_LWIP_ICMP=y
# CONFIG_RT_LWIP_SNMP is not set
CONFIG_RT_LWIP_DNS=y
CONFIG_RT_LWIP_DHCP=y
CONFIG_IP_SOF_BROADCAST=1
CONFIG_IP_SOF_BROADCAST_RECV=1
#
# Static IPv4 Address
#
CONFIG_RT_LWIP_IPADDR="192.168.1.30"
CONFIG_RT_LWIP_GWADDR="192.168.1.1"
CONFIG_RT_LWIP_MSKADDR="255.255.255.0"
# end of Static IPv4 Address
CONFIG_RT_LWIP_UDP=y
CONFIG_RT_LWIP_TCP=y
CONFIG_RT_LWIP_RAW=y
# CONFIG_RT_LWIP_PPP is not set
CONFIG_RT_MEMP_NUM_NETCONN=8
CONFIG_RT_LWIP_PBUF_NUM=16
CONFIG_RT_LWIP_RAW_PCB_NUM=4
CONFIG_RT_LWIP_UDP_PCB_NUM=4
CONFIG_RT_LWIP_TCP_PCB_NUM=4
CONFIG_RT_LWIP_TCP_SEG_NUM=40
CONFIG_RT_LWIP_TCP_SND_BUF=8196
CONFIG_RT_LWIP_TCP_WND=8196
CONFIG_RT_LWIP_TCPTHREAD_PRIORITY=10
CONFIG_RT_LWIP_TCPTHREAD_MBOX_SIZE=8
CONFIG_RT_LWIP_TCPTHREAD_STACKSIZE=1024
CONFIG_LWIP_NO_RX_THREAD=y
# CONFIG_LWIP_NO_TX_THREAD is not set
CONFIG_RT_LWIP_ETHTHREAD_PRIORITY=12
CONFIG_RT_LWIP_ETHTHREAD_STACKSIZE=1024
CONFIG_RT_LWIP_ETHTHREAD_MBOX_SIZE=8
# CONFIG_RT_LWIP_REASSEMBLY_FRAG is not set
CONFIG_LWIP_NETIF_STATUS_CALLBACK=1
CONFIG_LWIP_NETIF_LINK_CALLBACK=1
CONFIG_RT_LWIP_NETIF_NAMESIZE=6
CONFIG_SO_REUSE=1
CONFIG_LWIP_SO_RCVTIMEO=1
CONFIG_LWIP_SO_SNDTIMEO=1
CONFIG_LWIP_SO_RCVBUF=1
CONFIG_LWIP_SO_LINGER=0
# CONFIG_RT_LWIP_NETIF_LOOPBACK is not set
CONFIG_LWIP_NETIF_LOOPBACK=0
# CONFIG_RT_LWIP_STATS is not set
# CONFIG_RT_LWIP_USING_HW_CHECKSUM is not set
CONFIG_RT_LWIP_USING_PING=y
# CONFIG_LWIP_USING_DHCPD is not set
# CONFIG_RT_LWIP_DEBUG is not set
# CONFIG_RT_USING_SAL is not set
# CONFIG_RT_USING_NETDEV is not set
# CONFIG_RT_USING_LWIP is not set
# CONFIG_RT_USING_AT is not set
# end of Network
@ -456,19 +342,7 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_PKG_USING_COAP is not set
# CONFIG_PKG_USING_NOPOLL is not set
CONFIG_PKG_USING_NETUTILS=y
CONFIG_PKG_NETUTILS_PATH="/packages/iot/netutils"
# CONFIG_PKG_NETUTILS_TFTP is not set
CONFIG_PKG_NETUTILS_IPERF=y
CONFIG_IPERF_THREAD_STACK_SIZE=2048
# CONFIG_PKG_NETUTILS_NETIO is not set
# CONFIG_PKG_NETUTILS_NTP is not set
# CONFIG_PKG_NETUTILS_TELNET is not set
# CONFIG_PKG_NETUTILS_TCPDUMP is not set
CONFIG_PKG_USING_NETUTILS_LATEST_VERSION=y
# CONFIG_PKG_USING_NETUTILS_V133 is not set
CONFIG_PKG_NETUTILS_VER="latest"
CONFIG_PKG_NETUTILS_VER_NUM=0x99999
# CONFIG_PKG_USING_NETUTILS is not set
# CONFIG_PKG_USING_CMUX is not set
# CONFIG_PKG_USING_PPP_DEVICE is not set
# CONFIG_PKG_USING_AT_DEVICE is not set
@ -560,6 +434,7 @@ CONFIG_PKG_NETUTILS_VER_NUM=0x99999
# CONFIG_PKG_USING_JSMN is not set
# CONFIG_PKG_USING_AGILE_JSMN is not set
# CONFIG_PKG_USING_PARSON is not set
# CONFIG_PKG_USING_RYAN_JSON is not set
# end of JSON: JavaScript Object Notation, a lightweight data-interchange format
#
@ -770,6 +645,8 @@ CONFIG_PKG_NETUTILS_VER_NUM=0x99999
#
# STM32 HAL & SDK Drivers
#
# CONFIG_PKG_USING_STM32F4_HAL_DRIVER is not set
# CONFIG_PKG_USING_STM32F4_CMSIS_DRIVER is not set
# CONFIG_PKG_USING_STM32L4_HAL_DRIVER is not set
# CONFIG_PKG_USING_STM32L4_CMSIS_DRIVER is not set
# CONFIG_PKG_USING_STM32WB55_SDK is not set
@ -963,6 +840,7 @@ CONFIG_PKG_NETUTILS_VER_NUM=0x99999
# CONFIG_PKG_USING_SYSTEM_RUN_LED is not set
# CONFIG_PKG_USING_BT_MX01 is not set
# CONFIG_PKG_USING_RGPOWER is not set
# CONFIG_PKG_USING_BT_MX02 is not set
# CONFIG_PKG_USING_SPI_TOOLS is not set
# end of peripheral libraries and drivers
@ -1072,6 +950,7 @@ CONFIG_PKG_NETUTILS_VER_NUM=0x99999
# CONFIG_PKG_USING_ARDUINO_MSGQ_C_CPP_DEMO is not set
# CONFIG_PKG_USING_ARDUINO_SKETCH_LOADER_DEMO is not set
# CONFIG_PKG_USING_ARDUINO_ULTRASOUND_RADAR is not set
# CONFIG_PKG_USING_ARDUINO_RTDUINO_SENSORFUSION_SHIELD is not set
# CONFIG_PKG_USING_ARDUINO_NINEINONE_SENSOR_SHIELD is not set
# CONFIG_PKG_USING_ARDUINO_SENSOR_KIT is not set
# CONFIG_PKG_USING_ARDUINO_MATLAB_SUPPORT is not set
@ -1328,9 +1207,7 @@ CONFIG_BSP_USING_RTC=y
# CONFIG_BSP_USING_DAO is not set
# CONFIG_BSP_USING_PDM is not set
# CONFIG_BSP_USING_I2S is not set
CONFIG_BSP_USING_USB=y
CONFIG_BSP_USING_USB_DEVICE=y
# CONFIG_BSP_USING_USB_HOST is not set
# CONFIG_BSP_USING_USB is not set
# CONFIG_BSP_USING_WDG is not set
# CONFIG_BSP_USING_CAN is not set
# CONFIG_BSP_USING_ADC is not set

View File

@ -361,12 +361,25 @@ menu "On-chip Peripheral Drivers"
default n
if BSP_USING_USB
config BSP_USING_USB_DEVICE
bool "Enable USB Device"
bool "Enable USB Device, default is msc ramdisk"
default n
select RT_USING_CHERRYUSB
select RT_CHERRYUSB_DEVICE
select RT_CHERRYUSB_DEVICE_SPEED_HS
select RT_CHERRYUSB_DEVICE_HPM
select RT_CHERRYUSB_DEVICE_MSC
select RT_CHERRYUSB_DEVICE_TEMPLATE_MSC
config BSP_USING_USB_HOST
bool "Enable USB Host"
select RT_USING_CACHE
default n
select RT_USING_CACHE
select RT_USING_CHERRYUSB
select RT_CHERRYUSB_HOST
select RT_CHERRYUSB_HOST_EHCI_HPM
select RT_CHERRYUSB_HOST_CDC_ACM
select RT_CHERRYUSB_HOST_HID
select RT_CHERRYUSB_HOST_MSC
select RT_CHERRYUSB_HOST_CDC_RNDIS
endif

View File

@ -8,6 +8,7 @@ src = Split("""
rtt_board.c
pinmux.c
fal_flash_port.c
cherryusb_port.c
hpm_wm8960.c
""")

View File

@ -8,7 +8,34 @@
* 2024/04/23 sakumisu first version
*/
#include <rtthread.h>
#include <board.h>
/* low level init here, this has implemented in cherryusb */
/* low level deinit here, this has implemented in cherryusb */
#ifdef RT_CHERRYUSB_DEVICE_TEMPLATE_MSC
int cherryusb_devinit(void)
{
extern void msc_ram_init(uint8_t busid, uintptr_t reg_base);
board_init_usb_pins();
msc_ram_init(0, HPM_USB0_BASE);
return 0;
}
INIT_COMPONENT_EXPORT(cherryusb_devinit);
#endif
#ifdef RT_CHERRYUSB_HOST
#include "usbh_core.h"
int cherryusb_hostinit(void)
{
board_init_usb_pins();
usbh_initialize(0, HPM_USB0_BASE);
return 0;
}
INIT_COMPONENT_EXPORT(cherryusb_hostinit);
#endif

View File

@ -121,3 +121,14 @@ void rt_hw_cpu_reset(void)
}
MSH_CMD_EXPORT_ALIAS(rt_hw_cpu_reset, reset, reset the board);
#ifdef RT_USING_CACHE
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

View File

@ -6,21 +6,13 @@
#ifndef CHERRYUSB_CONFIG_H
#define CHERRYUSB_CONFIG_H
#define CHERRYUSB_VERSION 0x010300
#define CHERRYUSB_VERSION_STR "v1.3.0"
/* ================ USB common Configuration ================ */
#include <rtthread.h>
#include "hpm_soc_feature.h"
/* ================ USB common Configuration ================ */
#define CONFIG_USB_PRINTF(...) rt_kprintf(__VA_ARGS__)
#define usb_malloc(size) rt_malloc(size)
#define usb_free(ptr) rt_free(ptr)
#define memcpy rt_memcpy
#ifndef CONFIG_USB_DBG_LEVEL
#define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
#endif
@ -77,6 +69,10 @@
#define CONFIG_USBDEV_MSC_VERSION_STRING "0.01"
#endif
/* move msc read & write from isr to while(1), you should call usbd_msc_polling in while(1) */
// #define CONFIG_USBDEV_MSC_POLLING
/* move msc read & write from isr to thread */
// #define CONFIG_USBDEV_MSC_THREAD
#ifndef CONFIG_USBDEV_MSC_PRIO
@ -173,6 +169,17 @@
#define CONFIG_USBHOST_CDC_NCM_ETH_MAX_TX_SIZE (2048)
#endif
/* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
* you can change to 2K ~ 16K and must be larger than TCP RX windows size in order to avoid being overflow.
*/
#ifndef CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE
#define CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE (2048)
#endif
/* Because lwip do not support multi pbuf at a time, so increasing this variable has no performance improvement */
#ifndef CONFIG_USBHOST_ASIX_ETH_MAX_TX_SIZE
#define CONFIG_USBHOST_ASIX_ETH_MAX_TX_SIZE (2048)
#endif
/* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
* you can change to 2K ~ 16K and must be larger than TCP RX windows size in order to avoid being overflow.
*/
@ -208,7 +215,11 @@
//#define CONFIG_USBDEV_FSDEV_PMA_ACCESS 2 // maybe 1 or 2, many chips may have a difference
/* ---------------- DWC2 Configuration ---------------- */
/* (5 * number of control endpoints + 8) + ((largest USB packet used / 4) + 1 for
* status information) + (2 * number of OUT endpoints) + 1 for Global NAK
*/
// #define CONFIG_USB_DWC2_RXALL_FIFO_SIZE (1024 / 4)
/* IN Endpoints Max packet Size / 4 */
// #define CONFIG_USB_DWC2_TX0_FIFO_SIZE (64 / 4)
// #define CONFIG_USB_DWC2_TX1_FIFO_SIZE (512 / 4)
// #define CONFIG_USB_DWC2_TX2_FIFO_SIZE (64 / 4)
@ -264,4 +275,5 @@
// #define CONFIG_USB_MUSB_SUNXI
#define CONFIG_USB_EHCI_HPMICRO (1)
#endif

View File

@ -96,11 +96,6 @@
#define RT_SERIAL_RB_BUFSZ 64
#define RT_USING_RTC
#define RT_USING_PIN
#define RT_USING_CHERRYUSB
#define RT_CHERRYUSB_HOST
#define RT_CHERRYUSB_HOST_EHCI_HPM
#define RT_CHERRYUSB_HOST_CDC_ACM
#define RT_CHERRYUSB_HOST_HID
/* end of Device Drivers */
/* C/C++ and POSIX layer */
@ -120,8 +115,6 @@
#define RT_USING_POSIX_FS
#define RT_USING_POSIX_POLL
#define RT_USING_POSIX_SELECT
#define RT_USING_POSIX_SOCKET
/* Interprocess Communication (IPC) */
@ -134,66 +127,6 @@
/* Network */
#define RT_USING_SAL
#define SAL_INTERNET_CHECK
/* Docking with protocol stacks */
#define SAL_USING_LWIP
/* end of Docking with protocol stacks */
#define SAL_USING_POSIX
#define RT_USING_NETDEV
#define NETDEV_USING_IFCONFIG
#define NETDEV_USING_PING
#define NETDEV_USING_NETSTAT
#define NETDEV_USING_AUTO_DEFAULT
#define NETDEV_IPV4 1
#define NETDEV_IPV6 0
#define RT_USING_LWIP
#define RT_USING_LWIP212
#define RT_USING_LWIP_VER_NUM 0x20102
#define RT_LWIP_MEM_ALIGNMENT 4
#define RT_LWIP_IGMP
#define RT_LWIP_ICMP
#define RT_LWIP_DNS
#define RT_LWIP_DHCP
#define IP_SOF_BROADCAST 1
#define IP_SOF_BROADCAST_RECV 1
/* Static IPv4 Address */
#define RT_LWIP_IPADDR "192.168.1.30"
#define RT_LWIP_GWADDR "192.168.1.1"
#define RT_LWIP_MSKADDR "255.255.255.0"
/* end of Static IPv4 Address */
#define RT_LWIP_UDP
#define RT_LWIP_TCP
#define RT_LWIP_RAW
#define RT_MEMP_NUM_NETCONN 8
#define RT_LWIP_PBUF_NUM 16
#define RT_LWIP_RAW_PCB_NUM 4
#define RT_LWIP_UDP_PCB_NUM 4
#define RT_LWIP_TCP_PCB_NUM 4
#define RT_LWIP_TCP_SEG_NUM 40
#define RT_LWIP_TCP_SND_BUF 8196
#define RT_LWIP_TCP_WND 8196
#define RT_LWIP_TCPTHREAD_PRIORITY 10
#define RT_LWIP_TCPTHREAD_MBOX_SIZE 8
#define RT_LWIP_TCPTHREAD_STACKSIZE 1024
#define LWIP_NO_RX_THREAD
#define RT_LWIP_ETHTHREAD_PRIORITY 12
#define RT_LWIP_ETHTHREAD_STACKSIZE 1024
#define RT_LWIP_ETHTHREAD_MBOX_SIZE 8
#define LWIP_NETIF_STATUS_CALLBACK 1
#define LWIP_NETIF_LINK_CALLBACK 1
#define RT_LWIP_NETIF_NAMESIZE 6
#define SO_REUSE 1
#define LWIP_SO_RCVTIMEO 1
#define LWIP_SO_SNDTIMEO 1
#define LWIP_SO_RCVBUF 1
#define LWIP_SO_LINGER 0
#define LWIP_NETIF_LOOPBACK 0
#define RT_LWIP_USING_PING
/* end of Network */
/* Memory protection */
@ -240,11 +173,6 @@
/* end of CYW43439 WiFi */
/* end of Wi-Fi */
#define PKG_USING_NETUTILS
#define PKG_NETUTILS_IPERF
#define IPERF_THREAD_STACK_SIZE 2048
#define PKG_USING_NETUTILS_LATEST_VERSION
#define PKG_NETUTILS_VER_NUM 0x99999
/* IoT Cloud */
@ -405,8 +333,6 @@
#define BSP_USING_UART
#define BSP_USING_UART0
#define BSP_USING_RTC
#define BSP_USING_USB
#define BSP_USING_USB_DEVICE
/* end of On-chip Peripheral Drivers */
/* end of Hardware Drivers Config */

View File

@ -121,3 +121,14 @@ void rt_hw_cpu_reset(void)
}
MSH_CMD_EXPORT_ALIAS(rt_hw_cpu_reset, reset, reset the board);
#ifdef RT_USING_CACHE
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