This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit c63c061a52cccc93eac1645057840767b54509d3
Author: Tiago Medicci Serrano <[email protected]>
AuthorDate: Tue Apr 28 17:26:14 2026 -0300

    boards/risc-v: Enable ethernet on ESP32-P4-Function-EV-Board
    
    This commit simply enables the ethernet support for the ESP32-P4's
    Function EV board.
    
    Signed-off-by: Tiago Medicci Serrano <[email protected]>
---
 .../configs/ethernet/defconfig                     | 77 +++++++++++++++++++++
 .../esp32p4-function-ev-board/src/CMakeLists.txt   |  4 ++
 .../esp32p4-function-ev-board/src/Make.defs        |  4 ++
 .../src/esp32p4-function-ev-board.h                | 21 ++++++
 .../src/esp32p4_bringup.c                          |  8 +++
 .../src/esp32p4_ethernet.c                         | 78 ++++++++++++++++++++++
 6 files changed, 192 insertions(+)

diff --git 
a/boards/risc-v/esp32p4/esp32p4-function-ev-board/configs/ethernet/defconfig 
b/boards/risc-v/esp32p4/esp32p4-function-ev-board/configs/ethernet/defconfig
new file mode 100644
index 00000000000..34d313a977c
--- /dev/null
+++ b/boards/risc-v/esp32p4/esp32p4-function-ev-board/configs/ethernet/defconfig
@@ -0,0 +1,77 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed 
.config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that 
includes your
+# modifications.
+#
+# CONFIG_NDEBUG is not set
+# CONFIG_NSH_ARGCAT is not set
+# CONFIG_NSH_CMDOPT_HEXDUMP is not set
+CONFIG_ARCH="risc-v"
+CONFIG_ARCH_BOARD="esp32p4-function-ev-board"
+CONFIG_ARCH_BOARD_COMMON=y
+CONFIG_ARCH_BOARD_ESP32P4_FUNCTION_EV_BOARD=y
+CONFIG_ARCH_CHIP="esp32p4"
+CONFIG_ARCH_CHIP_ESP32P4=y
+CONFIG_ARCH_INTERRUPTSTACK=2048
+CONFIG_ARCH_IRQ_TO_NDX=y
+CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y
+CONFIG_ARCH_NUSER_INTERRUPTS=17
+CONFIG_ARCH_RISCV=y
+CONFIG_BOARDCTL_RESET=y
+CONFIG_BOARD_LOOPSPERMSEC=15000
+CONFIG_BUILTIN=y
+CONFIG_ESPRESSIF_EMAC=y
+CONFIG_ESPRESSIF_ETH_DMA_BUFFER_SIZE=512
+CONFIG_ESPRESSIF_MERGE_BINS=y
+CONFIG_ESPRESSIF_SPIFLASH=y
+CONFIG_ESPRESSIF_SPIFLASH_SMARTFS=y
+CONFIG_ESPRESSIF_SPIRAM=y
+CONFIG_ESPRESSIF_STORAGE_MTD_OFFSET=0x110000
+CONFIG_ESPRESSIF_STORAGE_MTD_SIZE=0xf0000
+CONFIG_EXPERIMENTAL=y
+CONFIG_FS_PROCFS=y
+CONFIG_IDLETHREAD_STACKSIZE=2048
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INTELHEX_BINARY=y
+CONFIG_LIBC_PERROR_STDOUT=y
+CONFIG_LIBC_STRERROR=y
+CONFIG_MM_KERNEL_HEAP=y
+CONFIG_MM_REGIONS=2
+CONFIG_NAME_MAX=48
+CONFIG_NETDB_DNSCLIENT=y
+CONFIG_NETDEV_LATEINIT=y
+CONFIG_NETDEV_PHY_IOCTL=y
+CONFIG_NETINIT_DHCPC=y
+CONFIG_NETINIT_THREAD=y
+CONFIG_NETUTILS_IPERF=y
+CONFIG_NET_BROADCAST=y
+CONFIG_NET_ETH_PKTSIZE=1514
+CONFIG_NET_ICMP_SOCKET=y
+CONFIG_NET_TCP=y
+CONFIG_NET_UDP=y
+CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_DISABLE_LOSMART=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_READLINE=y
+CONFIG_NSH_STRERROR=y
+CONFIG_PREALLOC_TIMERS=0
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_BACKTRACE=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_SMARTFS_MAXNAMLEN=48
+CONFIG_START_DAY=29
+CONFIG_START_MONTH=11
+CONFIG_START_YEAR=2019
+CONFIG_SYSTEM_DHCPC_RENEW=y
+CONFIG_SYSTEM_DUMPSTACK=y
+CONFIG_SYSTEM_FLASH_ERASEALL=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_PING=y
+CONFIG_TESTING_FSTEST=y
+CONFIG_TESTING_FSTEST_MOUNTPT="/mnt"
+CONFIG_TESTING_HEAP=y
+CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/CMakeLists.txt 
b/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/CMakeLists.txt
index 688eddaf1db..409bdf4574e 100644
--- a/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/CMakeLists.txt
+++ b/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/CMakeLists.txt
@@ -36,6 +36,10 @@ if(CONFIG_ARCH_BUTTONS)
   list(APPEND SRCS esp32p4_buttons.c)
 endif()
 
