From 7044e38cc70ccd25bedcbb2c8aa2a963242c0257 Mon Sep 17 00:00:00 2001 From: Jorge Guzman Date: Fri, 3 May 2024 21:00:27 -0300 Subject: [PATCH] stm32h7/linum-stm32h753bi: add support to ethernet connection Signed-off-by: Jorge Guzman --- .../boards/linum-stm32h753bi/index.rst | 37 +++++++- .../configs/netnsh/defconfig | 92 +++++++++++++++++++ .../stm32h7/linum-stm32h753bi/include/board.h | 16 ++++ .../linum-stm32h753bi/src/linum-stm32h753bi.h | 12 ++- .../linum-stm32h753bi/src/stm32_bringup.c | 9 ++ 5 files changed, 163 insertions(+), 3 deletions(-) create mode 100644 boards/arm/stm32h7/linum-stm32h753bi/configs/netnsh/defconfig diff --git a/Documentation/platforms/arm/stm32h7/boards/linum-stm32h753bi/index.rst b/Documentation/platforms/arm/stm32h7/boards/linum-stm32h753bi/index.rst index 9e4b74d06f..7a2c3d5ac7 100644 --- a/Documentation/platforms/arm/stm32h7/boards/linum-stm32h753bi/index.rst +++ b/Documentation/platforms/arm/stm32h7/boards/linum-stm32h753bi/index.rst @@ -719,4 +719,39 @@ After that check if your PC recognized the usb driver:: [27221.266103] sd 0:0:0:0: [sda] Attached SCSI removable disk [27228.147377] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck. -**OBS:** This example disable the macro CONFIG_STM32H7_SDMMC_IDMA, for more information read the file: arch/arm/stm32h7/stm32_sdmmc.c \ No newline at end of file +**OBS:** This example disable the macro CONFIG_STM32H7_SDMMC_IDMA, for more information read the file: arch/arm/stm32h7/stm32_sdmmc.c + +netnsh +------ + +This configuration is focused on network testing using the ethernet periferal:: + + $ nsh> ifconfig + eth0 Link encap:Ethernet HWaddr 00:e0:de:ad:be:ef at UP mtu 1486 + inet addr:192.168.1.6 DRaddr:192.168.1.1 Mask:255.255.255.0 + + IPv4 TCP UDP ICMP + Received 01b9 0025 0194 0000 + Dropped 0000 0000 0000 0000 + IPv4 VHL: 0000 Frg: 0000 + Checksum 0000 0000 0000 ---- + TCP ACK: 0000 SYN: 0000 + RST: 0000 0000 + Type 0000 ---- ---- 0000 + Sent 0028 0025 0003 0000 + Rexmit ---- 0000 ---- ---- + + nsh> ping google.com + PING 142.251.129.110 56 bytes of data + 56 bytes from 142.251.129.110: icmp_seq=0 time=10.0 ms + 56 bytes from 142.251.129.110: icmp_seq=1 time=0.0 ms + 56 bytes from 142.251.129.110: icmp_seq=2 time=0.0 ms + 56 bytes from 142.251.129.110: icmp_seq=3 time=0.0 ms + 56 bytes from 142.251.129.110: icmp_seq=4 time=0.0 ms + 56 bytes from 142.251.129.110: icmp_seq=5 time=0.0 ms + 56 bytes from 142.251.129.110: icmp_seq=6 time=0.0 ms + 56 bytes from 142.251.129.110: icmp_seq=7 time=0.0 ms + 56 bytes from 142.251.129.110: icmp_seq=8 time=0.0 ms + 56 bytes from 142.251.129.110: icmp_seq=9 time=0.0 ms + 10 packets transmitted, 10 received, 0% packet loss, time 10100 ms + rtt min/avg/max/mdev = 0.000/1.000/10.000/3.000 ms \ No newline at end of file diff --git a/boards/arm/stm32h7/linum-stm32h753bi/configs/netnsh/defconfig b/boards/arm/stm32h7/linum-stm32h753bi/configs/netnsh/defconfig new file mode 100644 index 0000000000..cbf7d7b38d --- /dev/null +++ b/boards/arm/stm32h7/linum-stm32h753bi/configs/netnsh/defconfig @@ -0,0 +1,92 @@ +# +# 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_STANDARD_SERIAL is not set +# CONFIG_STM32H7_USE_LEGACY_PINMAP is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="linum-stm32h753bi" +CONFIG_ARCH_BOARD_LINUM_STM32H753BI=y +CONFIG_ARCH_CHIP="stm32h7" +CONFIG_ARCH_CHIP_STM32H753BI=y +CONFIG_ARCH_CHIP_STM32H7=y +CONFIG_ARCH_CHIP_STM32H7_CORTEXM7=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV7M_DCACHE=y +CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y +CONFIG_ARMV7M_DTCM=y +CONFIG_ARMV7M_ICACHE=y +CONFIG_BOARD_LOOPSPERMSEC=43103 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ETH0_PHY_KSZ8081=y +CONFIG_EXAMPLES_ALARM=y +CONFIG_FS_PROCFS=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=4096 +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBM=y +CONFIG_MM_REGIONS=4 +CONFIG_NET=y +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x08080808 +CONFIG_NETDEV_PHY_DEBUG=y +CONFIG_NETDEV_WORK_THREAD=y +CONFIG_NETINIT_DHCPC=y +CONFIG_NETINIT_DRIPADDR=0x08080808 +CONFIG_NETINIT_NOMAC=y +CONFIG_NETUTILS_DHCPC=y +CONFIG_NETUTILS_DISCOVER=y +CONFIG_NETUTILS_TELNETD=y +CONFIG_NET_ARP_IPIN=y +CONFIG_NET_ARP_SEND=y +CONFIG_NET_BROADCAST=y +CONFIG_NET_ETH_PKTSIZE=1500 +CONFIG_NET_ICMP=y +CONFIG_NET_ICMP_SOCKET=y +CONFIG_NET_IGMP=y +CONFIG_NET_ROUTE=y +CONFIG_NET_STATISTICS=y +CONFIG_NET_TCP=y +CONFIG_NET_UDP=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_DISABLE_IFUPDOWN=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=245760 +CONFIG_RAM_START=0x20010000 +CONFIG_RAW_BINARY=y +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_READLINE_TABCOMPLETION=y +CONFIG_RR_INTERVAL=200 +CONFIG_RTC_ALARM=y +CONFIG_RTC_DATETIME=y +CONFIG_RTC_DRIVER=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_STM32H7_ETHMAC=y +CONFIG_STM32H7_PHYSR=30 +CONFIG_STM32H7_PHYSR_100FD=0x6 +CONFIG_STM32H7_PHYSR_100HD=0x2 +CONFIG_STM32H7_PHYSR_10FD=0x5 +CONFIG_STM32H7_PHYSR_10HD=0x1 +CONFIG_STM32H7_PHYSR_ALTCONFIG=y +CONFIG_STM32H7_PHYSR_ALTMODE=0x7 +CONFIG_STM32H7_PWR=y +CONFIG_STM32H7_RMII_MCO1=y +CONFIG_STM32H7_RTC=y +CONFIG_STM32H7_USART1=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_PING=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_USART1_SERIAL_CONSOLE=y diff --git a/boards/arm/stm32h7/linum-stm32h753bi/include/board.h b/boards/arm/stm32h7/linum-stm32h753bi/include/board.h index 0aced1f981..1568e8ff31 100644 --- a/boards/arm/stm32h7/linum-stm32h753bi/include/board.h +++ b/boards/arm/stm32h7/linum-stm32h753bi/include/board.h @@ -423,6 +423,22 @@ /* Select PLL2R to source clock of QSPI */ #define BOARD_QSPI_CLK RCC_D1CCIPR_QSPISEL_PLL2 +/* Ethernet */ + +#define BOARD_CFGR_MC01_SOURCE (RCC_CFGR_MCO1_HSE) +#define BOARD_CFGR_MC01_DIVIDER (RCC_CFGR_MCO1PRE(0)) +#define GPIO_MCO1 (GPIO_MCO1_0) /* PA8 */ + +#define GPIO_ETH_MDC (GPIO_ETH_MDC_0|GPIO_SPEED_100MHz) /* PC1 */ +#define GPIO_ETH_MDIO (GPIO_ETH_MDIO_0|GPIO_SPEED_100MHz) /* PA2 */ +#define GPIO_ETH_RMII_CRS_DV (GPIO_ETH_RMII_CRS_DV_0|GPIO_SPEED_100MHz) /* PA7 */ +#define GPIO_ETH_RMII_REF_CLK (GPIO_ETH_RMII_REF_CLK_0|GPIO_SPEED_100MHz) /* PA1 */ +#define GPIO_ETH_RMII_RXD0 (GPIO_ETH_RMII_RXD0_0|GPIO_SPEED_100MHz) /* PC4 */ +#define GPIO_ETH_RMII_RXD1 (GPIO_ETH_RMII_RXD1_0|GPIO_SPEED_100MHz) /* PC5 */ +#define GPIO_ETH_RMII_TXD0 (GPIO_ETH_RMII_TXD0_2|GPIO_SPEED_100MHz) /* PG13 */ +#define GPIO_ETH_RMII_TXD1 (GPIO_ETH_RMII_TXD1_3|GPIO_SPEED_100MHz) /* PG14 */ +#define GPIO_ETH_RMII_TX_EN (GPIO_ETH_RMII_TX_EN_2|GPIO_SPEED_100MHz) /* PG11 */ + /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h b/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h index 6c90d5b47a..72a6a9284e 100644 --- a/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h +++ b/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h @@ -92,9 +92,9 @@ # undef HAVE_SDIO #endif -#define GPIO_SDIO_NCD (GPIO_INPUT | GPIO_FLOAT | GPIO_EXTI | GPIO_PORTG | GPIO_PIN7) +#define GPIO_SDIO_NCD (GPIO_INPUT | GPIO_FLOAT | GPIO_EXTI | GPIO_PORTG | GPIO_PIN7) /* PG7 */ #define GPIO_SD1_PWR_EN_N (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \ - GPIO_OUTPUT_SET | GPIO_PORTD | GPIO_PIN7) + GPIO_OUTPUT_SET | GPIO_PORTD | GPIO_PIN7) /* PD7 */ #define SDIO_SLOTNO 0 #define SDIO_MINOR 0 @@ -103,6 +103,14 @@ #define BUZZER_PWMTIMER 4 +/* Ethernet + * + * PI4 Reset PHY pin + */ + +#define GPIO_ETH_RESET (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_100MHz |\ + GPIO_OUTPUT_CLEAR | GPIO_PORTI | GPIO_PIN4) /* PI4 */ + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_bringup.c b/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_bringup.c index 1b243b9142..c093ca3d4e 100644 --- a/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_bringup.c +++ b/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_bringup.c @@ -138,6 +138,15 @@ int stm32_bringup(void) struct rtc_lowerhalf_s *lower; #endif +#ifdef CONFIG_STM32H7_RMII + /* Reset Ethernet PHY */ + + stm32_configgpio(GPIO_ETH_RESET); + stm32_gpiowrite(GPIO_ETH_RESET, 0); + usleep(50000); + stm32_gpiowrite(GPIO_ETH_RESET, 1); +#endif + #ifdef CONFIG_FS_PROCFS /* Mount the procfs file system */