@@ -56,6 +56,9 @@ endif
ifdef CONFIG_SPL_YMODEM_SUPPORT
COBJS += spl_ymodem.o
endif
+ifdef CONFIG_SPL_ETH_SUPPORT
+COBJS += spl_eth.o
+endif
endif
ifndef CONFIG_SPL_BUILD
@@ -176,6 +176,11 @@ void board_init_r(gd_t *id, ulong dummy)
spl_ymodem_load_image();
break;
#endif
+#ifdef CONFIG_SPL_ETH_SUPPORT
+ case BOOT_DEVICE_CPGMAC:
+ spl_eth_load_image();
+ break;
+#endif
default:
printf("SPL: Un-supported Boot Device - %d!!!\n", boot_device);
hang();
new file mode 100644
@@ -0,0 +1,50 @@
+/*
+ * (C) Copyright 2000-2004
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * (C) Copyright 2012
+ * Ilya Yanok <ilya.yanok@gmail.com>
+ *
+ * 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.
+ */
+#include <common.h>
+#include <net.h>
+#include <asm/omap_common.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void spl_eth_load_image(void)
+{
+ int rv;
+
+ env_init();
+ env_relocate();
+ setenv("autoload", "yes");
+ load_addr = CONFIG_SYS_TEXT_BASE - sizeof(struct image_header);
+ rv = eth_initialize(gd->bd);
+ if (rv == 0) {
+ printf("No Ethernet devices found\n");
+ hang();
+ }
+ rv = NetLoop(BOOTP);
+ if (rv < 0) {
+ printf("Problem booting with BOOTP\n");
+ hang();
+ }
+ spl_parse_image_header((struct image_header *)load_addr);
+}
@@ -69,6 +69,7 @@ void preloader_console_init(void);
#define BOOT_DEVICE_MMC1 8
#define BOOT_DEVICE_MMC2 0
#define BOOT_DEVICE_UART 65
+#define BOOT_DEVICE_CPGMAC 70
#define BOOT_DEVICE_MMC2_2 0xFF
#endif
@@ -107,6 +108,9 @@ void spl_mmc_load_image(void);
/* YMODEM SPL functions */
void spl_ymodem_load_image(void);
+/* Ethernet SPL functions */
+void spl_eth_load_image(void);
+
#ifdef CONFIG_SPL_BOARD_INIT
void spl_board_init(void);
#endif
@@ -187,6 +187,12 @@ endif
ifdef CONFIG_SPL_BUILD
COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += cmd_nvedit.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += command.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_common.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_nowhere.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += main.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
endif
COBJS-y += console.o
COBJS-y += dlmalloc.o
@@ -578,7 +578,8 @@ ulong getenv_ulong(const char *name, int base, ulong default_val)
return str ? simple_strtoul(str, NULL, base) : default_val;
}
-#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
+#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE) && \
+ !defined(CONFIG_SPL_BUILD)
int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
printf("Saving Environment to %s...\n", env_name_spec);
@@ -912,7 +913,8 @@ static cmd_tbl_t cmd_env_sub[] = {
#if defined(CONFIG_CMD_RUN)
U_BOOT_CMD_MKENT(run, CONFIG_SYS_MAXARGS, 1, do_run, "", ""),
#endif
-#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
+#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE) && \
+ !defined(CONFIG_SPL_BUILD)
U_BOOT_CMD_MKENT(save, 1, 0, do_env_save, "", ""),
#endif
U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 0, do_env_set, "", ""),
@@ -225,7 +225,8 @@ void env_relocate(void)
env_reloc();
#endif
if (gd->env_valid == 0) {
-#if defined(CONFIG_ENV_IS_NOWHERE) /* Environment not changable */
+#if defined(CONFIG_ENV_IS_NOWHERE) || defined(CONFIG_SPL_BUILD)
+ /* Environment not changable */
set_default_env(NULL);
#else
bootstage_error(BOOTSTAGE_ID_NET_CHECKSUM);
@@ -52,12 +52,18 @@ COBJS-$(CONFIG_SHA1) += sha1.o
COBJS-$(CONFIG_SHA256) += sha256.o
COBJS-y += strmhz.o
COBJS-$(CONFIG_RBTREE) += rbtree.o
-else
-COBJS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += display_options.o
endif
ifdef CONFIG_SPL_BUILD
COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += crc32.o
+ifneq ($(CONFIG_SPL_SPI_FLASH_SUPPORT)$(CONFIG_SPL_NET_SUPPORT),)
+COBJS-y += display_options.o
+endif
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += errno.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += hashtable.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += net_utils.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += qsort.o
endif
COBJS-y += crc32.o
COBJS-y += ctype.o
@@ -784,7 +784,7 @@ void panic(const char *fmt, ...)
vprintf(fmt, args);
putc('\n');
va_end(args);
-#if defined (CONFIG_PANIC_HANG)
+#if defined (CONFIG_PANIC_HANG) || defined(CONFIG_SPL_BUILD)
hang();
#else
udelay (100000); /* allow messages to go out */
@@ -9,6 +9,9 @@
*/
#include <common.h>
+#ifdef CONFIG_SPL_BUILD
+#undef CONFIG_CMD_DHCP
+#endif
#include <command.h>
#include <net.h>
#include "bootp.h"
@@ -533,8 +536,13 @@ static int BootpExtended(u8 *e)
*e++ = (576 - 312 + OPT_FIELD_SIZE) & 0xff;
#endif
-#ifdef CONFIG_BOOTP_VCI_STRING
+#if defined(CONFIG_BOOTP_VCI_STRING) || \
+ (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_NET_VCI_STRING))
+#ifndef CONFIG_SPL_BUILD
put_vci(e, CONFIG_VCI_STRING);
+#else
+ put_vci(e, CONFIG_SPL_NET_VCI_STRING);
+#endif
#endif
#if defined(CONFIG_BOOTP_SUBNETMASK)
@@ -81,6 +81,9 @@
#include <common.h>
+#ifdef CONFIG_SPL_BUILD
+#undef CONFIG_CMD_DHCP
+#endif
#include <command.h>
#include <net.h>
#if defined(CONFIG_STATUS_LED)
@@ -57,6 +57,9 @@ LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o
LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/libonenand.o
LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/libdma.o
LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/memory.o
+LIBS-$(CONFIG_SPL_NET_SUPPORT) += net/libnet.o
+LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/libnet.o
+LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/libphy.o
ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)
LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
This patch adds support for networking in SPL. Some devices are capable of loading SPL via network so it makes sense to load the main U-Boot binary via network too. This patch tries to use existing network code as much as possible. Unfortunately, it depends on environment which in turn depends on other code so SPL size is increased significantly. No effort was done to decouple network code and environment so far. Signed-off-by: Ilya Yanok <ilya.yanok@cogentembedded.com> --- Changes in v3: - add support for setting different VCI in SPL - use BOOTP in SPL regardless of CONFIG_CMD_DHCP arch/arm/cpu/armv7/omap-common/Makefile | 3 ++ arch/arm/cpu/armv7/omap-common/spl.c | 5 +++ arch/arm/cpu/armv7/omap-common/spl_eth.c | 50 ++++++++++++++++++++++++++++++ arch/arm/include/asm/omap_common.h | 4 +++ common/Makefile | 6 ++++ common/cmd_nvedit.c | 6 ++-- common/env_common.c | 3 +- lib/Makefile | 10 ++++-- lib/vsprintf.c | 2 +- net/bootp.c | 10 +++++- net/net.c | 3 ++ spl/Makefile | 3 ++ 12 files changed, 98 insertions(+), 7 deletions(-) create mode 100644 arch/arm/cpu/armv7/omap-common/spl_eth.c