[U-Boot] [PATCH v4 0/5] OMAP: SPL networking support

These series provides support for networking in SPL. These patches try to use network infrasctructure as is, without trying to cut some minimal set of it, so the resulting SPL image is quite big and only useful for boards with plenty of SRAM/OCRAM (like TI AM335x based ones).
Changes in v3: - add support for setting different VCI in SPL - set Vendor Class Identifier for SPL - use BOOTP in SPL regardless of CONFIG_CMD_DHCP
Changes in v4: and CONFIG_BOOTD defined - SPL_BOARD_INIT is not needed anymore - fix compilation of SPL's libcommon with CONFIG_HUSH_PARSER - moved vci_strlen var inside macro - rename spl_eth.c to spl_net.c - set ethact variable if device name is passed - used strlen instead of sizeof
Ilya Yanok (5): net/bootp: add VCI support for BOOTP also spl: don't mark __u_boot_cmd* as undefined OMAP: spl: call timer_inti() from SPL OMAP: networking support for SPL am335x_evm: enable networking in SPL
arch/arm/cpu/armv7/omap-common/Makefile | 3 ++ arch/arm/cpu/armv7/omap-common/spl.c | 11 +++++++ arch/arm/cpu/armv7/omap-common/spl_net.c | 52 ++++++++++++++++++++++++++++++ arch/arm/include/asm/omap_common.h | 4 +++ common/Makefile | 6 ++++ common/cmd_nvedit.c | 6 ++-- common/command.c | 2 +- common/env_common.c | 3 +- common/main.c | 4 +-- include/configs/am335x_evm.h | 5 ++- lib/Makefile | 10 ++++-- lib/vsprintf.c | 2 +- net/bootp.c | 30 +++++++++++++---- net/net.c | 3 ++ spl/Makefile | 5 +-- 15 files changed, 128 insertions(+), 18 deletions(-) create mode 100644 arch/arm/cpu/armv7/omap-common/spl_net.c

Vendor Class Identifier option is common to BOOTP and DHCP and can be useful without PXE. So send VCI in both BOOTP and DHCP requests if CONFIG_BOOTP_VCI_STRING is defined.
Signed-off-by: Ilya Yanok ilya.yanok@cogentembedded.com
--- Changes in v4: - moved vci_strlen var inside macro - used strlen instead of sizeof
net/bootp.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/net/bootp.c b/net/bootp.c index c9b8349..35b2e77 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -341,6 +341,15 @@ BootpTimeout(void) } }
+#define put_vci(e, str) \ + do { \ + size_t vci_strlen = strlen(str); \ + *e++ = 60; /* Vendor Class Identifier */ \ + *e++ = vci_strlen; \ + memcpy(e, str, vci_strlen); \ + e += vci_strlen; \ + } while (0) + /* * Initialize BOOTP extension fields in the request. */ @@ -352,7 +361,6 @@ static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID, u8 *cnt; #if defined(CONFIG_BOOTP_PXE) char *uuid; - size_t vci_strlen; u16 clientarch; #endif
@@ -437,12 +445,10 @@ static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID, printf("Invalid pxeuuid: %s\n", uuid); } } +#endif
- *e++ = 60; /* Vendor Class Identifier */ - vci_strlen = strlen(CONFIG_BOOTP_VCI_STRING); - *e++ = vci_strlen; - memcpy(e, CONFIG_BOOTP_VCI_STRING, vci_strlen); - e += vci_strlen; +#ifdef CONFIG_BOOTP_VCI_STRING + put_vci(e, CONFIG_VCI_STRING); #endif
#if defined(CONFIG_BOOTP_VENDOREX) @@ -529,6 +535,10 @@ static int BootpExtended(u8 *e) *e++ = (576 - 312 + OPT_FIELD_SIZE) & 0xff; #endif
+#ifdef CONFIG_BOOTP_VCI_STRING + put_vci(e, CONFIG_VCI_STRING); +#endif + #if defined(CONFIG_BOOTP_SUBNETMASK) *e++ = 1; /* Subnet mask request */ *e++ = 4;

Hi Joe,
On Mon, Aug 6, 2012 at 1:21 AM, Ilya Yanok ilya.yanok@cogentembedded.comwrote:
Vendor Class Identifier option is common to BOOTP and DHCP and can be useful without PXE. So send VCI in both BOOTP and DHCP requests if CONFIG_BOOTP_VCI_STRING is defined.
Signed-off-by: Ilya Yanok ilya.yanok@cogentembedded.com
Changes in v4:
- moved vci_strlen var inside macro
- used strlen instead of sizeof
Is it ok now? What about the rest of the series?
Regards, Ilya.

Hi Ilya,
On Sun, Aug 5, 2012 at 4:21 PM, Ilya Yanok ilya.yanok@cogentembedded.com wrote:
Vendor Class Identifier option is common to BOOTP and DHCP and can be useful without PXE. So send VCI in both BOOTP and DHCP requests if CONFIG_BOOTP_VCI_STRING is defined.
Signed-off-by: Ilya Yanok ilya.yanok@cogentembedded.com
Acked-by: Joe Hershberger joe.hershberger@ni.com

