Skip to content

feat: add Seeed XIAO STM32C5 support - #3048

Open
cumin777 wants to merge 17 commits into
stm32duino:mainfrom
cumin777:feat/xiao-stm32c5
Open

feat: add Seeed XIAO STM32C5 support#3048
cumin777 wants to merge 17 commits into
stm32duino:mainfrom
cumin777:feat/xiao-stm32c5

Conversation

@cumin777

Copy link
Copy Markdown

Summary

Add Arduino core support for the Seeed XIAO STM32C5.

This PR implements the following features:

  • Seeed XIAO STM32C5 board variant, pin mapping and linker script
  • USB CDC Serial support for STM32C5 HAL v2
  • UF2 upload recipe for the TinyUF2 bootloader
  • Onboard IMU I2C, interrupt and heater-control pins

The board requires support for the STM32C5 HAL v2 USB device peripheral and
uses a 32 KiB TinyUF2 bootloader, so the application image starts at
0x08008000.

The application USB identity is 2886:80C5. The corresponding bootloader is
maintained separately with identity 2886:00C5.

Automatic upload uses the standard 1200-bps CDC touch flow to enter TinyUF2,
then writes the generated UF2 image to the XIAOC5BOOT mass-storage volume.
The uf2upload executable is supplied by the companion Arduino_Tools PR and
will be consumed through a subsequent STM32Tools release/package-index update.

Validation

Hardware validation was performed on Seeed XIAO STM32C5:

  • USB CDC enumeration and serial communication
  • 1200-bps touch from a running application, bootloader entry, and full
    automatic UF2 upload
  • SPI3 D9/D10 loopback
  • I2C scan
  • External flash access
  • Onboard LSM6DS3TR-C IMU readout and interrupt handling
  • IMU heater PWM temperature-control loop

CI and AStyle checks are pending GitHub Actions.

@fpistm fpistm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @cumin777
thanks for this PR.
It is a first round of review.
Have you any link on the board?

Comment thread libraries/USBDevice/inc/usbd_conf.h Outdated
Comment on lines +39 to +41
#define USB USB_DRD_FS
#define PCD_SNG_BUF HAL_PCD_SNG_BUF
#define PCD_DBL_BUF HAL_PCD_DBL_BUF

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be better to add it in the stm32_def.h, other series also redefine some USB definition.

/* STM32G0xx, STM32U0xx and some STM32U5xx defined USB_DRD_FS */
#if !defined(USB) && defined(USB_DRD_FS)
#define USB USB_DRD_FS
#define PinMap_USB PinMap_USB_DRD_FS
#if defined(STM32H5xx) || defined(STM32U0xx) ||\
defined(STM32U3xx) || defined(STM32U5xx)
#define USB_BASE USB_DRD_BASE
#if !defined(__HAL_RCC_USB_CLK_ENABLE)
#if defined(__HAL_RCC_USB_FS_CLK_ENABLE)
#define __HAL_RCC_USB_CLK_ENABLE __HAL_RCC_USB_FS_CLK_ENABLE
#define __HAL_RCC_USB_CLK_DISABLE __HAL_RCC_USB_FS_CLK_DISABLE
#endif
#if defined(__HAL_RCC_USB1_CLK_ENABLE)
#define __HAL_RCC_USB_CLK_ENABLE __HAL_RCC_USB1_CLK_ENABLE
#define __HAL_RCC_USB_CLK_DISABLE __HAL_RCC_USB1_CLK_DISABLE
#endif
#endif
#endif
#endif

USB_BASE should also be defined.

Comment thread libraries/USBDevice/inc/usbd_conf.h Outdated
Comment on lines +42 to +43
#define USB_IRQn USB_DRD_FS_IRQn
#define USB_IRQHandler USB_DRD_FS_IRQHandler

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When USB_BASE defined simply add STM32C5xx in the list:

