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 9e53add5896a6c91d297fea32e2d7935be2469fb Author: raiden00pl <[email protected]> AuthorDate: Tue Nov 17 10:52:46 2026 +0100 boards/stm32n6570-dk: Add Ethernet and the netnsh configuration. The RJ45 port is the RTL8211F PHY on ETH1 over RGMII. The netnsh configuration adds networking with DHCP, ping, telnetd and mdio. Assisted-by: Claude:claude-fable-5-1 Signed-off-by: raiden00pl <[email protected]> --- .../arm/stm32n6/boards/stm32n6570-dk/index.rst | 19 +++++ .../stm32n6/stm32n6570-dk/configs/netnsh/defconfig | 87 ++++++++++++++++++++++ boards/arm/stm32n6/stm32n6570-dk/include/board.h | 36 +++++++++ .../arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c | 11 +++ 4 files changed, 153 insertions(+) diff --git a/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst b/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst index 92b55872627..49f3d4c22d5 100644 --- a/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst +++ b/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst @@ -155,6 +155,18 @@ PG2 MOSI (D11) and PA3 as chip select (D10). It is registered as ``/dev/spi5`` and can be exercised with the ``spi`` tool; shorting D11 to D12 loops the transmitted bytes back. +Ethernet +======== + +The RJ45 port is driven by a Realtek RTL8211F gigabit PHY at MDIO address 1, +connected to ETH1 over RGMII: PD1 MDC, PD12 MDIO, PF0 GTX_CLK, PF2 CLK125, +PF7 RX_CLK, PF10 RX_CTL, PF14/PF15/PF8/PF9 RXD0-3, PF11 TX_CTL and +PF12/PF13/PG3/PG4 TXD0-3. The PHY is managed by PHYLIB with its RTL8211F +driver, which adds the RGMII clock delays (``PHY_INTERFACE_RGMII_ID``), and +its 125 MHz CLK125 output clocks the MAC. The MAC address is derived from the unique +device ID. The interface is ``eth0``; check it with ``ifconfig`` and +``ping``, and read the PHY registers with ``mdio``. + Clocking ======== @@ -177,3 +189,10 @@ nsh NuttShell with the user LEDs, the USER1 button, GPDMA1 and the RTC enabled. + +netnsh +------ + +The ``nsh`` configuration with Ethernet: IPv4, TCP, UDP, ICMP, a DHCP +client started by NSH, ``ping``, ``telnetd`` and ``mdio``. The link is +auto-negotiated up to 1000 Mbps when ``eth0`` comes up. diff --git a/boards/arm/stm32n6/stm32n6570-dk/configs/netnsh/defconfig b/boards/arm/stm32n6/stm32n6570-dk/configs/netnsh/defconfig new file mode 100644 index 00000000000..d49ee52481e --- /dev/null +++ b/boards/arm/stm32n6/stm32n6570-dk/configs/netnsh/defconfig @@ -0,0 +1,87 @@ +# +# 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_ARCH_LEDS is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="stm32n6570-dk" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_STM32N6570_DK=y +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_CHIP="stm32n6" +CONFIG_ARCH_CHIP_STM32=y +CONFIG_ARCH_CHIP_STM32N657X0=y +CONFIG_ARCH_CHIP_STM32N6=y +CONFIG_ARCH_INTERRUPTSTACK=4096 +CONFIG_ARCH_IRQBUTTONS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARD_LOOPSPERMSEC=84000 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_EXAMPLES_ALARM=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_I2C=y +CONFIG_IDLETHREAD_STACKSIZE=4096 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INPUT=y +CONFIG_INPUT_BUTTONS=y +CONFIG_INPUT_BUTTONS_LOWER=y +CONFIG_NET=y +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDEV_PHY_IOCTL=y +CONFIG_NETINIT_DHCPC=y +CONFIG_NETUTILS_TELNETD=y +CONFIG_NET_BROADCAST=y +CONFIG_NET_ETH_PKTSIZE=1514 +CONFIG_NET_ICMP_SOCKET=y +CONFIG_NET_LOOPBACK=y +CONFIG_NET_PHYLIB=y +CONFIG_NET_PHY_REALTEK_RTL8211F=y +CONFIG_NET_ROUTE=y +CONFIG_NET_STATISTICS=y +CONFIG_NET_TCP=y +CONFIG_NET_UDP=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=2620416 +CONFIG_RAM_START=0x34180400 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_RTC_ALARM=y +CONFIG_RTC_DATETIME=y +CONFIG_RTC_DRIVER=y +CONFIG_RTC_NALARMS=2 +CONFIG_RTC_PERIODIC=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_SPITOOL_MAXBUS=5 +CONFIG_STM32N6_DEBUG=y +CONFIG_STM32_DMA1=y +CONFIG_STM32_ETHMAC=y +CONFIG_STM32_I2C1=y +CONFIG_STM32_I2C2=y +CONFIG_STM32_I2C4=y +CONFIG_STM32_PHYADDR=1 +CONFIG_STM32_RGMII=y +CONFIG_STM32_RNG=y +CONFIG_STM32_RTC=y +CONFIG_STM32_SPI5=y +CONFIG_STM32_USART1=y +CONFIG_STM32_USART2=y +CONFIG_SYSTEM_DHCPC_RENEW=y +CONFIG_SYSTEM_I2CTOOL=y +CONFIG_SYSTEM_MDIO=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_PING=y +CONFIG_SYSTEM_SPITOOL=y +CONFIG_USART1_SERIAL_CONSOLE=y +CONFIG_USERLED=y +CONFIG_USERLED_LOWER=y diff --git a/boards/arm/stm32n6/stm32n6570-dk/include/board.h b/boards/arm/stm32n6/stm32n6570-dk/include/board.h index 347510e21e1..a81fa5d5429 100644 --- a/boards/arm/stm32n6/stm32n6570-dk/include/board.h +++ b/boards/arm/stm32n6/stm32n6570-dk/include/board.h @@ -244,6 +244,42 @@ /* Alternate function pin selections ****************************************/ +/* Ethernet GPIOs ***********************************************************/ + +/* ETH1 RGMII to the Realtek RTL8211F PHY at MDIO address 1: PD1 MDC, + * PD12 MDIO, PF0 GTX_CLK, PF2 CLK125, PF7 RX_CLK, PF10 RX_CTL, PF14 PF15 + * PF8 PF9 RXD0-3, PF11 TX_CTL, PF12 PF13 PG3 PG4 TXD0-3. The PHY drives + * the 125 MHz CLK125 that the MAC uses as GTX clock (the reset value of + * RCC CCIPR2 ETH1GTXCLKSEL). The PHY interrupt on PD3 is not used. + * GTX_CLK gets a 1 ns pad delay, without it about 1% of the frames sent + * at 1000 Mbps are lost. + */ + +#define GPIO_ETH_MDC (GPIO_ETH_MDC_1 | GPIO_SPEED_100MHZ) +#define GPIO_ETH_MDIO (GPIO_ETH_MDIO_1 | GPIO_SPEED_100MHZ) +#define GPIO_ETH_RGMII_CLK125 (GPIO_ETH_RGMII_CLK125_1 | GPIO_SPEED_100MHZ) +#define GPIO_ETH_RGMII_GTX_CLK (GPIO_ETH_RGMII_GTX_CLK_1 | GPIO_SPEED_100MHZ | \ + GPIO_DELAY_1000PS) +#define GPIO_ETH_RGMII_RX_CLK (GPIO_ETH_RGMII_RX_CLK_1 | GPIO_SPEED_100MHZ) +#define GPIO_ETH_RGMII_RX_CTL (GPIO_ETH_RGMII_RX_CTL_1 | GPIO_SPEED_100MHZ) +#define GPIO_ETH_RGMII_RXD0 (GPIO_ETH_RGMII_RXD0_1 | GPIO_SPEED_100MHZ) +#define GPIO_ETH_RGMII_RXD1 (GPIO_ETH_RGMII_RXD1_1 | GPIO_SPEED_100MHZ) +#define GPIO_ETH_RGMII_RXD2 (GPIO_ETH_RGMII_RXD2_1 | GPIO_SPEED_100MHZ) +#define GPIO_ETH_RGMII_RXD3 (GPIO_ETH_RGMII_RXD3_1 | GPIO_SPEED_100MHZ) +#define GPIO_ETH_RGMII_TX_CTL (GPIO_ETH_RGMII_TX_CTL_1 | GPIO_SPEED_100MHZ) +#define GPIO_ETH_RGMII_TXD0 (GPIO_ETH_RGMII_TXD0_1 | GPIO_SPEED_100MHZ) +#define GPIO_ETH_RGMII_TXD1 (GPIO_ETH_RGMII_TXD1_1 | GPIO_SPEED_100MHZ) +#define GPIO_ETH_RGMII_TXD2 (GPIO_ETH_RGMII_TXD2_1 | GPIO_SPEED_100MHZ) +#define GPIO_ETH_RGMII_TXD3 (GPIO_ETH_RGMII_TXD3_1 | GPIO_SPEED_100MHZ) + +/* The RTL8211F adds the RGMII delays on both the TX and RX clocks */ + +#define BOARD_ETH_PHY_INTERFACE PHY_INTERFACE_RGMII_ID + +/* The PTP clock is HCLK, as the Ethernet driver assumes */ + +#define STM32_RCC_CCIPR2_ETH1PTPSEL RCC_CCIPR2_ETH1PTPSEL_HCLK + /* I2C GPIOs ****************************************************************/ /* I2C1: camera connector, Arduino D15/D14 (PH9 SCL, PC1 SDA) diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c index 351277c24c1..ac812adce1c 100644 --- a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c +++ b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c @@ -34,6 +34,7 @@ #include <nuttx/leds/userled.h> #include <nuttx/input/buttons.h> #include <nuttx/timers/rtc.h> +#include <nuttx/net/realtek_phy.h> #include "stm32_rtc.h" #include "stm32n6570-dk.h" @@ -74,6 +75,16 @@ int stm32_bringup(void) ret); } +#ifdef CONFIG_NET_PHY_REALTEK_RTL8211F + /* Register the driver of the RTL8211F PHY of the RJ45 port */ + + ret = rtl8211f_register(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: rtl8211f_register() failed: %d\n", ret); + } +#endif + #if !defined(CONFIG_ARCH_LEDS) && defined(CONFIG_USERLED_LOWER) /* Register the LED driver */
