Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initialisation setting for USB_OTG_HS as a disable HOST fails to return from init when using FW_H7 v1.11.2. (not so with v1.11.1 #286

Closed
AnthonyGBES opened this issue Apr 4, 2024 · 8 comments
Assignees
Labels
bug Something isn't working cube mx Issue related to the Cube MX tool rather than the firmware published within this repository invalid This doesn't seem right usb USB-related (host or device) issue or pull-request

Comments

@AnthonyGBES
Copy link

Caution
The Issues are strictly limited for the reporting of problem encountered with the software provided in this project.
For any other problem related to the STM32 product, the performance, the hardware characteristics and boards, the tools the environment in general, please post a topic in the ST Community/STM32 MCUs forum

Describe the set-up

  • Custom Board based on stm32H753XI)
  • Keil IDE uVision 5.39 ARMclang compiler 6.21 STM32CubeMX 6.10.0 STCube FW_H7 1.11.2

Describe the bug
Setting up the USB_OTG_HS as host only and as internal Full speed PHY, and setting up the middleware USB_HOST to disabled. The Main() code never returns from MX_USB_OTG_HS_HCD_Init();
This was not the case with FW_H7 1.11.1

How To Reproduce
USB Clock set to 48Mhz via PLL1
enabling the pins for USB_OTG_HS and Set the USB_OTG_HS as host only and as internal Full speed PHY, but leave disabled in the middlewares Test with v1.11.1 and it will continue after function call to MX_USB_OTG_HS_HCD_Init(); (the reason for doing this is we have a HOST port connection there but it is not currently used)

Repeat same setup for v1.11.2 and it won't return from the MX_USB_OTG_HS_HCD_Init(); function.

Additional context
I beleive the problem is it returns HAL_TIMEOUT from the call USB_CoreReset(); in both varients. but the call to USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg) then void the return in HAL_HCD_init() in v1.11.1 and thus it carrys on regardless.

in v1.11.2 it checks the return value and then returns HAL_ERROR and gets caught by the Error_Handler(); within the MX_USB_OTG_HS_HCD_Init();

I suspect the real reason is why the USB_coreReset() is timing out???

Screenshots
If applicable, add screenshots to help explain your problem.

@AnthonyGBES
Copy link
Author

On closer inspection it appears that the STM32CubeMX has not set the __USB_OTG_HS_CLK_ENABLE() in this setup. This maybe the real reason it timesout.

@AnthonyGBES
Copy link
Author

Further Investigation has found STM32CubeMX has not created the HAL_HCD_mspInit() or HAL_HCD_mspDeInit().

When manually coding these it has fixed the problem.

So this should be passed to the STM32CubeMX team to fix as I have noticed there are many posts from people all having related problems to the Timeout issue here

@ALABSTM ALABSTM self-assigned this Apr 5, 2024
@ALABSTM ALABSTM added bug Something isn't working projects Projects-related (demos, applications, examples) issue or pull-request. usb USB-related (host or device) issue or pull-request labels Apr 5, 2024
@ALABSTM ALABSTM added this to To do in stm32cube-mcu-fw-dashboard via automation Apr 5, 2024
@ALABSTM ALABSTM added cube mx Issue related to the Cube MX tool rather than the firmware published within this repository needs clarification Needs clarification from user and removed projects Projects-related (demos, applications, examples) issue or pull-request. labels Apr 5, 2024
@ALABSTM
Copy link
Contributor

ALABSTM commented Apr 8, 2024

Hi @AnthonyGBES,

Thank you for all these helpful details. However, I generated a project using the same configuration as you described and noticed no issue. Both HAL_HCD_MspInit() and HAL_HCD_MspDeInit() have been generated in the stm32h7xx_hal_msp.c file as you can see below. I used version 6.10.0 of CubeMX and version 1.11.2 of the STM32CubeH7 firmware.

Would you mind double-checking please? Otherwise, please let me know in case I missed somehting.

image

Below the configuration I used:

  • USB OTG HS peripheral internal PHY FS Host Only,
  • USB Host Middleware Disabled.

image

image

With regards,

@ALABSTM ALABSTM moved this from To do to Analyzed in stm32cube-mcu-fw-dashboard Apr 8, 2024
@AnthonyGBES
Copy link
Author

AnthonyGBES commented Apr 8, 2024

Do you also have generate separate .c/.h files set?

When this is the case the MX_XXX_Init() and HAL_XXX_MspInit() functions are usually created in these seperate .c/.h files not the stm32h7xx_hal_msp.c. In this USB setup case it creates usb_otg_hs.c which has the MX_USB_OTG_HS_HCD_Init() but not the HAL_XXX_MspInit()/HAL_HCD_MspDeInit() functions.

All the other modules seem correct and have both sets of functions UART, QSPI, ,LTDC etc.

image

Here's the sum total of my stm32h7xx_hal_msp.c file and below that the /* USER CODE BEGIN Header */

/* USER CODE BEGIN Header /
/
*


  • @file stm32h7xx_hal_msp.c
  • @brief This file provides code for the MSP Initialization
  •           and de-Initialization codes.
    

  • @attention
  • Copyright (c) 2024 STMicroelectronics.
  • All rights reserved.
  • This software is licensed under terms that can be found in the LICENSE file
  • in the root directory of this software component.
  • If no LICENSE file comes with this software, it is provided AS-IS.

/
/
USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------/
/
USER CODE BEGIN TD */

