您的位置:首页 > 理论基础 > 计算机网络

U-Boot的网络控制台netcon的使用

2016-01-06 12:13 519 查看

之前一直疑惑Linux下有netconsloe,那么U-Boot中的是否也有相应的工具使用,果然,发现了一个网络控制台的实现方法。

需要的工具:Hercules



U-BOOT命令的源码:

#include <common.h>
#include <command.h>
#include <errno.h>

static int do_netcon(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
char *s;
/* Our IP addr (0 = unknown) */
IPaddr_t NetOurIP;
/* NetConsole IP addr (0 = unknown) */
IPaddr_t NetConsoleIP;

s = getenv("ncip");
if (!s)
{
printf("Not set environment variable 'ncip',");

s = getenv("serverip");
if (!s){
printf(" please set it.\n");
return -EINVAL;
}

printf(" used serverip as ncip.\n");
run_command("set ncip ${serverip}", 0);
}
else
{

}

NetOurIP = getenv_IPaddr("ipaddr");
NetConsoleIP = getenv_IPaddr("ncip");
printf("NetConsole IP address %pI4; Our IP address is %pI4",
&NetConsoleIP, &NetOurIP);

setenv("stdin", "nc");
setenv("stdout", "nc");
setenv("stderr", "nc");

printf("NetConsole IP address %pI4; Our IP address is %pI4",
&NetConsoleIP, &NetOurIP);

return 0;
}

U_BOOT_CMD(netcon, 1, 0, do_netcon,
"To switch to the network console",
"\t- Just do: set stdin nc; set stdout nc; set stderr nc.\n"
"You must has set environment variable 'ncip' ,before execute netcon command."
);
使用方法:
1、打开Hercules程序,将界面调到 UDP 选项卡

2、在UDP选项卡上的配置参数上,Module IP设置为U-Boot上的IP,Port和Local Port个端口都设为6666,并点击Listen

3、将U-Boot中的服务端IP设置成Hercules软件所在机器的IP地址,然后在U-boot中运行netcon命令,就连上了

这个软件的貌似 Ctrl+C指令 不好用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: