* [U-Boot] [PATCH 0/3] Net Boot Controller
@ 2010-11-16 18:04 tristan.lelong at blunderer.org
2010-11-16 18:04 ` [U-Boot] [PATCH 1/3] Add support for Net Boot Controller (NBC) packet tristan.lelong at blunderer.org
` (4 more replies)
0 siblings, 5 replies; 16+ messages in thread
From: tristan.lelong at blunderer.org @ 2010-11-16 18:04 UTC (permalink / raw)
To: u-boot
From: Tristan Lelong <tristan.lelong@blunderer.org>
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
--
1.7.2.3
^ permalink raw reply [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH 1/3] Add support for Net Boot Controller (NBC) packet
2010-11-16 18:04 [U-Boot] [PATCH 0/3] Net Boot Controller tristan.lelong at blunderer.org
@ 2010-11-16 18:04 ` tristan.lelong at blunderer.org
2010-11-17 10:54 ` Mike Frysinger
2010-11-17 13:28 ` Wolfgang Denk
2010-11-16 18:04 ` [U-Boot] [PATCH 2/3] Add sendnbc tool to broadcast NBC magic packet tristan.lelong at blunderer.org
` (3 subsequent siblings)
4 siblings, 2 replies; 16+ messages in thread
From: tristan.lelong at blunderer.org @ 2010-11-16 18:04 UTC (permalink / raw)
To: u-boot
From: Tristan Lelong <tristan.lelong@blunderer.org>
This adds the core NBC feature:
* Integration into u-boot
* NBC packet processing
* NetConsole reconfigure
Signed-off-by: Tristan Lelong <tristan.lelong@blunderer.org>
---
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
diff --git a/common/main.c b/common/main.c
index d97ccd7..e23b204 100644
--- a/common/main.c
+++ b/common/main.c
@@ -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;
diff --git a/include/net.h b/include/net.h
index a29dafc..25e177f 100644
--- a/include/net.h
+++ b/include/net.h
@@ -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);
diff --git a/net/Makefile b/net/Makefile
index 216d1ec..735e8c6 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -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)
diff --git a/net/nbc.c b/net/nbc.c
new file mode 100644
index 0000000..e1788e4
--- /dev/null
+++ b/net/nbc.c
@@ -0,0 +1,143 @@
+/*
+ * NBC support driver
+ * Network Boot Controller
+ *
+ * Copyright (c) 2010 Tristan Lelong <tristan.lelong@blunderer.org>
+ *
+ */
+
+#include <common.h>
+#include <command.h>
+#include <net.h>
+
+#include "nbc.h"
+
+#ifndef CONFIG_NETCONSOLE
+#error CONFIG_NETCONSOLE should be defined so that nbc can redirect stdin/stdout/stderr
+#endif
+
+static char NBC_Mode_On = 0;
+
+static void NBCHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
+{
+ 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)
+ 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));
+
+ if (nbcsource && strcmp (nbcsource, src_ip))
+ goto fail;
+
+ for (cnt = 0; cnt < (nbc_pkt->size - NBC_HEADER_SIZE);) {
+ struct _nbc_chunk *chk =
+ (struct _nbc_chunk *)(pkt + NBC_HEADER_SIZE + cnt);
+ if (strncmp (chk->name, "IP\0\0", 4) == 0) {
+ if (chk->size != NBC_CHK_IP_SIZE)
+ goto fail;
+ unsigned char *pkt_ip = (unsigned char *)chk->data;
+ sprintf (ip, "%d.%d.%d.%d", pkt_ip[0], pkt_ip[1],
+ pkt_ip[2], pkt_ip[3]);
+ } else if (strncmp (chk->name, "MAC\0", 4) == 0) {
+ if (chk->size != NBC_CHK_MAC_SIZE)
+ goto fail;
+ 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]);
+ } else if (strncmp (chk->name, "HOST", 4) == 0) {
+ unsigned char *pkt_hostname =
+ (unsigned char *)chk->data;
+ if (chk->size >= NBC_CHK_HOSTNAME_SIZE)
+ goto fail;
+ strncpy (hostname, pkt_hostname, chk->size);
+ hostname[chk->size] = '\0';
+ }
+ cnt += NBC_CHK_HEADER_SIZE + chk->size;
+ }
+
+ /* test if we are targeted by the magic packet */
+ if (strlen (mac)) {
+ char *our_mac = getenv ("ethaddr");
+ debug ("mac filter: cmp(%s,%s)\n", our_mac, mac);
+ if (strcmp (mac, our_mac))
+ goto fail;
+ }
+
+ if (strlen (hostname)) {
+ char *our_hostname = getenv ("hostname");
+ debug ("hostname filter: cmp(%s,%s)\n", our_hostname, hostname);
+ if (strcmp (hostname, our_hostname))
+ goto fail;
+ }
+
+ /* set server ip */
+ setenv ("serverip", src_ip);
+
+ /* set gateway ip */
+ setenv ("gatewayip", src_ip);
+
+ /* set addrip */
+ setenv ("ipaddr", ip);
+
+ printf ("activated nc from [%s] to [%s]\n", ip, src_ip);
+
+ /* activate the netconsole */
+ setenv ("ncip", src_ip);
+ setenv ("stdin", "nc");
+ setenv ("stdout", "nc");
+ setenv ("stderr", "nc");
+ console_assign (stdin, "nc");
+ console_assign (stdout, "nc");
+ console_assign (stderr, "nc");
+
+ NBC_Mode_On = 1;
+
+ NetState = NETLOOP_SUCCESS;
+
+ return;
+fail:
+ debug ("not a valid nbc magic packet\n");
+}
+
+static void NBCTimeout (void)
+{
+ NetState = NETLOOP_FAIL;
+ debug ("NBC Timeout!\n");
+}
+
+int NBCWait (void)
+{
+ char *nbcinhibit = getenv ("nbcinhibit");
+ if (nbcinhibit)
+ return 0;
+
+ NetLoop (NBC);
+
+ if (NBC_Mode_On) {
+ return 1;
+ }
+ return 0;
+}
+
+void NBCStart (void)
+{
+ NetSetTimeout (1000, NBCTimeout);
+ NetSetHandler (NBCHandler);
+}
diff --git a/net/nbc.h b/net/nbc.h
new file mode 100644
index 0000000..40371a5
--- /dev/null
+++ b/net/nbc.h
@@ -0,0 +1,39 @@
+/*
+ * (C) Tristan Lelong <tristan.lelong@blunderer.org> 2010
+ * Copyright 2010, Tristan Lelong <tristan.lelong@blunderer.org>
+ *
+ * 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
diff --git a/net/net.c b/net/net.c
index d5a5429..b722048 100644
--- a/net/net.c
+++ b/net/net.c
@@ -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.
*/
--
1.7.2.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH 2/3] Add sendnbc tool to broadcast NBC magic packet
2010-11-16 18:04 [U-Boot] [PATCH 0/3] Net Boot Controller tristan.lelong at blunderer.org
2010-11-16 18:04 ` [U-Boot] [PATCH 1/3] Add support for Net Boot Controller (NBC) packet tristan.lelong at blunderer.org
@ 2010-11-16 18:04 ` tristan.lelong at blunderer.org
2010-11-17 10:56 ` Mike Frysinger
2010-11-16 18:04 ` [U-Boot] [PATCH 3/3] Add the NBC + netconsole corresponding documentation tristan.lelong at blunderer.org
` (2 subsequent siblings)
4 siblings, 1 reply; 16+ messages in thread
From: tristan.lelong at blunderer.org @ 2010-11-16 18:04 UTC (permalink / raw)
To: u-boot
From: Tristan Lelong <tristan.lelong@blunderer.org>
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
Signed-off-by: Tristan Lelong <tristan.lelong@blunderer.org>
---
tools/Makefile | 6 ++
tools/sendnbc.c | 219 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 225 insertions(+), 0 deletions(-)
create mode 100644 tools/sendnbc.c
diff --git a/tools/Makefile b/tools/Makefile
index 619c9f2..e1719fc 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -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 $@ $^
diff --git a/tools/sendnbc.c b/tools/sendnbc.c
new file mode 100644
index 0000000..03bf5af
--- /dev/null
+++ b/tools/sendnbc.c
@@ -0,0 +1,219 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netinet/ether.h>
+
+static void usage (char *argv0)
+{
+ printf
+ ("SENDNBC: sends a magic packet to u-boot board to interrupt the autoboot\n");
+ printf (" and reconfigure u-boot in netconsole mode.\n");
+ printf
+ (" Use in combination with netconsole to connect and control\n");
+ printf (" your u-boot device\n");
+ printf
+ (" Ex: BOARD_IP=192.168.0.2 ./sendnbc -i $BOARD_IP -d eth0 && ./netconsole $BOARD_IP\n");
+ printf ("\nusage: %s [options]\n", argv0);
+ 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). Must be root to use this option\n");
+ printf (" -h: display this help\n");
+}
+
+static int build_nbc_pkt (char *buf, int buf_len, char *ip, char *mac,
+ char *hostname)
+{
+ int offset = 0;
+ char *size = NULL;
+ char *ip_size = NULL;
+ char *mac_size = NULL;
+ char *hostname_size = NULL;
+
+ struct in_addr binip;
+ struct ether_addr binmac;
+
+ memset (buf, 0, buf_len);
+
+ buf[0] = (char)0xD3; /* magic number */
+ offset += 1;
+
+ strcpy (buf + offset, "NBC"); /* packet header */
+ offset += 3;
+
+ size = (char *)(buf + offset); /* msg total size */
+ offset += 1;
+
+ strcpy (buf + offset, "IP"); /* IP chunk header */
+ offset += 4;
+
+ ip_size = (char *)(buf + offset); /* IP chunk size */
+ offset += 1;
+
+ inet_pton (AF_INET, ip, &binip);
+ memcpy (buf + offset, &binip, sizeof (struct in_addr)); /* IP chunk data */
+ offset += sizeof (struct in_addr);
+ *ip_size = sizeof (struct in_addr);
+
+ if (mac) {
+ strcpy (buf + offset, "MAC"); /* MAC chunk header */
+ offset += 4;
+
+ mac_size = (char *)(buf + offset); /* MAC chunk size */
+ offset += 1;
+
+ ether_aton_r (mac, &binmac);
+ memcpy (buf + offset, &binmac, sizeof (struct ether_addr)); /* MAC chunk data */
+ offset += sizeof (struct ether_addr);
+ *mac_size = sizeof (struct ether_addr);
+ }
+
+ if (hostname) {
+ strcpy (buf + offset, "HOST"); /* HOST chunk header */
+ offset += 4;
+
+ hostname_size = (char *)(buf + offset); /* HOST chunk size */
+ offset += 1;
+
+ strcpy (buf + offset, hostname); /* HOST chunk data */
+ offset += strlen (hostname);
+ *hostname_size = strlen (hostname);
+ }
+
+ *size = offset;
+
+ return offset;
+}
+
+int main (int argc, char *argv[])
+{
+ char buf[255];
+ int s, len, o, nbcport = 4446, netconsoleport = 6666;
+ int buf_len = sizeof (buf);
+ char option;
+ char *ip = NULL;
+ char *mac = NULL;
+ char *device = NULL;
+ char *hostname = NULL;
+ struct sockaddr_in addr;
+ struct sockaddr_in broadcast_addr;
+ socklen_t addr_len = sizeof (addr);
+ socklen_t broadcast_addr_len = sizeof (broadcast_addr);
+
+ s = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (s < 0) {
+ perror ("Error with socket creation");
+ return 1;
+ }
+ while ((option = getopt (argc, argv, "hn:m:i:d:")) >= 0) {
+ switch (option) {
+ case 'h':
+ usage (argv[0]);
+ exit (0);
+ case 'd':
+ device = optarg;
+ break;
+ case 'n':
+ hostname = optarg;
+ break;
+ case 'm':
+ mac = optarg;
+ break;
+ case 'i':
+ ip = optarg;
+ break;
+ default:
+ usage (argv[0]);
+ exit (0);
+ }
+ }
+
+ if (!ip) {
+ usage (argv[0]);
+ exit (0);
+ }
+
+ /* set sockoptions */
+ o = 1;
+ len = 4;
+ setsockopt (3, SOL_SOCKET, SO_REUSEADDR, &o, len);
+ o = 1;
+ len = 4;
+ setsockopt (3, SOL_SOCKET, SO_BROADCAST, &o, len);
+ if (device) {
+ len = strlen (device);
+ setsockopt (3, SOL_SOCKET, SO_BINDTODEVICE, device, len);
+ }
+
+ /* configure socket */
+ memset (&addr, 0, sizeof (struct sockaddr_in));
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons (netconsoleport);
+ addr.sin_addr.s_addr = INADDR_ANY;
+
+ memset (&broadcast_addr, 0, sizeof (struct sockaddr_in));
+ broadcast_addr.sin_family = AF_INET;
+ broadcast_addr.sin_port = htons (nbcport);
+ broadcast_addr.sin_addr.s_addr = INADDR_BROADCAST;
+
+ if (bind (s, (struct sockaddr *)&addr, sizeof (addr)) < 0) {
+ perror ("error with bind");
+ close (s);
+ }
+
+ /* build packets */
+ buf_len = build_nbc_pkt (buf, sizeof (buf), ip, mac, hostname);
+
+ for (;;) {
+ char recv_buf = '\n';
+ struct in_addr binip;
+ struct sockaddr_in board_addr;
+ socklen_t board_addr_len = sizeof (struct sockaddr_in);
+
+ memset (&addr, 0, sizeof (struct sockaddr_in));
+ inet_pton (AF_INET, ip, &binip);
+ board_addr.sin_family = AF_INET;
+ board_addr.sin_port = htons (netconsoleport);
+ memcpy (&board_addr.sin_addr.s_addr, &binip,
+ sizeof (struct in_addr));
+
+ /* send the magic packet */
+ len =
+ sendto (s, buf, buf_len, 0,
+ (struct sockaddr *)&broadcast_addr,
+ broadcast_addr_len);
+ if (len < 0) {
+ perror ("error in send");
+ break;
+ }
+
+ usleep (100000);
+
+ /* check for u-boot in netconsole mode */
+ len =
+ sendto (s, &recv_buf, 1, 0, (struct sockaddr *)&board_addr,
+ board_addr_len);
+ len = recv (s, &recv_buf, 1, MSG_PEEK | MSG_DONTWAIT);
+ if (len < 0) {
+ if (errno != EAGAIN) {
+ perror ("error in recv");
+ break;
+ }
+ } else if (len > 0) {
+ break;
+ }
+ }
+ if (len < 0) {
+ return 1;
+ }
+
+ close (s);
+
+ return 0;
+}
--
1.7.2.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH 3/3] Add the NBC + netconsole corresponding documentation
2010-11-16 18:04 [U-Boot] [PATCH 0/3] Net Boot Controller tristan.lelong at blunderer.org
2010-11-16 18:04 ` [U-Boot] [PATCH 1/3] Add support for Net Boot Controller (NBC) packet tristan.lelong at blunderer.org
2010-11-16 18:04 ` [U-Boot] [PATCH 2/3] Add sendnbc tool to broadcast NBC magic packet tristan.lelong at blunderer.org
@ 2010-11-16 18:04 ` tristan.lelong at blunderer.org
2010-11-17 10:50 ` Mike Frysinger
2010-11-17 10:25 ` [U-Boot] [PATCH 0/3] Net Boot Controller Stefano Babic
2010-11-17 11:34 ` Michael Zaidman
4 siblings, 1 reply; 16+ messages in thread
From: tristan.lelong at blunderer.org @ 2010-11-16 18:04 UTC (permalink / raw)
To: u-boot
From: Tristan Lelong <tristan.lelong@blunderer.org>
Signed-off-by: Tristan Lelong <tristan.lelong@blunderer.org>
---
doc/README.netconsole | 66 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 66 insertions(+), 0 deletions(-)
create mode 100644 doc/README.netconsole
diff --git a/doc/README.netconsole b/doc/README.netconsole
new file mode 100644
index 0000000..167f523
--- /dev/null
+++ b/doc/README.netconsole
@@ -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
+
--
1.7.2.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH 0/3] Net Boot Controller
2010-11-16 18:04 [U-Boot] [PATCH 0/3] Net Boot Controller tristan.lelong at blunderer.org
` (2 preceding siblings ...)
2010-11-16 18:04 ` [U-Boot] [PATCH 3/3] Add the NBC + netconsole corresponding documentation tristan.lelong at blunderer.org
@ 2010-11-17 10:25 ` Stefano Babic
2010-11-17 13:17 ` tristan
2010-11-17 11:34 ` Michael Zaidman
4 siblings, 1 reply; 16+ messages in thread
From: Stefano Babic @ 2010-11-17 10:25 UTC (permalink / raw)
To: u-boot
On 11/16/2010 07:04 PM, tristan.lelong at blunderer.org wrote:
> From: Tristan Lelong <tristan.lelong@blunderer.org>
>
> 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,
> 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
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
--
=====================================================================
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
=====================================================================
^ permalink raw reply [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH 3/3] Add the NBC + netconsole corresponding documentation
2010-11-16 18:04 ` [U-Boot] [PATCH 3/3] Add the NBC + netconsole corresponding documentation tristan.lelong at blunderer.org
@ 2010-11-17 10:50 ` Mike Frysinger
0 siblings, 0 replies; 16+ messages in thread
From: Mike Frysinger @ 2010-11-17 10:50 UTC (permalink / raw)
To: u-boot
On Tuesday, November 16, 2010 13:04:33 tristan.lelong at blunderer.org wrote:
> --- /dev/null
> +++ b/doc/README.netconsole
> @@ -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
^ permalink raw reply [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH 1/3] Add support for Net Boot Controller (NBC) packet
2010-11-16 18:04 ` [U-Boot] [PATCH 1/3] Add support for Net Boot Controller (NBC) packet tristan.lelong at blunderer.org
@ 2010-11-17 10:54 ` Mike Frysinger
2010-11-17 13:28 ` Wolfgang Denk
1 sibling, 0 replies; 16+ messages in thread
From: Mike Frysinger @ 2010-11-17 10:54 UTC (permalink / raw)
To: u-boot
On Tuesday, November 16, 2010 13:04:31 tristan.lelong at blunderer.org wrote:
> --- a/common/main.c
> +++ b/common/main.c
>
> +#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.
> + 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.
> --- a/net/Makefile
> +++ b/net/Makefile
> @@ -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
> --- /dev/null
> +++ b/net/nbc.c
> @@ -0,0 +1,143 @@
> +/*
> + * NBC support driver
> + * Network Boot Controller
> + *
> + * Copyright (c) 2010 Tristan Lelong <tristan.lelong@blunderer.org>
> + *
> + */
licensing info is missing
> +static void NBCHandler (uchar * pkt, unsigned dest, unsigned src, unsigned
> len) +{
style problems here -- no space after that asterisk
> + 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
> + 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.
> + 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.
> + if (NBC_Mode_On) {
> + return 1;
> + }
useless braces
> --- /dev/null
> +++ b/net/nbc.h
> @@ -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.
> --- a/net/net.c
> +++ b/net/net.c
> @@ -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
^ permalink raw reply [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH 2/3] Add sendnbc tool to broadcast NBC magic packet
2010-11-16 18:04 ` [U-Boot] [PATCH 2/3] Add sendnbc tool to broadcast NBC magic packet tristan.lelong at blunderer.org
@ 2010-11-17 10:56 ` Mike Frysinger
2010-11-17 13:33 ` tristan
0 siblings, 1 reply; 16+ messages in thread
From: Mike Frysinger @ 2010-11-17 10:56 UTC (permalink / raw)
To: u-boot
On Tuesday, November 16, 2010 13:04:32 tristan.lelong at blunderer.org wrote:
> --- /dev/null
> +++ b/tools/sendnbc.c
> @@ -0,0 +1,219 @@
> +#include <stdio.h>
missing licensing & copyright header
> +static void usage (char *argv0)
style problems throughout this file too
> + printf
> + ("SENDNBC: sends a magic packet to u-boot board to interrupt the
> autoboot\n"); + printf (" and reconfigure u-boot in netconsole
> mode.\n"); + printf
> + (" Use in combination with netconsole to connect and
> control\n"); + printf (" your u-boot device\n");
> + printf
> + (" Ex: BOARD_IP=192.168.0.2 ./sendnbc -i $BOARD_IP -d eth0 &&
> ./netconsole $BOARD_IP\n"); + printf ("\nusage: %s [options]\n", argv0);
> + 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).
> 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
^ permalink raw reply [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH 0/3] Net Boot Controller
2010-11-16 18:04 [U-Boot] [PATCH 0/3] Net Boot Controller tristan.lelong at blunderer.org
` (3 preceding siblings ...)
2010-11-17 10:25 ` [U-Boot] [PATCH 0/3] Net Boot Controller Stefano Babic
@ 2010-11-17 11:34 ` Michael Zaidman
2010-11-17 13:27 ` tristan
4 siblings, 1 reply; 16+ messages in thread
From: Michael Zaidman @ 2010-11-17 11:34 UTC (permalink / raw)
To: u-boot
Hi Tristan,
On Tue, Nov 16, 2010 at 8:04 PM, <tristan.lelong@blunderer.org> wrote:
>
> From: Tristan Lelong <tristan.lelong@blunderer.org>
>
> 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
^ permalink raw reply [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH 0/3] Net Boot Controller
2010-11-17 10:25 ` [U-Boot] [PATCH 0/3] Net Boot Controller Stefano Babic
@ 2010-11-17 13:17 ` tristan
2010-11-17 13:36 ` Stefano Babic
2010-11-17 13:52 ` Wolfgang Denk
0 siblings, 2 replies; 16+ messages in thread
From: tristan @ 2010-11-17 13:17 UTC (permalink / raw)
To: u-boot
Hi Stefano,
2010/11/17 Stefano Babic <sbabic@denx.de>
> On 11/16/2010 07:04 PM, tristan.lelong at blunderer.org wrote:
> > From: Tristan Lelong <tristan.lelong@blunderer.org>
> >
> > 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,
>
> > 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
>
> 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
>
> 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
>
> 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
>
> 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
> =====================================================================
>
--
618FE3EF
^ permalink raw reply [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH 0/3] Net Boot Controller
2010-11-17 11:34 ` Michael Zaidman
@ 2010-11-17 13:27 ` tristan
0 siblings, 0 replies; 16+ messages in thread
From: tristan @ 2010-11-17 13:27 UTC (permalink / raw)
To: u-boot
Hi Michael,
2010/11/17 Michael Zaidman <michael.zaidman@gmail.com>
> Hi Tristan,
>
> On Tue, Nov 16, 2010 at 8:04 PM, <tristan.lelong@blunderer.org> wrote:
> >
> > From: Tristan Lelong <tristan.lelong@blunderer.org>
> >
> > 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?
>
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.
>
> 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.
>
> 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
>
Regards
--
618FE3EF
^ permalink raw reply [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH 1/3] Add support for Net Boot Controller (NBC) packet
2010-11-16 18:04 ` [U-Boot] [PATCH 1/3] Add support for Net Boot Controller (NBC) packet tristan.lelong at blunderer.org
2010-11-17 10:54 ` Mike Frysinger
@ 2010-11-17 13:28 ` Wolfgang Denk
1 sibling, 0 replies; 16+ messages in thread
From: Wolfgang Denk @ 2010-11-17 13:28 UTC (permalink / raw)
To: u-boot
Dear tristan.lelong at blunderer.org,
In message <732b4e4395e5c02bb01c1fd7b7f8ce085a208950.1289929762.git.blunderer@blunderer.org> you wrote:
> From: Tristan Lelong <tristan.lelong@blunderer.org>
>
> 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
--
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH 2/3] Add sendnbc tool to broadcast NBC magic packet
2010-11-17 10:56 ` Mike Frysinger
@ 2010-11-17 13:33 ` tristan
0 siblings, 0 replies; 16+ messages in thread
From: tristan @ 2010-11-17 13:33 UTC (permalink / raw)
To: u-boot
Hi 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 <vapier@gentoo.org>
> On Tuesday, November 16, 2010 13:04:32 tristan.lelong at blunderer.org wrote:
> > --- /dev/null
> > +++ b/tools/sendnbc.c
> > @@ -0,0 +1,219 @@
> > +#include <stdio.h>
>
> missing licensing & copyright header
>
> > +static void usage (char *argv0)
>
> style problems throughout this file too
>
> > + printf
> > + ("SENDNBC: sends a magic packet to u-boot board to interrupt
> the
> > autoboot\n"); + printf (" and reconfigure u-boot in
> netconsole
> > mode.\n"); + printf
> > + (" Use in combination with netconsole to connect and
> > control\n"); + printf (" your u-boot device\n");
> > + printf
> > + (" Ex: BOARD_IP=192.168.0.2 ./sendnbc -i $BOARD_IP -d eth0 &&
> > ./netconsole $BOARD_IP\n"); + printf ("\nusage: %s [options]\n", argv0);
> > + 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).
> > 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
>
--
618FE3EF
^ permalink raw reply [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH 0/3] Net Boot Controller
2010-11-17 13:17 ` tristan
@ 2010-11-17 13:36 ` Stefano Babic
2010-11-17 13:52 ` Wolfgang Denk
1 sibling, 0 replies; 16+ messages in thread
From: Stefano Babic @ 2010-11-17 13:36 UTC (permalink / raw)
To: u-boot
On 11/17/2010 02:17 PM, tristan wrote:
> 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.
> 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.
> 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...
> 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
--
=====================================================================
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
=====================================================================
^ permalink raw reply [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH 0/3] Net Boot Controller
2010-11-17 13:17 ` tristan
2010-11-17 13:36 ` Stefano Babic
@ 2010-11-17 13:52 ` Wolfgang Denk
2010-11-17 14:07 ` tristan
1 sibling, 1 reply; 16+ messages in thread
From: Wolfgang Denk @ 2010-11-17 13:52 UTC (permalink / raw)
To: u-boot
Dear tristan,
In message <AANLkTi=01bccmnBEnot6OjcstvFAZPxX+AZPqkxK3SLt@mail.gmail.com> you wrote:
>
> > 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
^ permalink raw reply [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH 0/3] Net Boot Controller
2010-11-17 13:52 ` Wolfgang Denk
@ 2010-11-17 14:07 ` tristan
0 siblings, 0 replies; 16+ messages in thread
From: tristan @ 2010-11-17 14:07 UTC (permalink / raw)
To: u-boot
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 <wd@denx.de>
> Dear tristan,
>
> In message <AANLkTi=01bccmnBEnot6OjcstvFAZPxX+AZPqkxK3SLt at mail.gmail.com<01bccmnBEnot6OjcstvFAZPxX%2BAZPqkxK3SLt@mail.gmail.com>>
> you wrote:
> >
> > > 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
>
--
618FE3EF
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2010-11-17 14:07 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-16 18:04 [U-Boot] [PATCH 0/3] Net Boot Controller tristan.lelong at blunderer.org
2010-11-16 18:04 ` [U-Boot] [PATCH 1/3] Add support for Net Boot Controller (NBC) packet tristan.lelong at blunderer.org
2010-11-17 10:54 ` Mike Frysinger
2010-11-17 13:28 ` Wolfgang Denk
2010-11-16 18:04 ` [U-Boot] [PATCH 2/3] Add sendnbc tool to broadcast NBC magic packet tristan.lelong at blunderer.org
2010-11-17 10:56 ` Mike Frysinger
2010-11-17 13:33 ` tristan
2010-11-16 18:04 ` [U-Boot] [PATCH 3/3] Add the NBC + netconsole corresponding documentation tristan.lelong at blunderer.org
2010-11-17 10:50 ` Mike Frysinger
2010-11-17 10:25 ` [U-Boot] [PATCH 0/3] Net Boot Controller Stefano Babic
2010-11-17 13:17 ` tristan
2010-11-17 13:36 ` Stefano Babic
2010-11-17 13:52 ` Wolfgang Denk
2010-11-17 14:07 ` tristan
2010-11-17 11:34 ` Michael Zaidman
2010-11-17 13:27 ` tristan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox