[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Uisp-dev] added parallel mode programming with stk500 ,changes for stk5
From: |
Klaus Rudolph |
Subject: |
[Uisp-dev] added parallel mode programming with stk500 ,changes for stk500 firmware 1.10 |
Date: |
Sun, 28 Jul 2002 20:26:44 +0200 |
Hi all,
I have now updated the uisp for the new stk500 firmware version 1.10.
Changes:
Reading Writing Fuses/Locks now work with 1200 and mega128,
no other devices for test here :-( need your help
The stk500 uses new commands, there is no
"universal" command at all, so all avr devices have to be reworked.
Seems not to be a big problem, the first step is now done.
For that reason there are some new AVR_ constants which enable
the new functions, so each device can be switched on seperatly :-)
Fix some time out, the default timeout is now 4 seconds not longer only
1! Sometimes I got with 2 seconds also errors so i set it to 4.
Problems?
stk500 is now able to programm all devices in High Voltage Parallel Mode
with uisp (-mode=p)
Fix a bug which comes with reading fuses (xx_RD76) mode. There was
a wrong bit compare in :-)
Reading and Writing VTarget is now also available.
Reading and Writing ARef too.
ToDo:
A lot, because only Mega128 and 1200 tested and all other devices have
to be reworked now. The calibration byte is allways read 0 but i have
not looked for it now, (i dont need it :-)
Theodore also want to hold the old firmware 1.7 alive. This patch only
work with 1.10 and only devices mega128 & at90s1200 are ready to use.
My work is really not finished yet, but I donĀ“t want to loose all my
changes if any one else make updates in uisp. So feel free
to decide if you bring that patch in cvs or not :-)
I am not member of uisp-dev mailing list, so please reply to
my email adress, thanks.
I hope my work helps a bit :-)
Bye
Klaus
? aclocal.m4
? Makefile.in
? configure
? config.log
? config.status
? uisp.spec
? Makefile
? firware110.diff
? config/install-sh
? config/mkinstalldirs
? config/missing
? src/config-h.in
? src/stamp-h.in
? src/Makefile.in
? src/Makefile
? src/config.h
? src/stamp-h
? src/.deps
Index: src/Avr.h
===================================================================
RCS file: /cvsroot/uisp/uisp/src/Avr.h,v
retrieving revision 1.3
diff -u -r1.3 Avr.h
--- src/Avr.h 3 Jun 2002 06:36:39 -0000 1.3
+++ src/Avr.h 28 Jul 2002 18:16:45 -0000
@@ -93,9 +93,17 @@
/* Has 3 bytes of fuse bits (ATmega128). */
#define AVR_FUSE_EXT 0x0400
-/* Sets of the above flags ORed for different classes of devices. */
+/* Special method to read 1200 fuse in stk500 */
+#define AVR_FUSE_RD_1200 0x0800
+
+/* AVR at90s1200 read lock bits 76 and write it with 12 !*/
+#define AVR_LOCK_WR12 0x1000
+
+/*new method for stk500 needs additional parameter here sorry! */
+#define AVR_FUSE_RD_EHL 0x2000
-#define AVR_1200 0 /* XXX no polling */
+/* Sets of the above flags ORed for different classes of devices. */
+#define AVR_1200 (AVR_FUSE_RD_1200 | AVR_LOCK_RD76 | AVR_LOCK_WR12)
#define AVR_2313 (AVR_BYTE_POLL)
#define AVR_TN22 (AVR_BYTE_POLL | AVR_LOCK_RD76)
#define AVR_8535 (AVR_BYTE_POLL | AVR_LOCK_RD76 | AVR_FUSE_OLDWR)
@@ -110,7 +118,7 @@
#define AVR_M163 (AVR_BYTE_POLL | AVR_PAGE_POLL | AVR_LOCK_BOOT | AVR_FUSE_RD \
| AVR_FUSE_NEWWR | AVR_CAL_RD | AVR_FUSE_HIGH)
#define AVR_M128 (AVR_BYTE_POLL | AVR_PAGE_POLL | AVR_LOCK_BOOT | AVR_FUSE_RD \
- | AVR_FUSE_NEWWR | AVR_CAL_RD | AVR_FUSE_HIGH | AVR_FUSE_EXT)
+ | AVR_FUSE_NEWWR | AVR_CAL_RD | AVR_FUSE_HIGH | AVR_FUSE_EXT
| AVR_FUSE_RD_EHL)
/* XXX no boot lock bits, but ordinary lock bits are in bits 1 and 0.
XXX has 4 calibration bytes for 1/2/4/8 MHz, can only read one for now. */
@@ -136,7 +144,6 @@
unsigned int flags;
};
- static const TPart parts[];
const TPart* part;
bool device_locked;
long t_wd_flash;
@@ -155,6 +162,7 @@
/* Variables and Functions */
private:
+ static const TPart parts[];
TAddr GetWritePageSize();
void SetWriteTimings();
Index: src/Main.C
===================================================================
RCS file: /cvsroot/uisp/uisp/src/Main.C,v
retrieving revision 1.6
diff -u -r1.6 Main.C
--- src/Main.C 3 Jun 2002 06:36:39 -0000 1.6
+++ src/Main.C 28 Jul 2002 18:16:47 -0000
@@ -130,18 +130,20 @@
" --segment Set active segment (auto-select for AVA Motorola output)\n"
"\n"
"Fuse/Lock Bit Operations:\n"
-" --rd_fuses Read all fuses and print values to stdout\n"
-" --wr_fuse_l Write fuse low byte\n"
-" --wr_fuse_h Write fuse high byte\n"
-" --wr_fuse_e Write fuse extended byte\n"
-" --wr_lock Write lock bits. Argument is a byte where each bit is:\n"
+" --rd_fuses Read all fuses and print values to stdout\n"
+" --wr_fuse_l Write fuse low byte\n"
+" --wr_fuse_h Write fuse high byte\n"
+" --wr_fuse_e Write fuse extended byte\n"
+" --wr_fuse_hl Write fuse high & low byte\n"
+" --wr_fuse_ehl Write fuse extendet and high and low byte\n"
+" --wr_lock Write lock bits. Argument is a byte where each bit is:\n"
" Bit5 -> blb12\n"
" Bit4 -> blb11\n"
" Bit3 -> blb02\n"
" Bit2 -> blb01\n"
" Bit1 -> lb2\n"
" Bit0 -> lb1\n"
-" --lock Write lock bits [old method; deprecated].\n"
+" --lock Write lock bits [old method; deprecated].\n"
"\n"
"Files:\n"
" if Input file for the --upload and --verify functions in\n"
@@ -156,6 +158,17 @@
" --version Print version information\n"
" --terminal Invoke shell-like terminal\n"
"\n"
+"Stk500 Options:\n"
+" -mode=[s|p] Set Stk500 for serial or parallel programming\n"
+"\n"
+"Stk500 Additional Commands\n"
+" --raref Read ARef Voltage\n"
+" --rvtar Read VTarget\n"
+" --waref=4.0 Write ARef\n"
+" --wvtar=5.2 Write VTarget\n"
+" --wr_fuse_hl=2bytes Write high and low fuse\n"
+" --wr_fuse_ehl=3bytes Write extended, high and low fuse \n\n"
+"\n"
"Report bugs to: Maintainers <address@hidden>\n"
"Updates: http://freesoftware.fsf.org/download/uisp/\n";
@@ -249,7 +262,73 @@
else if (val && (strcmp(val, "stk500") == 0)) {
setgid(getgid());
setuid(getuid());
- device = new TStk500();
+ const char* moder=GetCmdParam("-mode",false);
+ if (moder==NULL || moder[0]!='p' && moder[0]!='s' ){
+ throw Error_Device("Please select -mode=[s|p] for
serial/parallel access with Stk500");
+ }
+
+
+ device = new TStk500(moder[0]);
+
+ const char *val;
+ TStk500* pStk500=(TStk500 *) &(*device);
+
+
+ if (val=GetCmdParam("--waref",false)) {
+ unsigned char value=10*(val[0]-'0')+val[2]-'0';
+ pStk500->WriteARef(value);
+ }
+
+ if (val=GetCmdParam("--wvtar",false)) {
+ unsigned char value=10*(val[0]-'0')+val[2]-'0';
+ pStk500->WriteVTar(value);
+ }
+
+ if (val=GetCmdParam("--rvtar",false)) {
+ unsigned char value=pStk500->ReadVTar();
+ unsigned char vh=value/10;
+ unsigned char vl=value%10;
+ printf("VTar is set to %c.%c V\n", vh+'0', vl+'0');
+ }
+
+ if (val=GetCmdParam("--raref",false)) {
+ unsigned char value=pStk500->ReadARef();
+ unsigned char vh=value/10;
+ unsigned char vl=value%10;
+ printf("ARef is set to %c.%c V\n", vh+'0', vl+'0');
+ }
+
+ if (val=GetCmdParam("--wr_fuse_hl", false)) {
+ TByte l,h;
+ const char *old_seg = device->TellActiveSegment();
+ device->SetSegment("fuse");
+
+ if (sscanf(val, "%x,%x", &h,&l) == 2)
+ {
+ pStk500->WriteFuseHL(h,l);
+ }
+ else
+ throw Error_Device("Invalid argument for --wr_fuse_hl.");
+
+ device->SetSegment(old_seg);
+ }
+
+ if (val=GetCmdParam("--wr_fuse_ehl", false)) {
+ TByte e,l,h;
+ const char *old_seg = device->TellActiveSegment();
+ device->SetSegment("fuse");
+
+ if (sscanf(val, "%x,%x,%x", &e,&h,&l) == 3)
+ {
+ pStk500->WriteFuseEHL(e,h,l);
+ }
+ else
+ throw Error_Device("Invalid argument for --wr_fuse_ehl.");
+
+ device->SetSegment(old_seg);
+ }
+
+
}
#ifndef NO_DAPA
else if (val) {
Index: src/Serial.h
===================================================================
RCS file: /cvsroot/uisp/uisp/src/Serial.h,v
retrieving revision 1.2
diff -u -r1.2 Serial.h
--- src/Serial.h 24 Jun 2002 13:10:43 -0000 1.2
+++ src/Serial.h 28 Jul 2002 18:16:47 -0000
@@ -54,7 +54,7 @@
public:
int Send(unsigned char* queue, int queue_size, int rec_queue_size=-1,
- int timeout = 1);
+ int timeout = 4);
TSerial();
~TSerial();
Index: src/Stk500.C
===================================================================
RCS file: /cvsroot/uisp/uisp/src/Stk500.C,v
retrieving revision 1.8
diff -u -r1.8 Stk500.C
--- src/Stk500.C 3 Jun 2002 06:34:56 -0000 1.8
+++ src/Stk500.C 28 Jul 2002 18:16:51 -0000
@@ -74,6 +74,33 @@
const TByte TStk500::DeviceParam_Reply[] = { 0x14, 0x10 };
+const TByte TStk500::ReadVTars[] = { 0x41, 0x84, 0x20 };
+const TByte TStk500::ReadVTar_Reply[] = { 0x14 , '?' , 0x10 };
+
+const TByte TStk500::ReadARefs[] = { 0x41, 0x85, 0x20 };
+const TByte TStk500::ReadARef_Reply[] = { 0x14 , '?' , 0x10 };
+
+const TByte TStk500::WriteVTars[] = { 0x40, 0x84, '?', 0x20 };
+const TByte TStk500::WriteVTar_Reply[] = { 0x14 , 0x10 };
+
+const TByte TStk500::WriteARefs[] = { 0x40, 0x85, '?', 0x20 };
+const TByte TStk500::WriteARef_Reply[] = { 0x14 , 0x10 };
+
+const TByte TStk500::ReadFuse1200s[] = { 0x73, 0x20 };
+const TByte TStk500::ReadFuse1200_Reply[] = { 0x14, '?', 0x10 };
+
+const TByte TStk500::WriteFuseLowBits1200s[] = { 0x62, '?', 0xff, 0x20 };
+const TByte TStk500::WriteFuseLowBits1200_Reply[] = { 0x14, 0x10};
+
+const TByte TStk500::WriteLockBitss[] = { 0x63, '?', 0x20 };
+const TByte TStk500::WriteLockBits_Reply[] = { 0x14, 0x10};
+
+const TByte TStk500::WriteFuseEHLBitss[] = { 0x65, '?' , '?' , '?' , 0x20 };
+const TByte TStk500::WriteFuseEHLBits_Reply[] = { 0x14, 0x10 };
+
+const TByte TStk500::ReadFuseEHLBitss[] = { 0x77, 0x20 };
+const TByte TStk500::ReadFuseEHLBits_Reply[] = { 0x14, '?' , '?' , '?' , 0x10
};
+
const TStk500::SPrgPart TStk500::prg_part[] = {
{"AT90S4414",
{0x42, 0x50, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x7f, 0x7f, 0x80,
@@ -169,24 +196,43 @@
switch (addr)
{
case AVR_FUSE_LOW_ADDR:
- if (TestFeatures(AVR_FUSE_RD))
+ if (TestFeatures(AVR_FUSE_RD_EHL)) {
+ val = ReadFuseLowBitsEHL();
+ break;
+ }
+
+ if (TestFeatures(AVR_FUSE_RD)) {
val = ReadFuseLowBits();
- else
- Info (1, "Cannot read low fuse bits on this device. Returning
0xff\n");
+ break;
+ }
+
+ if (TestFeatures(AVR_FUSE_RD_1200)) {
+ val = ReadFuse1200();
+ break;
+ }
+
+
+ Info (1, "Cannot read low fuse bits on this device.");
+
+
break;
case AVR_FUSE_HIGH_ADDR:
+ if (TestFeatures(AVR_FUSE_RD_EHL)) {
+ val = ReadFuseHighBitsEHL();
+ break;
+ }
if (TestFeatures(AVR_FUSE_HIGH))
val = ReadFuseHighBits();
else
- Info (1, "Cannot read high fuse bits on this device. Returning
0xff\n");
+ Info (1, "Cannot read high fuse bits on this device. ");
break;
case AVR_CAL_ADDR:
if (TestFeatures(AVR_CAL_RD))
val = ReadCalFuseBits(0);
else
- Info (1, "Cannot read calibration byte on this device. Returning
0xff\n");
+ Info (1, "Cannot read calibration byte on this device. ");
break;
case AVR_LOCK_ADDR:
@@ -194,10 +240,14 @@
break;
case AVR_FUSE_EXT_ADDR:
+ if (TestFeatures(AVR_FUSE_RD_EHL)) {
+ val = ReadFuseExtBitsEHL();
+ break;
+ }
if (TestFeatures(AVR_FUSE_EXT))
val = ReadFuseExtBits();
else
- Info (1, "Cannot read extended fuse bits on this device. Returning
0xff\n");
+ Info (1, "Cannot read extended fuse bits on this device. ");
break;
}
}
@@ -223,10 +273,17 @@
switch (addr)
{
case AVR_FUSE_LOW_ADDR:
- if (TestFeatures(AVR_FUSE_RD))
+ if (TestFeatures(AVR_FUSE_RD)) {
WriteFuseLowBits(byte);
- else
- Info (1, "Cannot write low fuse bits on this device.\n");
+ break;
+ }
+
+ if (TestFeatures(AVR_FUSE_RD_1200)) {
+ WriteFuseLowBits1200(byte);
+ break;
+ }
+
+ Info (1, "Cannot write low fuse bits on this device.\n");
break;
case AVR_FUSE_HIGH_ADDR:
@@ -294,7 +351,7 @@
buf[2] = ((addr/wordsize) >> 8) & 0xff;
Send(buf, sizeof(SetAddress), sizeof(SetAddress_Reply));
if (memcmp(buf, SetAddress_Reply, sizeof(SetAddress_Reply)) != 0) {
- throw Error_Device ("Device is not responding correctly."); }
+ throw Error_Device ("1Device is not responding correctly."); }
memcpy(buf, WriteMemory, sizeof(WriteMemory));
buf[1] = 0x01;
@@ -306,7 +363,7 @@
Send(buf, sizeof(WriteMemory)+0x100+sizeof(CmdStopByte),
sizeof(WriteMemory_Reply));
if (memcmp(buf, WriteMemory_Reply, sizeof(WriteMemory_Reply)) != 0) {
- throw Error_Device ("Device is not responding correctly."); }
+ throw Error_Device ("2Device is not responding correctly."); }
}
LeaveProgrammingMode();
}
@@ -321,18 +378,27 @@
memcpy(buf, EraseDevice, sizeof(EraseDevice));
Send(buf, sizeof(EraseDevice), sizeof(EraseDevice_Reply));
if (memcmp(buf, EraseDevice_Reply, sizeof(EraseDevice_Reply)) != 0) {
- throw Error_Device ("Device is not responding correctly."); }
+ throw Error_Device ("3Device is not responding correctly."); }
LeaveProgrammingMode();
}
+/* replaced with new firmware version 1.10 */
+#ifdef firmware_1_7
TByte TStk500::ReadLockFuseBits()
{
TByte cmd[] = { 0x58, 0x00, 0x00, 0x00 };
return UniversalCmd(cmd);
}
+#endif
+
+TByte TStk500::ReadLockFuseBits() {
+ return ReadFuse1200(); //same method used!
+}
+
+
/* ReadLockBits tries to return the lock bits in a uniform order, despite the
@@ -349,8 +415,10 @@
rbits = ReadLockFuseBits();
} else if (TestFeatures(AVR_LOCK_RD76)) {
rbits = ReadLockFuseBits();
+ printf("Found Lock bits here as %x \n",rbits);
/* LB1 LB2 x x x x x x -> 1 1 1 1 1 1 LB2 LB1 */
- rbits = ((rbits >> 7) & 1) | ((rbits >> 5) & 1) | 0xFC;
+ rbits = ((rbits >> 7) & 1) | ((rbits >> 5) & 2) | 0xFC;
+ printf("after that lock bits are %x\n", rbits);
} else if (TestFeatures(AVR_LOCK_RD12)) {
rbits = ReadLockFuseBits();
/* x x x x x LB2 LB1 x -> 1 1 1 1 1 1 LB2 LB1 */
@@ -382,15 +450,68 @@
return UniversalCmd(cmd);
}
+#include <iostream.h>
+
+
+
+TByte TStk500::ReadFuse1200() {
+ TByte buf[0x200];
+
+ EnterProgrammingMode();
+ memcpy(buf, ReadFuse1200s, sizeof(ReadFuse1200s));
+ Send(buf, sizeof(ReadFuse1200s), sizeof(ReadFuse1200_Reply));
+
+ LeaveProgrammingMode();
+ return buf[1];
+
+}
+
+void TStk500::WriteFuseLowBits1200(TByte fuse) {
+ TByte buf[0x200];
+ EnterProgrammingMode();
+
+ memcpy(buf, WriteFuseLowBits1200s, sizeof(WriteFuseLowBits1200s));
+ buf[1]=fuse;
+ Send(buf, sizeof(WriteFuseLowBits1200s), sizeof(WriteFuseLowBits1200_Reply));
+
+ LeaveProgrammingMode();
+}
+
+void TStk500::WriteFuseHL(TByte h, TByte l) {
+ TByte buf[0x200];
+ EnterProgrammingMode();
+
+ memcpy(buf, WriteFuseLowBits1200s, sizeof(WriteFuseLowBits1200s));
+ buf[1]=l;
+ buf[2]=h;
+ Send(buf, sizeof(WriteFuseLowBits1200s), sizeof(WriteFuseLowBits1200_Reply));
+
+ LeaveProgrammingMode();
+}
+
+void TStk500::WriteFuseEHL(TByte e, TByte h, TByte l) {
+ TByte buf[0x200];
+ EnterProgrammingMode();
+
+ memcpy(buf, WriteFuseEHLBitss, sizeof(WriteFuseEHLBitss));
+ buf[1]=l;
+ buf[2]=h;
+ buf[3]=e;
+ Send(buf, sizeof(WriteFuseEHLBitss), sizeof(WriteFuseEHLBits_Reply));
+ LeaveProgrammingMode();
+}
+
+
+/* seems to be old and not longer usable! */
TByte TStk500::ReadFuseLowBits()
{
+
TByte cmd[] = { 0x50, 0x00, 0x00, 0x00 };
return UniversalCmd(cmd);
}
-
TByte TStk500::ReadFuseHighBits()
{
TByte cmd[] = { 0x58, 0x08, 0x00, 0x00 };
@@ -406,14 +527,65 @@
return UniversalCmd(cmd);
}
+TByte TStk500::ReadFuseLowBitsEHL() {
+ TByte buf[0x200];
+ TByte ret;
+
+ EnterProgrammingMode();
+ memcpy(buf,ReadFuseEHLBitss , sizeof(ReadFuseEHLBitss));
+ Send(buf, sizeof(ReadFuseEHLBitss), sizeof(ReadFuseEHLBits_Reply));
+ ret=buf[1];
+
+ LeaveProgrammingMode();
+ return ret;
+}
+
+TByte TStk500::ReadFuseHighBitsEHL() {
+ TByte buf[0x200];
+ TByte ret;
+
+ EnterProgrammingMode();
+ memcpy(buf,ReadFuseEHLBitss , sizeof(ReadFuseEHLBitss));
+ Send(buf, sizeof(ReadFuseEHLBitss), sizeof(ReadFuseEHLBits_Reply));
+ ret=buf[2];
+
+ LeaveProgrammingMode();
+ return ret;
+}
+
+TByte TStk500::ReadFuseExtBitsEHL() {
+ TByte buf[0x200];
+ TByte ret;
+
+ EnterProgrammingMode();
+ memcpy(buf,ReadFuseEHLBitss , sizeof(ReadFuseEHLBitss));
+ Send(buf, sizeof(ReadFuseEHLBitss), sizeof(ReadFuseEHLBits_Reply));
+ ret=buf[3];
+
+ LeaveProgrammingMode();
+ return ret;
+}
+
+/* old stuff 1.7 firmware
void TStk500::WriteLockFuseBits(TByte bits)
{
TByte cmd[] = { 0xac, 0xff, 0xff, bits };
UniversalCmd(cmd);
}
+*/
+
+void TStk500::WriteLockFuseBits(TByte bits) {
+ TByte buf[0x200];
+ EnterProgrammingMode();
+ memcpy(buf, WriteLockBitss, sizeof(WriteLockBitss));
+ buf[1]=bits;
+ Send(buf, sizeof(WriteLockBitss), sizeof(WriteLockBits_Reply));
+
+ LeaveProgrammingMode();
+}
void TStk500::WriteFuseLowBits(TByte bits)
{
@@ -453,7 +625,10 @@
void TStk500::WriteLockBits(TByte bits)
{
TByte wbits;
- if (TestFeatures(AVR_LOCK_BOOT))
+ if (TestFeatures(AVR_LOCK_WR12)) {
+ wbits = ((bits << 1) & 0x06) | 0xF9;
+ }
+ else if (TestFeatures(AVR_LOCK_BOOT))
{
/* x x BLB12 BLB11 BLB02 BLB01 LB2 LB1 */
wbits = bits;
@@ -485,14 +660,20 @@
memcpy(buf, pSTK500, sizeof(pSTK500));
Send(buf, sizeof(pSTK500), sizeof(pSTK500_Reply));
if (memcmp(buf, pSTK500_Reply, sizeof(pSTK500_Reply)) != 0) {
- throw Error_Device ("Device is not responding correctly."); }
+ throw Error_Device ("4Device is not responding correctly."); }
memcpy(buf, prg_part[desired_part].params,
sizeof(prg_part[desired_part].params));
+
+ /* switch to parallel mode if selected via -mode=p KR*/
+ if(mode=='p') {
+ buf[3]=0x01;
+ }
+
Send(buf, sizeof(prg_part[desired_part].params),
sizeof(DeviceParam_Reply));
if (memcmp(buf, DeviceParam_Reply, sizeof(DeviceParam_Reply)) != 0) {
- throw Error_Device ("Device is not responding correctly."); }
+ throw Error_Device ("5Device is not responding correctly."); }
memcpy(buf, SWminor, sizeof(SWminor));
Send(buf, sizeof(SWminor), sizeof(SWminor_Reply));
@@ -502,13 +683,16 @@
Send(buf, sizeof(SWmajor), sizeof(SWmajor_Reply));
vmajor = buf[1];
- if (! (vmajor == 1 && vminor == 7))
- throw Error_Device ("Need STK500 firmware version 1.7.");
+ if (! (vmajor == 1 && vminor == 10))
+ throw Error_Device ("Need STK500 firmware version 1.10.");
+
+
+
memcpy(buf, MagicNumber, sizeof(MagicNumber));
Send(buf, sizeof(MagicNumber), sizeof(MagicNumber_Reply));
if (memcmp(buf, MagicNumber_Reply, sizeof(MagicNumber_Reply)) != 0) {
- throw Error_Device ("Device is not responding correctly."); }
+ throw Error_Device ("6Device is not responding correctly."); }
memcpy(buf, EnterPgmMode, sizeof(EnterPgmMode));
Send(buf, sizeof(EnterPgmMode), sizeof(EnterPgmMode_Reply));
@@ -523,7 +707,7 @@
memcpy(buf, LeavePgmMode, sizeof(LeavePgmMode));
Send(buf, sizeof(LeavePgmMode), sizeof(LeavePgmMode_Reply));
if (memcmp(buf, LeavePgmMode_Reply, sizeof(LeavePgmMode_Reply)) != 0) {
- throw Error_Device ("Device is not responding correctly."); }
+ throw Error_Device ("7Device is not responding correctly."); }
}
@@ -546,7 +730,7 @@
if ((buf[0] != 0x14) || (buf[2] != 0x10))
{
- throw Error_Device ("Device is not responding correctly.");
+ throw Error_Device ("8Device is not responding correctly.");
}
return buf[1];
@@ -591,7 +775,7 @@
buf[2] = ((addr/wordsize) >> 8) & 0xff;
Send(buf, sizeof(SetAddress), sizeof(SetAddress_Reply));
if (memcmp(buf, SetAddress_Reply, sizeof(SetAddress_Reply)) != 0) {
- throw Error_Device ("Device is not responding correctly."); }
+ throw Error_Device ("9Device is not responding correctly."); }
memcpy(buf, ReadMemory, sizeof(ReadMemory));
buf[3] = seg;
@@ -603,9 +787,48 @@
LeaveProgrammingMode();
}
+unsigned char TStk500::ReadARef() {
+ TByte buf[0x200];
+
+ memcpy(buf, ReadARefs, sizeof(ReadARefs));
+ Send(buf, sizeof(ReadARefs), sizeof(ReadARef_Reply));
+ return buf[1];
+}
+
+unsigned char TStk500::ReadVTar() {
+ TByte buf[0x200];
+
+ memcpy(buf, ReadVTars, sizeof(ReadVTars));
+ Send(buf, sizeof(ReadVTars), sizeof(ReadVTar_Reply));
+ return buf[1];
+}
+
+void TStk500::WriteVTar(unsigned char v){
+ TByte buf[0x200];
+
+ if (ReadARef()>v) { WriteARef(v); }
+
+ memcpy(buf, WriteVTars, sizeof(WriteVTars));
+ buf[2]=v;
+ Send(buf, sizeof(WriteVTars), sizeof(WriteVTar_Reply));
+}
+
+void TStk500::WriteARef(unsigned char v){
+ TByte buf[0x200];
+
+ if (v>ReadVTar()) { WriteVTar(v); }
+
+ memcpy(buf, WriteARefs, sizeof(WriteARefs));
+ buf[2]=v;
+ Send(buf, sizeof(WriteARefs), sizeof(WriteARef_Reply));
+}
+
+
+
-TStk500::TStk500() {
+TStk500::TStk500(char m) {
/* Select Part by name */
+ mode=m;
desired_part=-1;
const char* desired_partname = GetCmdParam("-dpart");
Index: src/Stk500.h
===================================================================
RCS file: /cvsroot/uisp/uisp/src/Stk500.h,v
retrieving revision 1.6
diff -u -r1.6 Stk500.h
--- src/Stk500.h 3 Jun 2002 06:36:39 -0000 1.6
+++ src/Stk500.h 28 Jul 2002 18:16:51 -0000
@@ -39,6 +39,7 @@
const TByte params[22];
};
+ char mode; /* s or p for serial or parallel programming */
int desired_part;
TByte* write_buffer[2]; /* buffer for SEG_FLASH and SEG_EEPROM */
TByte* read_buffer[2]; /* buffer for SEG_FLASH and SEG_EEPROM */
@@ -72,6 +73,31 @@
static const TByte EEPROM;
static const TByte DeviceParam_Reply[];
static const SPrgPart prg_part[];
+ static const TByte ReadVTars[];
+ static const TByte ReadVTar_Reply[];
+ static const TByte ReadARefs[];
+ static const TByte ReadARef_Reply[];
+
+ static const TByte WriteVTars[];
+ static const TByte WriteVTar_Reply[];
+ static const TByte WriteARefs[];
+ static const TByte WriteARef_Reply[];
+
+ static const TByte ReadFuse1200s[];
+ static const TByte ReadFuse1200_Reply[];
+
+ static const TByte WriteFuseLowBits1200s[];
+ static const TByte WriteFuseLowBits1200_Reply[];
+
+ static const TByte WriteLockBitss[];
+ static const TByte WriteLockBits_Reply[];
+
+ static const TByte WriteFuseEHLBitss[];
+ static const TByte WriteFuseEHLBits_Reply[];
+
+ static const TByte ReadFuseEHLBitss[];
+ static const TByte ReadFuseEHLBits_Reply[];
+
void EnterProgrammingMode();
void LeaveProgrammingMode();
@@ -85,6 +111,10 @@
TByte ReadFuseLowBits();
TByte ReadFuseHighBits();
TByte ReadFuseExtBits();
+ TByte ReadFuse1200();
+ TByte ReadFuseLowBitsEHL();
+ TByte ReadFuseHighBitsEHL();
+ TByte ReadFuseExtBitsEHL();
TByte ReadLockBits();
@@ -93,6 +123,13 @@
void WriteFuseHighBits(TByte bits);
void WriteFuseExtBits(TByte bits);
+ void WriteFuseLowBits1200(TByte bits);
+
+
+
+
+
+
public:
/* Read byte from active segment at address addr. */
TByte ReadByte(TAddr addr);
@@ -107,7 +144,17 @@
/* Write lock bits */
void WriteLockBits(TByte bits);
- TStk500();
+
+ void WriteVTar(unsigned char value);
+ void WriteARef(unsigned char value);
+
+ unsigned char ReadVTar();
+ unsigned char ReadARef();
+
+ void WriteFuseHL(TByte h, TByte l);
+ void WriteFuseEHL(TByte e, TByte h, TByte l);
+
+ TStk500(char mode);
~TStk500();
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Uisp-dev] added parallel mode programming with stk500 ,changes for stk500 firmware 1.10,
Klaus Rudolph <=