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

boards/gd32vf103c-start: new board #20270

Merged
merged 9 commits into from
Jan 20, 2024

Conversation

maribu
Copy link
Member

@maribu maribu commented Jan 17, 2024

Contribution description

This pull request adds support for the GD32VF103C-START board, the official evaluation board of the GD32VF103C MCU by the MCU vendor. Sadly, there is relatively little documentation provided on the board.

Testing procedure

Output when testing with the selftesting shield:

main(): This is RIOT! (Version: 2024.01-devel-611-gc01b6b4-boards/gd32vf103c-start)
self-testing peripheral drivers
===============================
Starting test for GPIO at tests/periph/selftest_shield/main.c:346
[OK]
Starting test for GPIO at tests/periph/selftest_shield/main.c:368
[OK]
Starting test for GPIO at tests/periph/selftest_shield/main.c:398
[OK]
Starting test for GPIO at tests/periph/selftest_shield/main.c:428
(skipped)
Starting test for GPIO at tests/periph/selftest_shield/main.c:454
(skipped)
Starting test for GPIO-IRQ at tests/periph/selftest_shield/main.c:501
[OK]
Starting test for GPIO-IRQ at tests/periph/selftest_shield/main.c:564
[OK]
Starting test for GPIO-IRQ at tests/periph/selftest_shield/main.c:627
[OK]
Starting test for I2C at tests/periph/selftest_shield/main.c:701
[OK]
Starting test for SPI at tests/periph/selftest_shield/main.c:829
[OK]
Starting test for SPI at tests/periph/selftest_shield/main.c:829
[OK]
Starting test for SPI at tests/periph/selftest_shield/main.c:829
[OK]
Starting test for SPI at tests/periph/selftest_shield/main.c:829
[OK]
Starting test for SPI at tests/periph/selftest_shield/main.c:829
[OK]
Starting test for SPI at tests/periph/selftest_shield/main.c:829
[OK]
Starting test for SPI at tests/periph/selftest_shield/main.c:829
[OK]
Starting test for SPI at tests/periph/selftest_shield/main.c:829
[OK]
Starting test for SPI at tests/periph/selftest_shield/main.c:829
[OK]
Starting test for SPI at tests/periph/selftest_shield/main.c:829
[OK]
Starting test for SPI at tests/periph/selftest_shield/main.c:829
[OK]
Starting test for SPI at tests/periph/selftest_shield/main.c:829
[OK]
Starting test for PWM at tests/periph/selftest_shield/main.c:958
FAILURE in tests/periph/selftest_shield/main.c:979
0 <= 426 <= 64: FAILED
[FAILED]
Starting test for PWM at tests/periph/selftest_shield/main.c:958
[OK]
Starting test for PWM at tests/periph/selftest_shield/main.c:958
FAILURE in tests/periph/selftest_shield/main.c:979
0 <= 199 <= 64: FAILED
FAILURE in tests/periph/selftest_shield/main.c:979
0 <= 937 <= 68: FAILED
[FAILED]
Starting test for PWM at tests/periph/selftest_shield/main.c:958
FAILURE in tests/periph/selftest_shield/main.c:979
0 <= 1018 <= 64: FAILED
FAILURE in tests/periph/selftest_shield/main.c:979
0 <= 936 <= 68: FAILED
[FAILED]
Starting test for PWM at tests/periph/selftest_shield/main.c:958
FAILURE in tests/periph/selftest_shield/main.c:979
0 <= 199 <= 64: FAILED
FAILURE in tests/periph/selftest_shield/main.c:979
0 <= 941 <= 68: FAILED
[FAILED]
Starting test for PWM at tests/periph/selftest_shield/main.c:958
FAILURE in tests/periph/selftest_shield/main.c:979
0 <= 1017 <= 64: FAILED
FAILURE in tests/periph/selftest_shield/main.c:979
0 <= 928 <= 68: FAILED
[FAILED]
Starting test for ADC at tests/periph/selftest_shield/main.c:1027
FAILURE in tests/periph/selftest_shield/main.c:1042
0 <= 545 <= 102: FAILED
FAILURE in tests/periph/selftest_shield/main.c:1042
0 <= 407 <= 166: FAILED
FAILURE in tests/periph/selftest_shield/main.c:1042
26 <= 358 <= 230: FAILED
FAILURE in tests/periph/selftest_shield/main.c:1042
90 <= 343 <= 294: FAILED
FAILURE in tests/periph/selftest_shield/main.c:1042
346 <= 328 <= 550: FAILED
FAILURE in tests/periph/selftest_shield/main.c:1042
410 <= 333 <= 614: FAILED
FAILURE in tests/periph/selftest_shield/main.c:1042
474 <= 336 <= 678: FAILED
FAILURE in tests/periph/selftest_shield/main.c:1042
538 <= 338 <= 742: FAILED
FAILURE in tests/periph/selftest_shield/main.c:1042
602 <= 338 <= 806: FAILED
FAILURE in tests/periph/selftest_shield/main.c:1042
666 <= 337 <= 870: FAILED
FAILURE in tests/periph/selftest_shield/main.c:1042
730 <= 338 <= 934: FAILED
FAILURE in tests/periph/selftest_shield/main.c:1042
794 <= 337 <= 998: FAILED
FAILURE in tests/periph/selftest_shield/main.c:1042
858 <= 338 <= 1023: FAILED
[FAILED]


SOME TESTS FAILED
{ "threads": [{ "name": "idle", "stack_size": 256, "stack_used": 228 }]}
{ "threads": [{ "name": "main", "stack_size": 1280, "stack_used": 740 }]}

Note: There are apparently some issues with at least the ADC. (The ADC is used to test the PWM output via a "low-pass filter DAC", but also via an R-2R DAC. Both tests fail. But just something broken with the ADC would be sufficient to explain this.)

Otherwise, the test result indicates correct configuration and Arduino mapping.

Issues/PRs references

None

Allow setting `OPENOCD_TRANSPORT` to `default` for when a transport to
not explicitly set the transport. This is useful when the target or
interface script already specify the transport.
When `stdio_cdc_acm` is used, prefer selecting the USB devices with
vendor `RIOT-os.org` and model `$(BOARD)` and only fall back
to `$(TTY_BOARD_FILTER)` if no such TTY was found.

This makes it possible to add a TTY board filter matching only an
integrated USB to UART bridge, but still do the right thing when
the user explicitly uses `stdio_cdc_acm` instead of the default
`stdio_uart`.
The API doc clearly states that arbitrary high PWM frequencies can
be requested and the driver should reduce the frequency while keeping
the resolution, when required. So change the code to just do that
rather than blowing assertions.
@maribu maribu added State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Area: boards Area: Board ports labels Jan 17, 2024
@github-actions github-actions bot added Area: doc Area: Documentation Area: build system Area: Build system Area: tools Area: Supplementary tools Area: cpu Area: CPU/MCU ports labels Jan 17, 2024
@maribu
Copy link
Member Author

maribu commented Jan 17, 2024

ToDos:

  • Fix the remaining test failures.

@riot-ci
Copy link

riot-ci commented Jan 17, 2024

Murdock results

✔️ PASSED

66abbd2 examples,tests: add gd32vr103c-start to Makefile.ci

Success Failures Total Runtime
8622 0 8623 11m:04s

Artifacts

@maribu
Copy link
Member Author

maribu commented Jan 18, 2024

With one hardware issue (PA1 / Arduino pin A0 not connected) on the board solved and Arduino Pin D2 (PB4) no longer being part of the JTAG interface, it looks better now:

