This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
RedBoot - JFFS2 support
- From: Gary Thomas <gary at mlbassoc dot com>
- To: eCos patches <ecos-patches at ecos dot sourceware dot org>
- Date: 02 Dec 2003 07:41:24 -0700
- Subject: RedBoot - JFFS2 support
- Organization: MLB Associates
>From David Woodhouse, with a few cosmetic cleanups.
--
Gary Thomas <gary@mlbassoc.com>
MLB Associates
Index: redboot/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/ChangeLog,v
retrieving revision 1.167
diff -u -5 -p -r1.167 ChangeLog
--- redboot/current/ChangeLog 1 Dec 2003 18:33:38 -0000 1.167
+++ redboot/current/ChangeLog 2 Dec 2003 14:12:14 -0000
@@ -1,26 +1,32 @@
-2003-11-21 David Vrabel <dvrabel@arcom.com>
+2003-11-27 David Woodhouse <dwmw2@redhat.com>
- * src/net/bootp.c (bootp_handler): Scan for DHCP Message Type tag
- as it isn't always the first tag.
+ * cdl/redboot.cdl, fs/fileio.c, include/fs/fileio.h, src/load.c:
+ Support for mounting and loading files from fileio file systems
+ such as JFFS2.
- * include/net/bootp.h: New #define's for DHCP message types
- (DHCP_MESSAGE_TYPE_DISCOVER etc.).
-
2003-11-25 John Dallaway <jld@ecoscentric.com>
* src/fconfig.c (load_flash_config):
Fix typo in output string.
-
+
2003-11-24 Gary Thomas <gary@mlbassoc.com>
* src/net/bootp.c (__bootp_find_local_ip):
Suppress diagnostic message that DNS info found.
2002-11-24 Jani Monoses <jani@iv.ro>
* src/flash.c: Remove references to FLASH_MIN_WORKSPACE.
+
+2003-11-21 David Vrabel <dvrabel@arcom.com>
+
+ * src/net/bootp.c (bootp_handler): Scan for DHCP Message Type tag
+ as it isn't always the first tag.
+
+ * include/net/bootp.h: New #define's for DHCP message types
+ (DHCP_MESSAGE_TYPE_DISCOVER etc.).
2002-11-20 Jani Monoses <jani@iv.ro>
* src/flash.c: flash_init() no longer takes three args.
Index: redboot/current/cdl/redboot.cdl
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/cdl/redboot.cdl,v
retrieving revision 1.59
diff -u -5 -p -r1.59 redboot.cdl
--- redboot/current/cdl/redboot.cdl 1 Nov 2003 09:08:34 -0000 1.59
+++ redboot/current/cdl/redboot.cdl 2 Dec 2003 14:11:11 -0000
@@ -837,10 +837,21 @@ cdl_package CYGPKG_REDBOOT {
2) the information in RAM has been verified to be invalid"
}
}
+ cdl_component CYGPKG_REDBOOT_FILEIO {
+ display "Allow RedBoot to support fileio"
+ flavor bool
+ default_value 1
+ active_if CYGPKG_IO_FILEIO
+ description "
+ If this option is enabled then RedBoot will provide commands
+ to load files from fileio file systems such as JFFS2."
+ compile -library=libextras.a fs/fileio.c
+ }
+
cdl_component CYGPKG_REDBOOT_DISK {
display "Allow RedBoot to support disks"
flavor bool
default_value 1
description "
Index: redboot/current/include/fs/fileio.h
===================================================================
RCS file: redboot/current/include/fs/fileio.h
diff -N redboot/current/include/fs/fileio.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ redboot/current/include/fs/fileio.h 2 Dec 2003 14:11:11 -0000
@@ -0,0 +1,61 @@
+//==========================================================================
+//
+// fileio.h
+//
+// Fileio subsystem support for RedBoot
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
+//
+// eCos 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 or (at your option) any later version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): dwmw2
+// Contributors: dwmw2
+// Date: 2003-11-24
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef CYGONCE_REDBOOT_FILEIO_H
+#define CYGONCE_REDBOOT_FILEIO_H
+
+extern getc_io_funcs_t fileio_io;
+extern int fileio_mounted;
+
+#endif // CYGONCE_REDBOOT_FILEIO_H
Index: redboot/current/src/load.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/src/load.c,v
retrieving revision 1.36
diff -u -5 -p -r1.36 load.c
--- redboot/current/src/load.c 17 Oct 2003 21:45:25 -0000 1.36
+++ redboot/current/src/load.c 2 Dec 2003 14:18:01 -0000
@@ -59,10 +59,13 @@
#include <xyzModem.h>
#endif
#ifdef CYGPKG_REDBOOT_DISK
#include <fs/disk.h>
#endif
+#ifdef CYGPKG_REDBOOT_FILEIO
+#include <fs/fileio.h>
+#endif
#ifdef CYGPKG_REDBOOT_NETWORKING
#ifdef CYGSEM_REDBOOT_NET_TFTP_DOWNLOAD
#include <net/tftp_support.h>
#endif
#ifdef CYGSEM_REDBOOT_NET_HTTP_DOWNLOAD
@@ -691,10 +694,17 @@ do_load(int argc, char *argv[])
io = &tftp_io;
#elif defined(CYGSEM_REDBOOT_NET_HTTP_DOWNLOAD)
which = "HTTP";
io = &http_io;
#endif
+#endif
+#ifdef CYGPKG_REDBOOT_FILEIO
+ // Make file I/O default if mounted
+ if (fileio_mounted) {
+ which = "file";
+ io = &fileio_io;
+ }
#endif
if (!io) {
#ifdef CYGBLD_BUILD_REDBOOT_WITH_XYZMODEM
which = "Xmodem";
io = &xyzModem_io;
Index: redboot/current/src/fs/fileio.c
===================================================================
RCS file: redboot/current/src/fs/fileio.c
diff -N redboot/current/src/fs/fileio.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ redboot/current/src/fs/fileio.c 2 Dec 2003 14:21:10 -0000
@@ -0,0 +1,222 @@
+//==========================================================================
+//
+// fileio.c
+//
+// RedBoot fileio support
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2002, 2003 Gary Thomas
+//
+// eCos 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 or (at your option) any later version.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): dwmw2, msalter
+// Date: 2003-11-27
+// Purpose:
+// Description:
+//
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+// Shoot me. But I don't want struct timeval because redboot provides it.
+#define _POSIX_SOURCE
+#include <time.h>
+#undef _POSIX_SOURCE
+
+#include <redboot.h>
+#include <errno.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <cyg/io/io.h>
+#include <cyg/io/flash.h>
+#include <cyg/io/config_keys.h>
+#include <cyg/fileio/fileio.h>
+
+static void do_mount(int argc, char *argv[]);
+static void do_umount(int argc, char *argv[]);
+
+#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE
+#define FLASHPART "[-f <partition>] "
+#else
+#define FLASHPART
+#endif
+
+RedBoot_cmd("mount",
+ "Mount file system",
+ FLASHPART "[-d <device>] -t fstype",
+ do_mount
+ );
+RedBoot_cmd("umount",
+ "Unmount file system",
+ "",
+ do_umount
+ );
+
+int fileio_mounted = 0;
+
+// Mount disk/filesystem
+static void
+do_mount(int argc, char *argv[])
+{
+ char *part_str, *dev_str, *type_str;
+ bool part_set = false, dev_set = false, type_set = false;
+ struct option_info opts[3];
+ int err, num_opts = 2;
+
+ init_opts(&opts[0], 'd', true, OPTION_ARG_TYPE_STR,
+ (void *)&dev_str, &dev_set, "device");
+ init_opts(&opts[1], 't', true, OPTION_ARG_TYPE_STR,
+ (void *)&type_str, &type_set, "fstype");
+#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE
+ init_opts(&opts[2], 'f', true, OPTION_ARG_TYPE_STR,
+ (void *)&part_str, &part_set, "partition");
+ num_opts++;
+#endif
+
+ if (!scan_opts(argc, argv, 1, opts, num_opts, NULL, 0, NULL))
+ return;
+
+ if (!type_set) {
+ diag_printf("Must specify file system type\n");
+ return;
+ }
+ if (fileio_mounted) {
+ diag_printf("A file system is already mounted\n");
+ return;
+ }
+#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE
+ if (part_set) {
+ int len;
+ cyg_io_handle_t h;
+
+ if (dev_set && strcmp(dev_str, CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1)) {
+ diag_printf("May only set one of <device> or <partition>\n");
+ return;
+ }
+
+ dev_str = CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1;
+ len = strlen(part_str);
+
+ err = cyg_io_lookup(dev_str, &h);
+ if (err < 0) {
+ diag_printf("cyg_io_lookup of \"%s\" returned %d\n", err);
+ return;
+ }
+ err = cyg_io_set_config(h, CYG_IO_SET_CONFIG_FLASH_FIS_NAME,
+ part_str, &len);
+ if (err < 0) {
+ diag_printf("FIS partition \"%s\" not found\n",
+ part_str);
+ return;
+ }
+ }
+#endif
+ err = mount(dev_str, "/", type_str);
+
+ if (err) {
+ diag_printf("Mount failed %d\n", err);
+ } else {
+// diag_printf("Mount %s file system succeeded\n", type_str);
+ fileio_mounted = 1;
+ }
+}
+
+static void
+do_umount(int argc, char *argv[])
+{
+ if (!fileio_mounted) {
+ return;
+ }
+ umount ("/");
+ fileio_mounted = 0;
+}
+
+static int fd;
+
+externC int
+fileio_stream_open(connection_info_t *info, int *err)
+{
+ char *filename = info->filename;
+
+ if (!fileio_mounted) {
+ diag_printf("No file system mounted\n");
+ return -1;
+ }
+ fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ diag_printf("Open failed, error %d\n", errno);
+ return -1;
+ }
+ return 0;
+}
+
+externC int
+fileio_stream_read(char *buf, int size, int *err)
+{
+ int nread;
+
+ if ((nread = read(fd, buf, size)) < 0) {
+ *err = errno;
+ return -1;
+ }
+ return nread;
+}
+
+externC void
+fileio_stream_close(int *err)
+{
+ close(fd);
+}
+
+externC char *
+fileio_error(int err)
+{
+ static char myerr[10];
+
+ diag_sprintf(myerr, "error %d\n", err);
+ return myerr;
+}
+
+//
+// RedBoot interface
+//
+GETC_IO_FUNCS(fileio_io, fileio_stream_open, fileio_stream_close,
+ 0, fileio_stream_read, fileio_error);
+RedBoot_load(file, fileio_io, true, true, 0);
+