Net Boot Controller
cover Net Boot Controller
From: Tristan Lelong <[email protected]>
This patch allow to interrupt u-boot autoboot from remote PC and auto-reconfigure a netconsole redirected to this remote PC
Tristan Lelong (3):
Add support for Net Boot Controller (NBC) packet Add sendnbc tool to broadcast NBC magic packet Add the NBC + netconsole corresponding documentation
common/main.c | 5 + doc/README.netconsole | 66 +++++++++++++++ include/net.h | 6 +- net/Makefile | 2 + net/nbc.c | 143 ++++++++++++++++++++++++++++++++ net/nbc.h | 39 +++++++++ net/net.c | 17 ++++ tools/Makefile | 6 ++ tools/sendnbc.c | 219 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 502 insertions(+), 1 deletions(-) create mode 100644 doc/README.netconsole create mode 100644 net/nbc.c create mode 100644 net/nbc.h create mode 100644 tools/sendnbc.c
Signature · 1 line
1.7.2.3
PATCH 1/3 Add support for Net Boot Controller (NBC) packet
From: Tristan Lelong <[email protected]>
This adds the core NBC feature:
* Integration into u-boot
* NBC packet processing
* NetConsole reconfigure
--- common/main.c | 5 ++ include/net.h | 6 ++- net/Makefile | 2 + net/nbc.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ net/nbc.h | 39 +++++++++++++++ net/net.c | 17 +++++++ 6 files changed, 211 insertions(+), 1 deletions(-) create mode 100644 net/nbc.c create mode 100644 net/nbc.h
common/main.c +5 -0
@@ -259,6 +259,11 @@ static __inline__ int abortboot(int bootdelay)putc ('\n' ); +#ifdef CONFIG_CMD_NBC +if (!abort) + abort =NBCWait (); +#endif +#ifdef CONFIG_SILENT_CONSOLE if (abort) gd->flags &= ~GD_FLG_SILENT ;
include/net.h +5 -1
@@ -359,7 +359,7 @@ extern int NetState; /* Network loop state */extern int NetRestartWrap;/* Tried all network devices */ #endif -typedef enum {BOOTP ,RARP ,ARP ,TFTP ,DHCP ,PING ,DNS ,NFS ,CDP ,NETCONS ,SNTP }proto_t ; +typedef enum {BOOTP ,RARP ,ARP ,TFTP ,DHCP ,PING ,DNS ,NFS ,CDP ,NETCONS ,SNTP ,NBC }proto_t ;/* from net/net.c */ extern char BootFile[128 ];/* Boot File name */
@@ -384,6 +384,10 @@ extern IPaddr_t NetNtpServerIP; /* the ip address to NTP */extern int NetTimeOffset;/* offset time from UTC */ #endif +#if defined(CONFIG_CMD_NBC ) +extern IPaddr_t NetSrcIP;/* Packet Src IP addr (0 = unknown) */ +#endif +/* Initialize the network adapter */ extern int NetLoop (proto_t );
net/Makefile +2 -0
@@ -35,6 +35,8 @@ COBJS-$(CONFIG_CMD_NFS) += nfs.o COBJS-$(CONFIG_CMD_RARP) += rarp.o COBJS-$(CONFIG_CMD_SNTP) += sntp.o COBJS-$(CONFIG_CMD_NET) += tftp.o +COBJS-$(CONFIG_CMD_NBC) += nbc.o + COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
net/nbc.c new file +143 -0
143 lines not on this page · raw message
net/nbc.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* (C) Tristan Lelong <[email protected]> 2010 +* Copyright 2010, Tristan Lelong <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2, or (at +* your option) any later version. +*/ + +#ifndef __NBC_H__ +#define __NBC_H__ + +#define NBC_SERVICE_PORT 4446 +#define NBC_TIMEOUT 2000 + +#define NBC_CHK_HEADER_SIZE 5 +#define NBC_HEADER_SIZE 5 +#define NBC_CHK_IP_SIZE 4 +#define NBC_CHK_MAC_SIZE 6 +#define NBC_CHK_HOSTNAME_SIZE 255 + +struct _nbc_packet { +unsigned char id; +unsigned char head[3 ]; +unsigned char size; +unsigned char data[255 ]; +}; + +struct _nbc_chunk { +unsigned char name[4 ]; +unsigned char size; +unsigned char data[255 ]; +}; + +extern void NBCStart (void ); +extern int NBCWait (void ); + +#endif
net/net.c +17 -0
@@ -97,6 +97,9 @@#if defined(CONFIG_CMD_DNS )#include "dns.h" #endif +#if defined(CONFIG_CMD_NBC ) +#include "nbc.h" +#endif DECLARE_GLOBAL_DATA_PTR ;
@@ -180,6 +183,10 @@ IPaddr_t NetNtpServerIP; /* NTP server IP address */int NetTimeOffset=0 ;/* offset time from UTC */ #endif +#if defined(CONFIG_CMD_NBC ) +IPaddr_t NetSrcIP;/* Src IP addr (0 = unknown) */ +#endif +#ifdef CONFIG_NETCONSOLE void NcStart (void );int nc_input_packet (uchar *pkt,unsigned dest,unsigned src,unsigned len);
@@ -384,6 +391,11 @@ restart: NetDevExists =1 ;#endif switch (protocol) { +#if defined(CONFIG_CMD_NBC ) +case NBC : +NBCStart (); +break ; +#endif case TFTP :/* always use ARP to get server ethernet address */ TftpStart ();
@@ -1631,6 +1643,7 @@ NetReceive(volatile uchar * inpkt, int len)ushort *sumptr;ushort sumlen; + xsum = ip->ip_p; xsum += (ntohs (ip->udp_len)); xsum += (ntohl (ip->ip_src) >>16 ) &0x0000ffff ;
@@ -1673,6 +1686,10 @@ NetReceive(volatile uchar * inpkt, int len)ntohs (ip->udp_src), ntohs(ip->udp_len) - 8);#endif + +#ifdef CONFIG_CMD_NBC + NetSrcIP =NetReadIP ((void *)&ip->ip_src); +#endif /* * IP header OK. Pass the packet to the current handler. */
Signature · 1 line
1.7.2.3
PATCH 2/3 Add sendnbc tool to broadcast NBC magic packet
In reply to tristan.lelong at blunderer.orgFrom: Tristan Lelong <[email protected]>
This tool send NBC packet filled with data provided on command line It can be used in combination with netconsole by calling:
BOARD_IP=192.168.0.2 ./sendnbc -i $BOARD_IP && ./netconsole $BOARD_IP
--- tools/Makefile | 6 ++ tools/sendnbc.c | 219 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 225 insertions(+), 0 deletions(-) create mode 100644 tools/sendnbc.c
tools/Makefile +6 -0
@@ -45,6 +45,7 @@ CONFIG_CMD_LOADS = y CONFIG_CMD_NET = y CONFIG_INCA_IP = y CONFIG_NETCONSOLE = y +CONFIG_CMD_NBC = y CONFIG_SHA1_CHECK_UB_IMG = y endif
@@ -64,6 +65,7 @@ BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX) BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX) BIN_FILES-y += mkimage$(SFX) BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX) +BIN_FILES-$(CONFIG_CMD_NBC) += sendnbc$(SFX) BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX) # Source files which exist outside the tools directory
@@ -86,6 +88,7 @@ NOPED_OBJ_FILES-y += kwbimage.o NOPED_OBJ_FILES-y += imximage.o NOPED_OBJ_FILES-y += mkimage.o OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o +OBJ_FILES-$(CONFIG_CMD_NBC) += sendnbc.o NOPED_OBJ_FILES-y += os_support.o OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
@@ -197,6 +200,9 @@ $(obj)ncb$(SFX): $(obj)ncb.o $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTSTRIP) $@ +$(obj)sendnbc$(SFX): $(obj)sendnbc.o + $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ + $(obj)ubsha1$(SFX): $(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
tools/sendnbc.c new file +219 -0
219 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 3/3 Add the NBC + netconsole corresponding documentation
In reply to tristan.lelong at blunderer.orgFrom: Tristan Lelong <[email protected]>
--- doc/README.netconsole | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 66 insertions(+), 0 deletions(-) create mode 100644 doc/README.netconsole
doc/README.netconsole new file +66 -0
@@ -0,0 +1,66 @@ +NETCONSOLE & NBC README + +# (C) Copyright 2010 +# Tristan Lelong, tristan.lelong at blunderer.org +# +# See file CREDITS for list of people who contributed to this +# project. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA + +Configuration Options: + + CONFIG_NETCONSOLE + This enable the netconsole. Netconsole provide a remote access to + u-boot command line thru udp stream. + basically, you just set some environment variables like: + - stdin, stdout, and stderr to "nc" + - ncip to <remote ip address> + and you can connect to the board ip, port 6666 (default) using + "tools/netconsole <board ip addr>" + + CONFIG_CMD_NBC + This enable the Net Boot Controller feature that will listen for + NBC magic packet at boot time. If one of NBC packet is received, + u-boot reconfigure itself automagically to use the netconsole + and interrupt the autoboot. + The NBC packet contains the new board IP and the remote ip. + It can also target special boards using filters on hostname and/or ethaddr + To broadcast NBC packets just use: + "tools/sendnbc -i <new board ip> [options]" + Two environment variable will allow to protect your board from receiving + NBC interruptions: + - nbcsource: only this remote IP can interrupt autoboot using NBC + - nbcinhibit: if this variable is present, NBC is fully inhibited + + +NOTE: + NBC packet has the following format: + +One header + - NBC header (5 bytes): + - magical number 1 byte '0xD3' + - ASCII header 3 bytes "NBC" + - packet size 1 byte 'X' + +Several Data Chunks + - NBC data chunks (X-5 bytes) + - chunk name 4 bytes "IP\0\0" | "MAC\0" | "HOST" + - chunk size 1 byte 'Y' + - chunk data Y bytes "xxxx" + +The IP chunk is mandatory, other are optional +
Signature · 1 line
1.7.2.3
cover Net Boot Controller
In reply to tristan.lelong at blunderer.orgQuoted 9 lines · tristan.lelong at blunderer.org
From: Tristan Lelong <[email protected]>
This patch allow to interrupt u-boot autoboot from remote PC and auto-reconfigure a netconsole redirected to this remote PC
Tristan Lelong (3):
Add support for Net Boot Controller (NBC) packet Add sendnbc tool to broadcast NBC magic packet Add the NBC + netconsole corresponding documentation
Hi Tristan,
Quoted 6 lines
common/main.c | 5 + doc/README.netconsole | 66 +++++++++++++++ include/net.h | 6 +- net/Makefile | 2 + net/nbc.c | 143 ++++++++++++++++++++++++++++++++ net/nbc.h | 39 +++++++++
Quoted 8 lines
net/net.c | 17 ++++ tools/Makefile | 6 ++ tools/sendnbc.c | 219 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 502 insertions(+), 1 deletions(-) create mode 100644 doc/README.netconsole create mode 100644 net/nbc.c create mode 100644 net/nbc.h create mode 100644 tools/sendnbc.c
Is NBC a standard ? Could you provide a link describing this protocol ?
I am quite confuse, this seems a way to replace DHCP in a simplest form to set up the ip address using some sort of knocking-port. As additional feature, the
Why cannot we reach the same result using the "Vendor Specific Information" (or another option field) of DHCP answer ? You can set there some infos that the target could understand.
It seems to me that the first packet is always sent to the broadcast address. What happens if we have two boards on the network, both waiting in autoboot ? Do they obtain the same ip address ?
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 3/3 Add the NBC + netconsole corresponding documentation
In reply to tristan.lelong at blunderer.orgdoc/README.netconsole line 1
Quoted 4 lines · On Tuesday, November 16, 2010 13:04:33 tristan.lelong at blunderer.org wrote:
doc/README.netconsole new file +1
-0@@ -0,0 +1,66 @@ +NETCONSOLE & NBC README
there is already a doc/README.NetConsole which contains a lot more useful information about the netconsole than this. start a new README.NBC file and stick to just NBC.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101117/e0eb9a40/attachment.pgp
PATCH 1/3 Add support for Net Boot Controller (NBC) packet
In reply to tristan.lelong at blunderer.orgcommon/main.c static __inline__ int abortboot(int bootdelay) · line 262
Quoted 4 lines · On Tuesday, November 16, 2010 13:04:31 tristan.lelong at blunderer.org wrote:
common/main.c +1
-0+#ifdef CONFIG_CMD_NBC
why did you pick "CONFIG_CMD_NBC" ? there is no "nbc" command that is run from the u-boot console, so "CONFIG_CMD_xxx" makes no sense.
common/main.c static __inline__ int abortboot(int bootdelay) · line 264
Quoted 2 lines
common/main.c +2
-0+if (!abort) + abort =NBCWait ();
incorrect style here and in many places -- no space before the paren. i wont bother pointing out this in other places ... find & fix yourself.
net/Makefile COBJS-$(CONFIG_CMD_NFS) += nfs.o · line 40
Quoted 9 lines
net/Makefile +2
-0@@ -35,6 +35,8 @@ COBJS-$(CONFIG_CMD_NFS) += nfs.o COBJS-$(CONFIG_CMD_RARP) += rarp.o COBJS-$(CONFIG_CMD_SNTP) += sntp.o COBJS-$(CONFIG_CMD_NET) += tftp.o +COBJS-$(CONFIG_CMD_NBC) += nbc.o +
do not add useless blank lines
net/nbc.c line 7
Quoted 10 lines
net/nbc.c new file +7
-0@@ -0,0 +1,143 @@ +/* +* NBC support driver +* Network Boot Controller +* +* Copyright (c) 2010 Tristan Lelong <[email protected]> +* +*/
licensing info is missing
Quoted 2 lines
net/nbc.c new file +1
-0+static void NBCHandler (uchar * pkt, unsigned dest, unsigned src, unsignedlen) +{
style problems here -- no space after that asterisk
net/nbc.c line 34
Quoted 12 lines
net/nbc.c new file +12
-0+int cnt =0 ; +char src_ip[16 ] ="" ; +char *nbcsource =NULL ; +char ip[16 ] ="" ; +char mac[18 ] ="" ; +char hostname[255 ] ="" ; + +struct _nbc_packet *nbc_pkt = (struct _nbc_packet *)pkt; + nbcsource =getenv ("nbcsource" ); + +/* check packet validity */ +if (nbc_pkt->id !=0xD3 )
magic numbers should be defines in headers, not inlined in source files
net/nbc.c line 43
Quoted 9 lines
net/nbc.c new file +9
-0+ goto fail; +if (strncmp (nbc_pkt->head,"NBC" ,3 )) + goto fail; +if (nbc_pkt->size != len) + goto fail; + +sprintf (src_ip,"%lu.%lu.%lu.%lu" , ((NetSrcIP >>0 ) &0xFF ), + ((NetSrcIP >>8 ) &0xFF ), ((NetSrcIP >>16 ) &0xFF ), + ((NetSrcIP >>24 ) &0xFF ));
we have printf modifiers to handle ip addresses already. use that instead.
net/nbc.c line 63
Quoted 4 lines
net/nbc.c new file +4
-0+unsigned char *pkt_mac = (unsigned char *)chk->data; +sprintf (mac,"%02X:%02X:%02X:%02X:%02X:%02X" , + pkt_mac[0 ], pkt_mac[1 ], pkt_mac[2 ], pkt_mac[3 ], + pkt_mac[4 ], pkt_mac[5 ]);
there are printf modifiers for MAC addresse too. although i dont think you need to go screwing with this in the first place. there are eth helpers for manipulating MAC addresses you should be using instead. see doc/README.enetaddr.
net/nbc.c line 135
Quoted 3 lines
net/nbc.c new file +3
-0+if (NBC_Mode_On) { +return 1 ; + }
useless braces
net/nbc.h line 8
Quoted 11 lines
net/nbc.h new file +8
-0@@ -0,0 +1,39 @@ +#define NBC_SERVICE_PORT 4446 +#define NBC_TIMEOUT 2000 + +#define NBC_CHK_HEADER_SIZE 5 +#define NBC_HEADER_SIZE 5 +#define NBC_CHK_IP_SIZE 4 +#define NBC_CHK_MAC_SIZE 6 +#define NBC_CHK_HOSTNAME_SIZE 255
indentation here is all screwd up. it's inconsistent and mixes spaces & tabs.
net/net.c NetReceive(volatile uchar * inpkt, int len) · line 1649
Quoted 10 lines
net/net.c +1
-0@@ -1631,6 +1643,7 @@ NetReceive(volatile uchar * inpkt, int len)ushort *sumptr;ushort sumlen; + xsum = ip->ip_p; xsum += (ntohs (ip->udp_len)); xsum += (ntohl (ip->ip_src) >>16 ) &0x0000ffff ;
please clean your patches of useless whitespace noise before submitting -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101117/592ab88d/attachment.pgp
PATCH 2/3 Add sendnbc tool to broadcast NBC magic packet
In reply to tristan.lelong at blunderer.orgtools/sendnbc.c line 1
Quoted 4 lines · On Tuesday, November 16, 2010 13:04:32 tristan.lelong at blunderer.org wrote:
tools/sendnbc.c new file +1
-0@@ -0,0 +1,219 @@ +#include <stdio.h>
missing licensing & copyright header
tools/sendnbc.c line 11
Quoted 1 line
tools/sendnbc.c new file +1
-0+static void usage (char *argv0)
style problems throughout this file too
Quoted 14 lines
tools/sendnbc.c new file +2
-0+ printf + ("SENDNBC: sends a magic packet to u-boot board to interrupt theautoboot\n"); + printf (" and reconfigure u-boot in netconsole
mode.\n"); + printftools/sendnbc.c new file +1
-0+ (" Use in combination with netconsole to connect andcontrol\n"); + printf (" your u-boot device\n");
tools/sendnbc.c new file +2
-0+ printf + (" Ex: BOARD_IP=192.168.0.2 ./sendnbc -i $BOARD_IP -d eth0 &&./netconsole $BOARD_IP\n"); + printf ("\nusage: %s [options]\n", argv0);
tools/sendnbc.c new file +5
-0+printf (" -i <ip addr>: the ip addr to assign to u-boot board\n" ); +printf (" -m <mac addr>: the targeted board mac addr \n" ); +printf (" -n <hostname>: the targeted board hostname \n" ); + printf + (" -d <device>: the net interface to use for broadcasting (ex: eth0).
Quoted 2 lines
Must be root to use this option\n"); + printf (" -h: display this
help\n");
multiple calls to printf() is such a waste. combine all the strings into one and call printf() just once.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101117/1e6cc770/attachment.pgp
cover Net Boot Controller
In reply to tristan.lelong at blunderer.orgHi Tristan,
Quoted 10 lines · On Tue, Nov 16, 2010 at 8:04 PM, <[email protected]> wrote:
From: Tristan Lelong <[email protected]>
This patch allow to interrupt u-boot autoboot from remote PC and auto-reconfigure a netconsole redirected to this remote PC
Tristan Lelong (3):
?Add support for Net Boot Controller (NBC) packet ?Add sendnbc tool to broadcast NBC magic packet ?Add the NBC + netconsole corresponding documentation
We usually need netconsole when serial console is not the option. The u-boot autorun lasts for few seconds only afterwards the control is passed to OS. That means that u-boot will be capable of NBC catching during very sort period of time. How the user is supposed to know when to issue the NBC packet?
It is also not clear how proposed feature will coexist with BOOTP?
In order to remotely connect to u-boot via netconsole I use the following approach - the u-boot wakes up with serial console and after few seconds switches to netconsole if user did not hit any key to stay with serial console.
The code is very simple and compact.
Add to your board configuration file:
#define CONFIG_NETCONSOLE 1
#define CONFIG_PREBOOT "setenv stdout nc;setenv stderr nc;setenv stdin nc;"
Override the last_stage_init() in your board .c file:
int last_stage_init(void)
{
int i, abort = 0;
int bootdelay = 2; /* Seconds */
printf("\nHit any key to stay with serial console: %2d ", bootdelay);
while ((bootdelay-- > 0) && (!abort)) {
/* delay 100 * 10mS */
for (i=0; !abort && i<100; ++i) {
if (tstc()) { /* we got a key press */
abort = 1;
bootdelay = 0; /* no more delay */
(void)getc(); /* consume input */
setenv("preboot","echo");
break;
}
udelay(10000);
}
printf("\b\b\b%2d ", bootdelay);
}
putc('\n');
return 0;
}Regards,
Michael
cover Net Boot Controller
In reply to Stefano BabicHi Stefano,
2010/11/17 Stefano Babic <[email protected]>
Quoted 23 lines · tristan.lelong at blunderer.org
Quoted 3 lines
From: Tristan Lelong <[email protected]>
This patch allow to interrupt u-boot autoboot from remote PC and
auto-reconfigure a netconsole redirected to this remote PC
Quoted 6 lines
Tristan Lelong (3):
Add support for Net Boot Controller (NBC) packet Add sendnbc tool to broadcast NBC magic packet Add the NBC + netconsole corresponding documentationHi Tristan,
Quoted 9 lines
common/main.c | 5 + doc/README.netconsole | 66 +++++++++++++++ include/net.h | 6 +- net/Makefile | 2 + net/nbc.c | 143 ++++++++++++++++++++++++++++++++ net/nbc.h | 39 +++++++++ net/net.c | 17 ++++ tools/Makefile | 6 ++ tools/sendnbc.c | 219
Quoted 9 lines
+++++++++++++++++++++++++++++++++++++++++++++++++
Quoted 5 lines
9 files changed, 502 insertions(+), 1 deletions(-) create mode 100644 doc/README.netconsole create mode 100644 net/nbc.c create mode 100644 net/nbc.h create mode 100644 tools/sendnbc.cIs NBC a standard ? Could you provide a link describing this protocol ?
NBC is not a standard, this is just a simple protocol I designed for this purpose
Quoted 10 lines
I am quite confuse, this seems a way to replace DHCP in a simplest form to set up the ip address using some sort of knocking-port. As additional feature, the
Why cannot we reach the same result using the "Vendor Specific Information" (or another option field) of DHCP answer ? You can set there some infos that the target could understand.
I did think about using DHCP for this, but finally decided to use a new packet format since the use is very specific and using DHCP
Quoted 5 lines
It seems to me that the first packet is always sent to the broadcast address. What happens if we have two boards on the network, both waiting in autoboot ? Do they obtain the same ip address ?
All the packets are sent to the broadcast adress, so if two boards are waiting at the same time there will be a conflict.
The way to use it in my mind is to start broadcasting with sendnbc, and then start the board.
As the sendnbc tool will stop broadcasting right after one target answered to the packet by sending back the u-booy prompt, the only case that can lead to this problem is if both targets are started exactly at the same time.
Indeed there could be some potential improvement on this conflicted situation.
Regards
Quoted 11 lines
Best regards,
Stefano Babic--
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
Signature · 1 line
618FE3EF
cover Net Boot Controller
In reply to Michael ZaidmanHi Michael,
2010/11/17 Michael Zaidman <[email protected]>
Quoted 15 lines
Hi Tristan,
Quoted 4 lines · On Tue, Nov 16, 2010 at 8:04 PM, <[email protected]> wrote:
From: Tristan Lelong <[email protected]>
This patch allow to interrupt u-boot autoboot from remote PC and
auto-reconfigure a netconsole redirected to this remote PC
Quoted 6 lines
Tristan Lelong (3):
Add support for Net Boot Controller (NBC) packet Add sendnbc tool to broadcast NBC magic packet Add the NBC + netconsole corresponding documentation
Quoted 6 lines
We usually need netconsole when serial console is not the option. The u-boot autorun lasts for few seconds only afterwards the control is passed to OS. That means that u-boot will be capable of NBC catching during very sort period of time. How the user is supposed to know when to issue the NBC packet?
You're right, netconsole is there when the serial console is not an option. The best example for me would be in a training class for embedded linux (where u-boot is not the subject but only a tool to handle kernels and rootfs), the need for several serial adapter is a real constrain that can be avoided.
The sendnbc will broadcast in a loop NBC packets until one board answer by sending the u-boot prompt. So, the user won't need to be aware of the right moment to send the packets, he will just start broadcasting and then start the board.
Quoted 8 lines
It is also not clear how proposed feature will coexist with BOOTP?
In order to remotely connect to u-boot via netconsole I use the following approach - the u-boot wakes up with serial console and after few seconds switches to netconsole if user did not hit any key to stay with serial console.
here, I choosed to add the "wait on NBC packet" after the "serial console autoboot abort" feature. This is done to keep the serial console with the higher priority and give the opportunity to skip nbc feature if a serial console is available.
Quoted 41 lines
The code is very simple and compact.
Add to your board configuration file:
#define
CONFIG_NETCONSOLE1
#defineCONFIG_PREBOOT"setenv stdout nc;setenv stderr nc;setenv stdin
nc;"Override the
last_stage_init()in your board .c file:int
last_stage_init(void)
{
int i, abort = 0;
int bootdelay = 2; /* Seconds */printf("\nHit any key to stay with serial console: %2d ",
bootdelay);while ((bootdelay-- > 0) && (!abort)) { /* delay 100 * 10mS */ for (i=0; !abort && i<100; ++i) { if (tstc()) { /* we got a key press */ abort = 1; bootdelay = 0; /* no more delay */ (void)getc(); /* consume input */ setenv("preboot","echo"); break; } udelay(10000); } printf("\b\b\b%2d ", bootdelay); } putc('\n'); return 0; }
Quoted 3 lines
Regards,
Michael
Regards
Signature · 1 line
618FE3EF
PATCH 1/3 Add support for Net Boot Controller (NBC) packet
In reply to tristan.lelong at blunderer.orgDear tristan.lelong at blunderer.org,
Quoted 6 lines · In message <732b4e4395e5c02bb01c1fd7b7f8ce085a208950.1289929762.git.blunderer@b…
From: Tristan Lelong <[email protected]>
This adds the core NBC feature:
* Integration into u-boot
* NBC packet processing
* NetConsole reconfigure
Like Stefano I wonder if this is protocol is ion any way standardized? For example, I cannot find a coresponding RFC for it.
And why is it needed? DHCP should work fine, doesn't it?
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Artificial Intelligence is no match for natural stupidity.
PATCH 2/3 Add sendnbc tool to broadcast NBC magic packet
In reply to Mike FrysingerHi Mike,
Thank you for all your correction hints.
I used the Lindent script to check for mistakes, but obviously, this was not enought, and I will correct all these with care.
Regards
2010/11/17 Mike Frysinger <[email protected]>
Quoted 37 lines · On Tuesday, November 16, 2010 13:04:32 tristan.lelong at blunderer.org wrote:
tools/sendnbc.c line 1
Quoted 4 lines
tools/sendnbc.c new file +1
-0@@ -0,0 +1,219 @@ +#include <stdio.h> missing licensing & copyright header
tools/sendnbc.c line 11
Quoted 1 line
tools/sendnbc.c new file +1
-0+static void usage (char *argv0)style problems throughout this file too
tools/sendnbc.c line 4
Quoted 2 lines
tools/sendnbc.c new file +2
-0+ printf + ("SENDNBC: sends a magic packet to u-boot board to interruptthe
Quoted 1 line
autoboot\n"); + printf (" and reconfigure u-boot in
netconsole
tools/sendnbc.c
Quoted 11 lines
mode.\n"); + printf
+ (" Use in combination with netconsole to connect and
control\n"); + printf (" your u-boot device\n");tools/sendnbc.c new file +2
-0+ printf + (" Ex: BOARD_IP=192.168.0.2 ./sendnbc -i $BOARD_IP -d eth0 &&./netconsole $BOARD_IP\n"); + printf ("\nusage: %s [options]\n", argv0);
tools/sendnbc.c new file +5
-0+printf (" -i <ip addr>: the ip addr to assign to u-boot board\n" ); +printf (" -m <mac addr>: the targeted board mac addr \n" ); +printf (" -n <hostname>: the targeted board hostname \n" ); + printf + (" -d <device>: the net interface to use for broadcasting (ex:eth0).
Quoted 2 lines
Must be root to use this option\n"); + printf (" -h: display this
help\n");multiple calls to
printf()is such a waste. combine all the strings into one
and callprintf()just once.
-mike
Signature · 1 line
618FE3EF
cover Net Boot Controller
In reply to tristanQuoted 5 lines · tristan
Is NBC a standard ? Could you provide a link describing this protocol ?
NBC is not a standard, this is just a simple protocol I designed for this purpose
IMHO we should not add such as protocol to u-boot, considering that u-boot already implements standard ways (DHCP, BOOTP) to achieve what you want.
Your solution works only locally and you have to synchronize yourself to send the broadcast message when you reset the board. DHCP works in anyway.
Michael sent an example how to switch the console to NetConsole. Is it not suitable for you ? You could add the dhcp command to the preboot variable if you need to obtain an IP address after a reset.
Quoted 2 lines
I did think about using DHCP for this, but finally decided to use a new packet format since the use is very specific and using DHCP
Not really, Your protocol is a way to set the IP address, after that you switch the console. Providing network addresses is exactly the DHCP's job.
Quoted 2 lines
All the packets are sent to the broadcast adress, so if two boards are waiting at the same time there will be a conflict.
This is not good...
Quoted 6 lines
The way to use it in my mind is to start broadcasting with sendnbc, and then start the board.
As the sendnbc tool will stop broadcasting right after one target answered to the packet by sending back the u-booy prompt, the only case that can lead to this problem is if both targets are started exactly at the same time.
It not so uncommon to have a lot of boards connected to the same network. If all of them support your protocol, we get in big trouble.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
cover Net Boot Controller
In reply to tristanDear tristan,
Quoted 5 lines · In message <[email protected]> you…
Quoted 2 lines
Is NBC a standard ? Could you provide a link describing this protocol ?
NBC is not a standard, this is just a simple protocol I designed for this purpose
Sorry, but in this case, and considering all the othe rproblems pointed out by Stefano, please maintain this code out of tree. We will not add this to mainline.
NAK for all three patches.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de No problem is insoluble. -- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4
cover Net Boot Controller
Thank you for your time. As I understand, there are some ways to achieve almost the same feature using only the preboot command.
I'll take a closer look at it.
Regards
2010/11/17 Wolfgang Denk <[email protected]>
Quoted 27 lines
Dear tristan,
In message <AANLkTi=01bccmnBEnot6OjcstvFAZPxX+AZPqkxK3SLt at mail.gmail.com<01bccmnBEnot6OjcstvFAZPxX%[email protected]>>
Quoted 5 lines · you
Quoted 2 lines
Is NBC a standard ? Could you provide a link describing this protocol ?
NBC is not a standard, this is just a simple protocol I designed for this purpose
Sorry, but in this case, and considering all the othe rproblems pointed out by Stefano, please maintain this code out of tree. We will not add this to mainline.
NAK for all three patches.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de No problem is insoluble.
-- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4
Signature · 1 line
618FE3EF