X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=common%2Fcmd_load.c;h=f63b8e805617517d3912a41f3649e37b3c453a19;hb=c76f951a747cfb87ba826ef45b5aea82d5b5dbb4;hp=31fef8151b76da3b5750a24c26cf6dc017c856bc;hpb=534ff676a9c2ffd460e096754894e78551e4ed1e;p=u-boot diff --git a/common/cmd_load.c b/common/cmd_load.c index 31fef8151b..f63b8e8056 100644 --- a/common/cmd_load.c +++ b/common/cmd_load.c @@ -33,9 +33,12 @@ DECLARE_GLOBAL_DATA_PTR; +#if (CONFIG_COMMANDS & CFG_CMD_LOADB) +static ulong load_serial_ymodem (ulong offset); +#endif + #if (CONFIG_COMMANDS & CFG_CMD_LOADS) static ulong load_serial (ulong offset); -static ulong load_serial_ymodem (ulong offset); static int read_record (char *buf, ulong len); # if (CONFIG_COMMANDS & CFG_CMD_SAVES) static int save_serial (ulong offset, ulong size); @@ -973,7 +976,7 @@ START: } static int getcxmodem(void) { - if (tstc()) + if (tstc()) return (getc()); return -1; } @@ -984,49 +987,51 @@ static ulong load_serial_ymodem (ulong offset) int err; int res; connection_info_t info; - char ymodemBuf[1024]; - ulong store_addr = ~0; - ulong addr = 0; + char ymodemBuf[1024]; + ulong store_addr = ~0; + ulong addr = 0; - size=0; - info.mode=xyzModem_ymodem; - res=xyzModem_stream_open(&info, &err); + size = 0; + info.mode = xyzModem_ymodem; + res = xyzModem_stream_open (&info, &err); if (!res) { - - while ((res=xyzModem_stream_read(ymodemBuf, 1024, &err)) > 0 ){ - store_addr = addr + offset; - size+=res; - addr+=res; -#ifndef CFG_NO_FLASH - if (addr2info(store_addr)) { - int rc; - rc = flash_write((char *)ymodemBuf,store_addr,res); - if (rc != 0) { - flash_perror (rc); - return (~0); - } - } else + while ((res = + xyzModem_stream_read (ymodemBuf, 1024, &err)) > 0) { + store_addr = addr + offset; + size += res; + addr += res; +#ifndef CFG_NO_FLASH + if (addr2info (store_addr)) { + int rc; + + rc = flash_write ((char *) ymodemBuf, + store_addr, res); + if (rc != 0) { + flash_perror (rc); + return (~0); + } + } else #endif - { - memcpy ((char *)(store_addr), ymodemBuf, res); - } - - } - } - else { - printf ("%s\n",xyzModem_error(err)); + { + memcpy ((char *) (store_addr), ymodemBuf, + res); + } + + } + } else { + printf ("%s\n", xyzModem_error (err)); } - - xyzModem_stream_close(&err); - xyzModem_stream_terminate(false,&getcxmodem); + + xyzModem_stream_close (&err); + xyzModem_stream_terminate (false, &getcxmodem); flush_cache (offset, size); - printf("## Total Size = 0x%08x = %d Bytes\n", size, size); - sprintf(buf, "%X", size); - setenv("filesize", buf); + printf ("## Total Size = 0x%08x = %d Bytes\n", size, size); + sprintf (buf, "%X", size); + setenv ("filesize", buf); return offset; }