]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
* Add support for ymodem protocol download
authorWolfgang Denk <wd@pollux.denx.de>
Sat, 1 Apr 2006 13:52:46 +0000 (15:52 +0200)
committerWolfgang Denk <wd@pollux.denx.de>
Sat, 1 Apr 2006 13:52:46 +0000 (15:52 +0200)
  Patch by Stefano Babic, 29 Mar 2006

* Memory Map Update for Delta board: U-Boot is at 0x80000000-0x84000000

Merge with /home/mk/8-benq/u-boot

1  2 
CHANGELOG
board/delta/delta.c
common/cmd_load.c

diff --combined CHANGELOG
index a1b52502abbc93d8bdc2975e448cec13bf34ccc5,34b8d20ebb68835cd9cc2589a8ad60d56e8a29c3..fdb6aae5e5f478405be348692e9ef004562f42c5
+++ b/CHANGELOG
@@@ -2,19 -2,6 +2,25 @@@
  Changes since U-Boot 1.1.4:
  ======================================================================
  
++* Add support for ymodem protocol download
++  Patch by Stefano Babic, 29 Mar 2006
++
++* Memory Map Update for Delta board: U-Boot is at 0x80000000-0x84000000
++  Merge from Markus Klotzbücher's repo, 01 Apr 2006
++
 +* GCC-4.x fixes: clean up global data pointer initialization for all
 +  boards
 +
 +* Update for Delta board:
 +  - redundant NAND environment
 +  - misc Monahans cleanups (remove dead code etc.)
 +  - DA9030 Initialization; some minimal changes to PXA I2C driver to
 +    make it work with the Monahans.
 +  - Make Monahans clock frequency configurable using
 +    CFG_MONAHANS_RUN_MODE_OSC_RATIO and
 +    CFG_MONAHANS_TURBO_RUN_MODE_RATIO.
 +  Merge from Markus Klotzbücher's repo, 25 Mar 2006
 +
  * Enable Quad UART om MCC200 board.
  
  * Cleanup MCC200 board configuration; omit non-existent stuff.
diff --combined board/delta/delta.c
index 2b7238674258839bf8a03574e5a860cf76070458,d00d72d8db48098b1a4d1b2f6d666454737a6819..b7671dd3b70420a5720ad6da9ac2c1704f0d92d7
@@@ -30,8 -30,6 +30,8 @@@
  #include <da9030.h>
  #include <asm/arch/pxa-regs.h>
  
 +DECLARE_GLOBAL_DATA_PTR;
 +
  /* ------------------------------------------------------------------------- */
  
  static void init_DA9030(void);
