Skip to content

Fix build for STM32C051xx boards #2791

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

nessotrin
Copy link

Summary

This PR adds the ability to compile for STM32C051xx based boards. Most of the infrastructure was already there.
The STM32C051xx is a recently upgraded version of the STM32C031xx with 2x more flash.

  • Add ldscript (direct copy from STM32C031xx)
  • Fix #ifdef missing the STM32C051xx

The link script still mentions the STM32C031CxTx. Since it is auto-generated I chose to leave it as is. Someone with STM32CubeIDE could generate a new one, but I suspect there would be no difference whatsoever.

Pin GPIO_AF0_USART2 is used by PeripheralPins.c

Signed-off-by: Nessotrin <[email protected]>
Direct copy from STM32C031xx. It looks compatible.

Signed-off-by: Nessotrin <[email protected]>
Copy link
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First thanks for your contribution,
It misses several update to be properly added:

  • Reference all the entries in the boards.txt
  • Reference in the README.md
  • Add a default clock config

@@ -61,7 +61,7 @@ extern "C" {
#define GPIO_AF0_OSC ((uint8_t)0x00) /*!< OSC (By pass and Enable) Alternate Function mapping */
#define GPIO_AF0_TIM14 ((uint8_t)0x00) /*!< TIM14 Alternate Function mapping */
#endif /* !STM32C011xx */
#if defined(STM32C031xx) || defined(STM32C071xx) || defined(STM32C091xx) || defined(STM32C092xx)
#if defined(STM32C031xx) || defined(STM32C051xx) || defined(STM32C071xx) || defined(STM32C091xx) || defined(STM32C092xx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, HAL could not be modified.
It is used as is and if an issue is identified then it have to be corrected first in the HAL driver; feel free to raised an issue on the related GitHub:
https://github.com/STMicroelectronics/stm32c0xx-hal-driver/blob/c283b143bef6bdaacf64240ee6f15eb61dad6125/Inc/stm32c0xx_hal_gpio_ex.h#L64
If it is a blocking issue then a workaround can be added in the stm32_def.h as it is already done for an other missing AF:

#if defined(STM32C0xx) && defined(USART3) && !defined(GPIO_AF7_USART3)
#define GPIO_AF7_USART3 ((uint8_t)0x07)
#endif // STM32C0xx && !defined(USART3)

MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE
FLASH (rx) : ORIGIN = 0x8000000+ LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FLASH (rx) : ORIGIN = 0x8000000+ LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET

@fpistm fpistm added the new variant Add support of new bard label Aug 18, 2025
@fpistm fpistm added this to the 2.11.1/2.12.0 milestone Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new variant Add support of new bard
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

2 participants