Skip to content

Conversation

@crasbe
Copy link
Contributor

@crasbe crasbe commented Oct 9, 2025

Contribution description

Unfortunately the PR #20939 that added several new STM32C0 based boards went stale, so I took the liberty to take it over.

The fixup commit changes the copyright notice to the new SPDX format and the headerguards to #pragma once as well as fixing a typo in the KConfig file. The flashing information now points to the guide merged in #21767 (following the scheme from #21337).

This PR is the second part #21775 because I don't have the hardware yet. After #21775 is merged, the DELETEME commit will be removed. Hardware arrive, PR is merged.

TODO: Apply the comments of benpicco's review from the other PR.

Testing procedure

tbd as soon as I have the hardware.

Issues/PRs references

This is continued from #20939 (and will close it).
Tracking Issue #19264.

@crasbe crasbe added the Type: new feature The issue requests / The PR implemements a new feature for RIOT label Oct 9, 2025
@crasbe crasbe added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: no fast fail don't abort PR build after first error labels Oct 9, 2025
@github-actions github-actions bot added Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: doc Area: Documentation Area: build system Area: Build system Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports Area: Kconfig Area: Kconfig integration labels Oct 9, 2025
@crasbe crasbe added the State: waiting for other PR State: The PR requires another PR to be merged first label Oct 9, 2025
@crasbe crasbe requested a review from kaspar030 as a code owner October 9, 2025 14:26
@github-actions github-actions bot added the Area: CI Area: Continuous Integration of RIOT components label Oct 9, 2025
@riot-ci
Copy link

riot-ci commented Oct 9, 2025

Murdock results

✔️ PASSED

7caafd0 tests: update Makefile.ci with stm32c0116-dk & stm32c0316-dk

Success Failures Total Runtime
3103 0 3103 06m:11s

Artifacts

@github-actions github-actions bot added Area: tests Area: tests and testing framework Area: examples Area: Example Applications labels Oct 9, 2025
Copy link
Contributor Author

@crasbe crasbe left a comment

Choose a reason for hiding this comment

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

I currently can not get the boards running right. The STM32C0116-DK can be flashed, but it appears that some clock configuration is wrong. The blinky example blinks way too fast even though ztimer is used. This probably also messes up the baudrate which is why no communication with the ST-Link is possibly even though I changed the pin and interrupt etc assignments.

The STM32C0316-DK cannot be flashed currently (neither with Linux nor WSL), I get this error. That board doesn't have a built-in ST-Link but ships with an ST-Link Mini V3.
Most likely it'll have similar issues as the C0116-DK as well.

### Flashing Target ###
Open On-Chip Debugger 0.12.0+dev-02241-g3fd975941-dirty (2025-10-14-09:55)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Warn : Transport "swd" was already selected
DEPRECATED! use 'tcl port' not 'tcl_port'
DEPRECATED! use 'telnet port', not 'telnet_port'
DEPRECATED! use 'gdb port', not 'gdb_port'
Error: libusb_open() failed with LIBUSB_ERROR_ACCESS
Error: open failed

@crasbe
Copy link
Contributor Author

crasbe commented Oct 14, 2025

The STM32C0316-DK cannot be flashed currently (neither with Linux nor WSL), I get this error. That board doesn't have a built-in ST-Link but ships with an ST-Link Mini V3.

Okay two issues: First of all OpenOCD does not update the udev rules when installing, so it did not know about the ST-Link V3 yet.
Secondly my STM32C0316-DK is broken. The 3.3V regulator does not output any voltage at all...

@crasbe
Copy link
Contributor Author

crasbe commented Oct 14, 2025

The STM32C0116-DK can be flashed, but it appears that some clock configuration is wrong. The blinky example blinks way too fast even though ztimer is used.

Now this is interesting. When using ztimer_usec (which is the default) for the blinky, it blinks with ~25Hz. When using ztimer_msec, it blinks somewhat erratic suggesting an overflow of some sort?
ztimer_sec does not work at all.
This is odd though because the Nucleo-C071RB uses the same timer configuration and it works there. The Nucleo-C071RB has crystals for HSE and LSE though, the C011 has neither. Setting CONFIG_BOARD_HAS_LSE and CONFIG_BOARD_HAS_HSE to zero didn't change anything.

This is what I mean with "erratic":

document_5436140939770890711.mp4

@crasbe crasbe force-pushed the pr/stm32c0-dk_new branch 5 times, most recently from 393d402 to a35ba66 Compare October 14, 2025 22:47
@crasbe
Copy link
Contributor Author

crasbe commented Oct 14, 2025

Now this is interesting. When using ztimer_usec (which is the default) for the blinky, it blinks with ~25Hz. When using ztimer_msec, it blinks somewhat erratic suggesting an overflow of some sort?
ztimer_sec does not work at all.

This is fixed thanks to a hint from Kaspar. The culprit was a missing TIMER_0_MAX_VALUE. The STM32C011 only has 16-bit timers and ztimer assumed 32-bits, which is why odd things happened.

Copy link
Member

@AnnsAnns AnnsAnns left a comment

Choose a reason for hiding this comment

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

I found nothing to really complain about. As with the other PR, I will simply trust you that it works since this is a quasi second round review PR and your work in itself is already a review of the old code. (And once again thank you for working on this and ty to the original author for the OG code) [and I also don't have the hardware 🙈]

@crasbe
Copy link
Contributor Author

crasbe commented Oct 15, 2025

I still have to test the addition with the STM32C0316-DK, once Digikey replies with how we proceed with the broken board.
Of course I can add a new 3.3V regulator, but if they want me to send it back it would be... inconvenient... to have modified it 😅

@AnnsAnns
Copy link
Member

I still have to test the addition with the STM32C0316-DK, once Digikey replies with how we proceed with the broken board. Of course I can add a new 3.3V regulator, but if they want me to send it back it would be... inconvenient... to have modified it 😅

Lets wait for the Digikey overlords to decide this PRs fate then 😛

@crasbe
Copy link
Contributor Author

crasbe commented Oct 20, 2025

The Digikey overloads said that I can keep the broken board, so anyway I started blast...soldering :D
image

Well what can I say, it works:

cbuec@W11nMate:~/RIOTstuff/riot-guides/RIOT$ BOARD=stm32c0316-dk make -C examples/basic/hello-world/ flash t
erm -j
Building application "hello-world" for "stm32c0316-dk" with CPU "stm32".

"make" -C /home/cbuec/RIOTstuff/riot-guides/RIOT/pkg/cmsis/
...
"make" -C /home/cbuec/RIOTstuff/riot-guides/RIOT/cpu/cortexm_common/periph
   text    data     bss     dec     hex filename
   6816       8    2292    9116    239c /home/cbuec/RIOTstuff/riot-guides/RIOT/examples/basic/hello-world/bin/stm32c0316-dk/hello-world.elf
/home/cbuec/RIOTstuff/riot-guides/RIOT/dist/tools/openocd/openocd.sh flash /home/cbuec/RIOTstuff/riot-guides/RIOT/examples/basic/hello-world/bin/stm32c0316-dk/hello-world.elf
### Flashing Target ###
Open On-Chip Debugger 0.12.0+dev-02241-g3fd975941-dirty (2025-10-14-09:55)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Warn : DEPRECATED: auto-selecting transport "swd (dapdirect)". Use 'transport select swd' to suppress this message.
swd (dapdirect)
swd (dapdirect)
DEPRECATED! use 'tcl port' not 'tcl_port'
DEPRECATED! use 'telnet port', not 'telnet_port'
DEPRECATED! use 'gdb port', not 'gdb_port'
Info : STLINK V3J16M8 (API v3) VID:PID 0483:3754
Info : Target voltage: 3.285562
Info : Unable to match requested speed 2000 kHz, using 1000 kHz
Info : Unable to match requested speed 2000 kHz, using 1000 kHz
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x0bc11477
Info : [stm32c0x.cpu] Cortex-M0+ r0p1 processor detected
Info : [stm32c0x.cpu] target has 4 breakpoints, 2 watchpoints
Info : [stm32c0x.cpu] Examination succeed
Info : [stm32c0x.cpu] starting gdb server on 0
Info : Listening on port 39163 for gdb connections
    TargetName         Type       Endian TapName            State
--  ------------------ ---------- ------ ------------------ ------------
 0* stm32c0x.cpu       cortex_m   little stm32c0x.cpu       unknown
[stm32c0x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x08000818 msp: 0x20000200
Info : device idcode = 0x10006453 (STM32C03xx - Rev A : 0x1000)
Info : RDP level 0 (0xAA)
Info : flash size = 32 KiB
Info : flash mode : single-bank
Warn : Adding extra erase range, 0x08001aa8 .. 0x08001fff
auto erase enabled
wrote 6824 bytes from file /home/cbuec/RIOTstuff/riot-guides/RIOT/examples/basic/hello-world/bin/stm32c0316-dk/hello-world.elf in 0.338695s (19.676 KiB/s)
verified 6824 bytes in 0.135212s (49.286 KiB/s)
shutdown command invoked
Done flashing
/home/cbuec/RIOTstuff/riot-guides/RIOT/dist/tools/pyterm/pyterm -p "/dev/ttyACM0" -b "115200" -ln "/tmp/pyterm-cbuec" -rn "2025-10-20_14.38.40-hello-world-stm32c0316-dk"
2025-10-20 14:38:40,616 # Connect to serial port /dev/ttyACM0
Welcome to pyterm!
Type '/exit' to exit.
2025-10-20 14:38:46,476 # main(): This is RIOT! (Version: 2025.10-devel-455-ga35ba66-pr/stm32c0-dk_new)
2025-10-20 14:38:46,477 # Hello World!
2025-10-20 14:38:46,481 # You are running RIOT on a(n) stm32c0316-dk board.
2025-10-20 14:38:46,486 # This board features a(n) stm32 CPU.

@crasbe crasbe force-pushed the pr/stm32c0-dk_new branch 3 times, most recently from 485beef to 93f98c3 Compare October 20, 2025 12:52
@github-actions github-actions bot removed the Area: CI Area: Continuous Integration of RIOT components label Oct 20, 2025
@crasbe crasbe enabled auto-merge October 20, 2025 12:54
@crasbe crasbe disabled auto-merge October 20, 2025 12:55
@crasbe crasbe force-pushed the pr/stm32c0-dk_new branch from 93f98c3 to 7caafd0 Compare October 20, 2025 12:57
@crasbe crasbe added this to the Release 2025.10 milestone Oct 20, 2025
@crasbe crasbe enabled auto-merge October 20, 2025 12:57
@AnnsAnns
Copy link
Member

Hooray

@crasbe crasbe added this pull request to the merge queue Oct 20, 2025
Merged via the queue into RIOT-OS:master with commit 365f157 Oct 20, 2025
25 checks passed
@crasbe
Copy link
Contributor Author

crasbe commented Oct 20, 2025

Thanks for the review :)

@crasbe crasbe deleted the pr/stm32c0-dk_new branch October 20, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: boards Area: Board ports Area: doc Area: Documentation Area: examples Area: Example Applications Area: Kconfig Area: Kconfig integration Area: tests Area: tests and testing framework CI: no fast fail don't abort PR build after first error CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants