Skip to content

boards: seeed: xiao_esp32c6 external antenna support #90059

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mariopaja
Copy link
Contributor

@mariopaja mariopaja commented May 16, 2025

This PR adds The RF switch node and support for the extenal antenna.

Based on: XIAO ESP32C6 Getting Started

@mariopaja mariopaja force-pushed the xiao_esp32c6_wifi_antenna_switch branch 5 times, most recently from 1826bde to d1744d6 Compare May 16, 2025 12:05
@mariopaja mariopaja force-pushed the xiao_esp32c6_wifi_antenna_switch branch 2 times, most recently from 22f751f to 676792e Compare May 16, 2025 12:08
@msalau
Copy link
Contributor

msalau commented May 16, 2025

Hello @mariopaja

There are hooks for board initialization:

To make the hooks functional they should be enabled in Kconfig:

config BOARD_XIAO_ESP32C6
+	select BOARD_EARLY_INIT_HOOK
+	select BOARD_LATE_INIT_HOOK

I think these hooks were added for scenarios like yours.

Best regards
Maksim

@mariopaja
Copy link
Contributor Author

@msalau Thank you for the input! I will have a look into it :)

return 0;
}

SYS_INIT(board_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
Copy link
Collaborator

Choose a reason for hiding this comment

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

use board hook


config XIAO_ESP32C6_EXT_ANTENNA
bool "XIAO ESP32C6 External Antenna"
default n
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
default n

@@ -37,6 +37,17 @@
watchdog0 = &wdt0;
};

rf_switch {
compatible = "gpio-keys";
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK gpio-keys is meant for inputs not outputs.
I don't know about any generic GPIO output driver, so gpio-leds is the best candidate.
Other boards use it for generic outputs too.
E.g.
heltec_wifi_lora32_v2/heltec_wifi_lora32_v2_procpu.dts
heltec_wifi_lora32_v2/board_init.c

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually good point, you need to create a custom DTS binding, use of LED for this is not allowed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nordicjm would dts/bindings/output/gpio-switch.yaml be okay. I guess then this would have to be added in a separate PR

Copy link
Contributor

@msalau msalau May 19, 2025

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you :D

@mariopaja mariopaja force-pushed the xiao_esp32c6_wifi_antenna_switch branch 8 times, most recently from 7839e88 to ad8031d Compare May 21, 2025 08:57
@mariopaja mariopaja force-pushed the xiao_esp32c6_wifi_antenna_switch branch from 169a8fd to e6a1373 Compare May 21, 2025 09:41
@msalau
Copy link
Contributor

msalau commented May 21, 2025

@mariopaja One last note :)

Is the feature specific to hpcore?
If yes - we should make this dependency explicit.

E.g.:
boards/seeed/xiao_esp32c6/Kconfig

config XIAO_ESP32C6_EXT_ANTENNA
	bool "XIAO ESP32C6 External Antenna Selector"
+	depends on BOARD_XIAO_ESP32C6_ESP32C6_HPCORE
	select BOARD_LATE_INIT_HOOK
	help
	  Select the external antenna of the XIAO ESP32-C6.
	  By default, the onboard antenna is used.

boards/seeed/xiao_esp32c6/CMakeLists.txt

if(CONFIG_BOARD_XIAO_ESP32C6_ESP32C6_HPCORE)
  zephyr_library()
  zephyr_library_sources(hpcore_init.c)
endif()

@jukkar jukkar added the platform: ESP32 Espressif ESP32 label May 21, 2025
@jukkar jukkar assigned sylvioalves and unassigned jukkar May 21, 2025
@mariopaja
Copy link
Contributor Author

mariopaja commented May 21, 2025

@mariopaja One last note :)

Is the feature specific to hpcore? If yes - we should make this dependency explicit.

E.g.: boards/seeed/xiao_esp32c6/Kconfig

config XIAO_ESP32C6_EXT_ANTENNA
	bool "XIAO ESP32C6 External Antenna Selector"
+	depends on BOARD_XIAO_ESP32C6_ESP32C6_HPCORE
	select BOARD_LATE_INIT_HOOK
	help
	  Select the external antenna of the XIAO ESP32-C6.
	  By default, the onboard antenna is used.

boards/seeed/xiao_esp32c6/CMakeLists.txt

