diff options
author | Wadim Egorov <w.egorov@phytec.de> | 2015-06-03 11:19:03 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-06-05 13:32:39 +0200 |
commit | 0b06cf7edf84f37e8b5fcdee2819cf4f59934593 (patch) | |
tree | 4f946db02c2667923d4d7cbb311133a5385d86c2 /arch/arm/mach-omap/xload.c | |
parent | e9bd26c7a7167b5e36696373ef8381a2caaff4a6 (diff) | |
download | barebox-0b06cf7edf84f37e8b5fcdee2819cf4f59934593.tar.gz barebox-0b06cf7edf84f37e8b5fcdee2819cf4f59934593.tar.xz |
ARM: am33xx: Add network boot
Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-omap/xload.c')
-rw-r--r-- | arch/arm/mach-omap/xload.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c index 7c8c350114..85c9120ccf 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; @@ -224,6 +228,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 +307,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, |