Skip to content

board: xhsc: hc32f4a0_evb: Add minimal supprot for hc32f4a0_evb board #94044

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

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

TrackingRobot
Copy link

This commit adds support for the hc32f4a0_evb board to print info by usart, including the necessary devicetree files, Kconfig configurations, peripherals and board-specific documentation.

The following changes about the board are included:

Add hc32f4a0_evb.dts with hardware description for the board.
Add Kconfig.board and Kconfig.defconfig for default software configurations.
Add board documentation in doc/index.rst. - Add board.yaml for test runner metadata.

To implement console output, the following peripheral are supported:

gpio
intc
clock
serial

Copy link

github-actions bot commented Aug 4, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hal_xhsc 🆕 N/A (Added) zephyrproject-rtos/hal_xhsc@45f9eec (zephyr) N/A

DNM label due to: 1 added project

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@TrackingRobot TrackingRobot force-pushed the xhsc-develop branch 2 times, most recently from 4fffc40 to d411de8 Compare August 4, 2025 06:28
Comment on lines 4 to 11
config CLOCK_CONTROL_HC32
bool "HC32 Clock Control"

if CLOCK_CONTROL_HC32

config HC32_LL_CLK
bool
default y
Copy link
Contributor

Choose a reason for hiding this comment

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

I have no clue what is going on here but no, fix properly and use proper dependency

Copy link
Author

Choose a reason for hiding this comment

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

That was defined in modules/Kconfig.xhsc, and its default value is 'y'. Therefore, I deleted lines 7 to 14 in this file.

Select High Driver for XTAL32

config HC32_XTAL32_DRV_M
bool "medium Driver"
Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalise first letter of prompt

bool "medium Driver"
help
Select medium Driver for XTAL32
endchoice
Copy link
Contributor

Choose a reason for hiding this comment

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

newline missing on line 26

Comment on lines 28 to 31
config HC32_XTAL32_DRV
int
default 0 if HC32_XTAL32_DRV_M
default 1 if HC32_XTAL32_DRV_H
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this?

Copy link
Author

Choose a reason for hiding this comment

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

These options configure the drive current strength of the external low-speed crystal based on varying capacitances.

Copy link
Contributor

Choose a reason for hiding this comment

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

make them dts properties

default y
depends on DT_HAS_XHSC_HC32_UART_ENABLED
select SERIAL_HAS_DRIVER
select HC32_LL_USART
Copy link
Contributor

Choose a reason for hiding this comment

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

tab not spaces for ident

Copy link
Contributor

Choose a reason for hiding this comment

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

file is way too huge, needs to be far smaller, then save as webp and put through https://tinypng.com/

Copy link
Author

@TrackingRobot TrackingRobot Aug 5, 2025

Choose a reason for hiding this comment

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

Reduce the image file size from its original 716KB (1128x828, jpg) to a smaller size of 61KB (789x579, webp).

Comment on lines 40 to 61
The board configuration supports the following hardware features:

.. list-table::
:header-rows: 1

* - Peripheral
- Kconfig option
- Devicetree compatible
* - GPIO
- :kconfig:option:`CONFIG_GPIO`
- :dtcompatible:`xhsc,hc32-gpio`
* - NVIC
- N/A
- :dtcompatible:`arm,v7m-nvic`
* - PINMUX
- :kconfig:option:`CONFIG_PINCTRL`
- :dtcompatible:`xhsc,hc32-pinctrl`
* - USART
* - :kconfig:option:`CONFIG_SERIAL`
- :dtcompatible:`xhsc,hc32-uart`

Other hardware features are not yet supported on this Zephyr port.
Copy link
Contributor

Choose a reason for hiding this comment

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

use hw directive tag

Comment on lines 4 to 6
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=240000000
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000
CONFIG_HC32_DDL_DEBUG=y
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=240000000
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000
CONFIG_HC32_DDL_DEBUG=y

CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_PINCTRL=y
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
CONFIG_PINCTRL=y

Copy link
Author

Choose a reason for hiding this comment

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

Moved to the soc/xhsc/hc32/hc32f4xx/Kconfig.

Comment on lines +277 to +281
- name: hal_xhsc
revision: 45f9eec3064663b992da9f1497aaaa8371bcb821
path: modules/hal/xhsc
groups:
- hal
Copy link
Contributor

Choose a reason for hiding this comment

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

this needs to come before things that need it

Copy link
Author

Choose a reason for hiding this comment

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

Hi @nordicjm,
May I ask, do you mean that we should first submit a PR for the manifest and MAINTAINERS files? After that pull request is merged, can we then submit the pull request for adding the board and SoC?
Or, do we simply need to adjust the commit sequence to move the manifest and MAINTAINERS to the first two commits?

@TrackingRobot
Copy link
Author

Hi @nordicjm, thanks for your efficient checking and quick comments. Being new contributors, we made a lot of mistakes in the code. We will fix these bugs as soon as possible, and the fixed issues will be marked with a thumbs-up emoji!

…_xhsc.

Add levizh as maintainers, add Pengbiao12345, ETRD, greya5, JamieTx,
TrackingRobot as collaborators for hal_xhsc.

Signed-off-by: TrackingRobot <code9527@126.com>
Add HAL repository information for the first supported HC32F4A0_EVB
and HC32F460_EVB.

Signed-off-by: TrackingRobot <code9527@126.com>
This is the initial commit to support clock_control driver for XHSC HC32F4A0

Signed-off-by: TrackingRobot <code9527@126.com>
This is the initial commit to support gpio driver for XHSC HC32F4A0

Signed-off-by: TrackingRobot <code9527@126.com>
This is the initial commit to support pinctrl driver for XHSC HC32F4A0

Signed-off-by: TrackingRobot <code9527@126.com>
This is the initial commit to support interrupt controller

Signed-off-by: TrackingRobot <code9527@126.com>
This is the initial commit to support USART driver for XHSC HC32F4A0

Signed-off-by: TrackingRobot <code9527@126.com>
Add support for XHSC HC32F4A0

Signed-off-by: TrackingRobot <code9527@126.com>
This adds minimal support for board HC32F4A0_EVB

Signed-off-by: TrackingRobot <code9527@126.com>
Copy link

sonarqubecloud bot commented Aug 8, 2025

@TrackingRobot
Copy link
Author

TrackingRobot commented Aug 8, 2025

In order to maintain the cleanliness of the submission, we had to use rebase and force push.
We created a another branch to make the PR changes traceable:
https://github.com/levizh/zephyr/tree/xhsc-pr-fixup#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants