OMAP: SPL networking support
Subsystems (4)
v6 cover OMAP: SPL networking support
These series provides support for networking in SPL.
In this version some effort is done to minimize the resulting SPL size and now Net-only SPL is <50KB in size. So theoretically it can be used on boards with enough SRAM space like AM3517. But real testing was done only on AM335x.
Changes in v3:
- use BOOTP in SPL regardless of CONFIG_CMD_DHCP
- add support for setting different VCI in SPL
- set Vendor Class Identifier for SPL
Changes in v4:
- used strlen instead of sizeof
- moved vci_strlen var inside macro
- 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
- SPL_BOARD_INIT is not needed anymore
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
Changes in v6:
- fix typo in patch name
- remove some unneeded changes introduced by earlier versions
- switch clauses and use ifdef instead of ifndef
- create new header config_uncmd_spl.h which undefines CONFIG_CMD_* options unneeded in SPL and include it last from config.h
- remove explicit undefs from net/net.c and net/bootp.c
Ilya Yanok (4):
net/bootp: add VCI support for BOOTP also
OMAP: spl: call timer_init() 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 | 4 +++ common/cmd_nvedit.c | 8 +++++ common/env_common.c | 7 ++-- include/bootstage.h | 6 +++- include/config_uncmd_spl.h | 24 ++++++++++++++ include/configs/am335x_evm.h | 5 ++- lib/Makefile | 9 ++++-- lib/hashtable.c | 2 ++ lib/vsprintf.c | 2 +- mkconfig | 1 + net/bootp.c | 27 ++++++++++++---- net/tftp.c | 4 +++ spl/Makefile | 3 ++ 17 files changed, 159 insertions(+), 13 deletions(-) create mode 100644 arch/arm/cpu/armv7/omap-common/spl_net.c create mode 100644 include/config_uncmd_spl.h
Signature · 1 line
1.7.9.5
PATCH v6 1/4 net/bootp: add VCI support for BOOTP also
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.
---
Changes in v4:
- used strlen instead of sizeof
- moved vci_strlen var inside macro
net/bootp.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
net/bootp.c +16 -6
@@ -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 ;
Signature · 1 line
1.7.9.5
PATCH v6 2/4 OMAP: spl: call timer_init() from SPL
In reply to Ilya YanokWe need to initialize timer properly, otherwise all delays inside SPL will be wrong.
---
Changes in v6:
- fix typo in patch name
arch/arm/cpu/armv7/omap-common/spl.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/cpu/armv7/omap-common/spl.c +2 -0
@@ -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
Signature · 1 line
1.7.9.5
PATCH v6 3/4 OMAP: networking support for SPL
In reply to Ilya YanokThis 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.
---
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
Changes in v6:
- remove some unneeded changes introduced by earlier versions
- switch clauses and use ifdef instead of ifndef
- create new header config_uncmd_spl.h which undefines CONFIG_CMD_* options unneeded in SPL and include it last from config.h
- remove explicit undefs from net/net.c and net/bootp.c
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 | 8 +++++ common/env_common.c | 7 ++-- include/bootstage.h | 6 +++- include/config_uncmd_spl.h | 24 ++++++++++++++ lib/Makefile | 9 ++++-- lib/hashtable.c | 2 ++ lib/vsprintf.c | 2 +- mkconfig | 1 + net/bootp.c | 7 +++- net/tftp.c | 4 +++ spl/Makefile | 3 ++ 16 files changed, 138 insertions(+), 7 deletions(-) create mode 100644 arch/arm/cpu/armv7/omap-common/spl_net.c create mode 100644 include/config_uncmd_spl.h
arch/arm/cpu/armv7/omap-common/Makefile +3 -0
@@ -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
arch/arm/cpu/armv7/omap-common/spl.c +9 -0
@@ -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 ();
arch/arm/cpu/armv7/omap-common/spl_net.c new file +52 -0
52 lines not on this page · raw message
arch/arm/include/asm/omap_common.h +4 -0
@@ -69,6 +69,7 @@ void preloader_console_init(void);#define BOOT_DEVICE_MMC1 8#define BOOT_DEVICE_MMC2 9/* eMMC or daughter card */ #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
common/Makefile +4 -0
@@ -189,6 +189,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
common/cmd_nvedit.c +8 -0
@@ -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[]) {
@@ -1038,3 +1045,4 @@ U_BOOT_CMD_COMPLETE(var_complete );#endif +#endif /* CONFIG_SPL_BUILD */
common/env_common.c +5 -2
@@ -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;
include/bootstage.h +5 -1
@@ -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 */ /*
include/config_uncmd_spl.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* We don't use any commands in SPL, but generic networking code +* has some features enabled/disabled based on CONFIG_CMD_* +* options. As we want a minimal set of features included +* into network SPL image, we undefine some config options here. +*/ + +#ifndef __CONFIG_UNCMD_SPL_H__ +#define __CONFIG_UNCMD_SPL_H__ + +#ifdef CONFIG_SPL_BUILD +/* SPL needs only BOOTP + TFTP so undefine other stuff to save space */ +#undef CONFIG_CMD_CDP +#undef CONFIG_CMD_DHCP +#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 /* CONFIG_SPL_BUILD */ +#endif /* __CONFIG_UNCMD_SPL_H__ */
lib/Makefile +7 -2
@@ -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
lib/hashtable.c +2 -0
@@ -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 /*
lib/vsprintf.c +1 -1
@@ -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 */
mkconfig +1 -0
@@ -185,6 +185,7 @@ cat << EOF >> config.h #include <configs/${CONFIG_NAME}.h> #include <asm/config.h> #include <config_fallbacks.h> +#include <config_uncmd_spl.h> EOF exit 0
net/bootp.c +6 -1
@@ -535,9 +535,14 @@ 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 )) +#ifdef CONFIG_SPL_BUILD +put_vci (e,CONFIG_SPL_NET_VCI_STRING ); +#else put_vci (e,CONFIG_VCI_STRING );#endif +#endif #if defined(CONFIG_BOOTP_SUBNETMASK ) *e++ =1 ;/* Subnet mask request */
net/tftp.c +4 -0
@@ -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"
spl/Makefile +3 -0
@@ -56,6 +56,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
Signature · 1 line
1.7.9.5
PATCH v6 3/4 OMAP: networking support for SPL
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 9 lines · Ilya Yanok
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 <[email protected]>
[snip]
Quoted 15 lines
(quoted diff) +0
-0
b/include/config_uncmd_spl.hnew file mode 100644 index 0000000..8ad6045 ---/dev/null+++b/include/config_uncmd_spl.h@@ -0,0 +1,24 @@ +/* + * We don't use any commands in SPL, but generic networking code + * has some features enabled/disabled based on CONFIG_CMD_* + * options. As we want a minimal set of features included + * into network SPL image, we undefine some config options here. + */ + +#ifndef__CONFIG_UNCMD_SPL_H__+#define__CONFIG_UNCMD_SPL_H__+ +#ifdefCONFIG_SPL_BUILD+/* SPL needs only BOOTP + TFTP so undefine other stuff to save space */ +#undefCONFIG_CMD_CDP+#undefCONFIG_CMD_DHCP+#undefCONFIG_CMD_DNS+#undefCONFIG_CMD_LINK_LOCAL+#undefCONFIG_CMD_NFS+#undefCONFIG_CMD_PING+#undefCONFIG_CMD_RARP+#undefCONFIG_CMD_SNTP+#undefCONFIG_CMD_TFTPPUT+#undefCONFIG_CMD_TFTPSRV+#endif /*CONFIG_SPL_BUILD*/ +#endif /*__CONFIG_UNCMD_SPL_H__*/
Please add a GPLv2+ header to the file, thanks.
Quoted 6 lines
lib/vsprintf.c index e38a4b7..6bb819c renamed from lib/vsprintf.c +0
-0100644 ---
a/lib/vsprintf.c+++b/lib/vsprintf.c@@ -784,7 +784,7 @@ voidpanic(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 */
Oh no, this change... Do we still really need this?
Quoted 6 lines
net/tftp.c index 59a8ebb..baba8f3 100644 renamed from net/tftp.c +0
-1--- a/net/tftp.c +++ b/net/tftp.c @@ -7,6 +7,10 @@ */#include <
common.h> +#ifdefCONFIG_SPL_BUILD+#undefCONFIG_CMD_TFTPPUT+#undefCONFIG_CMD_TFTPSRV+#endif #include <command.h> #include <net.h> #include "tftp.h"
Missed this.
Also I saw a few manual inclusions of <config_uncmd_spl.h>, please fix those since mkconfig adds it always. Thanks.
- --
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
iQIcBAEBAgAGBQJQV721AAoJENk4IS6UOR1WHnUP+wdiliv2T4GUH/Z39TYoW0uo WqAREC3pHZ9YMYKSZgGGOHwlAOuk2az5GPAqiCaXLLIgx43h5tkQnjbBHlB0T9rv R+uqy4LF0Lxyz86ITSf4nmpkn66gnd5L6ET2b46Siof+PFIzNLEnM0Z0sWpnsWAU ZlKnwS/Y/VAKDiwW5rxWiXTbs1vMHn8BWU+wTVrMLE80Sm3yE/C5mpzOBl42+O+V kmo/nUNIiTK4C8VmlvL7+w+mqMPDtB4nSFFmmjmH7z8991RBhLJ0Nmlg26wmtXDL Vyy5Jg6SQRSuyDJFplvoPu7FVhgI2umRxOIl6SEONKzSQQSBQmMqtIZV4pW4hFVZ 3RO5wrr0RKpJJy4Izb2MoGqvUv4fDIK9K2xiQihBUkc4X7UCpPMMqBpLwKVSoIdW 1y7o+2LzUAlBU9q/nP+ZHBzZFL9jYZHEDaYkuY+MT7i+tLcW2T6dV0Q4KsXTwHhx D9zbU6tEXbgRZr/n8gUMeSWu7r6F2tr3a4UiTMsAP8lkVyXUPmYnfUhpxQrUuIx/ yuGmpigYPNicvP1hiU/quX2Fxxx2kuy3gDLVIc7tZv0VSmW6NI+WZC8inGBhk4Bb GsZaYkoZnv799Z7GJy8wqCszSqb4BmI9wB3Hzz49jiwurvz/n7tDKEOtjjcIWCZc MXsKY53Ulu6dW0vk5qQK
=2lLS
-----END PGP SIGNATURE-----
PATCH v7 3/4 OMAP: networking support for SPL
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.
---
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
Changes in v6:
- remove some unneeded changes introduced by earlier versions
- switch clauses and use ifdef instead of ifndef
- create new header config_uncmd_spl.h which undefines CONFIG_CMD_* options unneeded in SPL and include it last from config.h
- remove explicit undefs from net/net.c and net/bootp.c
Changes in v7:
- remove explicit cmd undef from net/tftp.c also
- add GPLv2 header to config_uncmd_spl.h
- remove CONFIG_SPL_BUILD clause at hang() (not needed)
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 | 8 +++++ common/env_common.c | 7 ++-- include/bootstage.h | 6 +++- include/config_uncmd_spl.h | 44 +++++++++++++++++++++++++ lib/Makefile | 9 ++++-- lib/hashtable.c | 2 ++ mkconfig | 1 + net/bootp.c | 7 +++- spl/Makefile | 3 ++ 14 files changed, 153 insertions(+), 6 deletions(-) create mode 100644 arch/arm/cpu/armv7/omap-common/spl_net.c create mode 100644 include/config_uncmd_spl.h
arch/arm/cpu/armv7/omap-common/Makefile +3 -0
@@ -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
arch/arm/cpu/armv7/omap-common/spl.c +9 -0
@@ -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 ();
arch/arm/cpu/armv7/omap-common/spl_net.c new file +52 -0
52 lines not on this page · raw message
arch/arm/include/asm/omap_common.h +4 -0
@@ -69,6 +69,7 @@ void preloader_console_init(void);#define BOOT_DEVICE_MMC1 8#define BOOT_DEVICE_MMC2 9/* eMMC or daughter card */ #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
common/Makefile +4 -0
@@ -189,6 +189,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
common/cmd_nvedit.c +8 -0
@@ -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[]) {
@@ -1038,3 +1045,4 @@ U_BOOT_CMD_COMPLETE(var_complete );#endif +#endif /* CONFIG_SPL_BUILD */
common/env_common.c +5 -2
@@ -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;
include/bootstage.h +5 -1
@@ -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 */ /*
include/config_uncmd_spl.h new file +44 -0
44 lines not on this page · raw message
lib/Makefile +7 -2
@@ -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
lib/hashtable.c +2 -0
@@ -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 /*
mkconfig +1 -0
@@ -185,6 +185,7 @@ cat << EOF >> config.h #include <configs/${CONFIG_NAME}.h> #include <asm/config.h> #include <config_fallbacks.h> +#include <config_uncmd_spl.h> EOF exit 0
net/bootp.c +6 -1
@@ -535,9 +535,14 @@ 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 )) +#ifdef CONFIG_SPL_BUILD +put_vci (e,CONFIG_SPL_NET_VCI_STRING ); +#else put_vci (e,CONFIG_VCI_STRING );#endif +#endif #if defined(CONFIG_BOOTP_SUBNETMASK ) *e++ =1 ;/* Subnet mask request */
spl/Makefile +3 -0
@@ -56,6 +56,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
Signature · 1 line
1.7.9.5
PATCH v7 3/4 OMAP: networking support for SPL
Hi Ilya,
Quoted 39 lines · Ilya Yanok
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 <[email protected]>---
Changes in v3:
- use BOOTP in SPL regardless ofCONFIG_CMD_DHCP
- add support for setting different VCI in SPLChanges in v4:
- fix compilation of SPL's libcommon withCONFIG_HUSH_PARSERandCONFIG_BOOTDdefined
- renamespl_eth.ctospl_net.c
- set ethact variable if device name is passedChanges in v5:
- set up guards incmd_nvedit.cmore carefully
- now we don't needcommand.cand only needmain.cforshow_boot_progress()so defined it to be noop and remove both files from SPL sources
- SPL guards incommand.candmain.care no longer needed
- add some guards inenv_common.c
-qsort.cis no longer needed
- add guard tohashtable.cto save some space
- undefine unneeded CONFIG_CMD_* while building SPL to save spaceChanges in v6:
- remove some unneeded changes introduced by earlier versions
- switch clauses and use ifdef instead of ifndef
- create new headerconfig_uncmd_spl.hwhich undefines CONFIG_CMD_* options unneeded in SPL and include it last fromconfig.h
- remove explicit undefs fromnet/net.candnet/bootp.c
Quoted 4 lines
Changes in v7:
- remove explicit cmd undef fromnet/tftp.calso
- add GPLv2 header toconfig_uncmd_spl.h
- removeCONFIG_SPL_BUILDclause athang()(not needed)
PATCH v6 3/4 OMAP: networking support for SPL
In reply to Tom RiniHi Tom,
Quoted 3 lines · Tom Rini
Please add a GPLv2+ header to the file, thanks.
Done.
Quoted 10 lines
Quoted 7 lines
lib/vsprintf.c index e38a4b7..6bb819c renamed from lib/vsprintf.c +0
-0100644 ---
a/lib/vsprintf.c+++b/lib/vsprintf.c@@ -784,7 +784,7 @@ voidpanic(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 */Oh no, this change... Do we still really need this?
Seems like it's not needed anymore. I've removed it.
Quoted 10 lines
Quoted 7 lines
net/tftp.c index 59a8ebb..baba8f3 100644 renamed from net/tftp.c +0
-1--- a/net/tftp.c +++ b/net/tftp.c @@ -7,6 +7,10 @@ */#include <
common.h> +#ifdefCONFIG_SPL_BUILD+#undefCONFIG_CMD_TFTPPUT+#undefCONFIG_CMD_TFTPSRV+#endif #include <command.h> #include <net.h> #include "tftp.h"Missed this.
Yes, sorry.
Quoted 4 lines
Also I saw a few manual inclusions of <
config_uncmd_spl.h>, please fix those since mkconfig adds it always. Thanks.
Hm, I can't see any.
I reposted only this patch. Hope it's ok now.
Regards, Ilya.
PATCH v6 4/4 am335x_evm: enable networking in SPL
In reply to Ilya YanokThis 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".
---
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(-)
include/configs/am335x_evm.h +4 -1
@@ -194,7 +194,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 CONFIG_SYS_INIT_SP_ADDR#define CONFIG_SPL_BSS_START_ADDR 0x80000000
@@ -214,6 +214,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"/*
Signature · 1 line
1.7.9.5