__u_boot_cmd* symbols are not used in SPL so there is no need to tell the linker that they are undefined. With these symbols marked as undefined linker fails to garbage collect some unused functions and even fails to build the resulting image.
Signed-off-by: Ilya Yanok ilya.yanok@cogentembedded.com ---
spl/Makefile | 2 -- 1 file changed, 2 deletions(-)
diff --git a/spl/Makefile b/spl/Makefile index ea7d475..8576d56 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -126,8 +126,6 @@ $(obj)u-boot-spl.bin: $(obj)u-boot-spl $(OBJCOPY) $(OBJCFLAGS) -O binary $< $@
GEN_UBOOT = \ - UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) | \ - sed -n -e 's/.*($(SYM_PREFIX)__u_boot_cmd_.*)/-u\1/p'|sort|uniq`;\ cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__START) \ --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \ -Map u-boot-spl.map -o u-boot-spl

On Sun, Aug 5, 2012 at 2:21 PM, Ilya Yanok ilya.yanok@cogentembedded.com wrote:
__u_boot_cmd* symbols are not used in SPL so there is no need to tell the linker that they are undefined. With these symbols marked as undefined linker fails to garbage collect some unused functions and even fails to build the resulting image.
I don't like this because it causes SPL to bloat when the commands aren't also removed from the build. But I assume a number of commands were being pulled in as part of the networking stack?

Hi Tom,
On Mon, Aug 6, 2012 at 2:36 AM, Tom Rini trini@ti.com wrote:
On Sun, Aug 5, 2012 at 2:21 PM, Ilya Yanok ilya.yanok@cogentembedded.com wrote:
__u_boot_cmd* symbols are not used in SPL so there is no need to tell the linker that they are undefined. With these symbols marked as undefined linker fails to garbage collect some unused functions and even fails to build the resulting image.
I don't like this because it causes SPL to bloat when the commands aren't also removed from the build. But I assume a number of commands
Nah. As far as I understand it, UNDEF_SYM stuff is there to protect commands from being purged by linker garbage collector. This is needed for main U-Boot as commands are referenced inderectly. I seems to me that this stuff was just copy-pasted into SPL Makefile. As far as we don't need commands in SPL we don't care about them being garbage collected (well, actually we want them to be collected). So it has nothing to do about bloating, actually SPL image is smaller with this patch applied.
were being pulled in as part of the networking stack?
Not really, only some functions.
Regards, Ilya.

On 08/06/2012 08:10 AM, Ilya Yanok wrote:
Hi Tom,
On Mon, Aug 6, 2012 at 2:36 AM, Tom Rini <trini@ti.com mailto:trini@ti.com> wrote:
On Sun, Aug 5, 2012 at 2:21 PM, Ilya Yanok <ilya.yanok@cogentembedded.com <mailto:ilya.yanok@cogentembedded.com>> wrote: > __u_boot_cmd* symbols are not used in SPL so there is no need > to tell the linker that they are undefined. With these symbols > marked as undefined linker fails to garbage collect some unused > functions and even fails to build the resulting image. I don't like this because it causes SPL to bloat when the commands aren't also removed from the build. But I assume a number of commands
Nah. As far as I understand it, UNDEF_SYM stuff is there to protect commands from being purged by linker garbage collector. This is needed for main U-Boot as commands are referenced inderectly. I seems to me that this stuff was just copy-pasted into SPL Makefile. As far as we don't need commands in SPL we don't care about them being garbage collected (well, actually we want them to be collected). So it has nothing to do about bloating, actually SPL image is smaller with this patch applied.
What toolchain are you using? In my tests they have not been collected.

On Mon, Aug 6, 2012 at 7:30 PM, Tom Rini trini@ti.com wrote:
On 08/06/2012 08:10 AM, Ilya Yanok wrote:
Hi Tom,
On Mon, Aug 6, 2012 at 2:36 AM, Tom Rini <trini@ti.com mailto:trini@ti.com> wrote:
On Sun, Aug 5, 2012 at 2:21 PM, Ilya Yanok <ilya.yanok@cogentembedded.com <mailto:ilya.yanok@cogentembedded.com>> wrote: > __u_boot_cmd* symbols are not used in SPL so there is no need > to tell the linker that they are undefined. With these symbols > marked as undefined linker fails to garbage collect some unused > functions and even fails to build the resulting image. I don't like this because it causes SPL to bloat when the commands aren't also removed from the build. But I assume a number of
commands
Nah. As far as I understand it, UNDEF_SYM stuff is there to protect commands from being purged by linker garbage collector. This is needed for main U-Boot as commands are referenced inderectly. I seems to me that this stuff was just copy-pasted into SPL Makefile. As far as we don't need commands in SPL we don't care about them being garbage collected (well, actually we want them to be collected). So it has nothing to do about bloating, actually SPL image is smaller with this patch applied.
What toolchain are you using? In my tests they have not been collected.
ELDK 5.2
Regards, Ilya.

On Mon, Aug 6, 2012 at 8:31 AM, Ilya Yanok ilya.yanok@cogentembedded.com wrote:
On Mon, Aug 6, 2012 at 7:30 PM, Tom Rini trini@ti.com wrote:
On 08/06/2012 08:10 AM, Ilya Yanok wrote:
Hi Tom,
On Mon, Aug 6, 2012 at 2:36 AM, Tom Rini <trini@ti.com mailto:trini@ti.com> wrote:
On Sun, Aug 5, 2012 at 2:21 PM, Ilya Yanok <ilya.yanok@cogentembedded.com <mailto:ilya.yanok@cogentembedded.com>> wrote: > __u_boot_cmd* symbols are not used in SPL so there is no need > to tell the linker that they are undefined. With these symbols > marked as undefined linker fails to garbage collect some unused > functions and even fails to build the resulting image. I don't like this because it causes SPL to bloat when the commands aren't also removed from the build. But I assume a number of
commands
Nah. As far as I understand it, UNDEF_SYM stuff is there to protect commands from being purged by linker garbage collector. This is needed for main U-Boot as commands are referenced inderectly. I seems to me that this stuff was just copy-pasted into SPL Makefile. As far as we don't need commands in SPL we don't care about them being garbage collected (well, actually we want them to be collected). So it has nothing to do about bloating, actually SPL image is smaller with this patch applied.
What toolchain are you using? In my tests they have not been collected.
ELDK 5.2
OK, installed and it's still larger with this change than without and it's not garbage collecting and dropping commands if I un-guard the nandecc command for example. Tested with omap3_beagle.

Hi Tom,
On Mon, Aug 6, 2012 at 9:10 PM, Tom Rini trini@ti.com wrote:
OK, installed and it's still larger with this change than without and it's not garbage collecting and dropping commands if I un-guard the nandecc command for example. Tested with omap3_beagle.
Did some testing as well.
master branch, omap3_beagle config. Trying clean master, master + remove undef patch, master + remove undef patch + un-guard nandecc & master + un-guard nandecc.
Here is my results:
$ ls -l ../out/master/spl/u-boot-spl.bin -rwxrwxr-x 1 ilya ilya 44692 Aug 6 21:57 ../out/master/spl/u-boot-spl.bin $ ls -l ../out/undef/spl/u-boot-spl.bin -rwxrwxr-x 1 ilya ilya 44692 Aug 6 21:52 ../out/undef/spl/u-boot-spl.bin $ ls -l ../out/undef+nandecc/spl/u-boot-spl.bin -rwxrwxr-x 1 ilya ilya 44844 Aug 6 21:53 ../out/undef+nandecc/spl/u-boot-spl.bin
(and master + un-guard ecc actually failed to build with: $ ./MAKEALL omap3_beagle Configuring for omap3_beagle board... make[1]: *** [/work/u-boot/spl/u-boot-spl] Error 1 make: *** [spl/u-boot-spl.bin] Error 2 text data bss dec hex filename 326458 8460 266904 601822 92ede ./u-boot arch/arm/cpu/armv7/omap3/libomap3.o: In function `do_switch_ecc': /work/u-boot/arch/arm/cpu/armv7/omap3/board.c:312: undefined reference to `omap_nand_switch_ecc' /work/u-boot/arch/arm/cpu/armv7/omap3/board.c:314: undefined reference to `omap_nand_switch_ecc' make[1]: *** [/work/u-boot/spl/u-boot-spl] Error 1 make: *** [spl/u-boot-spl.bin] Error 2
which shows that without remove undef patch do_switch_ecc() function is preserved while with this patch it's garbage collected).
My interpretation: first two builds are equal, that's to be expected as in mainline U-Boot all command definitions are carefully guarded so remove undef patch has no effect at all. You said in your testing patched version produced bigger image... Probably you patched it by hand without commiting and got "-dirty" difference? (I did so initially ;) ) Next, when we unguard the command we definitely get bigger image... But the code is not here:
$ arm-linux-gnueabi-nm ../out/undef+nandecc/spl/u-boot-spl |grep do_switch_ecc $
By comparing of two images I've found that the difference comes from ro-strings (two help strings in U_BOOT_CMD, string in printf, "sw" & "hw"). It looks like the linker doesn't collect ro-strings referenced from collected functions... Probably that's a bug but I'm not sure...
Regards, Ilya.

On Mon, Aug 06, 2012 at 11:15:25PM +0400, Ilya Yanok wrote:
Hi Tom,
On Mon, Aug 6, 2012 at 9:10 PM, Tom Rini trini@ti.com wrote:
OK, installed and it's still larger with this change than without and it's not garbage collecting and dropping commands if I un-guard the nandecc command for example. Tested with omap3_beagle.
Did some testing as well.
[snip]
My interpretation: first two builds are equal, that's to be expected as in mainline U-Boot all command definitions are carefully guarded so remove undef patch has no effect at all. You said in your testing patched version produced bigger image... Probably you patched it by hand without commiting and got "-dirty" difference? (I did so initially ;) )
That would be it, yes :)
Next, when we unguard the command we definitely get bigger image... But the code is not here:
$ arm-linux-gnueabi-nm ../out/undef+nandecc/spl/u-boot-spl |grep do_switch_ecc $
By comparing of two images I've found that the difference comes from ro-strings (two help strings in U_BOOT_CMD, string in printf, "sw" & "hw"). It looks like the linker doesn't collect ro-strings referenced from collected functions... Probably that's a bug but I'm not sure...
Yes. What I meant was that not all of the stuff that is guarded today is garbage collected so the resulting image is larger than it must be. And yes, this is a toolchain issue of sorts (not being aggressive enough in collecting unreferenced data).
Regards, Ilya.
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Hi Tom,
On Tue, Aug 7, 2012 at 12:52 AM, Tom Rini trini@ti.com wrote:
By comparing of two images I've found that the difference comes from ro-strings (two help strings in U_BOOT_CMD, string in printf, "sw" &
"hw").
It looks like the linker doesn't collect ro-strings referenced from collected functions... Probably that's a bug but I'm not sure...
Yes. What I meant was that not all of the stuff that is guarded today is garbage collected so the resulting image is larger than it must be.
Yep. And that's actually goes beyond the subject of this patch: as long as we rely on linker GC and not putting guards by hands we will get unused string literals compiled in.
I still think that this patch does the correct things (UNDEF_SYM is there to protect commands from GC and we don't really want commands in SPL so there is nothing to protect). But I will try to add guards to make net-spl compile even without this patch.
And yes, this is a toolchain issue of sorts (not being aggressive enough in collecting unreferenced data).
Looks like it can be fixed by forcing the compiler to emit symbols for string literals... But I'm not really compiler guy...
Regards, Ilya.

Hi Tom,
On Tue, Aug 7, 2012 at 1:11 AM, Ilya Yanok ilya.yanok@cogentembedded.comwrote:
Yes. What I meant was that not all of the stuff that is guarded today
is garbage collected so the resulting image is larger than it must be.
Yep. And that's actually goes beyond the subject of this patch: as long as we rely on linker GC and not putting guards by hands we will get unused string literals compiled in.
I still think that this patch does the correct things (UNDEF_SYM is there to protect commands from GC and we don't really want commands in SPL so there is nothing to protect). But I will try to add guards to make net-spl compile even without this patch.
I've just posted v5 for patch 4/5 that doesn't depend on this patch. It really has some improvement wrt size (~50KB net-only SPL image) so probably it could be useful not only for AM33xx...
Regards, Ilya.

We need to initialize timer properly, otherwise all delays inside SPL will be wrong.
Signed-off-by: Ilya Yanok ilya.yanok@cogentembedded.com ---
arch/arm/cpu/armv7/omap-common/spl.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index 4d1ac85..f0d766c 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -152,6 +152,8 @@ void board_init_r(gd_t *id, ulong dummy) mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START, CONFIG_SYS_SPL_MALLOC_SIZE);
+ timer_init(); + #ifdef CONFIG_SPL_BOARD_INIT spl_board_init(); #endif

On Sun, Aug 5, 2012 at 2:21 PM, Ilya Yanok ilya.yanok@cogentembedded.com wrote:
We need to initialize timer properly, otherwise all delays inside SPL will be wrong.
Signed-off-by: Ilya Yanok ilya.yanok@cogentembedded.com
arch/arm/cpu/armv7/omap-common/spl.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index 4d1ac85..f0d766c 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -152,6 +152,8 @@ void board_init_r(gd_t *id, ulong dummy) mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START, CONFIG_SYS_SPL_MALLOC_SIZE);
timer_init();
#ifdef CONFIG_SPL_BOARD_INIT spl_board_init(); #endif
Calling it twice has other bad side-effects so there should be a timer_init removal somewhere too.

Hi Tom,
On Mon, Aug 6, 2012 at 2:35 AM, Tom Rini trini@ti.com wrote:
On Sun, Aug 5, 2012 at 2:21 PM, Ilya Yanok ilya.yanok@cogentembedded.com wrote:
We need to initialize timer properly, otherwise all delays inside SPL will be wrong.
Signed-off-by: Ilya Yanok ilya.yanok@cogentembedded.com
arch/arm/cpu/armv7/omap-common/spl.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/arch/arm/cpu/armv7/omap-common/spl.c
b/arch/arm/cpu/armv7/omap-common/spl.c
index 4d1ac85..f0d766c 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -152,6 +152,8 @@ void board_init_r(gd_t *id, ulong dummy) mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START, CONFIG_SYS_SPL_MALLOC_SIZE);
timer_init();
#ifdef CONFIG_SPL_BOARD_INIT spl_board_init(); #endif
Calling it twice has other bad side-effects so there should be a timer_init removal somewhere too.
Hm, I can see any so far. I think you are mixing it with init_timer() function you fixed in commit 2ab2810 (BTW, these two functions deal with the same piece of hardware. do we really need both?). Speaking about 2ab2810, I think the problem was not init_timer() being called twice but init_timer() called _after_ timer_init() (timer_init() programs the timer to get correct delays but init_timer() resets the timer so delays are wrong again).
Regards, Ilya.

On Mon, Aug 6, 2012 at 8:02 AM, Ilya Yanok ilya.yanok@cogentembedded.com wrote:
Hi Tom,
On Mon, Aug 6, 2012 at 2:35 AM, Tom Rini trini@ti.com wrote:
On Sun, Aug 5, 2012 at 2:21 PM, Ilya Yanok ilya.yanok@cogentembedded.com wrote:
We need to initialize timer properly, otherwise all delays inside SPL will be wrong.
Signed-off-by: Ilya Yanok ilya.yanok@cogentembedded.com
arch/arm/cpu/armv7/omap-common/spl.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/arch/arm/cpu/armv7/omap-common/spl.c
b/arch/arm/cpu/armv7/omap-common/spl.c
index 4d1ac85..f0d766c 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -152,6 +152,8 @@ void board_init_r(gd_t *id, ulong dummy) mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START, CONFIG_SYS_SPL_MALLOC_SIZE);
timer_init();
#ifdef CONFIG_SPL_BOARD_INIT spl_board_init(); #endif
Calling it twice has other bad side-effects so there should be a timer_init removal somewhere too.
Hm, I can see any so far. I think you are mixing it with init_timer() function you fixed in commit 2ab2810 (BTW, these two functions deal with the same piece of hardware. do we really need both?). Speaking about 2ab2810, I think the problem was not init_timer() being called twice but init_timer() called _after_ timer_init() (timer_init() programs the timer to get correct delays but init_timer() resets the timer so delays are wrong again).
Ug, that is a mess, your patch is fine, I'll go figure out what's going on in the am33xx-specific portion.

We have the timer code in arch/arm/cpu/armv7/omap-common/timer.c that has been configuring and enabling the timer, so remove our code that does the same thing by different methods.
Tested on EVM GP, SK-EVM and Beaglebone.
Signed-off-by: Tom Rini trini@ti.com --- arch/arm/cpu/armv7/am33xx/board.c | 20 -------------------- 1 file changed, 20 deletions(-)
diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index 2ca4ca7..5b00719 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -37,7 +37,6 @@ DECLARE_GLOBAL_DATA_PTR;
struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE; -struct gptimer *timer_base = (struct gptimer *)CONFIG_SYS_TIMERBASE; struct uart_sys *uart_base = (struct uart_sys *)DEFAULT_UART_BASE;
static const struct gpio_bank gpio_bank_am33xx[4] = { @@ -119,22 +118,6 @@ static int read_eeprom(void) #define UART_SMART_IDLE_EN (0x1 << 0x3) #endif
-#ifdef CONFIG_SPL_BUILD -/* Initialize timer */ -static void init_timer(void) -{ - /* Reset the Timer */ - writel(0x2, (&timer_base->tscir)); - - /* Wait until the reset is done */ - while (readl(&timer_base->tiocp_cfg) & 1) - ; - - /* Start the Timer */ - writel(0x1, (&timer_base->tclr)); -} -#endif - /* * Determine what type of DDR we have. */ @@ -183,9 +166,6 @@ void s_init(void) regVal |= UART_SMART_IDLE_EN; writel(regVal, &uart_base->uartsyscfg);
- /* Initialize the Timer */ - init_timer(); - preloader_console_init();
/* Initalize the board header */

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
Changes in v4: and CONFIG_BOOTD defined - fix compilation of SPL's libcommon with CONFIG_HUSH_PARSER - rename spl_eth.c to spl_net.c - set ethact variable if device name is passed
arch/arm/cpu/armv7/omap-common/Makefile | 3 ++ arch/arm/cpu/armv7/omap-common/spl.c | 9 ++++++ arch/arm/cpu/armv7/omap-common/spl_net.c | 52 ++++++++++++++++++++++++++++++ arch/arm/include/asm/omap_common.h | 4 +++ common/Makefile | 6 ++++ common/cmd_nvedit.c | 6 ++-- common/command.c | 2 +- common/env_common.c | 3 +- common/main.c | 4 +-- lib/Makefile | 10 ++++-- lib/vsprintf.c | 2 +- net/bootp.c | 10 +++++- net/net.c | 3 ++ spl/Makefile | 3 ++ 14 files changed, 107 insertions(+), 10 deletions(-) create mode 100644 arch/arm/cpu/armv7/omap-common/spl_net.c
diff --git a/arch/arm/cpu/armv7/omap-common/Makefile b/arch/arm/cpu/armv7/omap-common/Makefile index d37b22d..f042078 100644 --- a/arch/arm/cpu/armv7/omap-common/Makefile +++ b/arch/arm/cpu/armv7/omap-common/Makefile @@ -53,6 +53,9 @@ endif ifdef CONFIG_SPL_YMODEM_SUPPORT COBJS += spl_ymodem.o endif +ifdef CONFIG_SPL_NET_SUPPORT +COBJS += spl_net.o +endif endif
ifndef CONFIG_SPL_BUILD diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index f0d766c..53b9261 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -178,6 +178,15 @@ void board_init_r(gd_t *id, ulong dummy) spl_ymodem_load_image(); break; #endif +#ifdef CONFIG_SPL_ETH_SUPPORT + case BOOT_DEVICE_CPGMAC: +#ifdef CONFIG_SPL_ETH_DEVICE + spl_net_load_image(CONFIG_SPL_ETH_DEVICE); +#else + spl_net_load_image(NULL); +#endif + break; +#endif default: printf("SPL: Un-supported Boot Device - %d!!!\n", boot_device); hang(); diff --git a/arch/arm/cpu/armv7/omap-common/spl_net.c b/arch/arm/cpu/armv7/omap-common/spl_net.c new file mode 100644 index 0000000..cbb3087 --- /dev/null +++ b/arch/arm/cpu/armv7/omap-common/spl_net.c @@ -0,0 +1,52 @@ +/* + * (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_net_load_image(const char *device) +{ + 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(); + } + if (device) + setenv("ethact", device); + rv = NetLoop(BOOTP); + if (rv < 0) { + printf("Problem booting with BOOTP\n"); + hang(); + } + spl_parse_image_header((struct image_header *)load_addr); +} diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index 4e95eee..9b96527 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -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_net_load_image(const char *device); + #ifdef CONFIG_SPL_BOARD_INIT void spl_board_init(void); #endif diff --git a/common/Makefile b/common/Makefile index 483eb4d..d8b4b2a 100644 --- a/common/Makefile +++ b/common/Makefile @@ -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 diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index fd05e72..9bacf02 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -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, "", ""), diff --git a/common/command.c b/common/command.c index aa0fb0a..8fc2f35 100644 --- a/common/command.c +++ b/common/command.c @@ -526,7 +526,7 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[], if (argc > cmdtp->maxargs) rc = CMD_RET_USAGE;
-#if defined(CONFIG_CMD_BOOTD) +#if defined(CONFIG_CMD_BOOTD) && !defined(CONFIG_SPL_BUILD) /* avoid "bootd" recursion */ else if (cmdtp->cmd == do_bootd) { if (flag & CMD_FLAG_BOOTD) { diff --git a/common/env_common.c b/common/env_common.c index d9e990d..67982a5 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -236,7 +236,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); diff --git a/common/main.c b/common/main.c index a933357..98eac25 100644 --- a/common/main.c +++ b/common/main.c @@ -1131,7 +1131,7 @@ int parse_line (char *line, char *argv[])
/****************************************************************************/
-#ifndef CONFIG_SYS_HUSH_PARSER +#if !defined(CONFIG_SYS_HUSH_PARSER) || defined(CONFIG_SPL_BUILD) static void process_macros (const char *input, char *output) { char c, prev; @@ -1358,7 +1358,7 @@ static int builtin_run_command(const char *cmd, int flag) */ int run_command(const char *cmd, int flag) { -#ifndef CONFIG_SYS_HUSH_PARSER +#if !defined(CONFIG_SYS_HUSH_PARSER) || defined(CONFIG_SPL_BUILD) /* * builtin_run_command can return 0 or 1 for success, so clean up * its result. diff --git a/lib/Makefile b/lib/Makefile index c60c380..59b4e05 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -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 diff --git a/lib/vsprintf.c b/lib/vsprintf.c index e38a4b7..6bb819c 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -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 */ diff --git a/net/bootp.c b/net/bootp.c index 35b2e77..c8811e9 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -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" @@ -535,8 +538,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) diff --git a/net/net.c b/net/net.c index e8ff066..b8ca9e1 100644 --- a/net/net.c +++ b/net/net.c @@ -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) diff --git a/spl/Makefile b/spl/Makefile index 8576d56..da5d47f 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -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: - use BOOTP in SPL regardless of CONFIG_CMD_DHCP - add support for setting different VCI in SPL
Changes in v4: - fix compilation of SPL's libcommon with CONFIG_HUSH_PARSER and CONFIG_BOOTD defined - rename spl_eth.c to spl_net.c - set ethact variable if device name is passed
Changes in v5: - set up guards in cmd_nvedit.c more carefully - now we don't need command.c and only need main.c for show_boot_progress() so defined it to be noop and remove both files from SPL sources - SPL guards in command.c and main.c are no longer needed - add some guards in env_common.c - qsort.c is no longer needed - add guard to hashtable.c to save some space - undefine unneeded CONFIG_CMD_* while building SPL to save space
arch/arm/cpu/armv7/omap-common/Makefile | 3 ++ arch/arm/cpu/armv7/omap-common/spl.c | 9 ++++++ arch/arm/cpu/armv7/omap-common/spl_net.c | 52 ++++++++++++++++++++++++++++++ arch/arm/include/asm/omap_common.h | 4 +++ common/Makefile | 4 +++ common/cmd_nvedit.c | 11 ++++++- common/command.c | 2 +- common/env_common.c | 7 ++-- include/bootstage.h | 6 +++- lib/Makefile | 9 ++++-- lib/hashtable.c | 2 ++ lib/vsprintf.c | 2 +- net/bootp.c | 11 ++++++- net/net.c | 13 ++++++++ net/tftp.c | 4 +++ spl/Makefile | 3 ++ 16 files changed, 133 insertions(+), 9 deletions(-) create mode 100644 arch/arm/cpu/armv7/omap-common/spl_net.c
diff --git a/arch/arm/cpu/armv7/omap-common/Makefile b/arch/arm/cpu/armv7/omap-common/Makefile index d37b22d..f042078 100644 --- a/arch/arm/cpu/armv7/omap-common/Makefile +++ b/arch/arm/cpu/armv7/omap-common/Makefile @@ -53,6 +53,9 @@ endif ifdef CONFIG_SPL_YMODEM_SUPPORT COBJS += spl_ymodem.o endif +ifdef CONFIG_SPL_NET_SUPPORT +COBJS += spl_net.o +endif endif
ifndef CONFIG_SPL_BUILD diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index f0d766c..53b9261 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -178,6 +178,15 @@ void board_init_r(gd_t *id, ulong dummy) spl_ymodem_load_image(); break; #endif +#ifdef CONFIG_SPL_ETH_SUPPORT + case BOOT_DEVICE_CPGMAC: +#ifdef CONFIG_SPL_ETH_DEVICE + spl_net_load_image(CONFIG_SPL_ETH_DEVICE); +#else + spl_net_load_image(NULL); +#endif + break; +#endif default: printf("SPL: Un-supported Boot Device - %d!!!\n", boot_device); hang(); diff --git a/arch/arm/cpu/armv7/omap-common/spl_net.c b/arch/arm/cpu/armv7/omap-common/spl_net.c new file mode 100644 index 0000000..cbb3087 --- /dev/null +++ b/arch/arm/cpu/armv7/omap-common/spl_net.c @@ -0,0 +1,52 @@ +/* + * (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_net_load_image(const char *device) +{ + 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(); + } + if (device) + setenv("ethact", device); + rv = NetLoop(BOOTP); + if (rv < 0) { + printf("Problem booting with BOOTP\n"); + hang(); + } + spl_parse_image_header((struct image_header *)load_addr); +} diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index 4e95eee..9b96527 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -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_net_load_image(const char *device); + #ifdef CONFIG_SPL_BOARD_INIT void spl_board_init(void); #endif diff --git a/common/Makefile b/common/Makefile index 483eb4d..0a9f50c 100644 --- a/common/Makefile +++ b/common/Makefile @@ -187,6 +187,10 @@ 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) += env_common.o +COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_nowhere.o +COBJS-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o endif COBJS-y += console.o COBJS-y += dlmalloc.o diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index fd05e72..bc735e3 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -103,6 +103,7 @@ int get_env_id(void) return env_id; }
+#ifndef CONFIG_SPL_BUILD /* * Command interface: print one or all environment variables * @@ -196,6 +197,7 @@ static int do_env_grep(cmd_tbl_t *cmdtp, int flag, return rcode; } #endif +#endif /* CONFIG_SPL_BUILD */
/* * Set a new environment variable, @@ -394,6 +396,7 @@ int setenv_addr(const char *varname, const void *addr) return setenv(varname, str); }
+#ifndef CONFIG_SPL_BUILD int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { if (argc < 2) @@ -493,6 +496,7 @@ int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return setenv(argv[1], buffer); } #endif /* CONFIG_CMD_EDITENV */ +#endif /* CONFIG_SPL_BUILD */
/* * Look up variable from environment, @@ -578,6 +582,7 @@ ulong getenv_ulong(const char *name, int base, ulong default_val) return str ? simple_strtoul(str, NULL, base) : default_val; }
+#ifndef CONFIG_SPL_BUILD #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE) int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -592,6 +597,7 @@ U_BOOT_CMD( "" ); #endif +#endif /* CONFIG_SPL_BUILD */
/* @@ -613,6 +619,7 @@ int envmatch(uchar *s1, int i2) return -1; }
+#ifndef CONFIG_SPL_BUILD static int do_env_default(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -912,7 +919,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, "", ""), @@ -1038,3 +1046,4 @@ U_BOOT_CMD_COMPLETE( var_complete ); #endif +#endif /* CONFIG_SPL_BUILD */ diff --git a/common/command.c b/common/command.c index aa0fb0a..9827c70 100644 --- a/common/command.c +++ b/common/command.c @@ -526,7 +526,7 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[], if (argc > cmdtp->maxargs) rc = CMD_RET_USAGE;
-#if defined(CONFIG_CMD_BOOTD) +#ifdef CONFIG_CMD_BOOTD /* avoid "bootd" recursion */ else if (cmdtp->cmd == do_bootd) { if (flag & CMD_FLAG_BOOTD) { diff --git a/common/env_common.c b/common/env_common.c index d9e990d..fdd40b0 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -199,6 +199,7 @@ void set_default_env(const char *s) gd->flags |= GD_FLG_ENV_READY; }
+#ifndef CONFIG_SPL_BUILD /* * Check if CRC is valid and (if yes) import the environment. * Note that "buf" may or may not be aligned. @@ -229,6 +230,7 @@ int env_import(const char *buf, int check)
return 0; } +#endif
void env_relocate(void) { @@ -236,7 +238,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); @@ -247,7 +250,7 @@ void env_relocate(void) } }
-#ifdef CONFIG_AUTO_COMPLETE +#if defined(CONFIG_AUTO_COMPLETE) && !defined(CONFIG_SPL_BUILD) int env_complete(char *var, int maxv, char *cmdv[], int bufsz, char *buf) { ENTRY *match; diff --git a/include/bootstage.h b/include/bootstage.h index a000538..db94a95 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -210,6 +210,7 @@ enum bootstage_id { */ ulong timer_get_boot_us(void);
+#ifndef CONFIG_SPL_BUILD /* * Board code can implement show_boot_progress() if needed. * @@ -217,8 +218,11 @@ ulong timer_get_boot_us(void); * has occurred. */ void show_boot_progress(int val); +#else +#define show_boot_progress(val) do {} while (0) +#endif
-#ifdef CONFIG_BOOTSTAGE +#if defined(CONFIG_BOOTSTAGE) && !defined(CONFIG_SPL_BUILD) /* This is the full bootstage implementation */
/* diff --git a/lib/Makefile b/lib/Makefile index c60c380..ee10738 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -52,12 +52,17 @@ 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 endif COBJS-y += crc32.o COBJS-y += ctype.o diff --git a/lib/hashtable.c b/lib/hashtable.c index abd61c8..755f8b3 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -431,6 +431,7 @@ int hdelete_r(const char *key, struct hsearch_data *htab) * hexport() */
+#ifndef CONFIG_SPL_BUILD /* * Export the data stored in the hash table in linearized form. * @@ -597,6 +598,7 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep,
return size; } +#endif
/* diff --git a/lib/vsprintf.c b/lib/vsprintf.c index e38a4b7..6bb819c 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -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 */ diff --git a/net/bootp.c b/net/bootp.c index 35b2e77..e83e35f 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -9,6 +9,10 @@ */
#include <common.h> +#ifdef CONFIG_SPL_BUILD +#undef CONFIG_CMD_DHCP +#undef CONFIG_CMD_SNTP +#endif #include <command.h> #include <net.h> #include "bootp.h" @@ -535,8 +539,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) diff --git a/net/net.c b/net/net.c index e8ff066..bbd1a6d 100644 --- a/net/net.c +++ b/net/net.c @@ -81,6 +81,19 @@
#include <common.h> +#ifdef CONFIG_SPL_BUILD +/* SPL needs only BOOTP + TFTP so undefine other stuff to save space */ +#undef CONFIG_CMD_DHCP +#undef CONFIG_CMD_CDP +#undef CONFIG_CMD_DNS +#undef CONFIG_CMD_LINK_LOCAL +#undef CONFIG_CMD_NFS +#undef CONFIG_CMD_PING +#undef CONFIG_CMD_RARP +#undef CONFIG_CMD_SNTP +#undef CONFIG_CMD_TFTPPUT +#undef CONFIG_CMD_TFTPSRV +#endif #include <command.h> #include <net.h> #if defined(CONFIG_STATUS_LED) diff --git a/net/tftp.c b/net/tftp.c index b2e08b4..bbf48d9 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -7,6 +7,10 @@ */
#include <common.h> +#ifdef CONFIG_SPL_BUILD +#undef CONFIG_CMD_TFTPPUT +#undef CONFIG_CMD_TFTPSRV +#endif #include <command.h> #include <net.h> #include "tftp.h" diff --git a/spl/Makefile b/spl/Makefile index ea7d475..925e84f 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -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

Hi Ilya,
On Tue, Aug 7, 2012 at 3:07 AM, Ilya Yanok ilya.yanok@cogentembedded.com wrote:
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:
- use BOOTP in SPL regardless of CONFIG_CMD_DHCP
- add support for setting different VCI in SPL
Changes in v4:
- fix compilation of SPL's libcommon with CONFIG_HUSH_PARSER and CONFIG_BOOTD defined
- rename spl_eth.c to spl_net.c
- set ethact variable if device name is passed
Changes in v5:
- set up guards in cmd_nvedit.c more carefully
- now we don't need command.c and only need main.c for show_boot_progress() so defined it to be noop and remove both files from SPL sources
- SPL guards in command.c and main.c are no longer needed
- add some guards in env_common.c
- qsort.c is no longer needed
- add guard to hashtable.c to save some space
- undefine unneeded CONFIG_CMD_* while building SPL to save space
arch/arm/cpu/armv7/omap-common/Makefile | 3 ++ arch/arm/cpu/armv7/omap-common/spl.c | 9 ++++++ arch/arm/cpu/armv7/omap-common/spl_net.c | 52 ++++++++++++++++++++++++++++++ arch/arm/include/asm/omap_common.h | 4 +++ common/Makefile | 4 +++ common/cmd_nvedit.c | 11 ++++++- common/command.c | 2 +- common/env_common.c | 7 ++-- include/bootstage.h | 6 +++- lib/Makefile | 9 ++++-- lib/hashtable.c | 2 ++ lib/vsprintf.c | 2 +- net/bootp.c | 11 ++++++- net/net.c | 13 ++++++++ net/tftp.c | 4 +++ spl/Makefile | 3 ++ 16 files changed, 133 insertions(+), 9 deletions(-) create mode 100644 arch/arm/cpu/armv7/omap-common/spl_net.c
diff --git a/arch/arm/cpu/armv7/omap-common/Makefile b/arch/arm/cpu/armv7/omap-common/Makefile index d37b22d..f042078 100644 --- a/arch/arm/cpu/armv7/omap-common/Makefile +++ b/arch/arm/cpu/armv7/omap-common/Makefile @@ -53,6 +53,9 @@ endif ifdef CONFIG_SPL_YMODEM_SUPPORT COBJS += spl_ymodem.o endif +ifdef CONFIG_SPL_NET_SUPPORT +COBJS += spl_net.o +endif
Why not use common pattern of...
COBJS-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o
COBJS := $(sort $(COBJS-y))
endif
ifndef CONFIG_SPL_BUILD diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index f0d766c..53b9261 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -178,6 +178,15 @@ void board_init_r(gd_t *id, ulong dummy) spl_ymodem_load_image(); break; #endif +#ifdef CONFIG_SPL_ETH_SUPPORT
case BOOT_DEVICE_CPGMAC:
+#ifdef CONFIG_SPL_ETH_DEVICE
spl_net_load_image(CONFIG_SPL_ETH_DEVICE);
+#else
spl_net_load_image(NULL);
+#endif
break;
+#endif default: printf("SPL: Un-supported Boot Device - %d!!!\n", boot_device); hang(); diff --git a/arch/arm/cpu/armv7/omap-common/spl_net.c b/arch/arm/cpu/armv7/omap-common/spl_net.c new file mode 100644 index 0000000..cbb3087 --- /dev/null +++ b/arch/arm/cpu/armv7/omap-common/spl_net.c @@ -0,0 +1,52 @@ +/*
- (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>
What in here needs this header?
+DECLARE_GLOBAL_DATA_PTR;
+void spl_net_load_image(const char *device) +{
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();
}
if (device)
setenv("ethact", device);
rv = NetLoop(BOOTP);
if (rv < 0) {
printf("Problem booting with BOOTP\n");
hang();
}
spl_parse_image_header((struct image_header *)load_addr);
+} diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index 4e95eee..9b96527 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -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_net_load_image(const char *device);
#ifdef CONFIG_SPL_BOARD_INIT void spl_board_init(void); #endif diff --git a/common/Makefile b/common/Makefile index 483eb4d..0a9f50c 100644 --- a/common/Makefile +++ b/common/Makefile @@ -187,6 +187,10 @@ 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) += env_common.o +COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_nowhere.o +COBJS-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o endif COBJS-y += console.o COBJS-y += dlmalloc.o diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index fd05e72..bc735e3 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -103,6 +103,7 @@ int get_env_id(void) return env_id; }
+#ifndef CONFIG_SPL_BUILD /*
- Command interface: print one or all environment variables
@@ -196,6 +197,7 @@ static int do_env_grep(cmd_tbl_t *cmdtp, int flag, return rcode; } #endif +#endif /* CONFIG_SPL_BUILD */
/*
- Set a new environment variable,
@@ -394,6 +396,7 @@ int setenv_addr(const char *varname, const void *addr) return setenv(varname, str); }
+#ifndef CONFIG_SPL_BUILD int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { if (argc < 2) @@ -493,6 +496,7 @@ int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return setenv(argv[1], buffer); } #endif /* CONFIG_CMD_EDITENV */ +#endif /* CONFIG_SPL_BUILD */
/*
- Look up variable from environment,
@@ -578,6 +582,7 @@ ulong getenv_ulong(const char *name, int base, ulong default_val) return str ? simple_strtoul(str, NULL, base) : default_val; }
+#ifndef CONFIG_SPL_BUILD #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE) int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -592,6 +597,7 @@ U_BOOT_CMD( "" ); #endif +#endif /* CONFIG_SPL_BUILD */
/* @@ -613,6 +619,7 @@ int envmatch(uchar *s1, int i2) return -1; }
+#ifndef CONFIG_SPL_BUILD static int do_env_default(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -912,7 +919,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, "", ""), @@ -1038,3 +1046,4 @@ U_BOOT_CMD_COMPLETE( var_complete ); #endif +#endif /* CONFIG_SPL_BUILD */ diff --git a/common/command.c b/common/command.c index aa0fb0a..9827c70 100644 --- a/common/command.c +++ b/common/command.c @@ -526,7 +526,7 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[], if (argc > cmdtp->maxargs) rc = CMD_RET_USAGE;
-#if defined(CONFIG_CMD_BOOTD) +#ifdef CONFIG_CMD_BOOTD
Unrelated style change.
/* avoid "bootd" recursion */ else if (cmdtp->cmd == do_bootd) { if (flag & CMD_FLAG_BOOTD) {
diff --git a/common/env_common.c b/common/env_common.c index d9e990d..fdd40b0 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -199,6 +199,7 @@ void set_default_env(const char *s) gd->flags |= GD_FLG_ENV_READY; }
+#ifndef CONFIG_SPL_BUILD /*
- Check if CRC is valid and (if yes) import the environment.
- Note that "buf" may or may not be aligned.
@@ -229,6 +230,7 @@ int env_import(const char *buf, int check)
return 0;
} +#endif
void env_relocate(void) { @@ -236,7 +238,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); @@ -247,7 +250,7 @@ void env_relocate(void) } }
-#ifdef CONFIG_AUTO_COMPLETE +#if defined(CONFIG_AUTO_COMPLETE) && !defined(CONFIG_SPL_BUILD) int env_complete(char *var, int maxv, char *cmdv[], int bufsz, char *buf) { ENTRY *match; diff --git a/include/bootstage.h b/include/bootstage.h index a000538..db94a95 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -210,6 +210,7 @@ enum bootstage_id { */ ulong timer_get_boot_us(void);
+#ifndef CONFIG_SPL_BUILD /*
- Board code can implement show_boot_progress() if needed.
@@ -217,8 +218,11 @@ ulong timer_get_boot_us(void);
has occurred.
*/ void show_boot_progress(int val); +#else +#define show_boot_progress(val) do {} while (0) +#endif
-#ifdef CONFIG_BOOTSTAGE +#if defined(CONFIG_BOOTSTAGE) && !defined(CONFIG_SPL_BUILD) /* This is the full bootstage implementation */
/* diff --git a/lib/Makefile b/lib/Makefile index c60c380..ee10738 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -52,12 +52,17 @@ 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 endif COBJS-y += crc32.o COBJS-y += ctype.o diff --git a/lib/hashtable.c b/lib/hashtable.c index abd61c8..755f8b3 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -431,6 +431,7 @@ int hdelete_r(const char *key, struct hsearch_data *htab)
- hexport()
*/
+#ifndef CONFIG_SPL_BUILD /*
- Export the data stored in the hash table in linearized form.
@@ -597,6 +598,7 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep,
return size;
} +#endif
/* diff --git a/lib/vsprintf.c b/lib/vsprintf.c index e38a4b7..6bb819c 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -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 */ diff --git a/net/bootp.c b/net/bootp.c index 35b2e77..e83e35f 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -9,6 +9,10 @@ */
#include <common.h> +#ifdef CONFIG_SPL_BUILD +#undef CONFIG_CMD_DHCP +#undef CONFIG_CMD_SNTP +#endif #include <command.h> #include <net.h> #include "bootp.h" @@ -535,8 +539,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
Don't use negative logic for no reason.
put_vci(e, CONFIG_VCI_STRING);
+#else
put_vci(e, CONFIG_SPL_NET_VCI_STRING);
+#endif #endif
#if defined(CONFIG_BOOTP_SUBNETMASK) diff --git a/net/net.c b/net/net.c index e8ff066..bbd1a6d 100644 --- a/net/net.c +++ b/net/net.c @@ -81,6 +81,19 @@
#include <common.h> +#ifdef CONFIG_SPL_BUILD +/* SPL needs only BOOTP + TFTP so undefine other stuff to save space */ +#undef CONFIG_CMD_DHCP +#undef CONFIG_CMD_CDP +#undef CONFIG_CMD_DNS +#undef CONFIG_CMD_LINK_LOCAL +#undef CONFIG_CMD_NFS +#undef CONFIG_CMD_PING +#undef CONFIG_CMD_RARP +#undef CONFIG_CMD_SNTP +#undef CONFIG_CMD_TFTPPUT +#undef CONFIG_CMD_TFTPSRV +#endif
Is this the best place to do this? Seems it would be clearer to modify config_cmd_default.h or add a config_cmd_spl.h that will undefine them, and include that.
The other files will still be compiled. Is this enough for them to be garbage collected? Guessing it prolly is.
#include <command.h> #include <net.h> #if defined(CONFIG_STATUS_LED) diff --git a/net/tftp.c b/net/tftp.c index b2e08b4..bbf48d9 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -7,6 +7,10 @@ */
#include <common.h> +#ifdef CONFIG_SPL_BUILD +#undef CONFIG_CMD_TFTPPUT +#undef CONFIG_CMD_TFTPSRV +#endif
Same here.
#include <command.h> #include <net.h> #include "tftp.h" diff --git a/spl/Makefile b/spl/Makefile index ea7d475..925e84f 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -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 -- 1.7.9.5
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

On 08/29/2012 02:25 PM, Joe Hershberger wrote:
[snip]
#include <common.h> +#ifdef CONFIG_SPL_BUILD +/* SPL needs only BOOTP + TFTP so undefine other stuff to save space */ +#undef CONFIG_CMD_DHCP +#undef CONFIG_CMD_CDP +#undef CONFIG_CMD_DNS +#undef CONFIG_CMD_LINK_LOCAL +#undef CONFIG_CMD_NFS +#undef CONFIG_CMD_PING +#undef CONFIG_CMD_RARP +#undef CONFIG_CMD_SNTP +#undef CONFIG_CMD_TFTPPUT +#undef CONFIG_CMD_TFTPSRV +#endif
Is this the best place to do this? Seems it would be clearer to modify config_cmd_default.h or add a config_cmd_spl.h that will undefine them, and include that.
I was thinking about that too, include/config_cmd_spl.h should probably be how this happens.

Hi Joe,
On Thu, Aug 30, 2012 at 1:25 AM, Joe Hershberger joe.hershberger@gmail.comwrote:
diff --git a/arch/arm/cpu/armv7/omap-common/Makefile
b/arch/arm/cpu/armv7/omap-common/Makefile
index d37b22d..f042078 100644 --- a/arch/arm/cpu/armv7/omap-common/Makefile +++ b/arch/arm/cpu/armv7/omap-common/Makefile @@ -53,6 +53,9 @@ endif ifdef CONFIG_SPL_YMODEM_SUPPORT COBJS += spl_ymodem.o endif +ifdef CONFIG_SPL_NET_SUPPORT +COBJS += spl_net.o +endif
Why not use common pattern of...
COBJS-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o
COBJS := $(sort $(COBJS-y))
In fact, I'm just following the existing style here... But I can change it as you requested.
+#include <common.h> +#include <net.h> +#include <asm/omap_common.h>
What in here needs this header?
Looks like it's unneeded. Thanks, I'll remove it.
diff --git a/common/command.c b/common/command.c index aa0fb0a..9827c70 100644 --- a/common/command.c +++ b/common/command.c @@ -526,7 +526,7 @@ enum command_ret_t cmd_process(int flag, int argc,
char * const argv[],
if (argc > cmdtp->maxargs) rc = CMD_RET_USAGE;
-#if defined(CONFIG_CMD_BOOTD) +#ifdef CONFIG_CMD_BOOTD
Unrelated style change.
Yep, it came from earlier version. Will fix.
-#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
Don't use negative logic for no reason.
Ok, Will fix.
put_vci(e, CONFIG_VCI_STRING);
+#else
put_vci(e, CONFIG_SPL_NET_VCI_STRING);
+#endif #endif
#if defined(CONFIG_BOOTP_SUBNETMASK) diff --git a/net/net.c b/net/net.c index e8ff066..bbd1a6d 100644 --- a/net/net.c +++ b/net/net.c @@ -81,6 +81,19 @@
#include <common.h> +#ifdef CONFIG_SPL_BUILD +/* SPL needs only BOOTP + TFTP so undefine other stuff to save space */ +#undef CONFIG_CMD_DHCP +#undef CONFIG_CMD_CDP +#undef CONFIG_CMD_DNS +#undef CONFIG_CMD_LINK_LOCAL +#undef CONFIG_CMD_NFS +#undef CONFIG_CMD_PING +#undef CONFIG_CMD_RARP +#undef CONFIG_CMD_SNTP +#undef CONFIG_CMD_TFTPPUT +#undef CONFIG_CMD_TFTPSRV +#endif
Is this the best place to do this? Seems it would be clearer to modify config_cmd_default.h or add a config_cmd_spl.h that will undefine them, and include that.
I agree it's not the best place... config_cmd_spl.h sounds a little bit crazy as we don't have any commands at all in SPL...
Regards, Ilya.

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 09/17/12 02:55, Ilya Yanok wrote:
Hi Joe,
On Thu, Aug 30, 2012 at 1:25 AM, Joe Hershberger <joe.hershberger@gmail.com mailto:joe.hershberger@gmail.com> wrote:
[snip]
diff --git a/net/net.c b/net/net.c index e8ff066..bbd1a6d 100644 --- a/net/net.c +++ b/net/net.c @@ -81,6 +81,19 @@
#include <common.h> +#ifdef CONFIG_SPL_BUILD +/* SPL needs only BOOTP + TFTP so undefine other stuff to save
space */
+#undef CONFIG_CMD_DHCP +#undef CONFIG_CMD_CDP +#undef CONFIG_CMD_DNS +#undef CONFIG_CMD_LINK_LOCAL +#undef CONFIG_CMD_NFS +#undef CONFIG_CMD_PING +#undef CONFIG_CMD_RARP +#undef CONFIG_CMD_SNTP +#undef CONFIG_CMD_TFTPPUT +#undef CONFIG_CMD_TFTPSRV +#endif
Is this the best place to do this? Seems it would be clearer to modify config_cmd_default.h or add a config_cmd_spl.h that will undefine them, and include that.
I agree it's not the best place... config_cmd_spl.h sounds a little bit crazy as we don't have any commands at all in SPL...
How about config_uncmd_spl.h then and a nice big comment up top explaining what we're doing. Or can we take another stab at seeing why some stuff isn't being garbage collected? If garbage_collected_func_a calls never_seen_while_linking_func, we still succeed since we garbage collect the first func. There's just the gcc issue I've noted before about strings.
- -- Tom

Hi Tom,
On Mon, Sep 17, 2012 at 9:04 PM, Tom Rini trini@ti.com wrote:
I agree it's not the best place... config_cmd_spl.h sounds a little bit crazy as we don't have any commands at all in SPL...
How about config_uncmd_spl.h then and a nice big comment up top
Well, it will be at least less confusing...
explaining what we're doing. Or can we take another stab at seeing why some stuff isn't being garbage collected? If garbage_collected_func_a calls never_seen_while_linking_func, we still succeed since we garbage collect the first func. There's just the gcc issue I've noted before about strings.
That's not really about garbage collection in this case (net-spl). I want to disable some functionality of generic net code not some stuff used only by commands implementation. The confusion comes from the fact that this code is protected by CONFIG_CMD_* defines.
Regards, Ilya.

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 09/17/12 10:54, Ilya Yanok wrote:
Hi Tom,
On Mon, Sep 17, 2012 at 9:04 PM, Tom Rini <trini@ti.com mailto:trini@ti.com> wrote:
I agree it's not the best place... config_cmd_spl.h sounds a little bit crazy as we don't have any commands at all in SPL...
How about config_uncmd_spl.h then and a nice big comment up top
Well, it will be at least less confusing...
explaining what we're doing. Or can we take another stab at seeing why some stuff isn't being garbage collected? If garbage_collected_func_a calls never_seen_while_linking_func, we still succeed since we garbage collect the first func. There's just the gcc issue I've noted before about strings.
That's not really about garbage collection in this case (net-spl). I want to disable some functionality of generic net code not some stuff used only by commands implementation. The confusion comes from the fact that this code is protected by CONFIG_CMD_* defines.
So I guess the code construct is roughly: function_we_need(...) { #ifdef CONFIG_CMD_A ... stuff_spl_does_not_need(); #endif ... }
? Otherwise we would end up building files we don't use, but then all of the un-used code gets garbage collected.
- -- Tom

On Mon, Sep 17, 2012 at 10:07 PM, Tom Rini trini@ti.com wrote:
That's not really about garbage collection in this case (net-spl). I want to disable some functionality of generic net code not some stuff used only by commands implementation. The confusion comes from the fact that this code is protected by CONFIG_CMD_* defines.
So I guess the code construct is roughly: function_we_need(...) { #ifdef CONFIG_CMD_A ... stuff_spl_does_not_need(); #endif ... }
? Otherwise we would end up building files we don't use, but then all of the un-used code gets garbage collected.
Exactly.
Regards, Ilya.

BTW, I'm going to repost this serie soon. Shouldn't I rebase it on top of your SPL rework patches? Where can I find the tree?
Regards, Ilya.

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 09/17/12 11:10, Ilya Yanok wrote:
On Mon, Sep 17, 2012 at 10:07 PM, Tom Rini <trini@ti.com mailto:trini@ti.com> wrote:
That's not really about garbage collection in this case (net-spl). I want to disable some functionality of generic net code not some stuff used only by commands implementation. The confusion comes from the fact that this code is protected by CONFIG_CMD_* defines.
So I guess the code construct is roughly: function_we_need(...) { #ifdef CONFIG_CMD_A ... stuff_spl_does_not_need(); #endif ... }
? Otherwise we would end up building files we don't use, but then all of the un-used code gets garbage collected.
Exactly.
OK, config_uncmd_spl.h, nice big comment and v6, thanks :)
- -- Tom

On Mon, Sep 17, 2012 at 1:55 PM, Ilya Yanok ilya.yanok@cogentembedded.comwrote:
+#include <common.h>
+#include <net.h> +#include <asm/omap_common.h>
What in here needs this header?
Looks like it's unneeded. Thanks, I'll remove it.
Nope, it's needed for spl_parse_image_header.
Regards, Ilya.

This patch adds support for networking in SPL on TI AM335x based boards. Vendor Class Identifier used by SPL during BOOTP is "AM335x U-Boot SPL".
Signed-off-by: Ilya Yanok ilya.yanok@cogentembedded.com
--- Changes in v3: - set Vendor Class Identifier for SPL
Changes in v4: - SPL_BOARD_INIT is not needed anymore
include/configs/am335x_evm.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 69ab076..d36ad8f 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -185,7 +185,7 @@ /* Defines for SPL */ #define CONFIG_SPL #define CONFIG_SPL_TEXT_BASE 0x402F0400 -#define CONFIG_SPL_MAX_SIZE (46 * 1024) +#define CONFIG_SPL_MAX_SIZE (101 * 1024) #define CONFIG_SPL_STACK LOW_LEVEL_SRAM_STACK
#define CONFIG_SPL_BSS_START_ADDR 0x80000000 @@ -205,6 +205,9 @@ #define CONFIG_SPL_SERIAL_SUPPORT #define CONFIG_SPL_GPIO_SUPPORT #define CONFIG_SPL_YMODEM_SUPPORT +#define CONFIG_SPL_NET_SUPPORT +#define CONFIG_SPL_NET_VCI_STRING "AM335x U-Boot SPL" +#define CONFIG_SPL_ETH_SUPPORT #define CONFIG_SPL_LDSCRIPT "$(CPUDIR)/omap-common/u-boot-spl.lds"
/*
participants (3)
-
Ilya Yanok
-
Joe Hershberger
-
Tom Rini