Mercurial > ecos-v3_0-branch
changeset 2257:467fd46113f3
* src/fs/fileio.c (do_list): Use getcwd for current directory,
rather than "." which may not be implemented in the FS.
* src/parse.c (redboot_exec): Conditionalise use of
__mem_fault_handler to only be when stubs are included.
(error_handler): Ditto for this function.
* src/main.c (cyg_start): Conditionalise use of
__mem_fault_handler to only be when stubs are included.
(do_go): Ditto.
(error_handler): Ditto for this function.
* src/fs/fileio.c (do_mkdir, do_deldir, do_del, do_write): Added
some extra argument checking to these functions.
* src/fs/fileio.c (do_mount): Only support -f with "legacy" flash
block devices.
Clear mount table on failure.
(do_move): Silence rename undefined warning.
(do_write): Silence warnings.
(do_info): Support longer device names.
* src/decompress.c (ZLIB_COMPRESSION_OVERHEAD):
Increase substantially if jffs2 is present.
* src/fs/fileio.c: Fixed some bugs in handling of mounts. The
strings used in the mount table must be copied, otherwise the
mount table is corrupted by later commands. Also toughened up some
error testing.
* doc/redboot_cmds.sgml: Added file mode documentation to load
command.
* doc/redboot_cmds.sgml: Added documentation of filesystem access
commands.
* src/fs/fileio.c (do_write): Added O_TRUNC to the open call to
ensure that the file is resized to fit the new data.
* src/fs/fileio.c: Significantly reorganized to present an
interface similar to the fis commands. Added a variety of command
to manipulate files and directories in a filesystem.
* src/parse.c: Added redboot_exec() to provide an internal
interface for executing RedBoot commands. Added err_printf() which
allows an error message to be printed before longjumping out to an
enclosing call to redboot_exec(). Where redboot_exec() is not
involved, it just behaves like diag_printf().
* src/main.c: Removed unnecessary delay during startup. Changed
diag_printf() in do_go() into err_printf().
* src/load.c: Changed some calls to diag_printf() to err_printf().
* src/net/net_io.c: Changed init priority to RedBoot_INIT_NET.
* include/redboot.h: Added some extra initialization
priorities. Added prototypes for redboot_exec() and err_printf().
| author | jlarmour |
|---|---|
| date | Thu, 20 Jul 2006 20:27:47 +0000 |
| parents | 9838a9103c2a |
| children | 19ce76dd5f64 |
| files | packages/redboot/current/ChangeLog packages/redboot/current/doc/redboot_cmds.sgml packages/redboot/current/include/redboot.h packages/redboot/current/src/fs/fileio.c packages/redboot/current/src/load.c packages/redboot/current/src/main.c packages/redboot/current/src/net/net_io.c packages/redboot/current/src/parse.c |
| diffstat | 8 files changed, 1509 insertions(+), 116 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/redboot/current/ChangeLog +++ b/packages/redboot/current/ChangeLog @@ -40,6 +40,11 @@ 2006-02-25 Oliver Munz <munz@speag.ch> overflowed the workspace. * doc/redboot_cmds.sgml: Document new flag. +2006-02-24 Jonathan Larmour <jifl@eCosCentric.com> + + * src/fs/fileio.c (do_list): Use getcwd for current directory, + rather than "." which may not be implemented in the FS. + 2006-02-17 Andrew Lunn <andrew.lunn@ascom.ch> * src/flash.c (fis_lock & fis_unlock): Allow compilation without @@ -55,6 +60,17 @@ 2005-10-17 Gary Thomas <gary@mlbassoc. * src/iomem.c (do_iopeek): Correct number of options. +2005-09-13 Jonathan Larmour <jifl@eCosCentric.com> + + * src/parse.c (redboot_exec): Conditionalise use of + __mem_fault_handler to only be when stubs are included. + (error_handler): Ditto for this function. + + * src/main.c (cyg_start): Conditionalise use of + __mem_fault_handler to only be when stubs are included. + (do_go): Ditto. + (error_handler): Ditto for this function. + 2005-09-09 Andrew Dyer <adyer@righthandtech.com> * src/load.c: add calls to redboot_getc_terminate before exiting @@ -184,18 +200,47 @@ 2005-03-07 Alexander Neundorf <alexander * src/net/arp.c: use correct sizeof(rt->enet_addr) in __arp_lookup() +2005-01-26 Nick Garnett <nickg@ecoscentric.com> + + * src/fs/fileio.c (do_mkdir, do_deldir, do_del, do_write): Added + some extra argument checking to these functions. + 2005-01-22 Andrew Lunn <andrew.lunn@ascom.ch> * src/main.c (cyg_start): Fix compiler warning with HAL_THREAD_INIT_CONTEXT and the worspace end address. * src/fs/disk.c (find_dos_partitions): Removed unused variable. +2005-01-19 Jonathan Larmour <jifl@eCosCentric.com> + + * src/fs/fileio.c (do_mount): Only support -f with "legacy" flash + block devices. + Clear mount table on failure. + (do_move): Silence rename undefined warning. + (do_write): Silence warnings. + (do_info): Support longer device names. + + * src/decompress.c (ZLIB_COMPRESSION_OVERHEAD): + Increase substantially if jffs2 is present. + 2005-01-05 David Vrabel <dvrabel@arcom.com> * src/fs/fileio.c (do_ls): Remove useless "getcwd" message. * src/net/bootp.c (__bootp_find_local_ip): Only print the "waiting for BOOTP" message when after first retry. +2004-12-17 Nick Garnett <nickg@ecoscentric.com> + + * src/fs/fileio.c: Fixed some bugs in handling of mounts. The + strings used in the mount table must be copied, otherwise the + mount table is corrupted by later commands. Also toughened up some + error testing. + +2004-12-16 Nick Garnett <nickg@ecoscentric.com> + + * doc/redboot_cmds.sgml: Added file mode documentation to load + command. + 2004-12-01 Andrea Michelotti <amichelotti@atmel.com> * main.c : @@ -203,6 +248,36 @@ 2004-12-01 Andrea Michelotti <amichelo * mcmp.c : Changes required for use with GCC v4 - cast as lvalue is no longer supported. +2004-11-26 Nick Garnett <nickg@ecoscentric.com> + + * doc/redboot_cmds.sgml: Added documentation of filesystem access + commands. + + * src/fs/fileio.c (do_write): Added O_TRUNC to the open call to + ensure that the file is resized to fit the new data. + +2004-11-24 Nick Garnett <nickg@ecoscentric.com> + + * src/fs/fileio.c: Significantly reorganized to present an + interface similar to the fis commands. Added a variety of command + to manipulate files and directories in a filesystem. + + * src/parse.c: Added redboot_exec() to provide an internal + interface for executing RedBoot commands. Added err_printf() which + allows an error message to be printed before longjumping out to an + enclosing call to redboot_exec(). Where redboot_exec() is not + involved, it just behaves like diag_printf(). + + * src/main.c: Removed unnecessary delay during startup. Changed + diag_printf() in do_go() into err_printf(). + + * src/load.c: Changed some calls to diag_printf() to err_printf(). + + * src/net/net_io.c: Changed init priority to RedBoot_INIT_NET. + + * include/redboot.h: Added some extra initialization + priorities. Added prototypes for redboot_exec() and err_printf(). + 2004-11-09 Ian Campbell <icampbell@arcom.com> * cdl/redboot.cdl, doc/redboot_cmds.sgml, src/iomem.c: Add support
--- a/packages/redboot/current/doc/redboot_cmds.sgml +++ b/packages/redboot/current/doc/redboot_cmds.sgml @@ -1289,9 +1289,10 @@ IP: 192.168.1.32, Default server: 192.16 <arg choice="req"><group> <arg>xmodem</arg> <arg>ymodem</arg> - </group></arg> - <arg>tftp</arg> - <arg>disk</arg> + <arg>tftp</arg> + <arg>disk</arg> + <arg>file</arg></group> + </arg> </group> </arg> <arg>-h <replaceable> server_IP_address</replaceable></arg> @@ -1370,6 +1371,13 @@ serial download method since it would in <entry><acronym>TFTP</acronym></entry> </row> <row> + <entry>-m file</entry> + <entry></entry> + <entry>Transfer data from a local filesystem such as + JFFS2 or FAT.</entry> + <entry><acronym>TFTP</acronym></entry> + </row> + <row> <entry>-h <replaceable>server_IP_address</replaceable></entry> <entry>Numeric IP or DNS name</entry> <entry>The IP address of the <acronym>TFTP</acronym> or <acronym>HTTP</acronym> server.</entry> @@ -1451,6 +1459,14 @@ RedBoot> <userinput>load -mode disk hda1 Entry point: 0x00020000, address range: 0x00020000-0x0002fd70 </screen> </para> + <para> +Load an ELF file from /jffs2/applications which should be a directory +in a JFFS2 filesystem: +<screen> +RedBoot> <userinput>load -mode file /jffs2/applications/hello.elf</userinput> +Entry point: 0x00020000, address range: 0x00020000-0x0002fd70 +</screen> + </para> </refsect1> </refentry> @@ -2794,8 +2810,766 @@ RedBoot> <userinput>fis write -b 0x0606f </para> </refsect1> </refentry> +</sect1> + +<sect1 id="filesystem-commands"> +<title>Filesystem Interface</title> + +<para> +<indexterm><primary>commands</primary><secondary>filesystem access +</secondary></indexterm><indexterm><primary>filesystem commands</primary> +</indexterm><indexterm><primary>commands</primary><secondary>fs</secondary> +</indexterm><indexterm><primary>fs commands</primary></indexterm> + +If the platform has access to secondary storage, then RedBoot may be +able to access a filesystem stored on this device. RedBoot can access +FAT filesystems stored on IDE disks or CompactFlash devices and can +use JFFS2 filesystems stored in FLASH memory. The +<command>fs</command> command is used to manipulate files on +filesystems. Applications may be loaded into memory using the +<emphasis>file</emphasis> mode of the <command>load</command> command. +</para> + +<!-- ******** fs info ************************************************ --> + +<refentry id="fs-info-command"> + <refnamediv> + <refname>fs info</refname> + <refpurpose>Print filesystem information</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>fs info</command> + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>Arguments</title> + <para> + The command takes no arguments. + </para> + </refsect1> + <refsect1> + <title>Description</title> +<para>This command prints information about the filesystems that are +available. Three lists are produced. The first is a list of the +filsystem implementations available in RedBoot; names from this list +may be used in the <parameter>-t</parameter> option to the <command>fs +mount</command> command. The second list describes the block devices +that are available for mounting a filesystem; names from this list may +be used in the <parameter>-d</parameter> option to the <command>fs +mount</command> command. The last list describes the filesystems that +are already mounted. +</para> +</refsect1> + + <refsect1> + <title>Examples</title> + <para> +<screen> +RedBoot> <userinput>fs info</userinput> +Filesystems available: +ramfs +jffs2 + +Devices available: +/dev/flash1 + +Mounted filesystems: + Device Filesystem Mounted on + <undefined> ramfs / + /dev/flash1 jffs2 /flash +RedBoot></screen> + </para> + </refsect1> +</refentry> + +<!-- ******** fs mount ************************************************ --> + +<refentry id="fs-mount-command"> + <refnamediv> + <refname>fs mount</refname> + <refpurpose>Mount a filesystem</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>fs mount</command> + <arg choice="opt">-d <replaceable>device</replaceable></arg> + <arg choice="req">-t <replaceable>fstype</replaceable></arg> + <arg choice="req">mountpoint</arg> + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>Arguments</title> + <informaltable frame="all"> + <tgroup cols="4" colsep="1" rowsep="1" align="left"> + <colspec colname="c1"> + <colspec colname="c2"> + <colspec colname="c3"> + <colspec colname="c4"> + <thead> + <row> + <entry>Name</entry> + <entry>Type</entry> + <entry>Description</entry> + <entry>Default</entry> + </row> + </thead> + <tbody> + <row> + <entry><replaceable>device</replaceable></entry> + <entry>Number</entry> + <entry>Device containing filsystem to mount.</entry> + <entry>undefined</entry> + </row> + <row> + <entry><replaceable>fstype</replaceable></entry> + <entry>Number</entry> + <entry>Filesystem type.</entry> + <entry></entry> + </row> + <row> + <entry><replaceable>mountpoint</replaceable></entry> + <entry>String</entry> + <entry>Pathname for filesystem root.</entry> + <entry>/</entry> + </row> + </tbody> + </tgroup> + </informaltable> + </refsect1> + <refsect1> + <title>Description</title> +<para>This command is used make a filesystem available for access with +the filesystem access commands. Three things need to be defined to do +this. First, the name of the device on which the filesystem is stored +needs to be given to the <parameter>-d</parameter> option. Secondly, +the type of filesystem it is needs to be given to the +<parameter>-t</parameter> option. Finally, the pathname by which the +new filesystem will be accessed needs to be supplied. Following a +successful mount, the root of the filesystem will be accessible +at the mountpoint. +</para> +</refsect1> + + <refsect1> + <title>Examples</title> +<para>Mount a JFF2 partititon: +<screen> +RedBoot> <userinput>fs info</userinput> +Filesystems available: +ramfs +jffs2 + +Devices available: +/dev/flash1 + +Mounted filesystems: + Device Filesystem Mounted on + <undefined> ramfs / +RedBoot> <userinput>fs mount -d /dev/flash1 -t jffs2 /flash</userinput> +RedBoot> <userinput>fs info</userinput> +Filesystems available: +ramfs +jffs2 + +Devices available: +/dev/flash1 + +Mounted filesystems: + Device Filesystem Mounted on + <undefined> ramfs / + /dev/flash1 jffs2 /flash +RedBoot> +</screen> + </para> + </refsect1> +</refentry> + +<!-- ******** fs umount ************************************************ --> + +<refentry id="fs-umount-command"> + <refnamediv> + <refname>fs umount</refname> + <refpurpose>Unmount filesystem</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>fs umount</command> + <arg choice="req"><replaceable>mountpoint</replaceable></arg> + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>Arguments</title> + <informaltable frame="all"> + <tgroup cols="4" colsep="1" rowsep="1" align="left"> + <colspec colname="c1"> + <colspec colname="c2"> + <colspec colname="c3"> + <colspec colname="c4"> + <thead> + <row> + <entry>Name</entry> + <entry>Type</entry> + <entry>Description</entry> + <entry>Default</entry> + </row> + </thead> + <tbody> + <row> + <entry><replaceable>mountpoint</replaceable></entry> + <entry>String</entry> + <entry>Mountpoint of filesystem to unmount.</entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </informaltable> + </refsect1> + <refsect1> + <title>Description</title> +<para>This command removes a filesystem from being accessible using +the filesystem commands. The single argument needs to be the +mountpoint that was used when mounting the filesystem. This command +will fail if the current directory is currently within the filesystem +to be unmounted. +</para> +</refsect1> + + <refsect1> + <title>Examples</title> +<para>Unmount a JFF2 partititon: +<screen> +RedBoot> <userinput>fs info</userinput> +Filesystems available: +ramfs +jffs2 + +Devices available: +/dev/flash1 + +Mounted filesystems: + Device Filesystem Mounted on + <undefined> ramfs / + /dev/flash1 jffs2 /flash +RedBoot> <userinput>fs umount /flash</userinput> +RedBoot> <userinput>fs info</userinput> +Filesystems available: +ramfs +jffs2 + +Devices available: +/dev/flash1 + +Mounted filesystems: + Device Filesystem Mounted on + <undefined> ramfs / +RedBoot> +</screen> + </para> + </refsect1> +</refentry> + +<!-- ******** fs cd ************************************************ --> + +<refentry id="fs-cd-command"> + <refnamediv> + <refname>fs cd</refname> + <refpurpose>Change filesystem directory</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>fs cd</command> + <arg choice="opt"><replaceable>directory</replaceable></arg> + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>Arguments</title> + <informaltable frame="all"> + <tgroup cols="4" colsep="1" rowsep="1" align="left"> + <colspec colname="c1"> + <colspec colname="c2"> + <colspec colname="c3"> + <colspec colname="c4"> + <thead> + <row> + <entry>Name</entry> + <entry>Type</entry> + <entry>Description</entry> + <entry>Default</entry> + </row> + </thead> + <tbody> + <row> + <entry><replaceable>directory</replaceable></entry> + <entry>String</entry> + <entry>Pathname to directory to change to.</entry> + <entry>Root directory</entry> + </row> + </tbody> + </tgroup> + </informaltable> + </refsect1> + <refsect1> + <title>Description</title> +<para>This command changes the current filesystem +directory. Subsequent filesystem commands will be executed in the new +directory. If no argument is given, then the current directory is set +back to the root of the filesystem name space. +</para> +</refsect1> + + <refsect1> + <title>Examples</title> + <para>Change current directory: +<screen> +RedBoot> <userinput>fs list</userinput> +212416 d--------- 3 size 128 . +212416 d--------- 3 size 128 .. +211392 d--------- 2 size 96 tests +210368 ---------- 1 size 4096 image +RedBoot> <userinput>fs cd tests</userinput> +RedBoot> <userinput>fs list</userinput> +211392 d--------- 2 size 96 . +212416 d--------- 3 size 128 .. +205760 ---------- 1 size 16384 test1 +RedBoot> +</screen> + </para> + </refsect1> +</refentry> + +<!-- ******** fs mkdir ************************************************ --> + +<refentry id="fs-mkdir-command"> + <refnamediv> + <refname>fs mkdir</refname> + <refpurpose>Create filesystem directory</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>fs mkdir</command> + <arg choice="req"><replaceable>directory</replaceable></arg> + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>Arguments</title> + <informaltable frame="all"> + <tgroup cols="4" colsep="1" rowsep="1" align="left"> + <colspec colname="c1"> + <colspec colname="c2"> + <colspec colname="c3"> + <colspec colname="c4"> + <thead> + <row> + <entry>Name</entry> + <entry>Type</entry> + <entry>Description</entry> + <entry>Default</entry> + </row> + </thead> + <tbody> + <row> + <entry><replaceable>directory</replaceable></entry> + <entry>String</entry> + <entry>Pathname to directory to delete.</entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </informaltable> + </refsect1> + <refsect1> + <title>Description</title> +<para>This command creates (makes) a directory in the filesystem. +</para> +</refsect1> + + <refsect1> + <title>Examples</title> + <para>Create directory: +<screen> +RedBoot> <userinput>fs list</userinput> +212416 d--------- 2 size 128 . +212416 d--------- 2 size 128 .. +210368 ---------- 1 size 4096 image +RedBoot> <userinput>fs mkdir tests</userinput> +RedBoot> <userinput>fs list</userinput> +212416 d--------- 3 size 128 . +212416 d--------- 3 size 128 .. +211392 d--------- 2 size 64 tests +210368 ---------- 1 size 4096 image +RedBoot> +</screen> + </para> + </refsect1> +</refentry> + +<!-- ******** fs deldir ************************************************ --> + +<refentry id="fs-deldir-command"> + <refnamediv> + <refname>fs deldir</refname> + <refpurpose>Delete filesystem directory</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>fs deldir</command> + <arg choice="req"><replaceable>directory</replaceable></arg> + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>Arguments</title> + <informaltable frame="all"> + <tgroup cols="4" colsep="1" rowsep="1" align="left"> + <colspec colname="c1"> + <colspec colname="c2"> + <colspec colname="c3"> + <colspec colname="c4"> + <thead> + <row> + <entry>Name</entry> + <entry>Type</entry> + <entry>Description</entry> + <entry>Default</entry> + </row> + </thead> + <tbody> + <row> + <entry><replaceable>directory</replaceable></entry> + <entry>String</entry> + <entry>Pathname to directory to delete.</entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </informaltable> + </refsect1> + <refsect1> + <title>Description</title> +<para>This command deletes a directory from the filesystem. If the +directory contains files or other directories then this command will +fail. +</para> +</refsect1> + + <refsect1> + <title>Examples</title> + <para>Delete directory: +<screen> +RedBoot> <userinput>fs list</userinput> +212416 d--------- 3 size 128 . +212416 d--------- 3 size 128 .. +211392 d--------- 2 size 96 tests +210368 ---------- 1 size 4096 image +RedBoot> <userinput>fs deldir tests</userinput> +RedBoot> <userinput>fs list</userinput> +212416 d--------- 2 size 128 . +212416 d--------- 2 size 128 .. +210368 ---------- 1 size 4096 image +RedBoot> +</screen> + </para> + </refsect1> +</refentry> + +<!-- ******** fs del ************************************************ --> + +<refentry id="fs-del-command"> + <refnamediv> + <refname>fs del</refname> + <refpurpose>Delete file</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>fs del</command> + <arg choice="req"><replaceable>file</replaceable></arg> + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>Arguments</title> + <informaltable frame="all"> + <tgroup cols="4" colsep="1" rowsep="1" align="left"> + <colspec colname="c1"> + <colspec colname="c2"> + <colspec colname="c3"> + <colspec colname="c4"> + <thead> + <row> + <entry>Name</entry> + <entry>Type</entry> + <entry>Description</entry> + <entry>Default</entry> + </row> + </thead> + <tbody> + <row> + <entry><replaceable>file</replaceable></entry> + <entry>String</entry> + <entry>Pathname of file to delete.</entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </informaltable> + </refsect1> + <refsect1> + <title>Description</title> +<para>This command deletes a file from the filesystem. +</para> +</refsect1> + + <refsect1> + <title>Examples</title> + <para>Change current directory: +<screen> +RedBoot> <userinput>fs list tests</userinput> +211392 d--------- 2 size 96 . +212416 d--------- 3 size 128 .. +205760 ---------- 1 size 16384 test1 +RedBoot> <userinput>fs del tests/test1</userinput> +RedBoot> <userinput>fs list tests</userinput> +211392 d--------- 2 size 96 . +212416 d--------- 3 size 128 .. +RedBoot> +</screen> + </para> + </refsect1> +</refentry> + +<!-- ******** fs move ************************************************ --> + +<refentry id="fs-move-command"> + <refnamediv> + <refname>fs move</refname> + <refpurpose>Move file</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>fs move</command> + <arg choice="req"><replaceable>source</replaceable></arg> + <arg choice="req"><replaceable>dest</replaceable></arg> + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>Arguments</title> + <informaltable frame="all"> + <tgroup cols="4" colsep="1" rowsep="1" align="left"> + <colspec colname="c1"> + <colspec colname="c2"> + <colspec colname="c3"> + <colspec colname="c4"> + <thead> + <row> + <entry>Name</entry> + <entry>Type</entry> + <entry>Description</entry> + <entry>Default</entry> + </row> + </thead> + <tbody> + <row> + <entry><replaceable>source</replaceable></entry> + <entry>String</entry> + <entry>Pathname of file to move.</entry> + <entry></entry> + </row> + <row> + <entry><replaceable>dest</replaceable></entry> + <entry>String</entry> + <entry>Pathname to new file location.</entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </informaltable> + </refsect1> + <refsect1> + <title>Description</title> +<para>This command moves a file within a filesystem. This command will +fail if the destination file already exists, or is in a different +filesystem. +</para> +</refsect1> + + <refsect1> + <title>Examples</title> + <para>Rename a file: +<screen> +RedBoot> <userinput>fs list tests</userinput> +211392 d--------- 2 size 96 . +212416 d--------- 3 size 128 .. +205760 ---------- 1 size 12288 test1 +RedBoot> <userinput>fs move tests/test1 tests/test2</userinput> +RedBoot> <userinput>fs list tests</userinput> +211392 d--------- 2 size 128 . +212416 d--------- 3 size 128 .. +205760 ---------- 1 size 12288 test2 +RedBoot> +</screen> + </para> + </refsect1> +</refentry> + +<!-- ******** fs list ************************************************ --> + +<refentry id="fs-list-command"> + <refnamediv> + <refname>fs list</refname> + <refpurpose>List filesystem directory</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>fs list</command> + <arg choice="opt"><replaceable>directory</replaceable></arg> + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>Arguments</title> + <informaltable frame="all"> + <tgroup cols="4" colsep="1" rowsep="1" align="left"> + <colspec colname="c1"> + <colspec colname="c2"> + <colspec colname="c3"> + <colspec colname="c4"> + <thead> + <row> + <entry>Name</entry> + <entry>Type</entry> + <entry>Description</entry> + <entry>Default</entry> + </row> + </thead> + <tbody> + <row> + <entry><replaceable>directory</replaceable></entry> + <entry>String</entry> + <entry>Pathname to directory to list.</entry> + <entry>Current directory</entry> + </row> + </tbody> + </tgroup> + </informaltable> + </refsect1> + <refsect1> + <title>Description</title> +<para>This command prints a list of the contents of the named +directory. Each line of the listing starts with the file's inode +number, which is its address in the filesystem. Following is a set of +UNIX-like access flags, the first character of this will be a +”d“ if this entry is a directory. The third item indicates +the number of links to the file. Following this is the size of the +file in bytes and the last item is its name. +</para> +</refsect1> + + <refsect1> + <title>Examples</title> + <para>List the current directory: +<screen> +RedBoot> <userinput>fs list</userinput> +212416 d--------- 3 size 128 . +212416 d--------- 3 size 128 .. +211392 ---------- 1 size 4096 image +206784 d--------- 2 size 96 tests +RedBoot> +</screen> + </para> +<para> +List a subdirectory: +<screen> +RedBoot> fs list tests +206784 d--------- 2 size 96 . +212416 d--------- 3 size 128 .. +205760 ---------- 1 size 16384 test1 +RedBoot> +</screen> +</para> + </refsect1> +</refentry> + +<!-- ******** fs write ************************************************ --> + +<refentry id="fs-write-command"> + <refnamediv> + <refname>fs write</refname> + <refpurpose>Write to filesystem</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>fs write</command> + <arg choice="opt">-b <replaceable>mem_address</replaceable></arg> + <arg choice="opt">-l <replaceable>length</replaceable></arg> + <arg choice="req">name</arg> + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>Arguments</title> + <informaltable frame="all"> + <tgroup cols="4" colsep="1" rowsep="1" align="left"> + <colspec colname="c1"> + <colspec colname="c2"> + <colspec colname="c3"> + <colspec colname="c4"> + <thead> + <row> + <entry>Name</entry> + <entry>Type</entry> + <entry>Description</entry> + <entry>Default</entry> + </row> + </thead> + <tbody> + <row> + <entry><replaceable>mem_address</replaceable></entry> + <entry>Number</entry> + <entry>Address of data to be written to flash.</entry> + <entry>Address of last loaded file. If not set by a load + operation it must be specified.</entry> + </row> + <row> + <entry><replaceable>length</replaceable></entry> + <entry>Number</entry> + <entry>Length of data to be written.</entry> + <entry>Length of last loaded file.</entry> + </row> + <row> + <entry><replaceable>name</replaceable></entry> + <entry>String</entry> + <entry>Name of file to create.</entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </informaltable> + </refsect1> + <refsect1> + <title>Description</title> +<para>This command is used to write data from memory to a file. If the +file does not exist it will be created. If it does exist, then it will +be overwritten with the new contents.</para> +</refsect1> + + <refsect1> + <title>Examples</title> +<para>Write an area of data to a file +<screen> +RedBoot> <userinput>fs write -b 0x0606f000 -l 0x1000 image</userinput> +RedBoot> <userinput>fs list</userinput> +212416 d--------- 3 size 128 . +212416 d--------- 3 size 128 .. +211392 ---------- 1 size 4096 image +206784 d--------- 2 size 96 tests +RedBoot> +</screen> + </para> + </refsect1> +</refentry> + + </sect1> + + <sect1 id="Persistent-State-Flash"> <title>Persistent State Flash-based Configuration and Control</title> <para><indexterm><primary>persistent state flash-based configuration and control
--- a/packages/redboot/current/include/redboot.h +++ b/packages/redboot/current/include/redboot.h @@ -10,6 +10,7 @@ // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Red Hat, Inc. // Copyright (C) 2002, 2003, 2004, 2005 Gary Thomas +// Copyright (C) 2004, 2005 eCosCentric Limited // // 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 @@ -251,11 +252,14 @@ extern _cmd_entry(_s_,_h_,_u_,_f_,_subs_ static _cmd_entry(_s_,_h_,_u_,_f_,0,0,_n_) // Initialization functions -#define RedBoot_INIT_FIRST 0000 -#define RedBoot_INIT_SECOND 0100 +#define RedBoot_INIT_FIRST 0000 +#define RedBoot_INIT_SECOND 0100 // Specify a 3 digit numeric value for proper prioritizing #define RedBoot_INIT_PRIO(_n_) 1##_n_ -#define RedBoot_INIT_LAST 9999 +#define RedBoot_INIT_BEFORE_NET 6900 +#define RedBoot_INIT_NET 7000 +#define RedBoot_INIT_AFTER_NET 7100 +#define RedBoot_INIT_LAST 9999 typedef void void_fun(void); typedef void_fun *void_fun_ptr; struct init_tab_entry { @@ -312,6 +316,10 @@ externC bool scan_opts(int argc, char *a struct option_info *opts, int num_opts, void *def_arg, int def_arg_type, char *def_descr); +externC int redboot_exec( char *command, ... ); + +externC void err_printf( char *fmt, ... ); + #ifdef CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS #define CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS \ (CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS+CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS)
--- a/packages/redboot/current/src/fs/fileio.c +++ b/packages/redboot/current/src/fs/fileio.c @@ -10,6 +10,7 @@ // 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, 2004 Gary Thomas +// Copyright (C) 2004, 2005, 2006 eCosCentric Limited. // // 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 @@ -34,15 +35,14 @@ // 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 +// Author(s): nickg +// Contributors: dwmw2, msalter +// Date: 2004-11-21 // Purpose: // Description: // @@ -68,45 +68,86 @@ #include <cyg/io/flash.h> #include <cyg/io/config_keys.h> #endif +#include <cyg/io/devtab.h> #include <cyg/fileio/fileio.h> #include <cyg/infra/cyg_ass.h> // assertion macros +//========================================================================== + +// Define table boundaries +CYG_HAL_TABLE_BEGIN( __FS_cmds_TAB__, FS_cmds); +CYG_HAL_TABLE_END( __FS_cmds_TAB_END__, FS_cmds); + +extern struct cmd __FS_cmds_TAB__[], __FS_cmds_TAB_END__; + +//========================================================================== + +static void +fs_usage(char *why) +{ + diag_printf("*** invalid 'fs' command: %s\n", why); + cmd_usage(__FS_cmds_TAB__, &__FS_cmds_TAB_END__, "fs "); +} + + +//========================================================================== + +#define MAX_MOUNTS 4 + +static int mount_count = 0; + +static struct +{ + char dev_str[PATH_MAX]; + char mp_str[PATH_MAX]; + char type_str[PATH_MAX]; +} mounts[MAX_MOUNTS]; + +//========================================================================== + static void do_mount(int argc, char *argv[]); static void do_umount(int argc, char *argv[]); -#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE +#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE_LEGACY #define FLASHPART "[-f <partition>] " #else #define FLASHPART #endif -RedBoot_cmd("mount", - "Mount file system", - FLASHPART "[-d <device>] -t fstype", - do_mount +local_cmd_entry("mount", + "Mount file system", + FLASHPART "[-d <device>] -t <fstype> [<mountpoint>]", + do_mount, + FS_cmds ); -RedBoot_cmd("umount", - "Unmount file system", - "", - do_umount +local_cmd_entry("umount", + "Unmount file system", + "<mountpoint>", + do_umount, + FS_cmds ); -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; + char *dev_str = "<undefined>", *type_str, *mp_str; + bool dev_set = false, type_set = false; struct option_info opts[3]; int err, num_opts = 2; + int i,m=0; /* Set to 0 to silence warning */ +#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE_LEGACY + char *part_str; + bool part_set = false; +#endif 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 +#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE_LEGACY init_opts(&opts[2], 'f', true, OPTION_ARG_TYPE_STR, (void *)&part_str, &part_set, "partition"); num_opts++; @@ -114,24 +155,30 @@ do_mount(int argc, char *argv[]) CYG_ASSERT(num_opts <= NUM_ELEMS(opts), "Too many options"); - if (!scan_opts(argc, argv, 1, opts, num_opts, NULL, 0, NULL)) + if (!scan_opts(argc, argv, 1, opts, num_opts, &mp_str, OPTION_ARG_TYPE_STR, "mountpoint")) return; if (!type_set) { - diag_printf("Must specify file system type\n"); + err_printf("fs mount: Must specify file system type\n"); return; } - if (fileio_mounted) { - diag_printf("A file system is already mounted\n"); + + if( mp_str == 0 ) + mp_str = "/"; + + if( mount_count >= MAX_MOUNTS ) + { + err_printf("fs mount: Maximum number of mounts exceeded\n"); return; } -#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE + +#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE_LEGACY 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"); + err_printf("fs mount: May only set one of <device> or <partition>\n"); return; } @@ -140,78 +187,132 @@ do_mount(int argc, char *argv[]) err = cyg_io_lookup(dev_str, &h); if (err < 0) { - diag_printf("cyg_io_lookup of \"%s\" returned %d\n", err); + err_printf("fs mount: 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", + diag_printf("fs mount: FIS partition \"%s\" not found\n", part_str); return; } } #endif - err = mount(dev_str, "/", type_str); + + for( i = 0; i < MAX_MOUNTS; i++ ) + { + if( mounts[i].mp_str[0] != '\0' ) + { + if( strcmp(mounts[i].dev_str, dev_str ) == 0 ) + { + err_printf("fs mount: Device %s already mounted\n",dev_str); + return; + } + } + else + m = i; + } - if (err) { - diag_printf("Mount failed %d\n", err); - } else { -// diag_printf("Mount %s file system succeeded\n", type_str); - fileio_mounted = 1; -#ifdef CYGBLD_REDBOOT_FILEIO_WITH_LS - chdir("/"); -#endif + strcpy( mounts[m].mp_str, mp_str ); + strcpy( mounts[m].dev_str, dev_str ); + strcpy( mounts[m].type_str, type_str ); + + err = mount(mounts[m].dev_str, mounts[m].mp_str, mounts[m].type_str); + + if (err) + { + err_printf("fs mount: mount(%s,%s,%s) failed %d\n", dev_str, mp_str, type_str, errno); + mounts[m].mp_str[0] = '\0'; // mount failed so don't let it appear mounted + } + else + { + if( mount_count == 0 ) + chdir( "/" ); + mount_count++; } } +//========================================================================== + static void do_umount(int argc, char *argv[]) { - if (!fileio_mounted) { + char *dir_str; + int err; + int i; + + if( mount_count == 0 ) + { + err_printf("fs: No filesystems mounted\n"); + return; + } + + if (!scan_opts(argc, argv, 1, NULL, 0, &dir_str, OPTION_ARG_TYPE_STR, "mountpoint")) + return; + + if( dir_str == 0 ) + dir_str = "/"; + + for( i = 0; i < MAX_MOUNTS; i++ ) + { + if( strcmp(mounts[i].mp_str, dir_str ) == 0 ) + break; + } + + if( i == MAX_MOUNTS ) + { + err_printf("fs unmount: unknown mountpoint %s\n",dir_str); return; } - umount ("/"); - fileio_mounted = 0; + + err = umount (dir_str); + + if (err) + err_printf("fs umount: unmount failed %d\n", errno); + else + { + mounts[i].mp_str[0] = '\0'; + mount_count--; + if( mount_count == 0 ) + chdir( "/" ); + } + } -#ifdef CYGBLD_REDBOOT_FILEIO_WITH_LS +//========================================================================== + #include <dirent.h> static char rwx[8][4] = { "---", "r--", "-w-", "rw-", "--x", "r-x", "-wx", "rwx" }; static void -do_ls(int argc, char * argv[]) +do_list(int argc, char * argv[]) { char * dir_str; - struct option_info opts[1]; - bool dir_set = false; DIR *dirp; + char filename[PATH_MAX]; char cwd[PATH_MAX]; - char filename[PATH_MAX]; struct stat sbuf; int err; - - init_opts(&opts[0], 'd', true, OPTION_ARG_TYPE_STR, - (void *)&dir_str, &dir_set, "directory"); - - if (!fileio_mounted) { - diag_printf("No filesystem mounted\n"); - return; + + if( mount_count == 0 ) + { + err_printf("fs: No filesystems mounted\n"); + return; } - if (!scan_opts(argc, argv, 1, opts, 1, NULL, 0, NULL)) + if (!scan_opts(argc, argv, 1, NULL, 0, &dir_str, OPTION_ARG_TYPE_STR, "directory")) return; - if (!dir_set) { - getcwd(cwd,sizeof(cwd)); - dir_str = cwd; + if( dir_str == 0 ) + { + dir_str = getcwd(cwd, sizeof(cwd)); } - diag_printf("directory %s\n",dir_str); dirp = opendir(dir_str); if (dirp==NULL) { - diag_printf("no such directory %s\n",dir_str); + err_printf("fs list: no such directory %s\n",dir_str); return; } @@ -249,13 +350,350 @@ do_ls(int argc, char * argv[]) return; } -RedBoot_cmd("ls", - "list directory contents", - "[-d directory]", - do_ls +local_cmd_entry("list", + "list directory contents", + "[<directory>]", + do_list, + FS_cmds + ); + + +//========================================================================== + + +static void +do_mkdir(int argc, char * argv[]) +{ + char *dir_str; + int err; + + if( mount_count == 0 ) + { + err_printf("fs: No filesystems mounted\n"); + return; + } + + if (!scan_opts(argc, argv, 1, NULL, 0, &dir_str, OPTION_ARG_TYPE_STR, "directory") || + dir_str == NULL) + { + fs_usage("invalid arguments"); + return; + } + + err = mkdir( dir_str, 0 ); + + if( err != 0 ) + err_printf("fs mkdir: failed to create directory %s\n",dir_str); +} + +local_cmd_entry("mkdir", + "create directory", + "<directory>", + do_mkdir, + FS_cmds + ); + +//========================================================================== + +static void +do_deldir(int argc, char * argv[]) +{ + char *dir_str; + int err; + + if( mount_count == 0 ) + { + err_printf("fs: No filesystems mounted\n"); + return; + } + + if (!scan_opts(argc, argv, 1, NULL, 0, &dir_str, OPTION_ARG_TYPE_STR, "directory") || + dir_str == NULL) + { + fs_usage("invalid arguments"); + return; + } + + err = rmdir( dir_str ); + + if( err != 0 ) + err_printf("fs deldir: failed to remove directory %s\n",dir_str); +} + +local_cmd_entry("deldir", + "delete directory", + "<directory>", + do_deldir, + FS_cmds + ); + +//========================================================================== + +static void +do_del(int argc, char * argv[]) +{ + char *name_str = NULL; + int err; + + if( mount_count == 0 ) + { + err_printf("fs: No filesystems mounted\n"); + return; + } + + if (!scan_opts(argc, argv, 1, NULL, 0, &name_str, OPTION_ARG_TYPE_STR, "file") || + name_str == NULL) + { + fs_usage("invalid arguments"); + return; + } + + err = unlink( name_str ); + + if( err != 0 ) + err_printf("fs del: failed to delete file %s\n",name_str); +} + +local_cmd_entry("del", + "delete file", + "<file>", + do_del, + FS_cmds + ); + +//========================================================================== + +static void +do_move(int argc, char * argv[]) +{ + int err; + __externC int rename( const char *oldname, const char *newname ); + if( mount_count == 0 ) + { + err_printf("fs: No filesystems mounted\n"); + return; + } + + if( argc != 3 ) + fs_usage("bad arguments to move command\n"); + + err = rename( argv[1], argv[2] ); + + if( err != 0 ) + err_printf("fs move: failed to move file %s to %s\n",argv[1],argv[2]); +} + +local_cmd_entry("move", + "move file", + "<from> <to>", + do_move, + FS_cmds ); -#endif // CYGBLD_REDBOOT_FILEIO_WITH_LS +//========================================================================== + +static void +do_cd(int argc, char * argv[]) +{ + char *dir_str; + int err; + + if( mount_count == 0 ) + { + err_printf("fs: No filesystems mounted\n"); + return; + } + + if (!scan_opts(argc, argv, 1, NULL, 0, &dir_str, OPTION_ARG_TYPE_STR, "directory")) + return; + + if( dir_str == NULL ) + dir_str = "/"; + + err = chdir( dir_str ); + + if( err != 0 ) + err_printf("fs cd: failed to change directory %s\n",dir_str); +} + +local_cmd_entry("cd", + "change directory", + "[<directory>]", + do_cd, + FS_cmds + ); + +//========================================================================== + +static void +do_write(int argc, char * argv[]) +{ + char *name_str = NULL; + int err; + struct option_info opts[2]; + CYG_ADDRESS mem_addr = 0; + unsigned long length = 0; + bool mem_addr_set = false; + bool length_set = false; + int fd; + + if( mount_count == 0 ) + { + err_printf("fs: No filesystems mounted\n"); + return; + } + + init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM, + (void *)&mem_addr, (bool *)&mem_addr_set, "memory base address"); + init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM, + (void *)&length, (bool *)&length_set, "image length"); + + if (!scan_opts(argc, argv, 1, opts, 2, &name_str, OPTION_ARG_TYPE_STR, "file name") || + name_str == NULL) + { + fs_usage("invalid arguments"); + return; + } + +// diag_printf("load_address %08x %08x\n",load_address,load_address_end); +// diag_printf("ram %08x %08x\n",ram_start, ram_end); +// diag_printf("file name %08x >%s<\n",name_str,name_str); + + if (!mem_addr_set && + (load_address >= (CYG_ADDRESS)ram_start) && + ((load_address_end) < (CYG_ADDRESS)ram_end)) + { + mem_addr = load_address; + mem_addr_set = true; + if (!length_set) + { + length = load_address_end - load_address; + length_set = true; + // maybe get length from existing file size if no loaded + // image? + } + } + + fd = open( name_str, O_WRONLY|O_CREAT|O_TRUNC ); + + if( fd < 0 ) + { + err_printf("fs write: Cannot open %s\n", name_str ); + return; + } + +// diag_printf("write %08x %08x\n",mem_addr, length ); + + err = write( fd, (void *)mem_addr, length ); + + if( err != length ) + { + err_printf("fs write: failed to write to file %d(%d) %d\n",err,length,errno); + } + + err = close( fd ); + + if( err != 0 ) + err_printf("fs write: close failed\n"); +} + +local_cmd_entry("write", + "write data to file", + "-b <mem_base> -l <image_length> <file_name>", + do_write, + FS_cmds + ); + +//========================================================================== + +__externC cyg_fstab_entry cyg_fstab[]; +__externC cyg_fstab_entry cyg_fstab_end; +__externC cyg_mtab_entry cyg_mtab[]; +__externC cyg_mtab_entry cyg_mtab_end; + +static void +do_info(int argc, char * argv[]) +{ + cyg_bool found = false; + cyg_fstab_entry *f; + cyg_devtab_entry_t *t; + + for( f = &cyg_fstab[0] ; f != &cyg_fstab_end; f++ ) + { + if( !found ) + { + diag_printf("Filesystems available:\n"); + found = true; + } + diag_printf("%s\n",f->name); + } + + found = false; + for (t = &__DEVTAB__[0]; t != &__DEVTAB_END__; t++) + { + if( (t->status & CYG_DEVTAB_STATUS_BLOCK) == 0 || + (t->status & CYG_DEVTAB_STATUS_AVAIL) == 0 ) + continue; + + if( !found ) + { + diag_printf("\nDevices available:\n"); + found = true; + } + diag_printf("%s\n",t->name); + } + + if( mount_count != 0 ) + { + int i; + + diag_printf("\nMounted filesystems:\n"); + diag_printf(" Device Filesystem Mounted on\n"); + + for( i = 0; i < MAX_MOUNTS; i++ ) + { + if( mounts[i].mp_str[0] != '\0' ) + diag_printf("%32s %10s %s\n", mounts[i].dev_str, mounts[i].type_str, mounts[i].mp_str); + } + } +} + +local_cmd_entry("info", + "filesystem info", + "", + do_info, + FS_cmds + ); + +//========================================================================== + +static void +do_fs(int argc, char *argv[]) +{ + struct cmd *cmd; + + if (argc < 2) { + fs_usage("too few arguments"); + return; + } + if ((cmd = cmd_search(__FS_cmds_TAB__, &__FS_cmds_TAB_END__, + argv[1])) != (struct cmd *)0) { + (cmd->fun)(argc-1, argv+1); + return; + } + fs_usage("unrecognized command"); +} + +RedBoot_nested_cmd("fs", + "Manage Filesystem files", + "{cmds}", + do_fs, + __FS_cmds_TAB__, &__FS_cmds_TAB_END__ + ); + + +//========================================================================== + static int fd; externC int @@ -263,13 +701,15 @@ fileio_stream_open(connection_info_t *in { char *filename = info->filename; - if (!fileio_mounted) { - diag_printf("No file system mounted\n"); - return -1; - } + if( mount_count == 0 ) + { + diag_printf("fs: No filesystems mounted\n"); + return -1; + } + fd = open(filename, O_RDONLY); if (fd < 0) { - diag_printf("Open failed, error %d\n", errno); + diag_printf("fs: Open failed, error %d\n", errno); return -1; } return 0; @@ -298,7 +738,7 @@ fileio_error(int err) { static char myerr[10]; - diag_sprintf(myerr, "error %d\n", err); + diag_sprintf(myerr, "error %d", err); return myerr; } @@ -309,3 +749,6 @@ GETC_IO_FUNCS(fileio_io, fileio_stream_o 0, fileio_stream_read, fileio_error); RedBoot_load(file, fileio_io, true, true, 0); +//========================================================================== +// End of fileio.c +
--- a/packages/redboot/current/src/load.c +++ b/packages/redboot/current/src/load.c @@ -10,6 +10,7 @@ // 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, 2004 Gary Thomas +// Copyright (C) 2004 eCosCentric Limited // // 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 @@ -143,7 +144,7 @@ redboot_getc(void) } if (getc_info.avail == 0) { if (getc_info.verbose) { - diag_printf("%c\b", spin[getc_info.tick++]); + err_printf("%c\b", spin[getc_info.tick++]); if (getc_info.tick >= sizeof(spin)) { getc_info.tick = 0; } @@ -212,7 +213,7 @@ redboot_getc_init(connection_info_t *inf res = (funcs->open)(info, &getc_info.err); if (res < 0) { - diag_printf("Can't load '%s': %s\n", info->filename, (funcs->error)(getc_info.err)); + err_printf("Can't load '%s': %s\n", info->filename, (funcs->error)(getc_info.err)); return res; } getc_info.io = funcs; @@ -232,7 +233,7 @@ redboot_getc_init(connection_info_t *inf getc_info.fun = _decompress_stream; getc_info.err = (*_dc_init)(p); if (0 != getc_info.err && p->msg) { - diag_printf("open decompression error: %s\n", p->msg); + err_printf("open decompression error: %s\n", p->msg); } } #endif @@ -313,7 +314,7 @@ load_elf_image(getc_t getc, unsigned lon // Read the header if (_read(getc, (unsigned char *)&ehdr, sizeof(ehdr)) != sizeof(ehdr)) { - diag_printf("Can't read ELF header\n"); + err_printf("Can't read ELF header\n"); redboot_getc_terminate(true); return 0; } @@ -325,18 +326,18 @@ load_elf_image(getc_t getc, unsigned lon ehdr.e_shoff, ehdr.e_shentsize, ehdr.e_shnum); #endif if (ehdr.e_type != ET_EXEC) { - diag_printf("Only absolute ELF images supported\n"); + err_printf("Only absolute ELF images supported\n"); redboot_getc_terminate(true); return 0; } if (ehdr.e_phnum > MAX_PHDR) { - diag_printf("Too many program headers\n"); + err_printf("Too many program headers\n"); redboot_getc_terminate(true); return 0; } while (offset < ehdr.e_phoff) { if ((*getc)() < 0) { - diag_printf(SHORT_DATA); + err_printf(SHORT_DATA); redboot_getc_terminate(true); return 0; } @@ -344,7 +345,7 @@ load_elf_image(getc_t getc, unsigned lon } for (phx = 0; phx < ehdr.e_phnum; phx++) { if (_read(getc, (unsigned char *)&phdr[phx], sizeof(phdr[0])) != sizeof(phdr[0])) { - diag_printf("Can't read ELF program header\n"); + err_printf("Can't read ELF program header\n"); redboot_getc_terminate(true); return 0; } @@ -387,7 +388,7 @@ load_elf_image(getc_t getc, unsigned lon addr += addr_offset; if (offset > phdr[phx].p_offset) { if ((phdr[phx].p_offset + len) < offset) { - diag_printf("Can't load ELF file - program headers out of order\n"); + err_printf("Can't load ELF file - program headers out of order\n"); redboot_getc_terminate(true); return 0; } @@ -395,7 +396,7 @@ load_elf_image(getc_t getc, unsigned lon } else { while (offset < phdr[phx].p_offset) { if ((*getc)() < 0) { - diag_printf(SHORT_DATA); + err_printf(SHORT_DATA); redboot_getc_terminate(true); return 0; } @@ -412,12 +413,12 @@ load_elf_image(getc_t getc, unsigned lon #endif )) { redboot_getc_terminate(true); - diag_printf("*** Abort! Attempt to load ELF data to address: %p which is not valid\n", (void*)addr); + err_printf("*** Abort! Attempt to load ELF data to address: %p which is not valid\n", (void*)addr); return 0; } #endif if ((ch = (*getc)()) < 0) { - diag_printf(SHORT_DATA); + err_printf(SHORT_DATA); redboot_getc_terminate(true); return 0; } @@ -458,7 +459,7 @@ load_elf_image(getc_t getc, unsigned lon (void*)entry_address, (void *)load_address, (void *)load_address_end); return 1; #else // CYGSEM_REDBOOT_ELF - diag_printf("Loading ELF images not supported\n"); + err_printf("Loading ELF images not supported\n"); return 0; #endif // CYGSEM_REDBOOT_ELF } @@ -516,7 +517,7 @@ load_srec_image(getc_t getc, unsigned lo // Start of line if (c != 'S') { redboot_getc_terminate(true); - diag_printf("Invalid S-record at offset %p, input: %c\n", + err_printf("Invalid S-record at offset %p, input: %c\n", (void *)offset, c); return 0; } @@ -525,7 +526,7 @@ load_srec_image(getc_t getc, unsigned lo sum = 0; if ((count = _hex2(getc, 1, &sum)) < 0) { redboot_getc_terminate(true); - diag_printf("Bad S-record count at offset %p\n", (void *)offset); + err_printf("Bad S-record count at offset %p\n", (void *)offset); return 0; } offset += 1; @@ -558,7 +559,7 @@ load_srec_image(getc_t getc, unsigned lo // Only if there is no need to stop the download before printing // output can we ask confirmation questions. redboot_getc_terminate(true); - diag_printf("*** Abort! Attempt to load S-record to address: %p, which is not valid\n",(void*)addr); + err_printf("*** Abort! Attempt to load S-record to address: %p, which is not valid\n",(void*)addr); return 0; } #endif @@ -582,7 +583,7 @@ load_srec_image(getc_t getc, unsigned lo cksum = (~cksum & 0xFF); if (cksum != sum) { redboot_getc_terminate(true); - diag_printf("*** Warning! Checksum failure - Addr: %lx, %02lX <> %02lX\n", + err_printf("*** Warning! Checksum failure - Addr: %lx, %02lX <> %02lX\n", (unsigned long)base_addr, sum, cksum); return 0; } @@ -613,7 +614,7 @@ load_srec_image(getc_t getc, unsigned lo return load_address_end; default: redboot_getc_terminate(true); - diag_printf("Invalid S-record at offset 0x%lx, type: %x\n", + err_printf("Invalid S-record at offset 0x%lx, type: %x\n", (unsigned long)offset, type); return 0; } @@ -719,12 +720,12 @@ do_load(int argc, char *argv[]) if (hostname_set) { ip_route_t rt; if (!_gethostbyname(hostname, (in_addr_t *)&host)) { - diag_printf("Invalid host: %s\n", hostname); + err_printf("Invalid host: %s\n", hostname); return; } /* check that the host can be accessed */ if (__arp_lookup((ip_addr_t *)&host.sin_addr, &rt) < 0) { - diag_printf("Unable to reach host %s (%s)\n", + err_printf("Unable to reach host %s (%s)\n", hostname, inet_ntoa((in_addr_t *)&host)); return; } @@ -733,7 +734,7 @@ do_load(int argc, char *argv[]) host.sin_port = port; #endif if (chan >= CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS) { - diag_printf("Invalid I/O channel: %d\n", chan); + err_printf("Invalid I/O channel: %d\n", chan); return; } if (mode_str_set) { @@ -750,7 +751,7 @@ do_load(int argc, char *argv[]) io_tab != &__RedBoot_LOAD_TAB_END__; io_tab++) { diag_printf(" %s", io_tab->name); } - diag_printf("\n"); + err_printf("\n"); } if (!io) { return; @@ -758,7 +759,7 @@ do_load(int argc, char *argv[]) verbose &= io_tab->can_verbose; if (io_tab->need_filename && !filename) { diag_printf("File name required\n"); - diag_printf("usage: load %s\n", usage); + err_printf("usage: load %s\n", usage); return; } } else { @@ -773,7 +774,7 @@ do_load(int argc, char *argv[]) io = &http_io; #endif #endif -#ifdef CYGPKG_REDBOOT_FILEIO +#if 0 //def CYGPKG_REDBOOT_FILEIO // Make file I/O default if mounted if (fileio_mounted) { which = "file"; @@ -786,7 +787,7 @@ do_load(int argc, char *argv[]) io = &xyzModem_io; verbose = false; #else - diag_printf("No default protocol!\n"); + err_printf("No default protocol!\n"); return; #endif } @@ -811,7 +812,7 @@ do_load(int argc, char *argv[]) || flash_addr_set #endif )) { - diag_printf("Raw load requires a memory address\n"); + err_printf("Raw load requires a memory address\n"); return; } info.filename = filename; @@ -839,7 +840,7 @@ do_load(int argc, char *argv[]) // before printing output can we ask confirmation // questions. redboot_getc_terminate(true); - diag_printf("*** Abort! RAW data spills over limit of FLASH at %p\n",(void*)mp); + err_printf("*** Abort! RAW data spills over limit of FLASH at %p\n",(void*)mp); err = -1; break; } @@ -849,7 +850,7 @@ do_load(int argc, char *argv[]) // before printing output can we ask confirmation // questions. redboot_getc_terminate(true); - diag_printf("*** Abort! RAW data spills over limit of user RAM at %p\n",(void*)mp); + err_printf("*** Abort! RAW data spills over limit of user RAM at %p\n",(void*)mp); err = -1; break; } @@ -893,7 +894,7 @@ do_load(int argc, char *argv[]) end = load_srec_image(redboot_getc, base); } else { redboot_getc_terminate(true); - diag_printf("Unrecognized image type: 0x%lx\n", *(unsigned long *)type); + err_printf("Unrecognized image type: 0x%lx\n", *(unsigned long *)type); } } }
--- a/packages/redboot/current/src/main.c +++ b/packages/redboot/current/src/main.c @@ -10,6 +10,7 @@ // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc. // Copyright (C) 2002, 2003, 2004 Gary Thomas +// Copyright (C) 2003, 2004, 2005, 2006 eCosCentric Limited // // 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 @@ -33,16 +34,13 @@ // // 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): gthomas -// Contributors: gthomas, tkoeller +// Contributors: gthomas, tkoeller, eCosCentric // Date: 2000-07-14 // Purpose: // Description: @@ -178,7 +176,8 @@ do_version(int argc, char *argv[]) #ifdef HAL_PLATFORM_CPU diag_printf("Platform: %s (%s) %s\n", HAL_PLATFORM_BOARD, HAL_PLATFORM_CPU, HAL_PLATFORM_EXTRA); #endif - diag_printf("Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.\n\n"); + diag_printf("Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.\n"); + diag_printf("Copyright (C) 2003, 2004, 2005, 2006 eCosCentric Limited\n\n"); diag_printf("RAM: %p-%p, ", (void*)ram_start, (void*)ram_end); diag_printf("[%p-%p]", mem_segments[0].start, mem_segments[0].end); diag_printf(" available\n"); @@ -227,14 +226,13 @@ static void // static hal_jmp_buf error_jmpbuf; #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS -externC -#endif - void* volatile __mem_fault_handler; +__externC void* volatile __mem_fault_handler; static void error_handler(void) { hal_longjmp(error_jmpbuf, 1); } +#endif // @@ -274,7 +272,6 @@ cyg_start(void) console_selected = false; #endif console_echo = true; - CYGACC_CALL_IF_DELAY_US((cyg_int32)2*100000); ram_start = (unsigned char *)CYGMEM_REGION_ram; ram_end = (unsigned char *)(CYGMEM_REGION_ram+CYGMEM_REGION_ram_SIZE); @@ -422,13 +419,17 @@ cyg_start(void) while (strlen(command) > 0) { if ((cmd = parse(&command, &argc, &argv[0])) != (struct cmd *)0) { // Try to handle aborts - messy because of the stack unwinding... +#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS __mem_fault_handler = error_handler; +#endif if (hal_setjmp(error_jmpbuf)) { diag_printf("** command abort - illegal memory access?\n"); } else { (cmd->fun)(argc, argv); } +#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS __mem_fault_handler = 0; +#endif } else { diag_printf("** Error: Illegal command: \"%s\"\n", argv[0]); } @@ -527,7 +528,9 @@ do_go(int argc, char *argv[]) char line[8]; hal_virtual_comm_table_t *__chan; +#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS __mem_fault_handler = 0; // Let GDB handle any faults directly +#endif entry = entry_address; // Default from last 'load' operation init_opts(&opts[0], 'w', true, OPTION_ARG_TYPE_NUM, (void *)&wait_time, (bool *)&wait_time_set, "wait timeout"); @@ -547,7 +550,7 @@ do_go(int argc, char *argv[]) return; } if (entry == (unsigned long)NO_MEMORY) { - diag_printf("No entry point known - aborted\n"); + err_printf("No entry point known - aborted\n"); return; } if (wait_time_set) {
--- a/packages/redboot/current/src/net/net_io.c +++ b/packages/redboot/current/src/net/net_io.c @@ -594,7 +594,7 @@ RedBoot_idle(net_io_test, RedBoot_IDLE_N CYG_HAL_TABLE_BEGIN( __NETDEVTAB__, netdev ); CYG_HAL_TABLE_END( __NETDEVTAB_END__, netdev ); -RedBoot_init(net_init, RedBoot_INIT_LAST); +RedBoot_init(net_init, RedBoot_INIT_NET); static void show_addrs(void)
--- a/packages/redboot/current/src/parse.c +++ b/packages/redboot/current/src/parse.c @@ -9,6 +9,7 @@ // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 2004, 2005, 2006 eCosCentric Limited // // 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 @@ -32,16 +33,13 @@ // // 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): gthomas -// Contributors: gthomas +// Contributors: gthomas, eCosCentric // Date: 2000-07-14 // Purpose: // Description: @@ -193,6 +191,97 @@ cmd_usage(struct cmd *tab, struct cmd *t } } +// +// Handle illegal memory accesses (and other abort conditions) +// +static hal_jmp_buf error_jmpbuf; +static cyg_bool redboot_exec_call = false; +#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS +__externC void* volatile __mem_fault_handler; + +static void error_handler(void) +{ + hal_longjmp(error_jmpbuf, 1); +} +#endif + +// Routine to allow code to invoke RedBoot commands. This is useful +// during initialization and in platform specific code. +// +// Call it like this: +// +// result = redboot_exec( "load", "-m", "file", "foo", 0 ); +// +// Note the terminating zero. The result will be zero if the command +// succeeded, and <0 if something went wrong. + +#define ARGV_MAX 20 +int redboot_exec( char *command, ... ) +{ + int argc; + char *argv[ARGV_MAX+1]; + va_list ap; + struct cmd *cmd; + int result = 0; + + va_start(ap, command); + + argv[0] = command; + for( argc = 1; argc < ARGV_MAX; argc++ ) + { + char *arg = va_arg(ap, char *); + if( arg == 0 ) + break; + argv[argc] = arg; + } + argv[argc] = NULL; + + if(( cmd = cmd_search(__RedBoot_CMD_TAB__, &__RedBoot_CMD_TAB_END__, command) )) + { + // Try to handle aborts - messy because of the stack unwinding... +#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS + __mem_fault_handler = error_handler; +#endif + redboot_exec_call = true; + if (hal_setjmp(error_jmpbuf)) + result = -1; + else + (cmd->fun)(argc, argv); + + redboot_exec_call = false; +#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS + __mem_fault_handler = 0; +#endif + } + else + result = -1; + + va_end(ap); + + return result; +} + +externC void err_printf( char *fmt, ... ) +{ + va_list ap; + + va_start(ap, fmt); + + diag_vprintf( fmt, ap ); + + va_end(ap); + + // If we are not in redboot_exec() just return as usual. If we are + // inside a call to redboot_exec(), longjump out to terminate the command. + + if( redboot_exec_call ) + { + diag_printf("err_printf: aborting command\n"); + hal_longjmp(error_jmpbuf, 1); + } +} + + // Option processing // Initialize option table entry (required because these entries
