uisp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Uisp-dev] [PATCH] at89s support


From: Wojtek Kaniewski
Subject: [Uisp-dev] [PATCH] at89s support
Date: Wed, 04 Feb 2004 21:39:57 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007

i've made a patch for uisp, that allows to handle at89s51 by any ,,direct access'' programmers. the user simple needs to add ,,-d89'' to the command line, and use it just like for avrs. this switch inverts reset signal and changes some spi opcodes. the patch works fine for me, maybe others will find it useful too, because i haven't found any other at89s51 programmer for unix systems.

if you find the attached patch silly or you don't want support for non-avr chips, please let me know.

regards,
wojtek
? Makefile
? Makefile.in
? aclocal.m4
? autom4te.cache
? config.log
? config.status
? configure
? depcomp
? install-sh
? missing
? mkinstalldirs
? uisp-cvs-at89.patch
? uisp.1
? uisp.spec
? src/.deps
? src/Makefile
? src/Makefile.in
? src/config-h.in
? src/config.h
? src/mspc_n.hex
? src/stamp-h1
? src/uisp
Index: src/Avr.C
===================================================================
RCS file: /cvsroot/uisp/uisp/src/Avr.C,v
retrieving revision 1.8
diff -u -r1.8 Avr.C
--- src/Avr.C   13 May 2003 22:32:05 -0000      1.8
+++ src/Avr.C   4 Feb 2004 20:28:23 -0000
@@ -115,9 +115,8 @@
   { "ATmega603-old",0x06, 0x01,  65536, 256, 2048, 22000, 4000, AVR_M103 },
 #endif
 
-#if 0 /* not yet */
+  { "AT89S51",      0x51, 0x06,   4096,   0,    0,  1000,    0, AT89S51 },
   { "AT89S52",      0x52, 0x06,   8192,   0,    0,  1000,    0, AT89S52 },
-#endif
 
   { "",          TARGET_MISSING, 0,  0,   0,    0,     0,    0, 0 },
   { "locked",    DEVICE_LOCKED,  0,  0,   0,    0,     0,    0, 0 },
@@ -170,7 +169,7 @@
     vendor_code, part_family, part_number);  
 
   /* Identify AVR Part according to the vendor_code ... */
-  if (vendor_code==0x1e){vendor = "Atmel AVR";}
+  if 
(vendor_code==0x1e){vendor=(part_family==0x51||part_family==0x52)?"Atmel":"Atmel
 AVR";}
   
   if (vendor_code==0 && part_family==DEVICE_LOCKED && part_number==0x02){
     device_locked=true;
Index: src/Avr.h
===================================================================
RCS file: /cvsroot/uisp/uisp/src/Avr.h,v
retrieving revision 1.5
diff -u -r1.5 Avr.h
--- src/Avr.h   13 May 2003 22:32:05 -0000      1.5
+++ src/Avr.h   4 Feb 2004 20:28:32 -0000
@@ -93,6 +93,16 @@
 /* Has 3 bytes of fuse bits (ATmega128).  */
 #define AVR_FUSE_EXT   0x0400
 
+/* AT89S5x family. */
+#define AT89S          0x0800
+
+/* Read Lock Bits at bits 4, 3, 2. */
+#define AT89S_LOCK_RD432       0x1000
+
+/* Aliases. */
+#define AT89S_BYTE_POLL        AVR_BYTE_POLL
+#define AT89S_PAGE_POLL AVR_PAGE_POLL
+
 /* Sets of the above flags ORed for different classes of devices.  */
 
 #define AVR_1200 0  /* XXX no polling */
@@ -116,6 +126,9 @@
    XXX has 4 calibration bytes for 1/2/4/8 MHz, can only read one for now.  */
 #define AVR_TN26 (AVR_BYTE_POLL | AVR_PAGE_POLL | AVR_LOCK_BOOT | AVR_FUSE_RD \
                  | AVR_FUSE_NEWWR | AVR_CAL_RD | AVR_FUSE_HIGH)
+
+#define AT89S51 (AT89S | AT89S_BYTE_POLL | AT89S_LOCK_RD432)
+#define AT89S52 (AT89S | AT89S_BYTE_POLL | AT89S_LOCK_RD432)
 
 #define AVR_MIN_VOLTAGE                2.7     /* V */
 #define AVR_MAX_VOLTAGE                6.0     /* V */
Index: src/AvrDummy.C
===================================================================
RCS file: /cvsroot/uisp/uisp/src/AvrDummy.C,v
retrieving revision 1.4
diff -u -r1.4 AvrDummy.C
--- src/AvrDummy.C      3 Jun 2002 06:36:39 -0000       1.4
+++ src/AvrDummy.C      4 Feb 2004 20:28:32 -0000
@@ -55,6 +55,7 @@
     Send(prg, 4);
     if (no_retry) break;
     if (prg[2] == 0x53) break;
+    if (at89 && prg[3] == 0x69) break;
     PulseSck();
   } while (try_number--);
   
@@ -79,6 +80,12 @@
 TByte
 TAvrDummy::GetPartInfo(TAddr addr)
 {
+  if (at89) {
+    TByte info [4] = { 0x28, addr & 0x1f, 0, 0 };
+    Send(info, 4);
+    return info[3];
+  }
+
   TByte info [4] = { 0x30, 0, addr, 0 };
   Send(info, 4);
   return info[3];
@@ -144,7 +151,11 @@
   TByte readback = 0xFF;
     
   CheckMemoryRange(addr);
+
   if (segment == SEG_FLASH) {
+    if (at89)
+      addr <<= 1;
+
     TByte hl = (addr & 1) ? 0x28 : 0x20;
     TByte flash[4] = { hl,
                       (TByte)((addr >> 9) & 0xff),
@@ -205,6 +216,8 @@
 TAvrDummy::ReadLockFuseBits()
 {
   TByte lockfuse[4] = { 0x58, 0, 0, 0 };
+  if (at89)
+    lockfuse[0] = 0x24;
   Send(lockfuse, 4);
   return lockfuse[3];
 }
@@ -339,6 +352,7 @@
 
   CheckMemoryRange(addr);
   
+ 
   /* For speed, don't program a byte that is already there
      (such as 0xFF after chip erase).  */
   if (poll_data){
@@ -373,6 +387,9 @@
       if (flush_buffer){WriteProgramMemoryPage();}
     }
 
+    if (at89)
+      addr <<= 1;
+
     TByte hl = (addr & 1) ? 0x48 : 0x40;
     TByte flash [4] = { hl,
                        (TByte)((addr >> 9) & 0xff),
@@ -380,6 +397,9 @@
                        byte };
     Send(flash, 4);
 
+    if (at89)
+      addr >>= 1;
+
     /* Remember the last non-0xFF byte written, for page write polling.  */
     if (byte != 0xFF) {
       page_poll_addr = addr;
@@ -512,6 +532,9 @@
   TByte lock[4] = { 0xAC, 0xF9 | ((bits << 1) & 0x06), 0xFF, bits };
   TByte rbits;
 
+  if (at89)
+    lock[1] = 0xe0 | (bits & 0x03);
+
   Info(1, "Writing lock bits ...\n");
   Send(lock, 4);
   Delay_usec(Get_t_wd_erase());
@@ -539,6 +562,10 @@
     rbits = ReadLockFuseBits();
     /* x x x x x LB2 LB1 x -> 1 1 1 1 1 1 LB2 LB1 */
     rbits = ((rbits >> 1) & 3) | 0xFC;
+  } else if (TestFeatures(AT89S_LOCK_RD432)) {
+    rbits = ReadLockFuseBits();
+    /* x x x LB3 LB2 LB1 x x -> 0 0 0 0 0 LB3 LB2 LB1 */
+    rbits = (rbits >> 2) & 7;
   } else if (GetPartInfo(0) == 0 &&
             GetPartInfo(1) == 1 &&
             GetPartInfo(2) == 2) {
Index: src/DAPA.C
===================================================================
RCS file: /cvsroot/uisp/uisp/src/DAPA.C,v
retrieving revision 1.15
diff -u -r1.15 DAPA.C
--- src/DAPA.C  17 Nov 2003 06:07:13 -0000      1.15
+++ src/DAPA.C  4 Feb 2004 20:28:32 -0000
@@ -1113,6 +1113,13 @@
   mosi_invert = 0;
   miso_invert = 0;
   reset_invert = 0;
+
+  at89 = 0;
+  if (GetCmdParam("-d89",false)) {
+    reset_invert = 1;
+    at89 = 1;
+  }
+
   if ((val=GetCmdParam("-dinvert")))
     {
 #define MAXLINESIZE    256
Index: src/DAPA.h
===================================================================
RCS file: /cvsroot/uisp/uisp/src/DAPA.h,v
retrieving revision 1.4
diff -u -r1.4 DAPA.h
--- src/DAPA.h  13 May 2003 22:32:05 -0000      1.4
+++ src/DAPA.h  4 Feb 2004 20:28:32 -0000
@@ -63,6 +63,9 @@
   unsigned char par_status;  /* read */
   unsigned int ser_ctrl;  /* TIOCMGET/TIOCMSET */
 
+protected:
+  int at89;
+
 private:
   int SendRecv(int);
   /* low level access to parallel port lines */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]