This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
RedBoot - Improve download default modes & error handling
- From: Gary Thomas <gary at mlbassoc dot com>
- To: eCos patches <ecos-patches at sources dot redhat dot com>
- Date: 03 Apr 2003 08:21:49 -0700
- Subject: RedBoot - Improve download default modes & error handling
Index: redboot/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/ChangeLog,v
retrieving revision 1.99
diff -u -5 -p -r1.99 ChangeLog
--- redboot/current/ChangeLog 28 Mar 2003 13:49:32 -0000 1.99
+++ redboot/current/ChangeLog 3 Apr 2003 15:17:48 -0000
@@ -1,5 +1,13 @@
+2003-04-03 Gary Thomas <gary at mlbassoc dot com>
+
+ * src/load.c: Better handling of default download mode. Also
+ display information when I/O errors occor (was silent).
+
+ * src/net/http_client.c:
+ * include/net/http.h: Improve parsing of HTTP responses for errors.
+
2003-03-28 Gary Thomas <gary at mlbassoc dot com> inspired by
2003-03-28 Jani Monoses <jani at iv dot ro>
* src/load.c:
* cdl/redboot.cdl: Make TFTP download protocol optional.
Index: redboot/current/include/net/http.h
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/include/net/http.h,v
retrieving revision 1.2
diff -u -5 -p -r1.2 http.h
--- redboot/current/include/net/http.h 1 Jul 2002 20:55:28 -0000 1.2
+++ redboot/current/include/net/http.h 3 Apr 2003 15:11:34 -0000
@@ -7,11 +7,11 @@
//==========================================================================
//####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 Gary Thomas
+// 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.
//
@@ -63,8 +63,10 @@ extern char *http_error(int err);
#define HTTP_NOERR 0 // No error
#define HTTP_BADHDR 1 // Invalid HTTP header (response)
#define HTTP_OPEN 2 // Problems opening connection
#define HTTP_IO 3 // Misc I/O problems
+#define HTTP_BADREQ 4 // Bad request
+#define HTTP_NOFILE 5 // No such file
extern getc_io_funcs_t http_io;
#endif // _HTTP_H_
Index: redboot/current/src/load.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/src/load.c,v
retrieving revision 1.30
diff -u -5 -p -r1.30 load.c
--- redboot/current/src/load.c 28 Mar 2003 13:49:32 -0000 1.30
+++ redboot/current/src/load.c 3 Apr 2003 15:15:55 -0000
@@ -138,10 +138,13 @@ redboot_getc(void)
return -1;
}
getc_info.bufp = getc_info.buf;
getc_info.len = (*getc_info.fun)(getc_info.bufp, BUF_SIZE, &getc_info.err);
if ((getc_info.avail = getc_info.len) <= 0) {
+ if (getc_info.len < 0) {
+ diag_printf("I/O error: %s\n", (getc_info.io->error)(getc_info.err));
+ }
if (getc_info.verbose) diag_printf("\n");
return -1;
}
}
getc_info.avail--;
@@ -588,11 +591,11 @@ do_load(int argc, char *argv[])
unsigned long end = 0;
char type[4];
char *filename = 0;
struct option_info opts[7];
connection_info_t info;
- getc_io_funcs_t *io;
+ getc_io_funcs_t *io = NULL;
struct load_io_entry *io_tab;
#ifdef CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS
bool spillover_ok = false;
#endif
@@ -651,11 +654,10 @@ do_load(int argc, char *argv[])
if (chan >= CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS) {
diag_printf("Invalid I/O channel: %d\n", chan);
return;
}
if (mode_str_set) {
- io = (getc_io_funcs_t *)NULL;
for (io_tab = __RedBoot_LOAD_TAB__;
io_tab != &__RedBoot_LOAD_TAB_END__; io_tab++) {
if (strncasecmp(&mode_str[0], io_tab->name, strlen(&mode_str[0])) == 0) {
io = io_tab->funcs;
break;
@@ -677,24 +679,27 @@ do_load(int argc, char *argv[])
diag_printf("File name required\n");
diag_printf("usage: load %s\n", usage);
return;
}
} else {
+ char *which;
io_tab = (struct load_io_entry *)NULL; // Default
#ifdef CYGPKG_REDBOOT_NETWORKING
-#ifdef CYGSEM_REDBOOT_NET_TFTP_DOWNLOAD
+#ifdef CYGSEM_REDBOOT_NET_TFTP_DOWNLOAD
+ which = "TFTP";
io = &tftp_io;
-#elif CYGSEM_REDBOOT_NET_HTTP_DOWNLOAD
+#else if defined(CYGSEM_REDBOOT_NET_HTTP_DOWNLOAD)
+ which = "HTTP";
io = &http_io;
-#else
- io = &xyzModem_io;
- verbose = false;
-#endif
-#else
- io = &xyzModem_io;
- verbose = false;
#endif
+#endif
+ if (!io) {
+ which = "Xmodem";
+ io = &xyzModem_io;
+ verbose = false;
+ }
+ diag_printf("Using default protocol (%s)\n", which);
}
#ifdef CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS
if (base_addr_set &&
((base < (unsigned long)user_ram_start) ||
(base > (unsigned long)user_ram_end))) {
Index: redboot/current/src/net/http_client.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/src/net/http_client.c,v
retrieving revision 1.5
diff -u -5 -p -r1.5 http_client.c
--- redboot/current/src/net/http_client.c 16 Aug 2002 23:59:47 -0000 1.5
+++ redboot/current/src/net/http_client.c 3 Apr 2003 15:11:34 -0000
@@ -7,11 +7,11 @@
//==========================================================================
//####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 Gary Thomas
+// 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.
//
@@ -171,11 +171,21 @@ http_stream_read(char *buf,
while ((s->avail > 0) && (*s->bufp == ' ')) {
s->bufp++;
s->avail--;
}
if (strncmp(s->bufp, "OK", 2)) {
- *err = HTTP_BADHDR;
+ switch (code) {
+ case 400:
+ *err = HTTP_BADREQ;
+ break;
+ case 404:
+ *err = HTTP_NOFILE;
+ break;
+ default:
+ *err = HTTP_BADHDR;
+ break;
+ }
return -1;
}
// Find \r\n\r\n - end of HTTP preamble
while (s->avail > 4) {
// This could be done faster, but not simpler
@@ -222,10 +232,14 @@ http_error(int err)
switch (err) {
case HTTP_NOERR:
return "";
case HTTP_BADHDR:
return "Unrecognized HTTP response";
+ case HTTP_BADREQ:
+ return "Bad HTTP request (check file name)";
+ case HTTP_NOFILE:
+ return "No such file";
case HTTP_OPEN:
return "Can't connect to host";
case HTTP_IO:
return "I/O error";
}
--
------------------------------------------------------------
Gary Thomas |
MLB Associates | Consulting for the
+1 (970) 229-1963 | Embedded world
http://www.mlbassoc.com/ |
email: <gary at mlbassoc dot com> |
gpg: http://www.chez-thomas.org/gary/gpg_key.asc
------------------------------------------------------------