if(CONFIG_BOARD_XIAO_ESP32C6_ESP32C6_HPCORE)
  zephyr_library()
  zephyr_library_sources(hpcore_init.c)
endif()

@msalau I am not sure to tell the truth
@sylvioalves Is wifi enabled only on hpcore on esp32c6 or can it be used also on the lpcore?

@sylvioalves
Copy link
Collaborator

@msalau I am not sure to tell the truth @sylvioalves Is wifi enabled only on hpcore on esp32c6 or can it be used also on the lpcore?
Wi-Fi is for HPCore only.

@sylvioalves
Copy link
Collaborator

@mariopaja I think the antenna option (Kconfig and binding) should be SoC specific and not board specific. This Kconfig could be in soc/espressif/common/. That would enable any custom board to have that option available. Would you re-work it?

@mariopaja
Copy link
Contributor Author

@sylvioalves sure, I can do that

Is it okay if I move the Kconfig and dts in a separate commit, or I need to do a separate PR for that?

Is ESP32_EXT_ANTENNA okay as a config?

@sylvioalves
Copy link
Collaborator

sylvioalves commented May 21, 2025

@sylvioalves sure, I can do that

Is it okay if I move the Kconfig and dts in a separate commit, or I need to do a separate PR for that?

Is ESP32_EXT_ANTENNA okay as a config?

ESP32_EXT_ANTENNA sounds good.
Make it all same PR with different commits. Add board's antenna support in the latest to keep bisectability.

@mariopaja
Copy link
Contributor Author

@sylvioalves I started reworking the PR but I dont know where exactly to put the binding.

Should I add it here dts/bindings/net/wireless?

@mariopaja mariopaja force-pushed the xiao_esp32c6_wifi_antenna_switch branch from e6a1373 to 8588e0b Compare May 27, 2025 11:50
@mariopaja mariopaja force-pushed the xiao_esp32c6_wifi_antenna_switch branch from 8588e0b to ae1a724 Compare May 27, 2025 12:02
Group of GPIO-controlled relays used to enable an RF switch and select the active antenna.
compatible: "gpio-rf-switch"

Copy link
Contributor

Choose a reason for hiding this comment

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

The binding looks too generic for me. There is nothing RF or switch specific. This binding can be used to define a GPIO for any purpose.

It seems there nothing RF specific in the switch in general so I'd expect a devicetree entry for an RF switch to be something like this (inspired by zephyr,devmux):

rf_switch: rf-switch {
	compatible = "gpio-switch";
	enable-gpios = <&gpio0 3 GPIO_ACTIVE_LOW>;
	select-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
	selected = <1>;
	status = "okay";
};

This way we have pre-defined properties for GPIOs and also can pre-define the selection if needed.

Also adding a generic driver for it doesn't look unreasonable but this widens scope of the PR significantly from a board specific initialization step to a driver for GPIO controllable switches.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@msalau You are right :/

Isnt it then better to be moved to dts/bindings/misc and be renamed into zephyr,gpio-switch.
I wouldnt mind opening another PR specifically for GPIO controllable switches, but I would appreciate to agree upon it :)

Do you accidentally know who is responsible for dts/bindings/misc?

Copy link
Member

Choose a reason for hiding this comment

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

nobody is specifically responsible, because of the nature of them being miscellaneous. But generic bindings of all kind should be reviewed by DT maintainers

This commit add the required dts and Kconfigs to enable
external antennas on custom boards

Signed-off-by: Mario Paja <mariopaja@hotmail.com>
@mariopaja mariopaja force-pushed the xiao_esp32c6_wifi_antenna_switch branch 2 times, most recently from c87554e to 0f77ae3 Compare June 4, 2025 07:58
This PR adds adds The RF switch node and support for
the extenal antenna.

Signed-off-by: Mario Paja <mariopaja@hotmail.com>
@mariopaja mariopaja force-pushed the xiao_esp32c6_wifi_antenna_switch branch from 0f77ae3 to f869dea Compare June 4, 2025 08:14
@mariopaja mariopaja marked this pull request as ready for review June 4, 2025 08:31
Copy link

sonarqubecloud bot commented Jun 4, 2025

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

Successfully merging this pull request may close these issues.

6 participants