U-Boot的网络控制台netcon的使用
2019-07-13 04:42发布
生成海报
之前一直疑惑Linux下有netconsloe,那么U-Boot中的是否也有相应的工具使用,果然,发现了一个网络控制台的实现方法。
需要的工具:Hercules
U-BOOT命令的源码:
#include
#include
#include
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.
");
return -EINVAL;
}
printf(" used serverip as ncip.
");
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",
" - Just do: set stdin nc; set stdout nc; set stderr nc.
"
"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指令 不好用
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