+if(CONFIG_ESPRESSIF_EMAC)
+  list(APPEND SRCS esp32p4_ethernet.c)
+endif()
+
 target_sources(board PRIVATE ${SRCS})
 
 # 
##############################################################################
diff --git a/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/Make.defs 
b/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/Make.defs
index 021a384a173..572683238cc 100644
--- a/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/Make.defs
+++ b/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/Make.defs
@@ -38,6 +38,10 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y)
   CSRCS += esp32p4_buttons.c
 endif
 
+ifeq ($(CONFIG_ESPRESSIF_EMAC),y)
+  CSRCS += esp32p4_ethernet.c
+endif
+
 DEPPATH += --dep-path board
 VPATH += :board
 CFLAGS += 
${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board
diff --git 
a/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4-function-ev-board.h
 
b/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4-function-ev-board.h
index 6917761f504..cd926f34e3e 100644
--- 
a/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4-function-ev-board.h
+++ 
b/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4-function-ev-board.h
@@ -102,6 +102,9 @@ int board_twai_setup(int port);
  * Description:
  *   Configure the GPIO driver.
  *
+ * Input Parameters:
+ *   None.
+ *
  * Returned Value:
  *   Zero (OK).
  *
@@ -111,5 +114,23 @@ int board_twai_setup(int port);
 int esp_gpio_init(void);
 #endif
 
+/****************************************************************************
+ * Name: board_emac_init
+ *
+ * Description:
+ *   Bring up the ESP32-P4 Ethernet MAC driver (esp_eth backed).
+ *
+ * Input Parameters:
+ *   None.
+ *
+ * Returned Value:
+ *   Zero (OK) on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ESPRESSIF_EMAC
+int board_emac_init(void);
+#endif
+
 #endif /* __ASSEMBLY__ */
 #endif /* 
__BOARDS_RISCV_ESP32P4_ESP32P4_FUNCTION_EV_BOARD_SRC_ESP32P4_FUNCTION_EV_BOARD_H
 */
diff --git 
a/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4_bringup.c 
b/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4_bringup.c
index e32286ada4f..d2d185d3a75 100644
--- a/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4_bringup.c
+++ b/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4_bringup.c
@@ -447,6 +447,14 @@ int esp_bringup(void)
     }
 #endif
 
+#ifdef CONFIG_ESPRESSIF_EMAC
+  ret = board_emac_init();
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: board_emac_init failed: %d\n", ret);
+    }
+#endif
+
 #ifdef CONFIG_ESPRESSIF_USE_LP_CORE
 
   /* ULP initialization should be the handled later than
diff --git 
a/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4_ethernet.c 
b/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4_ethernet.c
new file mode 100644
index 00000000000..8a3d7558f8b
--- /dev/null
+++ b/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4_ethernet.c
@@ -0,0 +1,78 @@
+/****************************************************************************
+ * boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4_ethernet.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <debug.h>
+#include <errno.h>
+
+#include "espressif/esp_emac.h"
+#include "espressif/esp_hr_timer.h"
+
+#include "esp32p4-function-ev-board.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_emac_init
+ *
+ * Description:
+ *   Bring up the ESP32-P4 Ethernet interface (internal EMAC + external
+ *   PHY) and register it with the NuttX network stack.
+ *
+ * Input Parameters:
+ *   None.
+ *
+ * Returned Value:
+ *   0 (OK) on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int board_emac_init(void)
+{
+  int ret;
+
+  /* esp_eth_driver_install() relies on esp_timer; make sure the timer
+   * subsystem is initialised before creating the driver.
+   */
+
+  ret = esp_hr_timer_init();
+  if (ret < 0)
+    {
+      nerr("ERROR: esp_hr_timer_init failed: %d\n", ret);
+      return ret;
+    }
+
+  ret = esp_emac_init();
+  if (ret < 0)
+    {
+      nerr("ERROR: esp_emac_init failed: %d\n", ret);
+    }
+
+  return ret;
+}

Reply via email to