From 8cd31e6be0a894c5e89beebb3ab377d3405fe44e Mon Sep 17 00:00:00 2001 From: sakumisu <1203593632@qq.com> Date: Tue, 26 Dec 2023 20:11:23 +0800 Subject: [PATCH] add check for dwc2 ramsize and ep num --- port/dwc2/usb_dc_dwc2.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/port/dwc2/usb_dc_dwc2.c b/port/dwc2/usb_dc_dwc2.c index 76169b6e..a40d6350 100644 --- a/port/dwc2/usb_dc_dwc2.c +++ b/port/dwc2/usb_dc_dwc2.c @@ -564,6 +564,18 @@ int usb_dc_init(void) USB_LOG_INFO("dwc2 has %d endpoints, default config: %d endpoints\r\n", endpoints, CONFIG_USBDEV_EP_NUM); USB_LOG_INFO("=================================\r\n"); + if (endpoints < CONFIG_USBDEV_EP_NUM) { + USB_LOG_ERR("dwc2 has less endpoints than config, please check\r\n"); + while (1) { + } + } + + if ((hsphy_type == 0) && (CONFIG_USB_DWC2_RAM_SIZE != 1280)) { + USB_LOG_ERR("dwc2 hsphy type is 0, but ram size is not 1280, please check\r\n"); + while (1) { + } + } + USB_OTG_DEV->DCTL |= USB_OTG_DCTL_SDIS; USB_OTG_GLB->GAHBCFG &= ~USB_OTG_GAHBCFG_GINT;