Main Site Documentation

Help needed porting TinyCLR to Disco-STM32F429ZI


#1

Just to help my son for a university examination, I need to port TinyCLR to a Disco-STM32F429ZI.
I’ve done the porting very easy and now it is working fine. No display code for the moment.
But I’ve a very stupid problem I can’t figure out why… The board has microusb port connected to OTG_HS (pin on port B) and not standard OTG_FS (on Port A).

#ifdef OTG_USE_HS
#define STM32F4_USB_DM_PINS { { PIN(B, 14), AF(12) } }
#define STM32F4_USB_DP_PINS { { PIN(B, 15), AF(12) } }
#define STM32F4_USB_VB_PINS { { PIN(B, 13), AF(12) } }
#define STM32F4_USB_ID_PINS { { PIN(B, 12), AF(12) } }
#else
#define STM32F4_USB_DM_PINS { { PIN(A, 11), AF(10) } }
#define STM32F4_USB_DP_PINS { { PIN(A, 12), AF(10) } }
#define STM32F4_USB_VB_PINS { { PIN(A,  9), AF(10) } }
#define STM32F4_USB_ID_PINS { { PIN(A, 10), AF(10) } }
#endif // OTG_USE_HS

The code is rearranged to accomodate OTG_HS instead of FS for the small modifications needed to setup it. The HS USB port is working fine, I can distribute code to board from VS2107, but I can’t debug code. As soon program start in VS the HS usb detach from windows and it shows “USB device not recognized”. Then resetting the discovery board the program deployed start normally and HS USB become normal.
This means probably a crash of TinyCLR. Obviously if I compile for OTG FS and attaching an usb connector to FS port everything works fine.
Someone has just some experience with OTG HS port and difference from OTG FS?
I coudn’t find any diff in registers used by TinyCLR reading STM32F4xx datasheet.


#2

@dobova hope this picture will help

check this link


#3

Hi @valon_hoti_gmail_com
Thanks for you help, but I have lof of that tables… :disappointed_relieved:
The USB HS is working fine until starting debug in VS. This not happens when I use standard USB FS. It is very difficult to find the (minimal) difference between the two USB controllers and probably I need to set some more bit in some register for HS but at the moment I really can’t find it.
I’m looking in the interrupt management code, may be there something go wrong.


#4

you should decide which ones to use another to keep as UART Only

or leave both as uart and use default ST-LINK (USB COnnector for Debug-Deploy)

#define UART_DEBUGGER_INDEX 1
#define USB_DEBUGGER_INDEX 0

if you have STM32F429I-DISC1 ( STM32F429I-DISC have no virtual com)

//USB pins

USB_OTG_FS_SOF = PA_8,
USB_OTG_FS_VBUS = PA_9,
USB_OTG_FS_ID = PA_10,
USB_OTG_FS_DM = PA_11,
USB_OTG_FS_DP = PA_12,

USB_OTG_HS_SOF = PA_4,
USB_OTG_HS_VBUS = PB_13,
USB_OTG_HS_ID = PB_12,
USB_OTG_HS_DM = PB_14,
USB_OTG_HS_DP = PB_15,


USB_OTG_HS_ULPI_D1 = PB_0,
USB_OTG_HS_ULPI_D2 = PB_1,
USB_OTG_HS_ULPI_D7 = PB_5,
USB_OTG_HS_ULPI_D3 = PB_10,
USB_OTG_HS_ULPI_D4 = PB_11,
USB_OTG_HS_ULPI_D5 = PB_12,
USB_OTG_HS_ULPI_D6 = PB_13,
USB_OTG_HS_ULPI_D0 = PA_3,  
USB_OTG_HS_ULPI_CK = PA_5,  
USB_OTG_HS_ULPI_STP = PC_0,
USB_OTG_HS_ULPI_DIR = PC_2,
USB_OTG_HS_ULPI_NXT = PC_3,

#5

Thank you again. I will check tomorrow, but the debugger index can be the issue.!


#6

No success with USB HS. I noted that if I use “Erase App” from TinyCLR Config than USB HS stop working.


#7

How about if use “Reboot” feature from TinyCLR Config?


#8

are you want to use HS or FS !!!
so i belive is enough to use only those part if not used FS

#define STM32F4_USB_DM_PINS { { PIN(B, 14), AF(10) } }
#define STM32F4_USB_DP_PINS { { PIN(B, 15), AF(10) } }
#define STM32F4_USB_VB_PINS { { PIN(B, 13), AF(10) } }
#define STM32F4_USB_ID_PINS { { PIN(B, 12), AF(10) } }

and to define pulldown for pines that are not used for USB HS more on the part (example belove was part from Nucleo)

#define STM32F4_GPIO_PINS {/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
/PAx/ DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(),
/PBx/ DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(),
/PCx/ DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(),
/PDx/ DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(), DEFAULT(),
}


#9

Below is not all, but at least you should consider to change:

#define OTG_FS_BASE           (0x50000000)
#define OTG_FS                ((OTG_TypeDef *) OTG_FS_BASE)

STM32F4_InterruptInternal_Activate(OTG_FS_IRQn, (uint32_t*)&STM32F4_UsbClient_FullspeedInterrupt, 0);
STM32F4_InterruptInternal_Activate(OTG_FS_WKUP_IRQn, (uint32_t*)&STM32F4_UsbClient_FullspeedInterrupt, 0);

Beside,
Register RCC->AHB1ENR, Bit 29 to enable HS clock, enable bit 30 if PHY is used

Also GUSBCFG register to set HS or FS, PHY… Just a note here bit 6 on this register need to be clear if PHY is used, otherwise bit 6 need to be set.

Try force to FS first to see if it is OK. But if there is PHY exist on the board, recommend should use PHY interface.


#10

Hi @Dat_Tran and @valon_hoti_gmail_com, I made the change required. The discovery board has micro-usb for USB HS in FS mode (internal PHY, no ULPI).
I changed the call InterruptInternal to OTG_HS_IRQn and to OTG_HS_WKUP_IRQn, I activated HS clock in with bit RCC_AHB1ENR_OTGHSEN in RCC->AHB1ENR and set OTG_GUSBCFG_PHYSEL in the GUSBCFG reg.
Of course I changed PIN to HS port B af(12) instead of FS port A af(10). OTG_BASE memory area is declared at 0x40040000 for HS instead of 0x50000000 for FS.
Reading ref for stm32f4 and errata I can’t find no difference for device mode between the two port…:sob: but probably I’m doing something wrong.


#11

Fixed the problem on Disco-F429 OTG HS, and now it works fine also on the OTG HS, so the embedded micro-usb connector can be used to debug&deploy.