Skip to content

[bsp][gd32] fix pwm enable channel check#11547

Open
Old-Ding wants to merge 2 commits into
RT-Thread:masterfrom
Old-Ding:codex/fix-gd32-pwm-enable-channel
Open

[bsp][gd32] fix pwm enable channel check#11547
Old-Ding wants to merge 2 commits into
RT-Thread:masterfrom
Old-Ding:codex/fix-gd32-pwm-enable-channel

Conversation

@Old-Ding

@Old-Ding Old-Ding commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • define the PWM channel number before validating it in the GD32 PWM enable path
  • keep the enable/disable behavior unchanged and match the existing period/pulse helpers

Root cause

drv_pwm_enable() checks channel_num, but the local variable was never initialized in that function after the GD32 PWM refactor. The adjacent period and pulse helpers already derive it from configuration->channel before the same validation.

Closes #11331

Testing

  • git diff --check
  • verified the diff is limited to one insertion in bsp/gd32/arm/libraries/gd32_drivers/drv_pwm.c
  • verified the file keeps CRLF line endings

Not run: GD32 BSP build. This machine does not have scons, gcc, arm-none-eabi-gcc, or clang installed.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread!

为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。
To ensure your code complies with RT-Thread's coding style, please run the code formatting workflow by following the steps below (If the formatting of CI fails to run).


🛠 操作步骤 | Steps

  1. 前往 Actions 页面 | Go to the Actions page
    点击进入工作流 → | Click to open workflow →

  2. 点击 Run workflow | Click Run workflow

  • 设置需排除的文件/目录(目录请以"/"结尾)
    Set files/directories to exclude (directories should end with "/")
  • 将目标分支设置为 \ Set the target branch to:codex/fix-gd32-pwm-enable-channel
  • 设置PR number为 \ Set the PR number to:11547
  1. 等待工作流完成 | Wait for the workflow to complete
    格式化后的代码将自动推送至你的分支。
    The formatted code will be automatically pushed to your branch.

完成后,提交将自动更新至 codex/fix-gd32-pwm-enable-channel 分支,关联的 Pull Request 也会同步更新。
Once completed, commits will be pushed to the codex/fix-gd32-pwm-enable-channel branch automatically, and the related Pull Request will be updated.

如有问题欢迎联系我们,再次感谢您的贡献!💐
If you have any questions, feel free to reach out. Thanks again for your contribution!

@github-actions github-actions Bot added BSP BSP: GD32 BSP related with GD32 labels Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@Old-Ding Old-Ding marked this pull request as ready for review July 1, 2026 09:08
@Old-Ding Old-Ding requested a review from kurisaW as a code owner July 1, 2026 09:08

@CYFS3 CYFS3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@Rbb666

Rbb666 commented Jul 3, 2026

Copy link
Copy Markdown
Member

ci-attach也麻烦添加下吧,避免后面出现类似情况。教程:https://club.rt-thread.org/ask/article/d273bbcd1f8779bc.html

@Old-Ding

Old-Ding commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

已补充 ci-attach:新增 bsp/gd32/arm/gd32405rg/.ci/attachconfig/ci.attachconfig.yml,打开 CONFIG_BSP_USING_PWM=yCONFIG_BSP_USING_PWM0=y

这个 BSP 已在 gd32_n32_apm32 CI 分组里,并且本身有 PWM Kconfig 声明;加 attachconfig 后会额外编译 GD32 PWM 驱动路径,后续类似 BSP_USING_PWM 打开后才暴露的问题可以被 CI 覆盖到。

本地已检查:

  • git diff --check
  • attachconfig YAML 可解析

新 CI 已由提交触发,正在跑。

@CYFS3

CYFS3 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

已补充 ci-attach:新增 bsp/gd32/arm/gd32405rg/.ci/attachconfig/ci.attachconfig.yml,打开 CONFIG_BSP_USING_PWM=yCONFIG_BSP_USING_PWM0=y

这个 BSP 已在 gd32_n32_apm32 CI 分组里,并且本身有 PWM Kconfig 声明;加 attachconfig 后会额外编译 GD32 PWM 驱动路径,后续类似 BSP_USING_PWM 打开后才暴露的问题可以被 CI 覆盖到。

本地已检查:

  • git diff --check
  • attachconfig YAML 可解析

新 CI 已由提交触发,正在跑。

CI报错了麻烦处理一下

@Old-Ding

Old-Ding commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

更新一下 CI 结果:gd32_n32_apm32 的失败不是本 PR 这处 PWM channel 判断改动导致的编译错误,而是新增 ci-attach 打开 gd32405rgBSP_USING_PWM/PWM0 后,暴露了 gd32-arm-series package 里的 F4xx timer 源文件依赖缺口。

失败日志里 drv_pwm.o 已经被编译,但链接阶段缺这些 GD32 标准外设 timer 符号:timer_deinittimer_channel_output_configtimer_enable 等。根因是 package 的 GD32F4xx/SConscript 当前没有在 RT_USING_PWM/RT_USING_HWTIMER 下加入 GD32F4xx_standard_peripheral/Source/gd32f4xx_timer.c

我已经在 package 仓库补了对应修复:RT-Thread-packages/gd32-arm-series#11。等这个 package PR 合入后,重新跑本 PR 的 BSP CI attach 应该就能覆盖并通过 gd32405rg PWM0 路径。

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

Labels

BSP: GD32 BSP related with GD32 BSP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] bsp/gd32/arm/libraries/gd32_drivers/drv_pwm.c 开启BSP_USING_PWM 编译报错

3 participants