Hello @KJeps.3
I have raised this issue internally to the dedicated team for fix, (Ticket 227473 This is an internal tracking number and is not accessible or usable by customers.)
As a temporary workaround, I suggest that you copy the generated code of USART from the old project or to add this code manually to stm32u0xx_hal_msp.c :
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
{
.
.
/* Peripheral clock enable */
__HAL_RCC_USART1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/* USER CODE BEGIN USART1_MspInit 1 */
GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* USER CODE END USART1_MspInit 1 */
Also ensure to keep your custom code inside /* USER CODE BEGIN ... */ / /* USER CODE END ... */ so that CubeMX won’t overwrite it.
BR, Souhaib