Support "file-less" configuration#151
Support "file-less" configuration#151soburi wants to merge 6 commits intozephyrproject-rtos:nextfrom
Conversation
30e80c9 to
2157ae2
Compare
d14bab2 to
769f878
Compare
There was a problem hiding this comment.
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.
165377e to
aa5f7a5
Compare
There was a problem hiding this comment.
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.
9d23221 to
293076c
Compare
|
This PR looks quite interesting, will be on my next list of things to review! |
293076c to
7e1fd4c
Compare
| * Copyright (c) 2026 TOKITA Hiroshi | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ |
There was a problem hiding this comment.
If we can get #161 merged before this, then this will no longer be needed.
dd32c52 to
dc41a17
Compare
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>
b9a77a3 to
421542f
Compare
There was a problem hiding this comment.
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.
8a57e4f to
10ccce4
Compare
There was a problem hiding this comment.
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.
10ccce4 to
46e1825
Compare
There was a problem hiding this comment.
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.
46e1825 to
ebbb62a
Compare
There was a problem hiding this comment.
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.
variants/arduino_uno_r4_r7fa4m1ab3cfm/arduino_uno_r4_r7fa4m1ab3cfm.overlay
Show resolved
Hide resolved
DhruvaG2000
left a comment
There was a problem hiding this comment.
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:
- Create a Directory for Connectors (
variants/connectors/) - Create
variants/connectors/arduino_header_r3.h: Move all R3-specific pin names and ZARD_CONNECTOR definition there. - Create
variants/connectors/connector.h: Add the #if DT_NODE_HAS_COMPAT checks to select the right file - 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
documentation/variants.md
Outdated
| `LED_BUILTIN` to the **global GPIO number**, which matches the numeric pin | ||
| interpretation in that mode. |
There was a problem hiding this comment.
These 2 lines are not entirely clear, what is "global GPIO number" and what is "the numeric pin
interpretation "?
There was a problem hiding this comment.
I've created a chapter in the documentation and included references.
cores/arduino/Arduino.h
Outdated
| #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 |
There was a problem hiding this comment.
Umm why are we bringing in Arduino R3 pins inside a central file like Arduino.h ?
There was a problem hiding this comment.
- Create a Directory for Connectors (
variants/connectors/)- Create
variants/connectors/arduino_header_r3.h: Move all R3-specific pin names and ZARD_CONNECTOR definition there.- Create
variants/connectors/connector.h: Add the #if DT_NODE_HAS_COMPAT checks to select the right file- 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.
cores/arduino/Arduino.h
Outdated
| #else | ||
|
|
||
| #if DT_NODE_EXISTS(DT_NODELABEL(arduino_header)) | ||
| #if DT_NODE_HAS_COMPAT(DT_NODELABEL(arduino_header), arduino_header_r3) |
There was a problem hiding this comment.
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.
cores/arduino/Arduino.h
Outdated
| #define ZARD_ARDUINO_HEADER_R3_IS_DIGITAL_21 1 | ||
|
|
||
| #else | ||
| #error "Only arduino-header-r3 connector is supported" |
There was a problem hiding this comment.
No, we definitely can make this approach way better structured, but definitely not including #defines of board over board in a header single file
| #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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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>
ebbb62a to
834adb8
Compare
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>
834adb8 to
42996fc
Compare
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