Step by step, run the ping command under pcDuino3 -- uboot to accept the ping from the host.

Source: Internet
Author: User

Uboot is an excellent open-source project. You can not only learn bootloader, embedded, and various bus protocols. You can also understand the network protocol stack. In embedded development, uboot tftp and nfs are often used to accelerate development efficiency. Before using tftp, we must ensure that the host and pcDuino3 can be pinged. You can ping the host in uboot, but the host cannot ping the uboot. This is because uboot is not an operating system. We need to run a command to wait for the ping command from the host cyclically.

Before adding commands for uboot to receive the ping from the host, let's take a look at the ping process:

Hardware environment: the ip address of the host is 192.168.1.11, And the mac address is 5c: 26: 0a: 5c: 91: 50.

The ip address of pcDuino3 is 192.168.1.188, And the mac address is 12: 34: 56: 78: 11: 22.

When we send ping 192.168.1.188 from uboot to the host, we can use wireshark to capture the process:

First, the broadcast sends an ARP request, and then the host will reply to the request, so that the uboot end will get the mac address of the host;

The next step is to send the ICMP Echo request. When the Echo reply is received, the ping is successful.

In fact, the ping process from the host to pcDuino3 is the same. We only need to add a few lines of simple code,

Add a recvping command for uboot:

static int recv_ping(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]){printf("recv ping command excute \n");if (NetLoop(RECVPING) < 0) {printf("ping failed; ");return 1;}printf("host  is alive\n");return 0;}U_BOOT_CMD(recvping,2,1,recv_ping,"recv ICMP ECHO_REQUEST from network host","wait the ping from other host");

Add the Processing Branch for RECVPING in NetLoop:

case RECVPING:recvping_start();break;

The recvping_start function is as follows:

void recvping_start(void){printf("Using %s device\n", eth_get_name());NetSetTimeout(100000UL, ping_timeout);}

In this way, we ping the host again and use wireshark to capture packets:


Because the host sends four ICMP packets, there are multiple Echo requests.

From this perspective, the network protocol stack is quite simple and clear. Through this process, we only want to understand the network protocol stack, not just the socket, listen, bind.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.