Opened on 01/02/21 at 14:39:38
Closed on 11/29/22 at 22:51:15
#4209 closed defect (invalid)
STM32H743ZI Nucleo Consle support not working without workaround
Reported by: | rmueller | Owned by: | Joel Sherrill |
---|---|---|---|
Priority: | normal | Milestone: | 6.1 |
Component: | arch/arm | Version: | 6 |
Severity: | normal | Keywords: | stm32 |
Cc: | Blocked By: | ||
Blocking: |
Description
I think here is still some issue with the HUART3 console support, at least for the STM32H743ZI-Nucleo board.
I solves the issue by calling some hardware initializaton functions and override void HAL_UART_MspInit(UART_HandleTypeDef* huart) like this:
#include "hardware_init.h" #include <stm32h7xx_hal_rcc.h> #include <stdio.h> void hardware_init() { MX_USART3_UART_Init(115200); } /** * ST-LINK UART3 * CN5 pins on board */ UART_HandleTypeDef huart3; GPIO_InitTypeDef gpio_uart_init_struct; void MX_USART3_UART_Init(uint32_t baudRate) { __HAL_RCC_USART3_CONFIG(RCC_USART3CLKSOURCE_HSI); __HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_USART3_CLK_ENABLE(); int result; huart3.Instance = USART3; huart3.Init.BaudRate = baudRate; huart3.Init.WordLength = UART_WORDLENGTH_8B; huart3.Init.StopBits = UART_STOPBITS_1; huart3.Init.Parity = UART_PARITY_NONE; huart3.Init.Mode = UART_MODE_TX_RX; huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE; huart3.Init.OverSampling = UART_OVERSAMPLING_16; huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; huart3.Init.ClockPrescaler = UART_PRESCALER_DIV1; //huart3.Init.FIFOMode = UART_FIFOMODE_DISABLE; //huart3.Init.TXFIFOThreshold = UART_TXFIFO_THRESHOLD_1_8; //huart3.Init.RXFIFOThreshold = UART_RXFIFO_THRESHOLD_1_8; huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; // we can't do error handling (simple print out first) here because UART3 is our print interface result = HAL_UART_Init(&huart3); if(result == HAL_OK) { printf("\rUART3 configured successfully!\r\n"); } } // Will be called by HAL_UART_Init void HAL_UART_MspInit(UART_HandleTypeDef* huart) { /*Configure GPIO pins : PD8 PD9 */ gpio_uart_init_struct.Pin = GPIO_PIN_8|GPIO_PIN_9; gpio_uart_init_struct.Mode = GPIO_MODE_AF_PP; gpio_uart_init_struct.Pull = GPIO_NOPULL; gpio_uart_init_struct.Speed = GPIO_SPEED_FREQ_LOW; gpio_uart_init_struct.Alternate = GPIO_AF7_USART3; HAL_GPIO_Init(GPIOD, &gpio_uart_init_struct); }
I then call hardware_init() from my main application and after that, printf is working properly. Maybe the problem is also related to using the Nucleo board?
Kind Regards
Robin
Attachments (5)
Change History (15)
Changed on 01/02/21 at 14:41:11 by rmueller
Attachment: | hardware_init.c added |
---|
Changed on 01/02/21 at 14:42:08 by rmueller
Attachment: | hardware_init.h added |
---|
Hardware init header file
comment:1 Changed on 01/02/21 at 18:33:13 by rmueller
I found the UART config in console-uart3.c
static const stm32h7_uart_config stm32h7_usart3_config = { .gpio = { .regs = GPIOB, .config = { .Pin = GPIO_PIN_9 | GPIO_PIN_10, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_NOPULL, .Speed = GPIO_SPEED_FREQ_LOW, .Alternate = GPIO_AF7_USART3 } }, .irq = USART3_IRQn, .device_index = 2 };
and tried to replace it with this:
static const stm32h7_uart_config stm32h7_usart3_config = { .gpio = { .regs = GPIOD, .config = { .Pin = GPIO_PIN_8 | GPIO_PIN_9, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_NOPULL, .Speed = GPIO_SPEED_FREQ_LOW, .Alternate = GPIO_AF7_USART3 } }, .irq = USART3_IRQn, .device_index = 2 };
Recompiled the BSP but it still is not working without the workaround from above. If I call printf, the function also never exits and something appears to be broken.. I don't really know why..
comment:2 Changed on 01/03/21 at 10:14:39 by Sebastian Huber
The clocks are not initialized by the current console driver.
For a custom board initialization, you can provide the data structures defined in bsps/arm/stm32h7/start/stm32h7-config.c in your application configuration.
Changed on 01/04/21 at 15:16:22 by rmueller
Attachment: | nucleo-stm32.patch added |
---|
STM32H732ZINucleo patch
comment:3 Changed on 01/04/21 at 15:19:13 by rmueller
Thanks, it works now. I am not sure, maybe I did not rebuild the BSP properly.
I supplied a patch for this particular STM32H7 board configuration so users just
have to set an option in config.ini to true for the STM32H743ZI-Nucleo board.
Kind Regards
Robin
Changed on 01/05/21 at 22:50:06 by rmueller
Attachment: | nucleo-stm32-patch2.patch added |
---|
And yet it was another wrong file. This is the correct one.
Changed on 01/06/21 at 11:46:55 by rmueller
Attachment: | stm32h7-doc.patch added |
---|
Updated documentation.
comment:6 Changed on 09/08/22 at 14:31:42 by Sebastian Huber
There were some updates to the BSP. Is this issue still open?
comment:7 Changed on 11/29/22 at 22:25:20 by Chris Johns
Component: | admin → arch/arm |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Closing as the patches have not been applied.
If these changes are still valid please reopen and apply the attached patches.
comment:8 Changed on 11/29/22 at 22:44:32 by Chris Johns
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Te patches have been confirmed as suitable to be applied.
comment:9 Changed on 11/29/22 at 22:44:50 by Chris Johns
Owner: | changed from Sebastian Huber to Joel Sherrill |
---|---|
Status: | reopened → assigned |
comment:10 Changed on 11/29/22 at 22:51:15 by Joel Sherrill
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
Neither patch is applying cleanly for me. Please update them, reopen the ticket, and attach them.
Hardware Init source file