feat(esp32-ethernet-kit): Add BSP component for esp32-ethernet-kit official development board - #677
Conversation
|
✅Static analysis result - no issues found! ✅ |
There was a problem hiding this comment.
Pull request overview
Adds a new ESPP Board Support Package (BSP) component for the Espressif ESP32-Ethernet-Kit A V1.2, including documentation and an example project, to make it easier to bring up Ethernet in DHCP client or DHCP server mode on this commonly used test board.
Changes:
- Introduces the new
components/esp32-ethernet-kitcomponent implementing Ethernet init + DHCP client/server support. - Adds an ESP-IDF example app (with Kconfig options) demonstrating client/server modes.
- Integrates the board/component into the documentation set (Sphinx pages + Doxygen inputs/example paths).
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| doc/en/dev_boards/espressif/index.rst | Adds the new board page to the Espressif dev boards toctree. |
| doc/en/dev_boards/espressif/esp32_ethernet_kit.rst | New board documentation page describing DHCP modes, warnings, and pin mapping. |
| doc/en/dev_boards/espressif/esp32_ethernet_kit_example.md | Adds doc page that includes the example README. |
| doc/Doxyfile | Registers the new component header and example for Doxygen/Sphinx API integration. |
| components/esp32-ethernet-kit/src/esp32-ethernet-kit.cpp | Implements Ethernet bring-up, event handling, and DHCP client/server behavior. |
| components/esp32-ethernet-kit/include/esp32-ethernet-kit.hpp | Public BSP API for initializing Ethernet and receiving link/IP callbacks. |
| components/esp32-ethernet-kit/README.md | Component-level README documenting capabilities and usage snippets. |
| components/esp32-ethernet-kit/idf_component.yml | ESP Component Manager manifest for publishing/consuming the component. |
| components/esp32-ethernet-kit/CMakeLists.txt | Component build registration and dependencies for ESP-IDF. |
| components/esp32-ethernet-kit/example/CMakeLists.txt | Example project CMake configuration wiring in repository components. |
| components/esp32-ethernet-kit/example/sdkconfig.defaults | Example defaults enabling Ethernet + PHY and related settings. |
| components/esp32-ethernet-kit/example/README.md | Example README with build/flash instructions. |
| components/esp32-ethernet-kit/example/main/CMakeLists.txt | Example “main” component registration for ESP-IDF build. |
| components/esp32-ethernet-kit/example/main/Kconfig.projbuild | Kconfig options for selecting DHCP mode and server static IP parameters. |
| components/esp32-ethernet-kit/example/main/esp32_ethernet_kit_example.cpp | Example app demonstrating DHCP client or DHCP server operation. |
esp32-ethernet-kit official development board
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (5)
doc/Doxyfile:108
- The Doxyfile EXAMPLE_PATH list is intended to be kept sorted; this new entry is currently out of order relative to the other
esp32-*board examples (and also leavesesp32-p4-function-ev-boardbeforeesp32-timer-cam). Reorder this local block to keep the list consistent and easier to maintain.
$(PROJECT_PATH)/components/esp32-timer-cam/example/main/esp_timer_cam_example.cpp \
$(PROJECT_PATH)/components/esp32-ethernet-kit/example/main/esp32_ethernet_kit_example.cpp \
$(PROJECT_PATH)/components/esp32-p4-function-ev-board/example/main/esp32_p4_function_ev_board_example.cpp \
doc/Doxyfile:260
- The Doxyfile INPUT list is intended to be kept sorted; this new header entry is currently out of order relative to the other
esp32-*board headers (and also leavesesp32-p4-function-ev-boardbeforeesp32-timer-cam). Reorder this local block to keep the list consistent and easier to maintain.
$(PROJECT_PATH)/components/esp32-timer-cam/include/esp32-timer-cam.hpp \
$(PROJECT_PATH)/components/esp32-ethernet-kit/include/esp32-ethernet-kit.hpp \
$(PROJECT_PATH)/components/esp32-p4-function-ev-board/include/esp32-p4-function-ev-board.hpp \
components/esp32-ethernet-kit/src/esp32-ethernet-kit.cpp:179
esp_netif_init()returnsESP_ERR_INVALID_STATEif the netif stack was already initialized elsewhere (e.g. another component called it first). Treating that as fatal makesinitialize_ethernet()fail in valid application setups. Other code in this repo (e.g.components/wifi/include/wifi.hpp) treatsESP_ERR_INVALID_STATEas a no-op/success for init calls.
ret = esp_netif_init();
if (ret != ESP_OK) {
logger_.error("esp_netif_init failed: {}", esp_err_to_name(ret));
return false;
}
components/esp32-ethernet-kit/idf_component.yml:20
idf_component.ymldependency format foridfis inconsistent with other components in this repo (they use the nestedversion:key). Usingidf: ">=5.0"may not be accepted by the IDF Component Manager and can break publishing/build tooling.
dependencies:
idf: ">=5.0"
espp/base_component: ">=1.0"
components/esp32-ethernet-kit/idf_component.yml:11
- This PR adds a new component + example, but the repository’s CI/publishing lists don’t include it yet.
build.yml's matrix includes other BSP examples (e.g.components/esp32-timer-cam/example,components/esp32-p4-function-ev-board/example) but notcomponents/esp32-ethernet-kit/example, andupload_components.ymlincludes other BSP components (e.g.components/esp32-timer-cam,components/esp32-p4-function-ev-board) but notcomponents/esp32-ethernet-kit. Without those updates, the example won’t be built in CI and the component won’t be included in the upload workflow.
documentation: "https://esp-cpp.github.io/espp/dev_boards/espressif/esp32_ethernet_kit.html"
examples:
- path: example
tags:
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (9)
doc/Doxyfile:109
- The new entry was added in the middle of the existing list, but the
EXAMPLE_PATHsection is now out of alphabetical order (esp32-* entries are not sorted). This makes future merges/conflict resolution harder and violates the repo’s “keep Doxyfile entries alphabetically sorted” convention.
$(PROJECT_PATH)/components/encoder/example/main/encoder_example.cpp \
$(PROJECT_PATH)/components/esp32-timer-cam/example/main/esp_timer_cam_example.cpp \
$(PROJECT_PATH)/components/esp32-ethernet-kit/example/main/esp32_ethernet_kit_example.cpp \
$(PROJECT_PATH)/components/esp32-p4-function-ev-board/example/main/esp32_p4_function_ev_board_example.cpp \
$(PROJECT_PATH)/components/esp-box/example/main/esp_box_example.cpp \
doc/Doxyfile:261
- The
INPUTlist is no longer in alphabetical order after adding the new header entry (esp32-* headers are not sorted). Please keep this section sorted to match the convention used elsewhere in the repo.
$(PROJECT_PATH)/components/encoder/include/encoder_types.hpp \
$(PROJECT_PATH)/components/esp32-timer-cam/include/esp32-timer-cam.hpp \
$(PROJECT_PATH)/components/esp32-ethernet-kit/include/esp32-ethernet-kit.hpp \
$(PROJECT_PATH)/components/esp32-p4-function-ev-board/include/esp32-p4-function-ev-board.hpp \
$(PROJECT_PATH)/components/esp-box/include/esp-box.hpp \
components/esp32-ethernet-kit/src/esp32-ethernet-kit.cpp:276
esp_netif_init()commonly returnsESP_ERR_INVALID_STATEwhen the netif layer has already been initialized by the application (similar to how you already handleesp_event_loop_create_default). Treating that as a hard error can makeinitialize_ethernet()fail in otherwise-valid apps.
ret = esp_netif_init();
if (ret != ESP_OK) {
return fail("esp_netif_init failed", ret);
}
components/esp32-ethernet-kit/README.md:27
- In DHCP client mode, the code invokes
on_link_uponETHERNET_EVENT_CONNECTED(link up), and invokeson_got_iponIP_EVENT_ETH_GOT_IP(lease granted). This paragraph currently sayson_link_upfires once the lease is granted, which is inconsistent with the implementation and theEthernetConfigfield docs.
The `on_link_up` callback fires once the DHCP lease is granted.
components/esp32-ethernet-kit/README.md:36
- This snippet calls
initialize_ethernetwith a callback + mode parameter, but the actual API takes a singleEthernetConfigargument. Updating the example to match the struct-based API prevents compile errors for users following the README.
board.initialize_ethernet(
[](esp_ip4_addr_t ip) {
// called when lease is acquired
},
espp::Esp32EthernetKit::DhcpMode::CLIENT); // default — can be omitted
components/esp32-ethernet-kit/README.md:67
- This DHCP-server example uses the old multi-argument
initialize_ethernetcall signature. The implementation expects a singleEthernetConfigargument (with.modeand.server_configset).
board.initialize_ethernet(
[](esp_ip4_addr_t ip) {
// called when link is up (static IP is already known)
},
DhcpMode::SERVER,
components/esp32-ethernet-kit/README.md:22
- This README describes
initialize_ethernetas taking aDhcpModeparameter, but the public API inesp32-ethernet-kit.hppexposesinitialize_ethernet(const EthernetConfig&)(plus a no-arg default). Keeping the README aligned with the actual API avoids copy/paste usage errors.
This issue also appears in the following locations of the same file:
- line 27
- line 32
- line 63
`initialize_ethernet` accepts a `DhcpMode` parameter (default `CLIENT`).
doc/en/dev_boards/espressif/esp32_ethernet_kit.rst:17
- The DHCP client description says
on_link_upfires once the DHCP lease is granted, but the implementation triggerson_link_upon link-up andon_got_ipwhen the lease is granted. This documentation mismatch can lead users to wire callbacks incorrectly.
**DHCP client** (default): the ESP32 requests an IP address from an upstream
router or switch. The ``on_link_up`` callback fires once the DHCP lease is
granted.
components/esp32-ethernet-kit/idf_component.yml:10
- This PR adds a new component + example, but CI configuration doesn’t currently reference
components/esp32-ethernet-kitat all (no entry in.github/workflows/build.ymlmatrix, and no entry in.github/workflows/upload_components.ymlcomponents:list). Without those updates, the example won’t be built in CI and the registry dry-run won’t validate/publish the new component.
examples:
- path: example
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (4)
components/esp32-ethernet-kit/include/esp32-ethernet-kit.hpp:71
ServerConfig::ip_infouses a designated initializer assigning integers toesp_netif_ip_info_tsubfields (.ip = 0, etc.). Since the implementation later accessesip_info.ip.addr, these fields are structs, so this initializer is likely ill-formed in C++ and can break compilation. Use value-initialization ({}) to zero the whole struct instead.
struct ServerConfig {
esp_netif_ip_info_t ip_info{
.ip = 0, .netmask = 0, .gw = 0}; ///< IP / netmask / gateway; zero → 192.168.4.1/24
client_ip_callback_t on_client_assigned{
components/esp32-ethernet-kit/src/esp32-ethernet-kit.cpp:276
esp_netif_init()can legally returnESP_ERR_INVALID_STATEwhen the netif stack is already initialized (e.g. by other networking components). Treating that as a hard failure makesinitialize_ethernet()unexpectedly fail in multi-component apps.
ret = esp_netif_init();
if (ret != ESP_OK) {
return fail("esp_netif_init failed", ret);
}
components/esp32-ethernet-kit/example/main/esp32_ethernet_kit_example.cpp:35
- The example ignores the return value of
ip4addr_aton(...). If the user enters an invalid IP/netmask/gateway in Kconfig,srv_cfg.ip_infomay contain zeros/garbage and the example will behave unexpectedly. Validate the inputs and fall back to defaults (all-zeroip_info) when parsing fails.
espp::Esp32EthernetKit::ServerConfig srv_cfg;
ip4addr_aton(CONFIG_EXAMPLE_ETH_SERVER_IP, reinterpret_cast<ip4_addr_t *>(&srv_cfg.ip_info.ip));
ip4addr_aton(CONFIG_EXAMPLE_ETH_SERVER_NETMASK,
reinterpret_cast<ip4_addr_t *>(&srv_cfg.ip_info.netmask));
ip4addr_aton(CONFIG_EXAMPLE_ETH_SERVER_GW, reinterpret_cast<ip4_addr_t *>(&srv_cfg.ip_info.gw));
components/esp32-ethernet-kit/CMakeLists.txt:10
- This PR adds a new component + example, but it doesn’t add the corresponding CI entries (example build matrix in
.github/workflows/build.ymland component list entry in.github/workflows/upload_components.yml). Without those, the new BSP won’t be built/tested in CI or published consistently with other components.
idf_component_register(
INCLUDE_DIRS "include"
SRC_DIRS "src"
REQUIRES
"base_component"
"esp_eth"
"esp_netif"
"esp_event"
REQUIRED_IDF_TARGETS "esp32"
)
Description
bsp for Esp32-Ethernet-kit-A-v1.2
Motivation and Context
Lots of rtps_embedded example use this board to test. Better to have a bsp for it.
How has this been tested?
Tested with the esp32-ethernt-kit-A-V1.2 as a DHCP server and connect it to a ethernet switch. Connect another dhcp client to the switch and this dev-kit (dhcp Server) should assign a new ip to the client.
Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):
Types of changes
Checklist:
Software
.github/workflows/build.ymlfile to add my new test to the automated cloud build github action.Hardware