Skip to content

Comments

Support "file-less" configuration#151

Open
soburi wants to merge 6 commits intozephyrproject-rtos:nextfrom
soburi:configure_by_connector_def
Open

Support "file-less" configuration#151
soburi wants to merge 6 commits intozephyrproject-rtos:nextfrom
soburi:configure_by_connector_def

Conversation

@soburi
Copy link
Member

@soburi soburi commented Feb 1, 2026

This PR introduce new configuration system without variants/[board].overlay.

Boards that has arduino like connector mostly has define arduino-header.
We can use this information to configure automatically for each boards.
We can support all zephyr supported that has arduino-header.
That means, we make it works for more 200 boards, including Nucleo series.

However, only Blinky works out of the box, and ADC and PWM channels are required.
These should be made into snippets in the future.

Fix #11
Fix #90

@soburi soburi force-pushed the configure_by_connector_def branch from 30e80c9 to 2157ae2 Compare February 1, 2026 15:38
@soburi soburi changed the title Configure by connector def Support **file-less** configuration Feb 1, 2026
@soburi soburi changed the title Support **file-less** configuration Support "file-less" configuration Feb 1, 2026
@soburi soburi force-pushed the configure_by_connector_def branch 2 times, most recently from d14bab2 to 769f878 Compare February 5, 2026 15:17
@soburi soburi marked this pull request as ready for review February 5, 2026 15:17
Copilot AI review requested due to automatic review settings February 5, 2026 15:17
@soburi soburi marked this pull request as draft February 5, 2026 15:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a "file-less" configuration system that automatically configures boards using Arduino-compatible header definitions from the device tree, eliminating the need for board-specific overlay files. The system detects supported connector types (arduino_header, arduino_mkr_header, etc.) and automatically maps GPIO pins, enabling support for 200+ Zephyr-supported boards including the Nucleo series.

Changes:

  • Added automatic board detection using device tree connector labels (arduino_header, pico_header, etc.)
  • Introduced GPIO port/pin abstraction layer with constexpr helper functions for compile-time pin mapping
  • Modified tone/noTone implementation to support dynamic timer allocation by tracking pin assignments
  • Updated PWM and ADC pin mappings to support both legacy and new connector-based configurations

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 21 comments.

File Description
cores/arduino/Arduino.h Adds macro definitions for automatic connector detection (ZARD_CONNECTOR, ZARD_ADC_CONNECTOR, ZARD_PWM_CONNECTOR) and updates digital/analog pin enums to support both legacy and connector-based configurations
cores/arduino/zephyrCommon.cpp Implements GPIO abstraction layer with constexpr functions for pin mapping, updates all GPIO operations to use new abstraction, and modifies tone/noTone for improved timer management

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@soburi soburi force-pushed the configure_by_connector_def branch 3 times, most recently from 9d23221 to 293076c Compare February 9, 2026 10:57
@DhruvaG2000
Copy link
Member

This PR looks quite interesting, will be on my next list of things to review!

@soburi soburi force-pushed the configure_by_connector_def branch from 293076c to 7e1fd4c Compare February 9, 2026 14:23
* Copyright (c) 2026 TOKITA Hiroshi
*
* SPDX-License-Identifier: Apache-2.0
*/
Copy link
Member

Choose a reason for hiding this comment

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

If we can get #161 merged before this, then this will no longer be needed.

@soburi soburi force-pushed the configure_by_connector_def branch 8 times, most recently from dd32c52 to dc41a17 Compare February 11, 2026 03:46
@soburi soburi requested a review from Copilot February 11, 2026 04:41
In preparation for improvements to allow the use of GPIOs without
device tree definitions,
the interface will be changed to specify port and pin instead of
`gpio_dt_spec`.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@soburi soburi force-pushed the configure_by_connector_def branch 3 times, most recently from 8a57e4f to 10ccce4 Compare February 11, 2026 21:30
@soburi soburi requested a review from Copilot February 11, 2026 21:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@soburi soburi marked this pull request as ready for review February 11, 2026 22:38
@soburi soburi requested a review from DhruvaG2000 February 14, 2026 23:31
Copy link
Member

@DhruvaG2000 DhruvaG2000 left a comment

Choose a reason for hiding this comment

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

The commit ("cores: arduino: zephyrCommon: Generate config from connector definition") on it's own is rather too large to review.

I had to stop halfway through reviewing when I realised that a bunch of things have just been grouped together in it while it could definitely be split up in a cleaner more targeted way.

Here's my suggestion on how we need to make this cleaner:

  1. Create a Directory for Connectors (variants/connectors/)
  2. Create variants/connectors/arduino_header_r3.h: Move all R3-specific pin names and ZARD_CONNECTOR definition there.
  3. Create variants/connectors/connector.h: Add the #if DT_NODE_HAS_COMPAT checks to select the right file
  4. Clean cores/arduino/Arduino.h: Replace the mess with #include "connectors/connector.h".

I am open to hearing if you have alternate suggestions on similar lines, I just don't want to overcrowd the Arduino.h

Comment on lines 150 to 151
`LED_BUILTIN` to the **global GPIO number**, which matches the numeric pin
interpretation in that mode.
Copy link
Member

Choose a reason for hiding this comment

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

These 2 lines are not entirely clear, what is "global GPIO number" and what is "the numeric pin
interpretation "?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've created a chapter in the documentation and included references.