#elif defined(STM32C0xx) || defined(STM32H5xx) || defined(STM32U0xx)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it should be renamed to a more generic name like: usbd_confv2.c

Comment thread libraries/USBDevice/src/usbd_conf_c5.c Outdated
@@ -0,0 +1,251 @@
/**
******************************************************************************
* @file usbd_conf_c5.c

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

usbd_confv2.c

Comment thread libraries/USBDevice/src/usbd_conf_c5.c Outdated
/**
******************************************************************************
* @file usbd_conf_c5.c
* @brief STM32C5 HAL v2 USB device low-level adapter.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove STM32C5.

Comment thread libraries/SPI/src/utility/spi_com.c Outdated
Comment thread libraries/SPI/src/utility/spi_com.c Outdated
}

#if defined(SPI_IFCR_EOTC)
spi_transfer_end:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think there is a trap here. For future HALV2 series based. If SPI_IFCR_EOTC is not defined goto will not reach it.

Comment thread libraries/SPI/src/utility/spi_com.c Outdated
static bool spi_transfer_timed_out(uint32_t start_us)
{
return (SPI_TRANSFER_TIMEOUT != HAL_MAX_DELAY)
&& ((uint32_t)(micros() - start_us) >= (SPI_TRANSFER_TIMEOUT * 1000UL));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

micros() uses HAL_GetTick() so wonder if your statement is correct?

uint32_t m0 = HAL_GetTick();

Comment thread libraries/SPI/src/SPI.cpp Outdated
void SPIClass::configSpi(const SPISettings &settings, bool force)
{
if (_spiSettings != settings) {
if (force || _spiSettings != settings) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Interesting.
It seems we introduce a regression when the ArduinoCore-API was released.
Thanks for pointing this. I will provide a fix for this. I don't think adding a new arguments is the better way.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you file an issue for this, please?

#define PIN_SPI_SS2 NUM_DIGITAL_PINS
#define PIN_SPI_SS3 NUM_DIGITAL_PINS
#define PIN_SPI_MOSI PB_15_ALT2
#define PIN_SPI_MOSI (PB15 | ALT2)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PB15_ALT2

@cumin777

Copy link
Copy Markdown
Author

Hi @fpistm, thank you for the detailed first review.

  1. The Seeed XIAO STM32C5 is currently in the DVT stage and is planned for public launch in September, so there is no public product page available yet. I will share the official board link once it is published.

  2. I have pushed an update addressing your comments: the USB HAL v2 adapter has been generalized, the USB definitions were moved to the common layer, the board menus now follow the existing core conventions, and the SPI3 MOSI alternate-function name was updated. Could you please check whether this now matches your expectations?

  3. Regarding the SPI initialization regression, I saw that you have opened fix(spi): init never called at begin #3049, which addresses the same root cause. I have removed the board-specific SPI workaround from this PR, so I believe a separate issue is no longer needed. Please let me know if you would still prefer one.

@fpistm

fpistm commented Aug 19, 2026

Copy link
Copy Markdown
Member

Hi, thanks for the update.
and yes an issue for the SPI would help to track it.

As the board is not yet available. It would be fine to keep here only the board support addition and open separate PR for specific feature. I will try on my side and a Nucleo C562RE

@cumin777

Copy link
Copy Markdown
Author

Hi @fpistm, understood. I will open an issue for this.

Although the board does not yet have a public product page, I can provide test reports to demonstrate the product and its validation status. Our product manager is working to ensure Arduino platform support is ready as early as possible for our users.

If helpful, I would be glad to share this information with you. The current planned public launch date is August 29.

Thank you very much for your support.

@cumin777

cumin777 commented Aug 20, 2026

Copy link
Copy Markdown
Author

I also noticed that the CI workflows for the latest update are awaiting approval. Could you please approve them when convenient, so the checks can run? :)

@fpistm

fpistm commented Aug 20, 2026

Copy link
Copy Markdown
Member

Thanks for the update. Will check this tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants