nCe made high before programming blackfin to ensure seamless programming (#460)

This commit is contained in:
Dhanya Thattil 2022-05-18 12:17:44 +02:00 committed by GitHub
parent 4259363169
commit 73a45e1b5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 52 additions and 46 deletions

View File

@ -11,8 +11,8 @@
#define BLACKFIN_DEFINED
int defineGPIOpins(char *mess);
int FPGAdontTouchFlash(char *mess);
int FPGATouchFlash(char *mess);
int FPGAdontTouchFlash(char *mess, int programming);
int FPGATouchFlash(char *mess, int programming);
int resetFPGA(char *mess);
int emptyTempFolder(char *mess);

View File

@ -19,8 +19,11 @@
#define CMD_GPIO9_DEFINE "echo 9 > /sys/class/gpio/export"
#define CMD_GPIO3_DEFINE "echo 3 > /sys/class/gpio/export"
// N config done
#define CMD_GPIO7_EXIST "/sys/class/gpio/gpio7"
// N Config
#define CMD_GPIO9_EXIST "/sys/class/gpio/gpio9"
// N CE (access to AS interface)
#define CMD_GPIO3_EXIST "/sys/class/gpio/gpio3"
#define CMD_GPIO9_DEFINE_OUT "echo out > /sys/class/gpio/gpio9/direction"
@ -29,8 +32,11 @@
#define CMD_GPIO9_DEFINE_IN "echo in > /sys/class/gpio/gpio9/direction"
#define CMD_GPIO3_DEFINE_IN "echo in > /sys/class/gpio/gpio3/direction"
// nConfig
#define CMD_GPIO9_DONT_TOUCH_FLASH "echo 0 > /sys/class/gpio/gpio9/value"
#define CMD_GPIO3_DONT_TOUCH_FLASH "echo 0 > /sys/class/gpio/gpio3/value"
// nCE
#define CMD_GPIO3_DONT_TOUCH_FLASH "echo 1 > /sys/class/gpio/gpio3/value"
// CD
#define CMD_FPGA_PICKED_STATUS "cat /sys/class/gpio/gpio7/value"
#define CMD_GET_FPGA_FLASH_DRIVE "awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd"
@ -69,7 +75,7 @@ int defineGPIOpins(char *mess) {
if (FAIL == validateKernelVersion(KERNEL_DATE_VRSN_3GPIO)) {
latestKernelVerified = 0;
LOG(logWARNING,
("Kernel too old to use gpio 3 pins. Update kernel to "
("Kernel too old to use gpio3 (nCE). Update kernel to "
"guarantee error-free fpga programming. \n\tNot the end "
"of the world. Continuing with current kernel...\n"));
} else {
@ -82,35 +88,35 @@ int defineGPIOpins(char *mess) {
if (access(CMD_GPIO7_EXIST, F_OK) != 0) {
if (executeCommand(CMD_GPIO7_DEFINE, retvals, logDEBUG1) == FAIL) {
snprintf(mess, MAX_STR_LENGTH,
"Could not define gpio7 pins for fpga (%s)\n", retvals);
"Could not define gpio7 (CD) for fpga (%s)\n", retvals);
LOG(logERROR, (mess));
return FAIL;
}
LOG(logINFO, ("\tgpio7: defined\n"));
LOG(logINFO, ("\tgpio7 (CD): defined\n"));
} else {
LOG(logINFO, ("\tgpio7: already defined\n"));
LOG(logINFO, ("\tgpio7 (CD): already defined\n"));
}
// define gpio7 direction
if (executeCommand(CMD_GPIO7_DEFINE_IN, retvals, logDEBUG1) == FAIL) {
snprintf(mess, MAX_STR_LENGTH,
"Could not set gpio7 as input for fpga (%s)\n", retvals);
"Could not set gpio7 (CD) as input for fpga (%s)\n", retvals);
LOG(logERROR, (mess));
return FAIL;
}
LOG(logINFO, ("\tgpio7: setting intput\n"));
LOG(logINFO, ("\tgpio7 (CD): setting intput\n"));
// define gpio9
if (access(CMD_GPIO9_EXIST, F_OK) != 0) {
if (executeCommand(CMD_GPIO9_DEFINE, retvals, logDEBUG1) == FAIL) {
snprintf(mess, MAX_STR_LENGTH,
"Could not define gpio9 pins for fpga (%s)\n", retvals);
"Could not define gpio9 (nConfig) for fpga (%s)\n", retvals);
LOG(logERROR, (mess));
return FAIL;
}
LOG(logINFO, ("\tgpio9: defined\n"));
LOG(logINFO, ("\tgpio9 (nConfig): defined\n"));
} else {
LOG(logINFO, ("\tgpio9: already defined\n"));
LOG(logINFO, ("\tgpio9 (nConfig): already defined\n"));
}
// define gpio3 (not chip enable)
@ -118,21 +124,21 @@ int defineGPIOpins(char *mess) {
if (access(CMD_GPIO3_EXIST, F_OK) != 0) {
if (executeCommand(CMD_GPIO3_DEFINE, retvals, logDEBUG1) == FAIL) {
snprintf(mess, MAX_STR_LENGTH,
"Could not define gpio3 pins for fpga (%s)\n",
"Could not define gpio3 (nCE) for fpga (%s)\n",
retvals);
LOG(logERROR, (mess));
return FAIL;
}
LOG(logINFO, ("\tgpio3: defined\n"));
LOG(logINFO, ("\tgpio3 (nCE): defined\n"));
} else {
LOG(logINFO, ("\tgpio3: already defined\n"));
LOG(logINFO, ("\tgpio3 (nCE): already defined\n"));
}
}
return OK;
}
int FPGAdontTouchFlash(char *mess) {
int FPGAdontTouchFlash(char *mess, int programming) {
#ifdef VIRTUAL
return OK;
#endif
@ -140,51 +146,51 @@ int FPGAdontTouchFlash(char *mess) {
// define gpio9 as output
if (executeCommand(CMD_GPIO9_DEFINE_OUT, retvals, logDEBUG1) == FAIL) {
snprintf(mess, MAX_STR_LENGTH,
"Could not set gpio9 as output for fpga (%s)\n", retvals);
"Could not set gpio9 (nConfig) as output for fpga (%s)\n", retvals);
LOG(logERROR, (mess));
return FAIL;
}
LOG(logINFO, ("\tgpio9: setting output\n"));
LOG(logINFO, ("\tgpio9 (nConfig): setting output\n"));
// define gpio3 as output
if (latestKernelVerified == 1) {
if (programming && latestKernelVerified == 1) {
if (executeCommand(CMD_GPIO3_DEFINE_OUT, retvals, logDEBUG1) == FAIL) {
snprintf(mess, MAX_STR_LENGTH,
"Could not set gpio3 as output for fpga (%s)\n", retvals);
"Could not set gpio3 (nCE) as output for fpga (%s)\n", retvals);
LOG(logERROR, (mess));
return FAIL;
}
LOG(logINFO, ("\tgpio3: setting output\n"));
LOG(logINFO, ("\tgpio3 (nCE): setting output\n"));
}
// tell FPGA to not: gpio9
if (executeCommand(CMD_GPIO9_DONT_TOUCH_FLASH, retvals, logDEBUG1) ==
FAIL) {
snprintf(mess, MAX_STR_LENGTH,
"Could not set gpio9 to not touch flash for fpga (%s)\n",
"Could not set gpio9 (nConfig) to not touch flash for fpga (%s)\n",
retvals);
LOG(logERROR, (mess));
return FAIL;
}
LOG(logINFO, ("\tgpio9: fpga dont touch flash\n"));
LOG(logINFO, ("\tgpio9 (nConfig): fpga dont touch flash (Low)\n"));
// tell FPGA to not: gpio3
if (latestKernelVerified == 1) {
if (programming && latestKernelVerified == 1) {
if (executeCommand(CMD_GPIO3_DONT_TOUCH_FLASH, retvals, logDEBUG1) ==
FAIL) {
snprintf(mess, MAX_STR_LENGTH,
"Could not set gpio3 to not touch flash for fpga (%s)\n",
"Could not set gpio3 (nCE) to not touch flash for fpga (%s)\n",
retvals);
LOG(logERROR, (mess));
return FAIL;
}
LOG(logINFO, ("\tgpio3: fpga dont touch flash\n"));
LOG(logINFO, ("\tgpio3 (nCE): fpga dont touch flash (High)\n"));
}
// usleep(100*1000);
return OK;
}
int FPGATouchFlash(char *mess) {
int FPGATouchFlash(char *mess, int programming) {
#ifdef VIRTUAL
return OK;
#endif
@ -192,20 +198,20 @@ int FPGATouchFlash(char *mess) {
// tell FPGA to touch flash to program itself
if (executeCommand(CMD_GPIO9_DEFINE_IN, retvals, logDEBUG1) == FAIL) {
snprintf(mess, MAX_STR_LENGTH,
"Could not set gpio9 as input for fpga (%s)\n", retvals);
"Could not set gpio9 (nConfig) as input for fpga (%s)\n", retvals);
LOG(logERROR, (mess));
return FAIL;
}
LOG(logINFO, ("\tgpio9: setting input\n"));
LOG(logINFO, ("\tgpio9 (nConfig): setting input\n"));
if (latestKernelVerified == 1) {
if (programming && latestKernelVerified == 1) {
if (executeCommand(CMD_GPIO3_DEFINE_IN, retvals, logDEBUG1) == FAIL) {
snprintf(mess, MAX_STR_LENGTH,
"Could not set gpio3 as input for fpga (%s)\n", retvals);
"Could not set gpio3 (nCE) as input for fpga (%s)\n", retvals);
LOG(logERROR, (mess));
return FAIL;
}
LOG(logINFO, ("\tgpio3: setting input\n"));
LOG(logINFO, ("\tgpio3 (nCE): setting input\n"));
}
return OK;
}
@ -215,10 +221,10 @@ int resetFPGA(char *mess) {
#ifdef VIRTUAL
return OK;
#endif
if (FPGAdontTouchFlash(mess) == FAIL) {
if (FPGAdontTouchFlash(mess, 0) == FAIL) {
return FAIL;
}
if (FPGATouchFlash(mess) == FAIL) {
if (FPGATouchFlash(mess, 0) == FAIL) {
return FAIL;
}
usleep(CTRL_SRVR_INIT_TIME_US);
@ -341,7 +347,7 @@ int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
}
if (index == PROGRAM_FPGA) {
if (FPGAdontTouchFlash(mess) == FAIL) {
if (FPGAdontTouchFlash(mess, 1) == FAIL) {
return FAIL;
}
}
@ -665,14 +671,14 @@ int writeToFlash(char *mess, ssize_t fsize, FILE *flashfd, FILE *srcfd) {
int waitForFPGAtoTouchFlash(char *mess) {
// touch and program
if (FPGATouchFlash(mess) == FAIL) {
if (FPGATouchFlash(mess, 1) == FAIL) {
return FAIL;
}
#ifdef VIRTUAL
return OK;
#endif
LOG(logINFO, ("\tWaiting for FPGA to program from flash\n"));
LOG(logINFO, ("\tWaiting for FPGA to program from flash... \n\t[gpio7 (CD) should be High when done]\n"));
int timeSpent = 0;
int result = 0;
@ -710,8 +716,8 @@ int waitForFPGAtoTouchFlash(char *mess) {
LOG(logERROR, (mess));
return FAIL;
}
LOG(logDEBUG1, ("gpi07 returned %d\n", result));
LOG(logDEBUG1, ("gpi07 (CD)returned %d\n", result));
}
LOG(logINFO, ("\tFPGA has picked up the program from flash\n"));
LOG(logINFO, ("\tFPGA has picked up the program from flash. gpio7 (CD) is High\n"));
return OK;
}

View File

@ -5,10 +5,10 @@
#define APILIB 0x220408
#define APIRECEIVER 0x220408
#define APIGUI 0x220328
#define APICTB 0x220516
#define APIGOTTHARD 0x220516
#define APIGOTTHARD2 0x220516
#define APIJUNGFRAU 0x220516
#define APIMYTHEN3 0x220516
#define APIMOENCH 0x220503
#define APIEIGER 0x220516
#define APICTB 0x220518
#define APIGOTTHARD 0x220518
#define APIGOTTHARD2 0x220518
#define APIJUNGFRAU 0x220518
#define APIMYTHEN3 0x220518
#define APIMOENCH 0x220517
#define APIEIGER 0x220518