Comment on lines 86 to 131
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_A_0 A0
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_A_1 A1
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_A_2 A2
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_A_3 A3
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_A_4 A4
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_A_5 A5

#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_6 D0
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_7 D1
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_8 D2
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_9 D3
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_10 D4
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_11 D5
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_12 D6
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_13 D7
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_14 D8
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_15 D9
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_16 D10
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_17 D11
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_18 D12
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_19 D13
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_20 D14
#define ZARD_ARDUINO_HEADER_R3_PIN_NAME_D_21 D15

#define ZARD_ARDUINO_HEADER_R3_IS_ANALOG_0 1
#define ZARD_ARDUINO_HEADER_R3_IS_ANALOG_1 1
#define ZARD_ARDUINO_HEADER_R3_IS_ANALOG_2 1
#define ZARD_ARDUINO_HEADER_R3_IS_ANALOG_3 1
#define ZARD_ARDUINO_HEADER_R3_IS_ANALOG_4 1
#define ZARD_ARDUINO_HEADER_R3_IS_ANALOG_5 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_6 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_7 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_8 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_9 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_10 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_11 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_12 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_13 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_14 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_15 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_16 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_17 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_18 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_19 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_20 1
#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_21 1
Copy link
Member

Choose a reason for hiding this comment

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

Umm why are we bringing in Arduino R3 pins inside a central file like Arduino.h ?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. Create a Directory for Connectors (variants/connectors/)
  2. Create variants/connectors/arduino_header_r3.h: Move all R3-specific pin names and ZARD_CONNECTOR definition there.
  3. Create variants/connectors/connector.h: Add the #if DT_NODE_HAS_COMPAT checks to select the right file
  4. Clean cores/arduino/Arduino.h: Replace the mess with #include "connectors/connector.h".

The domain under variants is where special rules origins from the Arduino IDE apply, so it's best not to put it there.
I agree that it's better to split the files, so I split them into cores/arduino/connectors.

#else

#if DT_NODE_EXISTS(DT_NODELABEL(arduino_header))
#if DT_NODE_HAS_COMPAT(DT_NODELABEL(arduino_header), arduino_header_r3)
Copy link
Member

Choose a reason for hiding this comment

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

https://docs.zephyrproject.org/latest/build/dts/api/bindings/gpio/arduino-header-r3.html

GPIO pins exposed on Arduino Uno (R3) headers.

Please don't bring in board specific implementation inside the Arduino.h file.

Copy link
Member Author

Choose a reason for hiding this comment

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

ditto

#define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_21 1

#else
#error "Only arduino-header-r3 connector is supported"
Copy link
Member

Choose a reason for hiding this comment

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

No, we definitely can make this approach way better structured, but definitely not including #defines of board over board in a header single file

Copy link
Member Author

Choose a reason for hiding this comment

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

ditto

Comment on lines +298 to +319
#define ADC_PINS_GLOBAL(n, p, i) \
ZARD_GLOBAL_GPIO_OFFSET(DT_PHANDLE_BY_IDX(n, p, i)) + DT_PHA_BY_IDX(n, p, i, pin),
#define ADC_CH_CFG(n,p,i) arduino_adc[i].channel_cfg,
#define ADC_CONN_CHANNEL_CFG(n, p, i) \
COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MAP_ENTRY_PARENT_BY_IDX(n, p, i)), \
(ADC_CHANNEL_CFG_DT(ADC_CHANNEL_DT_NODE(DT_MAP_ENTRY_PARENT_BY_IDX(n, p, i), \
DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(n, p, i, 0))),), \
())
#define ADC_CONN_CHANNEL_DT(n, p, i) \
COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MAP_ENTRY_PARENT_BY_IDX(n, p, i)), \
(ADC_DT_SPEC_STRUCT(DT_MAP_ENTRY_PARENT_BY_IDX(n, p, i), \
DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(n, p, i, 0)),), \
())
#define ADC_CONN_PINNUM(n, p, i) \
COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MAP_ENTRY_PARENT_BY_IDX(n, p, i)), \
(ZARD_CONNECTOR_PIN_NAME_A(DT_NODELABEL(ZARD_CONNECTOR), \
DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 0)),), \
())

const struct adc_dt_spec arduino_adc[] = {
#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), io_channels)
DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), io_channels, ADC_DT_SPEC)
Copy link
Member

Choose a reason for hiding this comment

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

All these ADC related changes aren't even really part of the aim of this commit, please split this up into it's own commit

Copy link
Member Author

Choose a reason for hiding this comment

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

I split the commits into gpio, adc and pwm.

If digital-gpio-pins is not defined,
the pin configuration will be generated using the connector definition.

This allows ArduinoCore-Zephyr to be used on boards that have
arduino-header defined,
without requiring specific configuration in ArduinoCore-Zephyr.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
…nition

Like digital pins, PWMs are also defined from connectors.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
…nition

Like digital pins, ADCs are also defined from connectors.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Add guide for adding new board configuration and configuration
reference.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
@soburi soburi force-pushed the configure_by_connector_def branch from ebbb62a to 834adb8 Compare February 21, 2026 03:16
@soburi soburi requested a review from DhruvaG2000 February 21, 2026 03:23
A new configuration method has been adopted, allowing support to be added
with less configuration than before.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
@soburi soburi force-pushed the configure_by_connector_def branch from 834adb8 to 42996fc Compare February 21, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Builds fail if variant does not have any GPIOs Autogenerate board support

2 participants