2024-01-18 21:21:50,916 # START
2024-01-18 21:21:50,922 # main(): This is RIOT! (Version: 2024.01-devel-612-g740717-boards/gd32vf103c-start)
2024-01-18 21:21:50,925 # self-testing peripheral drivers
2024-01-18 21:21:50,928 # ===============================
2024-01-18 21:21:50,934 # Starting test for GPIO at tests/periph/selftest_shield/main.c:346
2024-01-18 21:21:50,934 # [OK]
2024-01-18 21:21:50,942 # Starting test for GPIO at tests/periph/selftest_shield/main.c:368
2024-01-18 21:21:50,942 # [OK]
2024-01-18 21:21:50,948 # Starting test for GPIO at tests/periph/selftest_shield/main.c:398
2024-01-18 21:21:50,948 # [OK]
2024-01-18 21:21:50,954 # Starting test for GPIO at tests/periph/selftest_shield/main.c:428
2024-01-18 21:21:50,954 # (skipped)
2024-01-18 21:21:50,959 # Starting test for GPIO at tests/periph/selftest_shield/main.c:454
2024-01-18 21:21:50,961 # (skipped)
2024-01-18 21:21:50,967 # Starting test for GPIO-IRQ at tests/periph/selftest_shield/main.c:501
2024-01-18 21:21:50,967 # [OK]
2024-01-18 21:21:50,973 # Starting test for GPIO-IRQ at tests/periph/selftest_shield/main.c:564
2024-01-18 21:21:50,973 # [OK]
2024-01-18 21:21:50,981 # Starting test for GPIO-IRQ at tests/periph/selftest_shield/main.c:627
2024-01-18 21:21:50,982 # [OK]
2024-01-18 21:21:50,987 # Starting test for I2C at tests/periph/selftest_shield/main.c:701
2024-01-18 21:21:51,072 # [OK]
2024-01-18 21:21:51,077 # Starting test for SPI at tests/periph/selftest_shield/main.c:829
2024-01-18 21:21:51,090 # [OK]
2024-01-18 21:21:51,095 # Starting test for SPI at tests/periph/selftest_shield/main.c:829
2024-01-18 21:21:51,109 # [OK]
2024-01-18 21:21:51,114 # Starting test for SPI at tests/periph/selftest_shield/main.c:829
2024-01-18 21:21:51,127 # [OK]
2024-01-18 21:21:51,133 # Starting test for SPI at tests/periph/selftest_shield/main.c:829
2024-01-18 21:21:51,145 # [OK]
2024-01-18 21:21:51,151 # Starting test for SPI at tests/periph/selftest_shield/main.c:829
2024-01-18 21:21:51,155 # [OK]
2024-01-18 21:21:51,160 # Starting test for SPI at tests/periph/selftest_shield/main.c:829
2024-01-18 21:21:51,165 # [OK]
2024-01-18 21:21:51,171 # Starting test for SPI at tests/periph/selftest_shield/main.c:829
2024-01-18 21:21:51,175 # [OK]
2024-01-18 21:21:51,181 # Starting test for SPI at tests/periph/selftest_shield/main.c:829
2024-01-18 21:21:51,185 # [OK]
2024-01-18 21:21:51,192 # Starting test for SPI at tests/periph/selftest_shield/main.c:829
2024-01-18 21:21:51,192 # [OK]
2024-01-18 21:21:51,199 # Starting test for SPI at tests/periph/selftest_shield/main.c:829
2024-01-18 21:21:51,200 # [OK]
2024-01-18 21:21:51,206 # Starting test for SPI at tests/periph/selftest_shield/main.c:829
2024-01-18 21:21:51,206 # [OK]
2024-01-18 21:21:51,213 # Starting test for SPI at tests/periph/selftest_shield/main.c:829
2024-01-18 21:21:51,214 # [OK]
2024-01-18 21:21:51,219 # Starting test for PWM at tests/periph/selftest_shield/main.c:958
2024-01-18 21:21:51,224 # FAILURE in tests/periph/selftest_shield/main.c:979
2024-01-18 21:21:51,226 # 0 <= 549 <= 64: FAILED
2024-01-18 21:21:51,231 # [FAILED]
2024-01-18 21:21:51,237 # Starting test for PWM at tests/periph/selftest_shield/main.c:958
2024-01-18 21:21:51,241 # [OK]
2024-01-18 21:21:51,246 # Starting test for PWM at tests/periph/selftest_shield/main.c:958
2024-01-18 21:21:51,249 # FAILURE in tests/periph/selftest_shield/main.c:979
2024-01-18 21:21:51,252 # 0 <= 201 <= 64: FAILED
2024-01-18 21:21:51,259 # FAILURE in tests/periph/selftest_shield/main.c:979
2024-01-18 21:21:51,259 # 0 <= 928 <= 68: FAILED
2024-01-18 21:21:51,263 # [FAILED]
2024-01-18 21:21:51,269 # Starting test for PWM at tests/periph/selftest_shield/main.c:958
2024-01-18 21:21:51,272 # FAILURE in tests/periph/selftest_shield/main.c:979
2024-01-18 21:21:51,275 # 0 <= 1016 <= 64: FAILED
2024-01-18 21:21:51,282 # FAILURE in tests/periph/selftest_shield/main.c:979
2024-01-18 21:21:51,282 # 0 <= 928 <= 68: FAILED
2024-01-18 21:21:51,287 # [FAILED]
2024-01-18 21:21:51,291 # Starting test for PWM at tests/periph/selftest_shield/main.c:958
2024-01-18 21:21:51,294 # FAILURE in tests/periph/selftest_shield/main.c:979
2024-01-18 21:21:51,297 # 0 <= 201 <= 64: FAILED
2024-01-18 21:21:51,305 # FAILURE in tests/periph/selftest_shield/main.c:979
2024-01-18 21:21:51,305 # 0 <= 956 <= 68: FAILED
2024-01-18 21:21:51,309 # [FAILED]
2024-01-18 21:21:51,314 # Starting test for PWM at tests/periph/selftest_shield/main.c:958
2024-01-18 21:21:51,318 # FAILURE in tests/periph/selftest_shield/main.c:979
2024-01-18 21:21:51,320 # 0 <= 1016 <= 64: FAILED
2024-01-18 21:21:51,327 # FAILURE in tests/periph/selftest_shield/main.c:979
2024-01-18 21:21:51,327 # 0 <= 933 <= 68: FAILED
2024-01-18 21:21:51,331 # [FAILED]
2024-01-18 21:21:51,337 # Starting test for ADC at tests/periph/selftest_shield/main.c:1027
2024-01-18 21:21:51,353 # [OK]
2024-01-18 21:21:51,354 # 
2024-01-18 21:21:51,354 # 
2024-01-18 21:21:51,354 # SOME TESTS FAILED
2024-01-18 21:21:51,361 # { "threads": [{ "name": "idle", "stack_size": 256, "stack_used": 228 }]}
2024-01-18 21:21:51,368 # { "threads": [{ "name": "main", "stack_size": 1280, "stack_used": 740 }]}

