Changes since U-Boot 1.1.1:
======================================================================
+* Patch by Detlev Zundel, 08 Sep 2004:
+ Update etags build target
+
+* Improve NetConsole support: add support for broadcast destination
+ address and buffered input.
+
+* Cleanup compiler warnings for GCC 3.3.x and later
+
+* Fix problem in cmd_jffs2.c introduced by CFG_JFFS_SINGLE_PART patch
+
* Add support for IDS "NC650" board
* Add automatic update support for LWMON board
etags:
etags -a `find $(SUBDIRS) include \
+ lib_generic board/$(BOARDDIR) cpu/$(CPU) lib_$(ARCH) \
+ fs/cramfs fs/fat fs/fdos fs/jffs2 \
+ net disk rtc dtt drivers drivers/sk98lin common \
\( -name CVS -prune \) -o \( -name '*.[ch]' -print \)`
System.map: u-boot
examples/eepro100_eeprom examples/sched \
examples/mem_to_mem_idma2intr examples/82559_eeprom
rm -f tools/img2srec tools/mkimage tools/envcrc tools/gen_eth_addr
- rm -f tools/mpc86x_clk
+ rm -f tools/mpc86x_clk tools/ncb
rm -f tools/easylogo/easylogo tools/bmp_logo
rm -f tools/gdb/astest tools/gdb/gdbcont tools/gdb/gdbsend
rm -f tools/env/fw_printenv tools/env/fw_setenv
#if defined (CFG_DRAM_TEST_DATA)
unsigned long long pattern[] = {
- 0xaaaaaaaaaaaaaaaa,
- 0xcccccccccccccccc,
- 0xf0f0f0f0f0f0f0f0,
- 0xff00ff00ff00ff00,
- 0xffff0000ffff0000,
- 0xffffffff00000000,
- 0x00000000ffffffff,
- 0x0000ffff0000ffff,
- 0x00ff00ff00ff00ff,
- 0x0f0f0f0f0f0f0f0f,
- 0x3333333333333333,
- 0x5555555555555555
+ 0xaaaaaaaaaaaaaaaaULL,
+ 0xccccccccccccccccULL,
+ 0xf0f0f0f0f0f0f0f0ULL,
+ 0xff00ff00ff00ff00ULL,
+ 0xffff0000ffff0000ULL,
+ 0xffffffff00000000ULL,
+ 0x00000000ffffffffULL,
+ 0x0000ffff0000ffffULL,
+ 0x00ff00ff00ff00ffULL,
+ 0x0f0f0f0f0f0f0f0fULL,
+ 0x3333333333333333ULL,
+ 0x5555555555555555ULL,
};
/*********************************************************************/
#if defined (CFG_DRAM_TEST_DATA)
unsigned long long pattern[] = {
- 0xaaaaaaaaaaaaaaaa,
- 0xcccccccccccccccc,
- 0xf0f0f0f0f0f0f0f0,
- 0xff00ff00ff00ff00,
- 0xffff0000ffff0000,
- 0xffffffff00000000,
- 0x00000000ffffffff,
- 0x0000ffff0000ffff,
- 0x00ff00ff00ff00ff,
- 0x0f0f0f0f0f0f0f0f,
- 0x3333333333333333,
- 0x5555555555555555
+ 0xaaaaaaaaaaaaaaaaULL,
+ 0xccccccccccccccccULL,
+ 0xf0f0f0f0f0f0f0f0ULL,
+ 0xff00ff00ff00ff00ULL,
+ 0xffff0000ffff0000ULL,
+ 0xffffffff00000000ULL,
+ 0x00000000ffffffffULL,
+ 0x0000ffff0000ffffULL,
+ 0x00ff00ff00ff00ffULL,
+ 0x0f0f0f0f0f0f0f0fULL,
+ 0x3333333333333333ULL,
+ 0x5555555555555555ULL,
};
/*********************************************************************/
/* ------------------------------------------------------------------------- */
/* Prototypes */
-int gunzip(void *, int, unsigned char *, int *);
+int gunzip(void *, int, unsigned char *, unsigned long *);
int board_early_init_f (void)
{
unsigned long cntrl0Reg;
dst = malloc(CFG_FPGA_MAX_SIZE);
- if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, (int *)&len) != 0) {
+ if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
printf ("GUNZIP ERROR - must RESET board to recover\n");
do_reset (NULL, 0, 0, NULL);
}
/* Prototypes */
-int gunzip(void *, int, unsigned char *, int *);
+int gunzip(void *, int, unsigned char *, unsigned long *);
int board_early_init_f (void)
int i;
dst = malloc(CFG_FPGA_MAX_SIZE);
- if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, (int *)&len) != 0) {
+ if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
printf ("GUNZIP ERROR - must RESET board to recover\n");
do_reset (NULL, 0, 0, NULL);
}
/* Prototypes */
int cpci405_version(void);
-int gunzip(void *, int, unsigned char *, int *);
+int gunzip(void *, int, unsigned char *, unsigned long *);
int board_early_init_f (void)
mtdcr(cntrl0, cntrl0Reg | 0x00300000);
dst = malloc(CFG_FPGA_MAX_SIZE);
- if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, (int *)&len) != 0) {
+ if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
printf ("GUNZIP ERROR - must RESET board to recover\n");
do_reset (NULL, 0, 0, NULL);
}
/* Prototypes */
-int gunzip(void *, int, unsigned char *, int *);
+int gunzip(void *, int, unsigned char *, unsigned long *);
int board_early_init_f (void)
*/
dst = malloc(CFG_FPGA_MAX_SIZE);
- if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, (int *)&len) != 0) {
+ if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
printf ("GUNZIP ERROR - must RESET board to recover\n");
do_reset (NULL, 0, 0, NULL);
}
/* Prototypes */
-int gunzip(void *, int, unsigned char *, int *);
+int gunzip(void *, int, unsigned char *, unsigned long *);
int board_early_init_f (void)
#if 1 /* test-only */
dst = malloc(CFG_FPGA_MAX_SIZE);
- if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, (int *)&len) != 0) {
+ if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
printf ("GUNZIP ERROR - must RESET board to recover\n");
do_reset (NULL, 0, 0, NULL);
}
/* Prototypes */
-int gunzip(void *, int, unsigned char *, int *);
+int gunzip(void *, int, unsigned char *, unsigned long *);
int board_early_init_f (void)
int i;
dst = malloc(CFG_FPGA_MAX_SIZE);
- if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, (int *)&len) != 0) {
+ if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
printf ("GUNZIP ERROR - must RESET board to recover\n");
do_reset (NULL, 0, 0, NULL);
}
#if defined (CFG_DRAM_TEST_DATA)
unsigned long long pattern[] = {
- 0xaaaaaaaaaaaaaaaa,
- 0xcccccccccccccccc,
- 0xf0f0f0f0f0f0f0f0,
- 0xff00ff00ff00ff00,
- 0xffff0000ffff0000,
- 0xffffffff00000000,
- 0x00000000ffffffff,
- 0x0000ffff0000ffff,
- 0x00ff00ff00ff00ff,
- 0x0f0f0f0f0f0f0f0f,
- 0x3333333333333333,
- 0x5555555555555555
+ 0xaaaaaaaaaaaaaaaaULL,
+ 0xccccccccccccccccULL,
+ 0xf0f0f0f0f0f0f0f0ULL,
+ 0xff00ff00ff00ff00ULL,
+ 0xffff0000ffff0000ULL,
+ 0xffffffff00000000ULL,
+ 0x00000000ffffffffULL,
+ 0x0000ffff0000ffffULL,
+ 0x00ff00ff00ff00ffULL,
+ 0x0f0f0f0f0f0f0f0fULL,
+ 0x3333333333333333ULL,
+ 0x5555555555555555ULL,
};
/*********************************************************************/
static int compare_magic (uchar *kbd_data, uchar *str)
{
uchar compare[KEYBD_DATALEN-1];
- uchar *nxt;
+ char *nxt;
int i;
/* Don't include modifier byte */
c = (uchar) simple_strtoul (str, (char **) (&nxt), 16);
- if (str == nxt) { /* invalid character */
+ if (str == (uchar *)nxt) { /* invalid character */
break;
}
#define FIRM_START 0xFFF00000
#endif
-extern int gunzip(void *, int, uchar *, int *);
+extern int gunzip(void *, int, uchar *, unsigned long *);
extern int mem_test(ulong start, ulong ramsize, int quiet);
#define I2C_BACKUP_ADDR 0x7C00 /* 0x200 bytes for backup */
switch (hdr->ih_comp) {
case IH_COMP_GZIP:
puts("Uncompressing (GZIP) ... ");
- rc = gunzip ((void *)(buf), IMAGE_SIZE, data, (int *)&len);
+ rc = gunzip ((void *)(buf), IMAGE_SIZE, data, &len);
if (rc != 0) {
puts("GUNZIP ERROR\n");
free(buf);
*
*/
const static unsigned long long pattern[] = {
- 0xaaaaaaaaaaaaaaaa,
- 0xcccccccccccccccc,
- 0xf0f0f0f0f0f0f0f0,
- 0xff00ff00ff00ff00,
- 0xffff0000ffff0000,
- 0xffffffff00000000,
- 0x00000000ffffffff,
- 0x0000ffff0000ffff,
- 0x00ff00ff00ff00ff,
- 0x0f0f0f0f0f0f0f0f,
- 0x3333333333333333,
- 0x5555555555555555};
-const unsigned long long otherpattern = 0x0123456789abcdef;
+ 0xaaaaaaaaaaaaaaaaULL,
+ 0xccccccccccccccccULL,
+ 0xf0f0f0f0f0f0f0f0ULL,
+ 0xff00ff00ff00ff00ULL,
+ 0xffff0000ffff0000ULL,
+ 0xffffffff00000000ULL,
+ 0x00000000ffffffffULL,
+ 0x0000ffff0000ffffULL,
+ 0x00ff00ff00ff00ffULL,
+ 0x0f0f0f0f0f0f0f0fULL,
+ 0x3333333333333333ULL,
+ 0x5555555555555555ULL,
+};
+const unsigned long long otherpattern = 0x0123456789abcdefULL;
static int memory_post_dataline(unsigned long long * pmem)
# define CHUNKSZ (64 * 1024)
#endif
-int gunzip (void *, int, unsigned char *, int *);
+int gunzip (void *, int, unsigned char *, unsigned long *);
static void *zalloc(void *, unsigned, unsigned);
static void zfree(void *, void *, unsigned);
case IH_COMP_GZIP:
printf (" Uncompressing %s ... ", name);
if (gunzip ((void *)ntohl(hdr->ih_load), unc_len,
- (uchar *)data, (int *)&len) != 0) {
+ (uchar *)data, &len) != 0) {
puts ("GUNZIP ERROR - must RESET board to recover\n");
SHOW_BOOT_PROGRESS (-6);
do_reset (cmdtp, flag, argc, argv);
#define DEFLATED 8
-int gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)
+int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp)
{
z_stream s;
int r, i, flags;
return 0;
}
+
+U_BOOT_CMD(
+ chpart, 2, 0, do_jffs2_chpart,
+ "chpart\t- change active partition\n",
+ " - change active partition\n"
+);
#endif /* CFG_JFFS_SINGLE_PART */
/***************************************************/
" - list files in a directory.\n"
);
-U_BOOT_CMD(
- chpart, 2, 0, do_jffs2_chpart,
- "chpart\t- change active partition\n",
- " - change active partition\n"
-);
-
#endif /* CFG_CMD_JFFS2 */
set either of these variables to "nc". Input and output can be
switched independently.
+We use an environment variable 'ncip' to set the IP address and the
+port of the destination. The format is <ip_addr>:<port>. If <port> is
+omitted, the value of 6666 is used. If the env var doesn't exist, the
+broadcast address and port 6666 are used. If it is set to an IP
+address of 0 (or 0.0.0.0) then no messages are sent to the network.
+
On the host side, please use this script to access the console:
+++++++++++++++++++++++++++++++++++++++++++
stty icanon echo intr ^C
+++++++++++++++++++++++++++++++++++++++++++
+It turned out that 'netcat' couldn't be used to listen to broadcast
+packets. We developed our own tool 'ncb' (see tools directory) that
+listens to broadcast packets on a given port and dumps them to the
+standard output. use it as follows:
+
++++++++++++++++++++++++++++++++++++++++++++
+#! /bin/bash
+
+stty icanon echo intr ^T
+./ncb &
+nc -u mpc5200 6666
+stty icanon echo intr ^C
+kill 0
++++++++++++++++++++++++++++++++++++++++++++
+
For Linux, the network-based console needs special configuration.
Minimally, the host IP address needs to be specified. This can be
done either via the kernel command line, or by passing parameters
u_char map, ioctl;
map = io->map;
- if ((map > 1) || (io->start > 0xffff) || (io->stop > 0xffff) ||
+ /* comment out: comparison is always false due to limited range of data type */
+ if ((map > 1) || /* (io->start > 0xffff) || (io->stop > 0xffff) || */
(io->stop < io->start))
return -1;
/* Turn off the window before changing anything */
#error define CONFIG_NET_MULTI to use netconsole
#endif
-static uchar nc_buf = 0; /* input buffer */
+static char input_buffer[512];
+static int input_size = 0; /* char count in input buffer */
+static int input_offset = 0; /* offset to valid chars in input buffer */
static int input_recursion = 0;
static int output_recursion = 0;
static int net_timeout;
+static uchar nc_ether[6]; /* server enet address */
+static IPaddr_t nc_ip; /* server ip */
+static short nc_port; /* source/target port */
+static const char *output_packet; /* used by first send udp */
+static int output_packet_len = 0;
static void nc_wait_arp_handler (uchar * pkt, unsigned dest, unsigned src,
unsigned len)
static void nc_handler (uchar * pkt, unsigned dest, unsigned src,
unsigned len)
{
- if (nc_buf)
+ if (input_size)
NetState = NETLOOP_SUCCESS; /* got input - quit net loop */
}
void NcStart (void)
{
- if (memcmp (NetServerEther, NetEtherNullAddr, 6)) {
+ if (!output_packet_len || memcmp (nc_ether, NetEtherNullAddr, 6)) {
/* going to check for input packet */
NetSetHandler (nc_handler);
NetSetTimeout (net_timeout, nc_timeout);
} else {
/* send arp request */
+ uchar *pkt;
NetSetHandler (nc_wait_arp_handler);
- NetSendUDPPacket (NetServerEther, NetServerIP, 6665, 6666, 0);
+ pkt = (uchar *) NetTxPacket + NetEthHdrSize () + IP_HDR_SIZE;
+ memcpy (pkt, output_packet, output_packet_len);
+ NetSendUDPPacket (nc_ether, nc_ip, nc_port, nc_port, output_packet_len);
}
}
int nc_input_packet (uchar * pkt, unsigned dest, unsigned src, unsigned len)
{
- if (dest != 6666 || !len)
+ int end, chunk;
+
+ if (dest != nc_port || !len)
return 0; /* not for us */
- nc_buf = *pkt;
+ if (input_size == sizeof input_buffer)
+ return 1; /* no space */
+ if (len > sizeof input_buffer - input_size)
+ len = sizeof input_buffer - input_size;
+
+ end = input_offset + input_size;
+ if (end > sizeof input_buffer)
+ end -= sizeof input_buffer;
+
+ chunk = len;
+ if (end + len > sizeof input_buffer) {
+ chunk = sizeof input_buffer - end;
+ memcpy(input_buffer, pkt + chunk, len - chunk);
+ }
+ memcpy (input_buffer + end, pkt, chunk);
+
+ input_size += len;
+
return 1;
}
struct eth_device *eth;
int inited = 0;
uchar *pkt;
+ uchar *ether;
+ IPaddr_t ip;
- if (!memcmp (NetServerEther, NetEtherNullAddr, 6))
+ if ((eth = eth_get_dev ()) == NULL) {
return;
+ }
- if ((eth = eth_get_dev ()) == NULL) {
+ if (!memcmp (nc_ether, NetEtherNullAddr, 6)) {
+ if (eth->state == ETH_STATE_ACTIVE)
+ return; /* inside net loop */
+ output_packet = buf;
+ output_packet_len = len;
+ NetLoop (NETCONS); /* wait for arp reply and send packet */
+ output_packet_len = 0;
return;
}
}
pkt = (uchar *) NetTxPacket + NetEthHdrSize () + IP_HDR_SIZE;
memcpy (pkt, buf, len);
- NetSendUDPPacket (NetServerEther, NetServerIP, 6666, 6665, len);
+ ether = nc_ether;
+ ip = nc_ip;
+ NetSendUDPPacket (ether, ip, nc_port, nc_port, len);
if (inited)
eth_halt ();
int nc_start (void)
{
- if (memcmp (NetServerEther, NetEtherNullAddr, 6))
- return 0;
-
- return NetLoop (NETCONS); /* wait for arp reply */
+ int netmask, our_ip;
+
+ nc_port = 6666; /* default port */
+
+ if (getenv ("ncip")) {
+ nc_ip = getenv_IPaddr ("ncip");
+ if (!nc_ip)
+ return -1; /* ncip is 0.0.0.0 */
+ char *p = strchr (getenv ("ncip"), ':');
+ if (p)
+ nc_port = simple_strtoul (p + 1, NULL, 10);
+ } else
+ nc_ip = ~0; /* ncip is not set */
+
+ our_ip = getenv_IPaddr ("ipaddr");
+ netmask = getenv_IPaddr ("netmask");
+
+ if (nc_ip == ~0 || /* 255.255.255.255 */
+ ((netmask & our_ip) == (netmask & nc_ip) && /* on the same net */
+ (netmask | nc_ip) == ~0)) /* broadcast to our net */
+ memset (nc_ether, 0xff, sizeof nc_ether);
+ else
+ memset (nc_ether, 0, sizeof nc_ether); /* force arp request */
+
+ return 0;
}
void nc_putc (char c)
input_recursion = 1;
net_timeout = 0; /* no timeout */
- while (!nc_buf)
+ while (!input_size)
NetLoop (NETCONS);
input_recursion = 0;
- uchar tmp = nc_buf;
+ uchar c = input_buffer[input_offset];
+ input_offset++;
+ if (input_offset >= sizeof input_buffer)
+ input_offset -= sizeof input_buffer;
+ input_size--;
- nc_buf = 0;
- return tmp;
+ return c;
}
int nc_tstc (void)
if (input_recursion)
return 0;
- if (nc_buf)
+ if (input_size)
return 1;
eth = eth_get_dev ();
input_recursion = 1;
net_timeout = 1;
- NetLoop (NETCONS); /* kind of poll */
+ NetLoop (NETCONS); /* kind of poll */
input_recursion = 0;
- return nc_buf != 0;
+ return input_size != 0;
}
int drv_nc_init (void)
smiWrite (SMI_INDX_C4, 0x6b, 0x15);
/* VCLK */
- freq = 1000000000000L / var -> pixclock;
+ freq = 1000000000000LL / var -> pixclock;
FindPQ ((unsigned int)freq, &p, &q);
#define CFG_LOADS_BAUD_CHANGE 1 /* allow baudrate change */
-#define CONFIG_COMMANDS ( (CONFIG_CMD_DFL & (~CFG_CMD_NET) & \
- (~CFG_CMD_RTC) & ~(CFG_CMD_PCI) & ~(CFG_CMD_I2C)) | \
+#define CONFIG_COMMANDS ((CONFIG_CMD_DFL & \
+ ~( CFG_CMD_NET | \
+ CFG_CMD_RTC | \
+ CFG_CMD_PCI | \
+ CFG_CMD_I2C \
+ ) ) | \
CFG_CMD_IRQ | \
CFG_CMD_KGDB | \
CFG_CMD_BEDBUG | \
- CFG_CMD_ELF | CFG_CMD_JFFS2 )
+ CFG_CMD_ELF | \
+ CFG_CMD_JFFS2 )
/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
#include <cmd_confdefs.h>
/* What U-Boot subsytems do you want enabled? */
/*
*/
-#define CONFIG_COMMANDS ( CFG_CMD_ALL & \
- ~CFG_CMD_BMP & \
- ~CFG_CMD_BSP & \
- ~CFG_CMD_DCR & \
- ~CFG_CMD_DHCP & \
- ~CFG_CMD_DOC & \
- ~CFG_CMD_DTT & \
- ~CFG_CMD_EEPROM & \
- ~CFG_CMD_FDC & \
- ~CFG_CMD_FDOS & \
- ~CFG_CMD_HWFLOW & \
- ~CFG_CMD_IDE & \
- ~CFG_CMD_JFFS2 & \
- ~CFG_CMD_KGDB & \
- ~CFG_CMD_MII & \
- ~CFG_CMD_MMC & \
- ~CFG_CMD_NAND & \
- ~CFG_CMD_PCI & \
- ~CFG_CMD_PCMCIA & \
- ~CFG_CMD_REISER & \
- ~CFG_CMD_SCSI & \
- ~CFG_CMD_SPI & \
- ~CFG_CMD_USB & \
- ~CFG_CMD_VFD & \
- ~CFG_CMD_XIMG )
+#define CONFIG_COMMANDS ( CFG_CMD_ALL & \
+ ~( CFG_CMD_BMP | \
+ CFG_CMD_BSP | \
+ CFG_CMD_DCR | \
+ CFG_CMD_DHCP | \
+ CFG_CMD_DOC | \
+ CFG_CMD_DTT | \
+ CFG_CMD_EEPROM | \
+ CFG_CMD_FDC | \
+ CFG_CMD_FDOS | \
+ CFG_CMD_HWFLOW | \
+ CFG_CMD_IDE | \
+ CFG_CMD_JFFS2 | \
+ CFG_CMD_KGDB | \
+ CFG_CMD_MII | \
+ CFG_CMD_MMC | \
+ CFG_CMD_NAND | \
+ CFG_CMD_PCI | \
+ CFG_CMD_PCMCIA | \
+ CFG_CMD_REISER | \
+ CFG_CMD_SCSI | \
+ CFG_CMD_SPI | \
+ CFG_CMD_USB | \
+ CFG_CMD_VFD | \
+ CFG_CMD_XIMG ) )
/* Where do the internal registers live? */
#define CFG_IMMR 0xF0000000
*
*/
const static unsigned long long pattern[] = {
- 0xaaaaaaaaaaaaaaaa,
- 0xcccccccccccccccc,
- 0xf0f0f0f0f0f0f0f0,
- 0xff00ff00ff00ff00,
- 0xffff0000ffff0000,
- 0xffffffff00000000,
- 0x00000000ffffffff,
- 0x0000ffff0000ffff,
- 0x00ff00ff00ff00ff,
- 0x0f0f0f0f0f0f0f0f,
- 0x3333333333333333,
- 0x5555555555555555};
-const unsigned long long otherpattern = 0x0123456789abcdef;
+ 0xaaaaaaaaaaaaaaaaULL,
+ 0xccccccccccccccccULL,
+ 0xf0f0f0f0f0f0f0f0ULL,
+ 0xff00ff00ff00ff00ULL,
+ 0xffff0000ffff0000ULL,
+ 0xffffffff00000000ULL,
+ 0x00000000ffffffffULL,
+ 0x0000ffff0000ffffULL,
+ 0x00ff00ff00ff00ffULL,
+ 0x0f0f0f0f0f0f0f0fULL,
+ 0x3333333333333333ULL,
+ 0x5555555555555555ULL
+};
+const unsigned long long otherpattern = 0x0123456789abcdefULL;
static int memory_post_dataline(unsigned long long * pmem)
$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
$(STRIP) $@
+ncb$(SFX): ncb.o
+ $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
+ $(STRIP) $@
+
gen_eth_addr$(SFX): gen_eth_addr.o
$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
$(STRIP) $@
mkimage.o: mkimage.c
$(CC) -g $(CFLAGS) -c $<
+ncb.o: ncb.c
+ $(CC) -g $(CFLAGS) -c $<
+
gen_eth_addr.o: gen_eth_addr.c
$(CC) -g $(CFLAGS) -c $<
--- /dev/null
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <linux/in.h>
+
+int main (int argc, char *argv[])
+{
+ int s, len, o, port = 6666;
+ char buf[512];
+ struct sockaddr_in addr;
+ int addr_len = sizeof addr;
+
+ if (argc > 1)
+ port = atoi (argv[1]);
+
+ s = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+
+ o = 1;
+ len = 4;
+ setsockopt (3, SOL_SOCKET, SO_REUSEADDR, &o, len);
+
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons (port);
+ addr.sin_addr.s_addr = INADDR_ANY; /* receive broadcasts */
+
+ bind (s, (struct sockaddr *) &addr, sizeof addr);
+
+ for (;;) {
+ len = recvfrom (s, buf, sizeof buf, 0, (struct sockaddr *) &addr, &addr_len);
+ if (len < 0)
+ break;
+ write (1, buf, len);
+ }
+
+ return 0;
+}