From 85ec0bcc1bc40a67368461fee0435d79305168b1 Mon Sep 17 00:00:00 2001 From: wdenk Date: Mon, 31 Mar 2003 16:34:49 +0000 Subject: * Patch by Arun Dharankar, 24 Mar 2003: - add threads / scheduler example code * Add patches by Robert Schwebel, 31 Mar 2003: - add ctrl-c support for kermit download - align bdinfo output on ARM * Add CPU ID, version, and clock speed for INCA-IP --- common/cmd_boot.c | 19 +++++++++++++++---- common/cmd_nand.c | 24 +++++++++++++++++++----- 2 files changed, 34 insertions(+), 9 deletions(-) (limited to 'common') diff --git a/common/cmd_boot.c b/common/cmd_boot.c index 1c9a41d8e..59bab35df 100644 --- a/common/cmd_boot.c +++ b/common/cmd_boot.c @@ -163,10 +163,10 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); } printf ("\n" - "ip_addr = "); + "ip_addr = "); print_IPaddr (bd->bi_ip_addr); printf ("\n" - "baudrate = %d bps\n", bd->bi_baudrate); + "baudrate = %d bps\n", bd->bi_baudrate); return 0; } @@ -575,6 +575,7 @@ write_record (char *buf) #define XON_CHAR 17 #define XOFF_CHAR 19 #define START_CHAR 0x01 +#define ETX_CHAR 0x03 #define END_CHAR 0x0D #define SPACE 0x20 #define K_ESCAPE 0x23 @@ -995,8 +996,18 @@ static int k_recv (void) #endif /* get a packet */ - /* wait for the starting character */ - while (serial_getc () != START_CHAR); + /* wait for the starting character or ^C */ + for (;;) { + switch (serial_getc ()) { + case START_CHAR: /* start packet */ + break; + case ETX_CHAR: /* ^C waiting for packet */ + return (0); + default: + ; + } + } + /* get length of packet */ sum = 0; new_char = serial_getc (); diff --git a/common/cmd_nand.c b/common/cmd_nand.c index e9331200f..a041b29c2 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -1266,6 +1266,7 @@ static int nand_erase(struct nand_chip* nand, size_t ofs, size_t len) { unsigned long nandptr; struct Nand *mychip; + int ret = 0; if (ofs & (nand->erasesize-1) || len & (nand->erasesize-1)) { printf ("Offset and size must be sector aligned, erasesize = %d\n", @@ -1275,6 +1276,17 @@ static int nand_erase(struct nand_chip* nand, size_t ofs, size_t len) nandptr = nand->IO_ADDR; + /* Select the NAND device */ + NAND_ENABLE_CE(nand); /* set pin low */ + + /* Check the WP bit */ + NanD_Command(nand, NAND_CMD_STATUS); + if (!(READ_NAND(nand->IO_ADDR) & 0x80)) { + printf ("nand_write_ecc: Device is write protected!!!\n"); + ret = -1; + goto out; + } + /* FIXME: Do nand in the background. Use timers or schedule_task() */ while(len) { mychip = &nand->chips[shr(ofs, nand->chipshift)]; @@ -1288,20 +1300,22 @@ static int nand_erase(struct nand_chip* nand, size_t ofs, size_t len) if (READ_NAND(nandptr) & 1) { printf("Error erasing at 0x%lx\n", (long)ofs); /* There was an error */ - goto callback; + ret = -1; + goto out; } ofs += nand->erasesize; len -= nand->erasesize; } - callback: - return 0; +out: + /* De-select the NAND device */ + NAND_DISABLE_CE(nand); /* set pin high */ + + return ret; } static inline int nandcheck(unsigned long potential, unsigned long physadr) { - - return 0; } -- cgit v1.2.3