@@@ -42,6 -40,8 +42,6 @@@
  
  int board_init (void)
  {
 -      DECLARE_GLOBAL_DATA_PTR;
 -
        /* memory and cpu-speed are setup before relocation */
        /* so we do _nothing_ here */
  
@@@ -65,6 -65,8 +65,6 @@@ int board_late_init(void
  
  int dram_init (void)
  {
 -      DECLARE_GLOBAL_DATA_PTR;
 -
        gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
        gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
        gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
        return 0;
  }
  
- /* initialize the DA9030 Power Controller */
- static void init_DA9030()
+ void i2c_init_board()
  {
-       uchar addr = (uchar) DA9030_I2C_ADDR, val = 0;
+       CKENB |= (CKENB_4_I2C);
  
        /* setup I2C GPIO's */
        GPIO32 = 0x801;         /* SCL = Alt. Fkt. 1 */
        GPIO33 = 0x801;         /* SDA = Alt. Fkt. 1 */
+ }
  
-       /* rising Edge on EXTON */
-       GPIO17 = 0x8800;
-       udelay(5);
-       GPIO17 = 0xc800;
-       udelay(100000);         /* wait for DA9030 */
+ /* initialize the DA9030 Power Controller */
+ static void init_DA9030()
+ {
+       uchar addr = (uchar) DA9030_I2C_ADDR, val = 0;
+       CKENB |= CKENB_7_GPIO;
+       udelay(100);
+       /* Rising Edge on EXTON to reset DA9030 */
+       GPIO17 = 0x8800;        /* configure GPIO17, no pullup, -down */
+       GPDR0 |= (1<<17);       /* GPIO17 is output */
+       GSDR0 = (1<<17);
+       GPCR0 = (1<<17);        /* drive GPIO17 low */
+       GPSR0 = (1<<17);        /* drive GPIO17 high */
+ #if CFG_DA9030_EXTON_DELAY
+       udelay((unsigned long) CFG_DA9030_EXTON_DELAY); /* wait for DA9030 */
+ #endif
+       GPCR0 = (1<<17);        /* drive GPIO17 low */
  
        /* reset the watchdog and go active (0xec) */
        val = (SYS_CONTROL_A_HWRES_ENABLE |
               (0x6<<4) |
               SYS_CONTROL_A_WDOG_ACTION |
               SYS_CONTROL_A_WATCHDOG);
-       i2c_reg_write(addr, SYS_CONTROL_A, val);
+       if(i2c_write(addr, SYS_CONTROL_A, 1, &val, 1)) {
+               printf("Error accessing DA9030 via i2c.\n");
+               return;
+       }
  
        i2c_reg_write(addr, REG_CONTROL_1_97, 0xfd); /* disable LDO1, enable LDO6 */
        i2c_reg_write(addr, LDO2_3, 0xd1);      /* LDO2 =1,9V, LDO3=3,1V */
        i2c_reg_write(addr, LDO4_5, 0xcc);      /* LDO2 =1,9V, LDO3=3,1V */
-       i2c_reg_write(addr, LDO6_SIMCP, 0x3e);  /* LDO6=3,2V, SIMCP = 5V support */
+       i2c_reg_write(addr, LDO6_SIMCP, 0x3e);  /* LDO6=3,2V, SIMCP = 5V support */
        i2c_reg_write(addr, LDO7_8, 0xc9);      /* LDO7=2,7V, LDO8=3,0V */
        i2c_reg_write(addr, LDO9_12, 0xec);     /* LDO9=3,0V, LDO12=3,2V */
-       i2c_reg_write(addr, BUCK, 0x0c);        /* Buck=1.2V */
+       i2c_reg_write(addr, BUCK, 0x0c);        /* Buck=1.2V */
        i2c_reg_write(addr, REG_CONTROL_2_98, 0x7f); /* All LDO'S on 8,9,10,11,12,14 */
-       i2c_reg_write(addr, LDO_10_11, 0xcc);   /* LDO10=3.0V  LDO11=3.0V */
+       i2c_reg_write(addr, LDO_10_11, 0xcc);   /* LDO10=3.0V  LDO11=3.0V */
        i2c_reg_write(addr, LDO_15, 0xae);      /* LDO15=1.8V, dislock first 3bit */
-       i2c_reg_write(addr, LDO_14_16, 0x05);   /* LDO14=2.8V, LDO16=NB */
+       i2c_reg_write(addr, LDO_14_16, 0x05);   /* LDO14=2.8V, LDO16=NB */
        i2c_reg_write(addr, LDO_18_19, 0x9c);   /* LDO18=3.0V, LDO19=2.7V */
        i2c_reg_write(addr, LDO_17_SIMCP0, 0x2c); /* LDO17=3.0V, SIMCP=3V support */
        i2c_reg_write(addr, BUCK2_DVC1, 0x9a);  /* Buck2=1.5V plus Update support of 520 MHz */
diff --combined common/cmd_load.c
index b18709a47f594bedabe827c104c88791250a33d6,54460cdcc3386ef2ff2a0eed7ef0bc419eaa7603..31fef8151b76da3b5750a24c26cf6dc017c856bc
  #include <s_record.h>
  #include <net.h>
  #include <exports.h>
+ #include <xyzModem.h>
  
 +DECLARE_GLOBAL_DATA_PTR;
 +
  #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);
@@@ -54,6 -54,7 +56,6 @@@ int do_load_serial (cmd_tbl_t *cmdtp, i
        char *env_echo;
        int rcode = 0;
  #ifdef        CFG_LOADS_BAUD_CHANGE
 -      DECLARE_GLOBAL_DATA_PTR;
        int load_baudrate, current_baudrate;
  
        load_baudrate = current_baudrate = gd->baudrate;
@@@ -213,6 -214,7 +215,6 @@@ load_serial (ulong offset
  static int
  read_record (char *buf, ulong len)
  {
 -      DECLARE_GLOBAL_DATA_PTR;
        char *p;
        char c;
  
@@@ -255,6 -257,7 +257,6 @@@ int do_save_serial (cmd_tbl_t *cmdtp, i
        ulong offset = 0;
        ulong size   = 0;
  #ifdef        CFG_LOADS_BAUD_CHANGE
 -      DECLARE_GLOBAL_DATA_PTR;
        int save_baudrate, current_baudrate;
  
        save_baudrate = current_baudrate = gd->baudrate;
@@@ -431,6 -434,8 +433,6 @@@ char his_quote;      /* quote chars he'
  
  int do_load_serial_bin (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  {
 -      DECLARE_GLOBAL_DATA_PTR;
 -
        ulong offset = 0;
        ulong addr;
        int load_baudrate, current_baudrate;
                }
        }
  
-       printf ("## Ready for binary (kermit) download "
-               "to 0x%08lX at %d bps...\n",
-               offset,
-               load_baudrate);
-       addr = load_serial_bin (offset);
+       if (strcmp(argv[0],"loady")==0) {
+               printf ("## Ready for binary (ymodem) download "
+                       "to 0x%08lX at %d bps...\n",
+                       offset,
+                       load_baudrate);
+               addr = load_serial_ymodem (offset);
  
-       if (addr == ~0) {
-               load_addr = 0;
-               printf ("## Binary (kermit) download aborted\n");
-               rcode = 1;
        } else {
-               printf ("## Start Addr      = 0x%08lX\n", addr);
-               load_addr = addr;
-       }
  
+               printf ("## Ready for binary (kermit) download "
+                       "to 0x%08lX at %d bps...\n",
+                       offset,
+                       load_baudrate);
+               addr = load_serial_bin (offset);
+               if (addr == ~0) {
+                       load_addr = 0;
+                       printf ("## Binary (kermit) download aborted\n");
+                       rcode = 1;
+               } else {
+                       printf ("## Start Addr      = 0x%08lX\n", addr);
+                       load_addr = addr;
+               }
+       }
        if (load_baudrate != current_baudrate) {
                printf ("## Switch baudrate to %d bps and press ESC ...\n",
                        current_baudrate);
@@@ -959,6 -974,66 +971,66 @@@ START
        }
        return ((ulong) os_data_addr - (ulong) bin_start_address);
  }
+ static int getcxmodem(void) {
+       if (tstc()) 
+               return (getc());
+       return -1;
+ }
+ static ulong load_serial_ymodem (ulong offset)
+ {
+       int size;
+       char buf[32];
+       int err;
+       int res;
+       connection_info_t info;
+       char    ymodemBuf[1024];
+       ulong   store_addr = ~0;
+       ulong   addr = 0;
+       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
+ #endif
+                   {
+                       memcpy ((char *)(store_addr), ymodemBuf, res);
+                   }
+       
+          }
+       } 
+       else {
+               printf ("%s\n",xyzModem_error(err));
+       }
+       
+       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);
+       return offset;
+ }
  #endif        /* CFG_CMD_LOADB */
  
  /* -------------------------------------------------------------------- */
@@@ -1018,6 -1093,14 +1090,14 @@@ U_BOOT_CMD
        " with offset 'off' and baudrate 'baud'\n"
  );
  
+ U_BOOT_CMD(
+       loady, 3, 0,    do_load_serial_bin,
+       "loady   - load binary file over serial line (ymodem mode)\n",
+       "[ off ] [ baud ]\n"
+       "    - load binary file over serial line"
+       " with offset 'off' and baudrate 'baud'\n"
+ );
  #endif        /* CFG_CMD_LOADB */
  
  /* -------------------------------------------------------------------- */