From: Wadim Egorov <w.egorov@phytec.de>
To: barebox@lists.infradead.org
Subject: [RFC 3/3] ARM: am33xx: Add network boot
Date: Fri, 22 May 2015 14:11:18 +0200 [thread overview]
Message-ID: <1432296678-375-3-git-send-email-w.egorov@phytec.de> (raw)
In-Reply-To: <1432296678-375-1-git-send-email-w.egorov@phytec.de>
Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
---
arch/arm/mach-omap/Kconfig | 9 +++++++
arch/arm/mach-omap/am33xx_generic.c | 3 +++
arch/arm/mach-omap/xload.c | 52 ++++++++++++++++++++++++++++++++++++-
3 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
index 444ddf8..bc00d5b 100644
--- a/arch/arm/mach-omap/Kconfig
+++ b/arch/arm/mach-omap/Kconfig
@@ -110,6 +110,15 @@ config ARCH_TEXT_BASE
default 0x80e80000 if MACH_OMAP343xSDP
default 0x80e80000 if MACH_BEAGLE
+config AM33XX_NET_BOOT
+ bool "enable AM335x network boot"
+ select ENVIRONMENT_VARIABLES
+ select NET_DHCP
+ select FS_TFTP
+ select DRIVER_NET_CPSW
+ default n
+ depends on ARCH_AM33XX && NET
+
config OMAP4_USBBOOT
bool "enable booting from USB"
default n
diff --git a/arch/arm/mach-omap/am33xx_generic.c b/arch/arm/mach-omap/am33xx_generic.c
index ee30351..7ce32f0 100644
--- a/arch/arm/mach-omap/am33xx_generic.c
+++ b/arch/arm/mach-omap/am33xx_generic.c
@@ -145,6 +145,9 @@ static int am33xx_bootsource(void)
case 0x44:
src = BOOTSOURCE_USB;
break;
+ case 0x46:
+ src = BOOTSOURCE_NET;
+ break;
default:
src = BOOTSOURCE_UNKNOWN;
}
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index 7c8c350..08490ce 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -13,6 +13,10 @@
#include <filetype.h>
#include <xymodem.h>
#include <mach/generic.h>
+#include <mach/am33xx-generic.h>
+#include <net.h>
+#include <environment.h>
+#include <dhcp.h>
struct omap_barebox_part *barebox_part;
@@ -126,7 +130,6 @@ static void *omap_xload_boot_mmc(void)
printf("could not read barebox.bin from sd card\n");
return NULL;
}
-
return buf;
}
@@ -224,6 +227,45 @@ static void *omap_serial_boot(void){
return buf;
}
+static void *am33xx_net_boot(void)
+{
+ void *buf = NULL;
+ int err;
+ int len;
+ struct dhcp_req_param dhcp_param;
+ const char *bootfile;
+
+ am33xx_register_ethaddr(0, 0);
+
+ memset(&dhcp_param, 0, sizeof(struct dhcp_req_param));
+ dhcp_param.vendor_id = "am335x barebox-mlo";
+ err = dhcp(20, &dhcp_param);
+ if (err) {
+ printf("dhcp failed\n");
+ return NULL;
+ }
+
+ err = mount(ip_to_string(net_get_serverip()), "tftp", "/", NULL);
+ if (err < 0) {
+ printf("Unable to mount.\n");
+ return NULL;
+ }
+
+ bootfile = getenv("bootfile");
+ if (!bootfile) {
+ printf("bootfile not found.\n");
+ return NULL;
+ }
+
+ buf = read_file(bootfile, &len);
+ if (!buf)
+ printf("could not read %s.\n", bootfile);
+
+ umount("/");
+
+ return buf;
+}
+
/*
* Replaces the default shell in xload configuration
*/
@@ -264,6 +306,14 @@ static __noreturn int omap_xload(void)
func = omap_serial_boot();
break;
}
+ case BOOTSOURCE_NET:
+ if (IS_ENABLED(CONFIG_AM33XX_NET_BOOT)) {
+ printf("booting from NET\n");
+ func = am33xx_net_boot();
+ break;
+ } else {
+ printf("booting from network not enabled\n");
+ }
default:
printf("unknown boot source. Fall back to nand\n");
func = omap_xload_boot_nand(barebox_part->nand_offset,
--
1.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-05-22 12:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-22 12:11 [RFC 1/3] bootsource: Add NET bootsource Wadim Egorov
2015-05-22 12:11 ` [RFC 2/3] net: dhcp: Split dhcp funcionality & add dhcp command Wadim Egorov
2015-05-22 12:11 ` Wadim Egorov [this message]
2015-05-26 6:19 ` [RFC 1/3] bootsource: Add NET bootsource Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1432296678-375-3-git-send-email-w.egorov@phytec.de \
--to=w.egorov@phytec.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox