14.6. lwip_ping_freertos_socket

14.6.1. Overview

This example shows the usage of ping on FreeRTOS.

  • MCU pings the specified network device( Enter IP or URL)

14.6.2. Board Settings

  • Connect a USB port on PC to the PWR DEBUG port on the development board with a USB Type-C cable

  • Connect an Ethernet port on PC to a RGMII port or a RMII port on the development board with an Ethernet cable

14.6.3. Project Configurations

  • Ethernet Port Settings: Refer to Ethernet common project settings

  • Ethernet DHCP Configurations

    • the configurations in the CMakeLists.txt as follows:

      • sdk_compile_definitions(-DLWIP_DHCP=0): Disable DHCP feature

      • sdk_compile_definitions(-DLWIP_DHCP=1): Enable DHCP feature

14.6.4. Run Example

  • Compiling and Downloading

  • Running log is shown in the serial terminal as follows:

    This is an ethernet demo: Ping With Socket API On FreeRTOS
    LwIP Version: 2.1.2
    Enet phy init passed !
    Link Status: Down
    Link Status: Up
    Link Speed:  1000Mbps
    Link Duplex: Full duplex
    DHCP State: SELECTING
    DHCP State: CHECKING
    DHCP State: BOUND
    IPv4 Address: 192.168.11.25
    IPv4 Netmask: 255.255.255.0
    IPv4 Gateway: 192.168.11.254
    Please enter a target name(IP or URL):
    
  • Enter an IP or URL, and then press “Enter” to confirm

    www.hpmicro.com
    
  • View log:

    Pinging www.hpmicro.com [47.108.71.172] ..................
    from 47.108.71.172 bytes=60 icmp_seq=0 ttl=48 time=33 ms
    from 47.108.71.172 bytes=60 icmp_seq=1 ttl=48 time=33 ms
    from 47.108.71.172 bytes=60 icmp_seq=2 ttl=48 time=33 ms
    from 47.108.71.172 bytes=60 icmp_seq=3 ttl=48 time=33 ms