mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM: am33xx: netboot use ramfs
@ 2015-07-06  6:55 Jan Remmet
  2015-07-08  6:24 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Remmet @ 2015-07-06  6:55 UTC (permalink / raw)
  To: barebox

Older tftp server don't send the file size.
Then tftpfs needs temporary place to store the file.
mount ramfs and then tftpfs in a own mount point

Signed-off-by: Jan Remmet <j.remmet@phytec.de>
Tested-by: Wadim Egorov <w.egorov@phytec.de>
---
 arch/arm/mach-omap/Kconfig |  1 +
 arch/arm/mach-omap/xload.c | 30 ++++++++++++++++++++++++++----
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
index af35975..aeed79f 100644
--- a/arch/arm/mach-omap/Kconfig
+++ b/arch/arm/mach-omap/Kconfig
@@ -106,6 +106,7 @@ config AM33XX_NET_BOOT
 	bool "enable AM335x network boot"
 	select ENVIRONMENT_VARIABLES
 	select NET_DHCP
+	select FS_RAMFS
 	select FS_TFTP
 	select DRIVER_NET_CPSW
 	default n
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index 4a0714e..b0ce1d6 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -229,13 +229,16 @@ static void *omap_serial_boot(void){
 	return buf;
 }
 
+#define TFTP_MOUNT "/.tftp"
+
 static void *am33xx_net_boot(void)
 {
 	void *buf = NULL;
 	int err;
 	int len;
 	struct dhcp_req_param dhcp_param;
-	const char *bootfile;
+	const char *bootfile, *ip;
+	char *file;
 
 	am33xx_register_ethaddr(0, 0);
 
@@ -247,7 +250,22 @@ static void *am33xx_net_boot(void)
 		return NULL;
 	}
 
-	err = mount(ip_to_string(net_get_serverip()), "tftp", "/", NULL);
+	/*
+	 * Older tftp server don't send the file size.
+	 * Then tftpfs needs temporary place to store the file.
+	 */
+	err = mount("none", "ramfs", "/", NULL);
+	if (err < 0) {
+		printf("failed to mount ramfs\n");
+		return NULL;
+	}
+
+	err = make_directory(TFTP_MOUNT);
+	if (err)
+		return NULL;
+
+	ip = ip_to_string(net_get_serverip());
+	err = mount(ip, "tftp", TFTP_MOUNT, NULL);
 	if (err < 0) {
 		printf("Unable to mount.\n");
 		return NULL;
@@ -259,11 +277,15 @@ static void *am33xx_net_boot(void)
 		return NULL;
 	}
 
-	buf = read_file(bootfile, &len);
+	file = asprintf("%s/%s", TFTP_MOUNT, bootfile);
+
+	buf = read_file(file, &len);
 	if (!buf)
 		printf("could not read %s.\n", bootfile);
 
-	umount("/");
+	free(file);
+
+	umount(TFTP_MOUNT);
 
 	return buf;
 }
-- 
1.9.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ARM: am33xx: netboot use ramfs
  2015-07-06  6:55 [PATCH] ARM: am33xx: netboot use ramfs Jan Remmet
@ 2015-07-08  6:24 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2015-07-08  6:24 UTC (permalink / raw)
  To: Jan Remmet; +Cc: barebox

Hi Jan,

On Mon, Jul 06, 2015 at 08:55:26AM +0200, Jan Remmet wrote:
> Older tftp server don't send the file size.
> Then tftpfs needs temporary place to store the file.
> mount ramfs and then tftpfs in a own mount point

I don't like this at all. The missing file size has led to a workaround
in read_file and now it additionally leads to a workaround in a user of
read_file. I hoped I could think of something better, but so far I
failed, so: Applied.
Anyway, I'm still open for better solutions.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-08  6:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-06  6:55 [PATCH] ARM: am33xx: netboot use ramfs Jan Remmet
2015-07-08  6:24 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox