Skip to content
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

cpu/stm32: add support for STM32C0 and NUCLEO-C031C6 #20300

Merged
merged 3 commits into from
Jan 31, 2024

Conversation

jparker324
Copy link

@jparker324 jparker324 commented Jan 25, 2024

Cleaned-up commit history of PR #20267

Support added for ST Micro's board NUCLEO-C031C6, it's cpu STM32C031C6, and the rest of the cpu family STM32C0XX (as CPU_FAM_STM32C0). This currently includes STM32C011 and STM32C031, but code for identification has also been added for the STM32C071 and STM32C091 lines due out later this year.

Code was adapted from CPU_FAM_STM32G0 where applicable.

The most important difference in the STM32C0 product line is the removal of the PLL. As coded the default clock source is HSI.

fixes #19210

@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: tools Area: Supplementary tools Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports Area: Kconfig Area: Kconfig integration labels Jan 25, 2024
@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jan 25, 2024
@benpicco benpicco changed the title Support added for board NUCLEO-C031C6 and CPU_FAM_STM32C0 cpu/stm32: add support for STM32C0 and NUCLEO-C031C6 Jan 25, 2024
Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

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

Code looks good to me!
Nice addition.

@riot-ci
Copy link

riot-ci commented Jan 25, 2024

Murdock results

✔️ PASSED

a67f778 tests: add nucleo-c031c6 to Makefile.ci

Success Failures Total Runtime
8629 0 8629 08m:30s

Artifacts

@benpicco
Copy link
Contributor

One more thing: Since the STM32C031C6 has very little memory (32k ROM, 12k RAM) I expect that some applications won't fit on it.

CI tries to build every application for every board, so you need to tell it which ones to exclude for a board because they won't fit. You can do this by running

dist/tools/insufficient_memory/update_insufficient_memory_board.sh nucleo-c031c6

This will build all applications & tests for nucleo-c031c6 and update their Makefile.ci if the application does not fit.

You then need to commit the updated Makefile.ci files.

@benpicco benpicco added this pull request to the merge queue Jan 25, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 25, 2024
@benpicco
Copy link
Contributor

benpicco commented Jan 29, 2024

Looks like there is no low power timer on STM32C0 - so you might have to remove the periph_rtt feature.
Or is there a timer that keeps running in Deep Sleep?

@jparker324
Copy link
Author

There is not a dedicated low-power timer LPTIM peripheral like on previous ST parts (example STM32G071 section 3.18.4). Though they offer, according to datasheet STM32C031x4/x6 section 3.15 and 3.16, the LSI as a low-power RC clock source and there are 2 low-power timers that support a couple low-power RTC interrupts. I don't know if that meets all the requirements to support RIOT's periph_rtt.

@benpicco
Copy link
Contributor

benpicco commented Jan 29, 2024

The only requirement for periph_rtt is that it keeps ticking in the deepest sleep state (and can wake up/reset the CPU).
But you can also provide that as a follow-up PR and just drop advertising the feature for now.

@jparker324
Copy link
Author

jparker324 commented Jan 29, 2024

Alright. I'll do that. I still get build errors for tests/pkg/lvgl, tests/pkg/lvgl_touch, tests/sys/progress_bar, and tests/sys/xtimer_hang. lvgl and lvgl_touch also fail when I try them under nucleo_g071rb for example, so that's either expected or local to my environment. The progress_bar and xtimer_hang though are "OK" for that board.

@jparker324
Copy link
Author

I think the failures of tests/sys/progress_bar and tests/sys/xtimer_hang were due to previous interrupted or cancelled builds. I cleaned their build and bin dirs, and they both appear to build fine now.

tests/sys/progress_bar OK
tests/sys/xtimer_hang OK

LVGL still fails though. I also get a brief message on spi_dma before it's not supported output, although it's not explicitly build failed.

tests/periph/spi_dma                    dist/tools/insufficient_memory/../../../tests/periph/spi_dma/Makefile.ci:3: ../spi/Makefile.ci: No such file or directory
make: *** No rule to make target '../spi/Makefile.ci'.  Stop.
not supported

@github-actions github-actions bot added Area: tests Area: tests and testing framework Area: examples Area: Example Applications labels Jan 29, 2024
@jparker324 jparker324 force-pushed the stm32c0_and_nucleo_c031c6 branch 2 times, most recently from 591fa48 to 765c7ec Compare January 29, 2024 19:56
@benpicco
Copy link
Contributor

I also get a brief message on spi_dma before it's not supported output, although it's not explicitly build failed.

That's because you don't advertise the periph_dma feature, but as you also didn't configure any DMA channels for the SPI, that's correct.

@jparker324 jparker324 force-pushed the stm32c0_and_nucleo_c031c6 branch from 9ff2c49 to 765c7ec Compare January 30, 2024 14:23
@jparker324 jparker324 force-pushed the stm32c0_and_nucleo_c031c6 branch from a2d4847 to a2f4a13 Compare January 30, 2024 15:12
@jparker324
Copy link
Author

I've restored and re-built the Makefile.ci files again. They look better now. If I had to guess, it was probably another result of earlier cancelled builds.

@benpicco benpicco added this pull request to the merge queue Jan 30, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 31, 2024
@benpicco
Copy link
Contributor

looks like (at least) tests/pkg/lvgl_touch also needs a Makefile.ci update

@jparker324
Copy link
Author

  1. Does anything need to be done about the tests/sys/ztimer_overhead error yesterday?
make: Entering directory '/tmp/dwq.0.29611624904775513/5b84c211eba9dea6bec9bf777727be8b/tests/sys/ztimer_overhead'
r
/tmp/dwq.0.29611624904775513/5b84c211eba9dea6bec9bf777727be8b/build/tests_ztimer_overhead.elf  tap0 
RIOT native interrupts/signals initialized.
RIOT native board initialized.
RIOT native hardware initialization complete.

Help: Press s to start test, r to print it is ready
READY
s
START
main(): This is RIOT! (Version: buildtest)
ZTIMER_USEC auto_adjust params:
    ZTIMER_USEC->adjust_set = 11
    ZTIMER_USEC->adjust_sleep = 5
ZTIMER_USEC auto_adjust params cleared
zitmer_overhead_set...
min=7 max=43 avg_diff=13
zitmer_overhead_sleep...
min=11 max=255 avg_diff=36
ZTIMER_USEC adjust params for native:
    CONFIG_ZTIMER_USEC_ADJUST_SET    7
    CONFIG_ZTIMER_USEC_ADJUST_SLEEP  11

make: Leaving directory '/tmp/dwq.0.29611624904775513/5b84c211eba9dea6bec9bf777727be8b/tests/sys/ztimer_overhead'
Traceback (most recent call last):
  File "/tmp/dwq.0.29611624904775513/5b84c211eba9dea6bec9bf777727be8b/tests/sys/ztimer_overhead/tests/01-run.py", line 33, in <module>
    sys.exit(run(testfunc))
  File "/tmp/dwq.0.29611624904775513/5b84c211eba9dea6bec9bf777727be8b/dist/pythonlibs/testrunner/__init__.py", line 30, in run
    testfunc(child)
  File "/tmp/dwq.0.29611624904775513/5b84c211eba9dea6bec9bf777727be8b/tests/sys/ztimer_overhead/tests/01-run.py", line 29, in testfunc
    assert auto_adjust_sleep >= adjust_sleep - ADJUST_SLEEP_MARGIN
AssertionError
make: *** [/tmp/dwq.0.29611624904775513/5b84c211eba9dea6bec9bf777727be8b/makefiles/tests/tests.inc.mk:26: test] Error 1
  1. When running ./dist/tools/insufficient_memory/update_insufficient_memory_board.sh nucleo-c031c6 do you not see the error in the lvgl and lvgl_touch packages? How did it/I miss the other Makefile.ci you corrected?
tests/pkg/lvgl                          build failed
make: Entering directory '/home/parkerj/RIOT/tests/pkg/lvgl'
Launching build container using image "docker.io/riot/riotbuild:latest".
docker run --rm --tty --user $(id -u) -v '/usr/share/zoneinfo/America/New_York:/etc/localtime:ro' -v '/home/parkerj/RIOT:/data/riotbuild/riotbase:delegated' -v '/home/parkerj/.cargo/registry:/data/riotbuild/.cargo/registry:delegated' -v '/home/parkerj/.cargo/git:/data/riotbuild/.cargo/git:delegated' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles'      -e 'BOARD=nucleo-c031c6' -e 'RIOT_CI_BUILD=1' -e 'DISABLE_MODULE=test_utils_interactive_sync' -e 'DEFAULT_MODULE=' -e 'FEATURES_REQUIRED=' -e 'FEATURES_BLACKLIST=' -e 'FEATURES_OPTIONAL=' -e 'USEMODULE=lvgl_contrib lvgl_extra_layout_flex lvgl_extra_theme_default lvgl_extra_theme_default_dark lvgl_extra_widget_chart lvgl_extra_widget_win' -e 'USEPKG=lvgl'  -w '/data/riotbuild/riotbase/tests/pkg/lvgl/' 'docker.io/riot/riotbuild:latest' make 'BOARD=nucleo-c031c6'   -j12  
Building application "tests_lvgl" for "nucleo-c031c6" with MCU "stm32".

/tmp/ccXrsj5w.s: Assembler messages:
/tmp/ccXrsj5w.s: Error: unaligned opcodes detected in executable segment

@benpicco benpicco added this pull request to the merge queue Jan 31, 2024
@benpicco
Copy link
Contributor

That's just a sporadic failure that occurs when CI is under high load.
Re-running the build usually fixes it.

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 31, 2024
@benpicco benpicco added this pull request to the merge queue Jan 31, 2024
Merged via the queue into RIOT-OS:master with commit 4ea27d4 Jan 31, 2024
25 checks passed
@jparker324 jparker324 deleted the stm32c0_and_nucleo_c031c6 branch January 31, 2024 18:23
@benpicco
Copy link
Contributor

That was a great first PR!
Let's continue with GD32E23x 😃

@jparker324
Copy link
Author

Thanks for your help. I'll get back to GD32 it but it might be a few weeks, yet.

@MrKevinWeiss MrKevinWeiss added this to the Release 2024.04 milestone Apr 30, 2024
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: build system Area: Build system Area: cpu Area: CPU/MCU ports Area: doc Area: Documentation Area: examples Area: Example Applications Area: Kconfig Area: Kconfig integration Area: tests Area: tests and testing framework Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support for new STM32C0 MCU and eval boards
4 participants