summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuriyan Ramasami <suriyan.r@gmail.com>2014-02-24 22:48:32 +0400
committerMauro Ribeiro <mauro.ribeiro@hardkernel.com>2014-02-24 22:48:32 +0400
commit348b2352d431ac62596cca0f29d8822dae286dfb (patch)
tree4960e49d3eb5e10771d06214def9480c8b28d4c1
parentdd9a970aa4accf5d266d334c0f319c674e933027 (diff)
downloadu-boot-348b2352d431ac62596cca0f29d8822dae286dfb.tar.xz
netconsole changes with bootscan
Have netconsole configure itself for the most part using dhcp Assign a ncip variable automatically for netconsole.
-rw-r--r--common/cmd_bootscan.c62
-rw-r--r--include/configs/smdk4412.h13
-rw-r--r--net/bootp.c23
3 files changed, 85 insertions, 13 deletions
diff --git a/common/cmd_bootscan.c b/common/cmd_bootscan.c
index db9ba4712e..68c65f8a66 100644
--- a/common/cmd_bootscan.c
+++ b/common/cmd_bootscan.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Suriyan Ramasami <suriyan.r@gmail.com>
+ * Copyright (C) 2014 Suriyan Ramasami <suriyan.r@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/
@@ -59,13 +59,14 @@
#define BOOTSCAN_CHOICE "bootscan_choice"
#define BOOTSCAN_ROOT "bootscan_root"
-#define BOOTSCAN_BANNER \
+#define BOOTSCAN_BANNER1 \
" ___ _ _ _\n" \
" /___\\__| |_ __ ___ (_) __| |\n" \
" // // _` | '__/ _ \\| |/ _` |\n" \
" / \\_// (_| | | | (_) | | (_| |\n" \
" \\___/ \\__,_|_| \\___/|_|\\__,_|\n" \
-"\n" \
+"\n"
+#define BOOTSCAN_BANNER2 \
" _ _ _ _ _ ____\n" \
" | || | | || | / |___ \\\n" \
" | || |_| || |_| | __) |\n" \
@@ -138,7 +139,8 @@ static void debug_print_bootlist(struct bootscan_bootables b[])
static void display_banner(void)
{
- puts(BOOTSCAN_BANNER);
+ puts(BOOTSCAN_BANNER1);
+ puts(BOOTSCAN_BANNER2);
}
static void bootscan_menuprint(void *print_buffer)
@@ -1100,6 +1102,56 @@ static void populate_devices(struct bootscan_bootables bootlist[],
}
}
+static void gen_set_ncip(char ncip[20])
+{
+ int i, len;
+
+ len = strlen(ncip) - 1;
+ while (len) {
+ if (ncip[len] == '.') {
+ /* Make that .227 as long as its not .227 */
+ if (strcmp(&ncip[len], ".227") == 0)
+ strcpy(&ncip[len], ".228");
+ else
+ strcpy(&ncip[len], ".227");
+ setenv("ncip", ncip);
+ break;
+ }
+ len--;
+ }
+}
+
+static void bootscan_netconsole()
+{
+ char *tmp, ncip[20];
+
+ /* Lets initialize stuff for netconsole */
+ if (!is_eth_dev_on_usb_host())
+ return
+
+ /* Issue a dhcp first */
+ setenv("abcdtest", "no");
+ setenv("autoload", "no");
+ run_command("dhcp", 0);
+
+ /* Check if ipaddr is set - either thru dhcp or static */
+ tmp = getenv("ipaddr");
+ if (tmp == NULL)
+ return;
+
+ tmp = getenv("ncip");
+ if (tmp == NULL) {
+ /* Generate an ncip based on ipaddress */
+ tmp = getenv("ipaddr");
+ strcpy(ncip, tmp);
+ gen_set_ncip(ncip);
+ }
+
+ setenv("nc_test", "ping ${ncip}");
+ setenv("nc_start", "setenv stdin serial,nc; setenv stdout serial,nc; setenv stderr serial,nc; version");
+ run_command("run nc_test nc_start", 0);
+}
+
/* bootlist[] can hold a max of BOOTSCAN_MAX_BOOTABLES entries */
static void populate_bootlist(struct bootscan_bootables bootlist[])
{
@@ -1123,6 +1175,8 @@ static void populate_bootlist(struct bootscan_bootables bootlist[])
# endif
#endif
+ bootscan_netconsole();
+
/* This scans the partitions in the IDE storage */
#if defined(CONFIG_CMD_IDE)
ide_init();
diff --git a/include/configs/smdk4412.h b/include/configs/smdk4412.h
index b4e7ee5ff2..ec0c2cc482 100644
--- a/include/configs/smdk4412.h
+++ b/include/configs/smdk4412.h
@@ -213,6 +213,8 @@
/* NETCONSOLE */
#define CONFIG_NETCONSOLE
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_MULTI
/* CONSOLE MUX */
#define CONFIG_CONSOLE_MUX
@@ -255,6 +257,9 @@
#define CONFIG_CMD_BOOTSCAN
#define CONFIG_MENU
#define CONFIG_MENU_SHOW
+#ifdef CONFIG_MENU_SHOW
+#define CONFIG_BOOTP_MAY_FAIL
+#endif
#define CONFIG_SYS_NAND_QUIET_TEST
#define CONFIG_SYS_ONENAND_QUIET_TEST
@@ -277,15 +282,11 @@
#define CONFIG_BOOTP_HOSTNAME
#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_USB_ETHADDR 00:10:75:2a:ae:e0
-#define CONFIG_NETMASK 255.255.255.0
-#define CONFIG_IPADDR 10.0.0.31
-#define CONFIG_SERVERIP 10.0.0.204
-#define CONFIG_GATEWAYIP 10.0.0.2
+#define CONFIG_USB_ETHADDR DE:AD:BE:EF:00:03
#define CONFIG_OF_LIBFDT 1
-#define CONFIG_BOOTDELAY 1
+#define CONFIG_BOOTDELAY 5
/* Default boot commands for Android booting. */
#if defined(CONFIG_HKDK4412) && defined(CONFIG_EXYNOS_PRIME)
#define CONFIG_BOOTCOMMAND \
diff --git a/net/bootp.c b/net/bootp.c
index 4300f1c2f1..c3957ed17e 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -7,7 +7,6 @@
* Copyright 2000 Paolo Scaffardi
* Copyright 2000-2004 Wolfgang Denk, wd@denx.de
*/
-
#include <common.h>
#include <command.h>
#include <net.h>
@@ -23,7 +22,7 @@
#define BOOTP_VENDOR_MAGIC 0x63825363 /* RFC1048 Magic Cookie */
-#define TIMEOUT 5000UL /* Milliseconds before trying BOOTP again */
+#define TIMEOUT 10000UL /* Milliseconds before trying BOOTP again */
#ifndef CONFIG_NET_RETRY_COUNT
# define TIMEOUT_COUNT 5 /* # of timeouts before giving up */
#else
@@ -38,6 +37,7 @@
#endif
ulong BootpID;
+ulong BootpIDlist[TIMEOUT_COUNT];
int BootpTry;
#if defined(CONFIG_CMD_DHCP)
@@ -65,6 +65,22 @@ static char *dhcpmsg2str(int type)
#endif
#endif
+static int BootpIDCheck(ulong ID)
+{
+ int i;
+
+ for (i = 0; i < BootpTry; i++)
+ {
+ if (BootpIDlist[i] == ID)
+ {
+ BootpID = ID;
+ debug("ID match: %x\n", ID);
+ return 0;
+ }
+ }
+ return 1;
+}
+
static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)
{
struct Bootp_t *bp = (struct Bootp_t *) pkt;
@@ -84,7 +100,7 @@ static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)
retval = -4;
else if (bp->bp_hlen != HWL_ETHER)
retval = -5;
- else if (NetReadLong((ulong *)&bp->bp_id) != BootpID)
+ else if (BootpIDCheck(NetReadLong((ulong *) &bp->bp_id)) == 1)
retval = -6;
debug("Filtering pkt = %d\n", retval);
@@ -677,6 +693,7 @@ BootpRequest(void)
| (ulong)NetOurEther[5];
BootpID += get_timer(0);
BootpID = htonl(BootpID);
+ BootpIDlist[BootpTry - 1] = BootpID;
NetCopyLong(&bp->bp_id, &BootpID);
/*