Support GAL20XV10

This commit is contained in:
rhgndf 2023-09-16 14:20:12 +08:00
parent 47432b8c05
commit 82b6691bba
2 changed files with 63 additions and 37 deletions

View File

@ -145,6 +145,7 @@ typedef enum {
UNKNOWN, UNKNOWN,
GAL16V8, GAL16V8,
GAL20V8, GAL20V8,
GAL20XV10,
GAL22V10, GAL22V10,
ATF16V8B, ATF16V8B,
ATF22V10B, ATF22V10B,
@ -158,9 +159,10 @@ typedef enum {
// config bit numbers // config bit numbers
#define CFG_BASE_16 2048 #define CFG_BASE_16 2048
#define CFG_BASE_20 2560 #define CFG_BASE_20 2560
#define CFG_BASE_22 5808 #define CFG_BASE_20XV 1600
#define CFG_BASE_22 5808
#define CFG_STROBE_ROW 0 #define CFG_STROBE_ROW 0
#define CFG_SET_ROW 1 #define CFG_SET_ROW 1
@ -196,6 +198,22 @@ static const unsigned char cfgV8AB[]=
4,5,6,7, 4,5,6,7,
}; };
// common CFG fuse address map for cfg20XV10
// starting address: 1600
// total size 31
static const unsigned char cfgXV10[]=
{
30,
28, 29,
20, 21, 22,
10, 11, 12, 13, 14,
0, 1, 2, 3, 4,
27, 26,
23, 24, 25,
19, 18, 17, 16, 15,
9, 8, 7, 6, 5
};
// common CFG fuse address map for cfg22V10 // common CFG fuse address map for cfg22V10
// starting address: 5808 // starting address: 5808
// total size 20 // total size 20
@ -204,7 +222,6 @@ static const unsigned char cfgV10[]=
1,0,3,2,5,4,7,6,9,8,11,10,13,12,15,14,17,16,19,18, 1,0,3,2,5,4,7,6,9,8,11,10,13,12,15,14,17,16,19,18,
}; };
// UES user electronic signature // UES user electronic signature
// PES programmer electronic signature (ATF = text string, others = Vendor/Vpp/timing) // PES programmer electronic signature (ATF = text string, others = Vendor/Vpp/timing)
// cfg configuration bits for OLMCs // cfg configuration bits for OLMCs
@ -238,12 +255,13 @@ galinfo[]=
// +-- type + id0 + id1 | | +rows | | +uesfuse | +eraseallrow +cfgrow | | + cfgbits +cfgmethod // +-- type + id0 + id1 | | +rows | | +uesfuse | +eraseallrow +cfgrow | | + cfgbits +cfgmethod
// | | | | | | | | | | | | | | | | | | | // | | | | | | | | | | | | | | | | | | |
{UNKNOWN, 0x00, 0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, NULL, 0 , 0}, {UNKNOWN, 0x00, 0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, NULL, 0 , 0},
{GAL16V8, 0x00, 0x1A, 2194, 20, 32, 64, 32, 2056, 8, 63, 62, 58, 8, 60, CFG_BASE_16, cfgV8AB, sizeof(cfgV8AB), CFG_STROBE_ROW}, {GAL16V8, 0x00, 0x1A, 2194, 20, 32, 64, 32, 2056, 8, 63, 62, 58, 8, 60, CFG_BASE_16 , cfgV8AB, sizeof(cfgV8AB) , CFG_STROBE_ROW},
{GAL20V8, 0x20, 0x3A, 2706, 24, 40, 64, 40, 2568, 8, 63, 62, 58, 8, 60, CFG_BASE_20, cfgV8AB, sizeof(cfgV8AB), CFG_STROBE_ROW}, {GAL20V8, 0x20, 0x3A, 2706, 24, 40, 64, 40, 2568, 8, 63, 62, 58, 8, 60, CFG_BASE_20 , cfgV8AB, sizeof(cfgV8AB) , CFG_STROBE_ROW},
{GAL22V10, 0x48, 0x49, 5892, 24, 44, 132, 44, 5828, 8, 61, 62, 58, 10, 16, CFG_BASE_22, cfgV10, sizeof(cfgV10) , CFG_SET_ROW }, {GAL20XV10, 0x65, 0x66, 1671, 24, 40, 40, 44, 1631, 5, 61, 60, 58, 5, 16, CFG_BASE_20XV, cfgXV10, sizeof(cfgXV10) , CFG_SET_ROW },
{ATF16V8B, 0x00, 0x00, 2194, 20, 32, 64, 32, 2056, 8, 63, 62, 58, 8, 60, CFG_BASE_16, cfgV8AB, sizeof(cfgV8AB), CFG_STROBE_ROW}, {GAL22V10, 0x48, 0x49, 5892, 24, 44, 132, 44, 5828, 8, 61, 62, 58, 10, 16, CFG_BASE_22 , cfgV10, sizeof(cfgV10) , CFG_SET_ROW },
{ATF22V10B, 0x00, 0x00, 5892, 24, 44, 132, 44, 5828, 8, 61, 62, 58, 10, 16, CFG_BASE_22, cfgV10, sizeof(cfgV10) , CFG_SET_ROW }, {ATF16V8B, 0x00, 0x00, 2194, 20, 32, 64, 32, 2056, 8, 63, 62, 58, 8, 60, CFG_BASE_16 , cfgV8AB, sizeof(cfgV8AB) , CFG_STROBE_ROW},
{ATF22V10C, 0x00, 0x00, 5892, 24, 44, 132, 44, 5828, 8, 61, 62, 58, 10, 16, CFG_BASE_22, cfgV10, sizeof(cfgV10) , CFG_SET_ROW }, {ATF22V10B, 0x00, 0x00, 5892, 24, 44, 132, 44, 5828, 8, 61, 62, 58, 10, 16, CFG_BASE_22 , cfgV10, sizeof(cfgV10) , CFG_SET_ROW },
{ATF22V10C, 0x00, 0x00, 5892, 24, 44, 132, 44, 5828, 8, 61, 62, 58, 10, 16, CFG_BASE_22 , cfgV10, sizeof(cfgV10) , CFG_SET_ROW },
}; };
// MAXFUSES calculated as the biggest required space to hold the fuse bitmap + UES bitmap + CFG bitmap // MAXFUSES calculated as the biggest required space to hold the fuse bitmap + UES bitmap + CFG bitmap
@ -341,6 +359,7 @@ static void setPinMux(uint8_t pm) {
break; break;
case GAL20XV10:
case GAL22V10: case GAL22V10:
case ATF22V10B: case ATF22V10B:
case ATF22V10C: case ATF22V10C:
@ -720,7 +739,7 @@ static void setPV(char on) {
const unsigned short b = galinfo[gal].cfgbase; const unsigned short b = galinfo[gal].cfgbase;
uint8_t pin = PIN_ZIF23; uint8_t pin = PIN_ZIF23;
if (b == CFG_BASE_22) { if (b == CFG_BASE_22 || b == CFG_BASE_20XV) {
pin = PIN_ZIF3; pin = PIN_ZIF3;
} else } else
if (b == CFG_BASE_20) { if (b == CFG_BASE_20) {
@ -766,7 +785,7 @@ static void setRow(char row)
if (row & 0x10) srval |= PIN_ZIF6; //RA4 if (row & 0x10) srval |= PIN_ZIF6; //RA4
if (row & 0x20) srval |= PIN_ZIF7; //RA5 if (row & 0x20) srval |= PIN_ZIF7; //RA5
} else } else
if (b == CFG_BASE_22) { if (b == CFG_BASE_22 || b == CFG_BASE_20XV) {
if (row & 0x1) srval |= PIN_ZIF4; //RA0 if (row & 0x1) srval |= PIN_ZIF4; //RA0
if (row & 0x2) srval |= PIN_ZIF5; //RA1 if (row & 0x2) srval |= PIN_ZIF5; //RA1
if (row & 0x4) srval |= PIN_ZIF6; //RA2 if (row & 0x4) srval |= PIN_ZIF6; //RA2
@ -799,7 +818,7 @@ static char getSDOUT(void)
const unsigned short b = galinfo[gal].cfgbase; const unsigned short b = galinfo[gal].cfgbase;
uint8_t pin = PIN_ZIF16; uint8_t pin = PIN_ZIF16;
if (b == CFG_BASE_22) { if (b == CFG_BASE_22 || b == CFG_BASE_20XV) {
pin = PIN_ZIF14; pin = PIN_ZIF14;
} else } else
if (b == CFG_BASE_20) { if (b == CFG_BASE_20) {
@ -945,6 +964,7 @@ static void strobeRow(char row, char setBit = BIT_NONE)
} }
strobe(2); // pulse /STB for 2ms strobe(2); // pulse /STB for 2ms
break; break;
case GAL20XV10:
case GAL22V10: case GAL22V10:
case ATF22V10B: case ATF22V10B:
case ATF22V10C: case ATF22V10C:
@ -1155,6 +1175,7 @@ void printPes(char type) {
switch (type) { switch (type) {
case GAL16V8: Serial.print(F("GAL16V8 ")); break; case GAL16V8: Serial.print(F("GAL16V8 ")); break;
case GAL20V8: Serial.print(F("GAL20V8 ")); break; case GAL20V8: Serial.print(F("GAL20V8 ")); break;
case GAL20XV10: Serial.print(F("GAL20XV10 ")); break;
case GAL22V10: Serial.print(F("GAL22V10 ")); break; case GAL22V10: Serial.print(F("GAL22V10 ")); break;
case ATF16V8B: Serial.print(0 == (flagBits & FLAG_BIT_ATF16V8C) ? F("ATF16V8B "): F("ATF16V8C ")); break; case ATF16V8B: Serial.print(0 == (flagBits & FLAG_BIT_ATF16V8C) ? F("ATF16V8B "): F("ATF16V8C ")); break;
case ATF22V10B: Serial.print(F("ATF22V10B ")); break; case ATF22V10B: Serial.print(F("ATF22V10B ")); break;
@ -1199,7 +1220,6 @@ static void readGalFuseMap(const unsigned char* cfgArray, char useDelay, char do
setPV(0); setPV(0);
} }
// read fuse rows
for(row = 0; row < galinfo[gal].rows; row++) { for(row = 0; row < galinfo[gal].rows; row++) {
strobeRow(row); //set address of the row strobeRow(row); //set address of the row
if (flagBits & FLAG_BIT_ATF16V8C) { if (flagBits & FLAG_BIT_ATF16V8C) {
@ -1441,14 +1461,16 @@ static void readOrVerifyGal(char verify)
} }
break; break;
case GAL20XV10:
case GAL22V10: case GAL22V10:
case ATF22V10B: case ATF22V10B:
case ATF22V10C: case ATF22V10C:
//read with delay 1 ms, discard 68 cfg bits on ATFxx //read with delay 1 ms, discard 68 cfg bits on ATFxx
bool isGAL = (gal == GAL20XV10 || gal == GAL22V10);
if (verify) { if (verify) {
i = verifyGalFuseMap(cfgV10, 1, (gal == GAL22V10) ? 0 : 68); i = verifyGalFuseMap(cfgV10, 1, isGAL ? 0 : 68);
} else { } else {
readGalFuseMap(cfgV10, 1, (gal == GAL22V10) ? 0 : 68); readGalFuseMap(cfgV10, 1, isGAL ? 0 : 68);
} }
break; break;
} }
@ -1590,10 +1612,12 @@ static void writeGal()
writeGalFuseMapV8(cfgV8AB); writeGalFuseMapV8(cfgV8AB);
break; break;
case GAL20XV10:
case GAL22V10: case GAL22V10:
case ATF22V10B: case ATF22V10B:
case ATF22V10C: case ATF22V10C:
writeGalFuseMapV10(cfgV10, (gal == GAL22V10) ? 0 : 1, (gal == ATF22V10C) ? 1 : 0); bool isGAL = (gal == GAL20XV10 || gal == GAL22V10);
writeGalFuseMapV10(cfgV10, isGAL ? 0 : 1, isGAL ? 1 : 0);
break; break;
} }
turnOff(); turnOff();
@ -1765,6 +1789,7 @@ static void printGalName() {
switch (gal) { switch (gal) {
case GAL16V8: Serial.println(F("GAL16V8")); break; case GAL16V8: Serial.println(F("GAL16V8")); break;
case GAL20V8: Serial.println(F("GAL20V8")); break; case GAL20V8: Serial.println(F("GAL20V8")); break;
case GAL20XV10: Serial.println(F("GAL20XV10")); break;
case GAL22V10: Serial.println(F("GAL22V10")); break; case GAL22V10: Serial.println(F("GAL22V10")); break;
case ATF16V8B: case ATF16V8B:
if (flagBits & FLAG_BIT_ATF16V8C) { if (flagBits & FLAG_BIT_ATF16V8C) {

View File

@ -57,6 +57,7 @@ typedef enum {
UNKNOWN, UNKNOWN,
GAL16V8, GAL16V8,
GAL20V8, GAL20V8,
GAL20XV10,
GAL22V10, GAL22V10,
ATF16V8B, ATF16V8B,
ATF22V10B, ATF22V10B,
@ -87,6 +88,7 @@ galinfo[] = {
{UNKNOWN, 0x00, 0x00, "unknown", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0}, {UNKNOWN, 0x00, 0x00, "unknown", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0},
{GAL16V8, 0x00, 0x1A, "GAL16V8", 2194, 20, 32, 64, 32, 2056, 8, 63, 54, 58, 8, 60, 82}, {GAL16V8, 0x00, 0x1A, "GAL16V8", 2194, 20, 32, 64, 32, 2056, 8, 63, 54, 58, 8, 60, 82},
{GAL20V8, 0x20, 0x3A, "GAL20V8", 2706, 24, 40, 64, 40, 2568, 8, 63, 59, 58, 8, 60, 82}, {GAL20V8, 0x20, 0x3A, "GAL20V8", 2706, 24, 40, 64, 40, 2568, 8, 63, 59, 58, 8, 60, 82},
{GAL20XV10, 0x65, 0x66, "GAL20XV10", 1671, 24, 40, 40, 44, 1631, 5, 61, 60, 58, 5, 16, 31},
{GAL22V10, 0x48, 0x49, "GAL22V10", 5892, 24, 44, 132, 44, 5828, 8, 61, 60, 58, 10, 16, 20}, {GAL22V10, 0x48, 0x49, "GAL22V10", 5892, 24, 44, 132, 44, 5828, 8, 61, 60, 58, 10, 16, 20},
{ATF16V8B, 0x00, 0x00, "ATF16V8B", 2194, 20, 32, 64, 32, 2056, 8, 63, 54, 58, 8, 60, 82}, {ATF16V8B, 0x00, 0x00, "ATF16V8B", 2194, 20, 32, 64, 32, 2056, 8, 63, 54, 58, 8, 60, 82},
{ATF22V10B, 0x00, 0x00, "ATF22V10B", 5892, 24, 44, 132, 44, 5828, 8, 61, 60, 58, 10, 16, 20}, {ATF22V10B, 0x00, 0x00, "ATF22V10B", 5892, 24, 44, 132, 44, 5828, 8, 61, 60, 58, 10, 16, 20},
@ -127,6 +129,14 @@ char flagEraseAll = 0;
static int waitForSerialPrompt(char* buf, int bufSize, int maxDelay); static int waitForSerialPrompt(char* buf, int bufSize, int maxDelay);
static char sendGenericCommand(const char* command, const char* errorText, int maxDelay, char printResult); static char sendGenericCommand(const char* command, const char* errorText, int maxDelay, char printResult);
static void printGalTypes() {
for (int i = 1; i < sizeof(galinfo) / sizeof(galinfo[0]); i++) {
if (i > 1) {
printf(" ");
}
printf("%s", galinfo[i].name);
}
}
static void printHelp() { static void printHelp() {
printf("Afterburner " VERSION " a GAL programming tool for Arduino based programmer\n"); printf("Afterburner " VERSION " a GAL programming tool for Arduino based programmer\n");
@ -144,7 +154,9 @@ static void printHelp() {
printf(" m : measure variable VPP on new board designs. Ensure the GAL is NOT inserted.\n"); printf(" m : measure variable VPP on new board designs. Ensure the GAL is NOT inserted.\n");
printf("options:\n"); printf("options:\n");
printf(" -v : verbose mode\n"); printf(" -v : verbose mode\n");
printf(" -t <gal_type> : the GAL type. use GAL16V8 GAL20V8 GAL22V10 ATF16V8B ATF22V10B ATF22V10C\n"); printf(" -t <gal_type> : the GAL type. use ");
printGalTypes();
printf("\n");
printf(" -f <file> : JEDEC fuse map file\n"); printf(" -f <file> : JEDEC fuse map file\n");
printf(" -d <serial_device> : name of the serial device. Default is: %s\n", DEFAULT_SERIAL_DEVICE_NAME); printf(" -d <serial_device> : name of the serial device. Default is: %s\n", DEFAULT_SERIAL_DEVICE_NAME);
printf(" serial params are: 38400, 8N1\n"); printf(" serial params are: 38400, 8N1\n");
@ -169,7 +181,6 @@ static void printHelp() {
printf(" Atmel ATF16V8B, AFT16V8C, ATF22V10C: 10V \n"); printf(" Atmel ATF16V8B, AFT16V8C, ATF22V10C: 10V \n");
} }
static int8_t verifyArgs(char* type) { static int8_t verifyArgs(char* type) {
if (!opRead && !opWrite && !opErase && !opInfo && !opVerify && !opTestVPP && !opCalibrateVPP && !opMeasureVPP && !opWritePes) { if (!opRead && !opWrite && !opErase && !opInfo && !opVerify && !opTestVPP && !opCalibrateVPP && !opMeasureVPP && !opWritePes) {
printHelp(); printHelp();
@ -196,27 +207,17 @@ static int8_t verifyArgs(char* type) {
printf("Error: missing GAL type. Use -t <type> to specify.\n"); printf("Error: missing GAL type. Use -t <type> to specify.\n");
return -1; return -1;
} else if (0 != type) { } else if (0 != type) {
if (strcmp("GAL16V8", type) == 0) { for (int i = 0; i < sizeof(galinfo) / sizeof(galinfo[0]); i++) {
gal = GAL16V8; if (strcmp(type, galinfo[i].name) == 0) {
} gal = galinfo[i].type;
if (strcmp("GAL20V8", type) == 0) { break;
gal = GAL20V8; }
}
if (strcmp("GAL22V10", type) == 0) {
gal = GAL22V10;
}
if (strcmp("ATF16V8B", type) == 0) {
gal = ATF16V8B;
}
if (strcmp("ATF22V10B", type) == 0) {
gal = ATF22V10B;
}
if (strcmp("ATF22V10C", type) == 0) {
gal = ATF22V10C;
} }
if (UNKNOWN == gal) { if (UNKNOWN == gal) {
printf("Error: unknow GAL type. Types: GAL16V8 GAL20V8 GAL22V10 ATF16V8B ATF22V10B ATF22V10C\n"); printf("Error: unknown GAL type. Types: ");
printGalTypes();
printf("\n");
return -1; return -1;
} }
} }