@maribu maribu removed the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Jan 19, 2024
@maribu
Copy link
Member Author

maribu commented Jan 19, 2024

I don't think the remaining PWM issues are related to this board and rather are periph_pwm related issues.

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.

Looks good, just some minor things - please squash directly.

boards/gd32vf103c-start/include/periph_conf.h Show resolved Hide resolved
boards/gd32vf103c-start/include/periph_conf.h Outdated Show resolved Hide resolved
boards/gd32vf103c-start/Makefile.include Outdated Show resolved Hide resolved
@maribu maribu force-pushed the boards/gd32vf103c-start branch from 740717c to 3e69c96 Compare January 19, 2024 20:22
Expose the compile time configuration knob `CONFIG_AFIO_PCF0_SWJ_CFG`
to allow freeing some/all JTAG pins and use them as GPIOs.

As default, PB4 is remapped from NJTRST to be usable as regular GPIO.
This still allows using the JTAG interface for debugging/flashing,
but makes an GPIO exposed by some boards available.
Let boards explicitly use the common OpenOCD config if it works for
them, rather than having boards with specific needs opt out.
This adds support for the GD32VF103C-START, the official "starter board"
for the GD32VF103C MCU by the MCU vendor.
@maribu maribu force-pushed the boards/gd32vf103c-start branch from 3e69c96 to 7f27e6c Compare January 19, 2024 22:17
@benpicco benpicco enabled auto-merge January 20, 2024 13:29
@benpicco benpicco added this pull request to the merge queue Jan 20, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 20, 2024
C has this feature that the order of struct members in the
initialization doesn't need to match the order in the declaration.
C++ has not yet caught up:

    boards/common/gd32v/include/cfg_usbdev_default.h:50:1: error: designator order for field 'dwc2_usb_otg_fshs_config_t::type' does not match declaration order in 'const dwc2_usb_otg_fshs_config_t'

So, just reorder the fields for now by hand.
@github-actions github-actions bot added Area: tests Area: tests and testing framework Area: examples Area: Example Applications labels Jan 20, 2024
@maribu maribu enabled auto-merge January 20, 2024 16:00
@maribu maribu added this pull request to the merge queue Jan 20, 2024
Merged via the queue into RIOT-OS:master with commit 504c169 Jan 20, 2024
25 checks passed
@maribu
Copy link
Member Author

maribu commented Jan 20, 2024

Wooohooo 🎉

Thx :)

@maribu maribu deleted the boards/gd32vf103c-start branch January 20, 2024 18:59
@MrKevinWeiss MrKevinWeiss added this to the Release 2024.01 milestone Feb 7, 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: 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 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