/* USER CODE END TD */

/* Private define ------------------------------------------------------------/
/
USER CODE BEGIN Define */

/* USER CODE END Define */

/* Private macro -------------------------------------------------------------/
/
USER CODE BEGIN Macro */

/* USER CODE END Macro */

/* Private variables ---------------------------------------------------------/
/
USER CODE BEGIN PV */

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------/
/
USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* External functions --------------------------------------------------------/
/
USER CODE BEGIN ExternalFunctions */

/* USER CODE END ExternalFunctions */

/* USER CODE BEGIN 0 */

/* USER CODE END 0 /
/
*

  • Initializes the Global MSP.
    /
    void HAL_MspInit(void)
    {
    /
    USER CODE BEGIN MspInit 0 */

/* USER CODE END MspInit 0 */

__HAL_RCC_SYSCFG_CLK_ENABLE();

HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_3);

/* System interrupt init*/
/* SVCall_IRQn interrupt configuration /
HAL_NVIC_SetPriority(SVCall_IRQn, 6, 0);
/
PendSV_IRQn interrupt configuration */
HAL_NVIC_SetPriority(PendSV_IRQn, 7, 0);

/** Enable the VREF clock
*/
__HAL_RCC_VREF_CLK_ENABLE();

/** Disable the Internal Voltage Reference buffer
*/
HAL_SYSCFG_DisableVREFBUF();

/** Configure the internal voltage reference buffer high impedance mode
*/
HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE);

/* USER CODE BEGIN MspInit 1 */

/* USER CODE END MspInit 1 */
}

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

This is the generated usb_otg_hs.c i have
/**


  • @file usb_otg_hs.c
  • @brief This file provides code for the configuration
  •      of the USB_OTG_HS instances.
    

  • @attention
  • Copyright (c) 2024 STMicroelectronics.
  • All rights reserved.
  • This software is licensed under terms that can be found in the LICENSE file
  • in the root directory of this software component.
  • If no LICENSE file comes with this software, it is provided AS-IS.

/
/
USER CODE END Header /
/
Includes ------------------------------------------------------------------*/
#include "usb_otg_hs.h"

/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

HCD_HandleTypeDef hhcd_USB_OTG_HS;

/* USB_OTG_HS init function */

void MX_USB_OTG_HS_HCD_Init(void)
{

/* USER CODE BEGIN USB_OTG_HS_Init 0 */

/* USER CODE END USB_OTG_HS_Init 0 */

/* USER CODE BEGIN USB_OTG_HS_Init 1 */

/* USER CODE END USB_OTG_HS_Init 1 /
hhcd_USB_OTG_HS.Instance = USB_OTG_HS;
hhcd_USB_OTG_HS.Init.Host_channels = 16;
hhcd_USB_OTG_HS.Init.speed = HCD_SPEED_FULL;
hhcd_USB_OTG_HS.Init.dma_enable = DISABLE;
hhcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY;
hhcd_USB_OTG_HS.Init.Sof_enable = DISABLE;
hhcd_USB_OTG_HS.Init.low_power_enable = DISABLE;
hhcd_USB_OTG_HS.Init.use_external_vbus = DISABLE;
if (HAL_HCD_Init(&hhcd_USB_OTG_HS) != HAL_OK)
{
Error_Handler();
}
/
USER CODE BEGIN USB_OTG_HS_Init 2 */

/* USER CODE END USB_OTG_HS_Init 2 */

}

@ALABSTM
Copy link
Contributor

ALABSTM commented Apr 29, 2024

Hi @AnthonyGBES,

I regenerated my project after having ticket the option Generate ... as pair of '.c/.h' ... and I still get both HAL_HCD_MspInit() and HAL_HCD_MspDeInit() functions, but this time within a dedicated file named usb_otg.c, as you can see below.

It could be that you have ticked some other option at some moment, which causes this unwanted behavior. May I suggest that you restart creating a new IOC file from scratch with the tool's default options? Please keep me informed.

image

With regards,

@ALABSTM ALABSTM moved this from Analyzed to In progress in stm32cube-mcu-fw-dashboard Apr 29, 2024
@ALABSTM
Copy link
Contributor

ALABSTM commented May 2, 2024

Hi @AnthonyGBES,

I hope my previous comment is useful and you can easily overcome the issue you are facing. As suggested, it could be that you have ticked some other option at some moment, which causes this unwanted behavior.

Please allow me to close this thread. Thank you for your comprehension.

With regards,

@ALABSTM ALABSTM closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2024
stm32cube-mcu-fw-dashboard automation moved this from In progress to Done May 2, 2024
@ALABSTM ALABSTM added invalid This doesn't seem right and removed needs clarification Needs clarification from user labels May 2, 2024
@AnthonyGBES
Copy link
Author

AnthonyGBES commented May 2, 2024 via email

@ALABSTM
Copy link
Contributor

ALABSTM commented May 6, 2024

Hi @AnthonyGBES,

Really sorry to read that. Best of luck to update your project. Just one question about this sentence you wrote:

As all the user code sections will need redoing.

Could you be more precise please? I guess your user code is correctly placed between the different /* USER CODE BEGIN ... */ and /* USER CODE END ... */ sections so it is regenerated along with the rest of the project each time.

With regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cube mx Issue related to the Cube MX tool rather than the firmware published within this repository invalid This doesn't seem right usb USB-related (host or device) issue or pull-request
Projects
Development

No branches or pull requests

2 participants