cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429 USB Host

mihnea95rusu
Associate II
Posted on November 01, 2015 at 19:28

Hey guys,

I've been trying to create USB FS host drivers for a vendor-specific device on the STM32F429 Discovery board. So far I've not had any luck getting ANY device (be it from the MSC, HID or Vendor classes) to simply enumerate (which doesn't require any special drivers). I'm just plain stuck. Before you ask, yes there is power on the USB port. I've been using CubeMX to generate the codes and I'm programming using Keil MDK-ARM uVision 5. Initially the main state machine in USBH_Process() (of usb_core.c) would be forever stuck at HOST_IDLE. I fixed this by adding callingUSBH_LL_Connect() in USBH_Start(), as this is the function that seemingly changes the device's status to connected. I've also modified the HOST_DEV_WAIT_FOR_ATTACHMENT state to go to HOST_DEV_ATTACHED, otherwise it would do nothing. Now the state machine gets stuck at HOST_DEV_ATTACHED and every status that returns from deeper within the code is USBH_BUSY. Below is my clock initialisation, as generated by CubeMX. It seems to be OK (HSE is at 8MHz) but maybe the USB speed is not 48MHz. I read of people having had problems with this in the past, but I don't think it's the case here.


void SystemClock_Config(void)

{


RCC_OscInitTypeDef RCC_OscInitStruct;

RCC_ClkInitTypeDef RCC_ClkInitStruct;


__PWR_CLK_ENABLE();


__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);


RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

RCC_OscInitStruct.HSEState = RCC_HSE_ON;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

RCC_OscInitStruct.PLL.PLLM = 8;

RCC_OscInitStruct.PLL.PLLN = 336;

RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

RCC_OscInitStruct.PLL.PLLQ = 7;

HAL_RCC_OscConfig(&RCC_OscInitStruct);


RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1

|RCC_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;

HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);


HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);


HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);


/* SysTick_IRQn interrupt configuration */

HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

}

Please if anyone could help me, I don't know how much hair I have left to pull on this problem...I just want to get a device to enumerate and be able to browse through its enumeration data in the debugger (VID, PID, etc.). #stm32-usb-host-discovery #stm32-usb-host
5 REPLIES 5
mihnea95rusu
Associate II
Posted on November 02, 2015 at 19:42

Has no one ever implemented a USB Host using CubeMX on these devices? :(

Posted on November 02, 2015 at 20:30

Apparently... Forums can be like talking into an empty room some times.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Amel NASRI
ST Employee
Posted on November 10, 2015 at 17:29

Hi rusu.mihnea,

Did you tried to increase the heap size of the generated project?

If you have already increased the heap size and you still facing the enumeration issue, I recommend you have a look to the example available in STM32Cube_FW_F4_V1.9.0\Projects\STM32F429I-Discovery\Applications\USB_Host\FWupgrade_Standalone.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

st140728
Associate II
Posted on November 13, 2015 at 23:18

I'm trying the same on a 32F429I-DISCO board.

From CubeMX I downloaded the latest examples V1.9.0 , and from  Eclipse openSTM32/AC6  imported the Demonstration SW4STM32 files

STM32Cube\Repository\STM32Cube_FW_F4_V1.9.0\Projects\STM32F429I-Discovery\Demonstrations\SW4STM32

and sucessfully built it OK.

It is a USB HOST MSC example, and worked for me.

My target is to be able to do a USB HOST CDC on a F407 - and I also am pulling out a lot of hair

I am starting with known working code structure/environment and modify it to move it to my target board.

I'm struggling with modifying the SW4STM32 structures to make code modifications and introduce serial debug capabilities.

I was at the recent ArmTechCon in Santa Clara, California - which STM had a good stall, and spoke to the software engineer that wrote the code for it. He assured me it should run across all versions of F4xx - F405 F407 F429 etc. so that was reassuring - but still pulling out what is left of my hair  

st140728
Associate II
Posted on November 26, 2015 at 01:33

A friend pointed this out, if using WFI sleep mode.

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Power%20consumption%20without%20low%20power&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=600]https://my.st.com/public/STe2ecommuniti ... tviews=600

The second to the last post in that thread points to a couple of bits and says that we need to 

1 - Clear OTGHSULPILPEN bit in the AHB1LPENR register

2 - Set OTGHSLPEN bit in the AHB1LPENR register

and then the USB HS clock stays enabled when entering WFI sleep mode

It hasn't been implemented in the STM32cubeMX projects I've been using.