/* * File: * f1FirmwareUpdate.c * * Description: * JLab f1TDC firmware updating program for a single board. * * */ #include #include #include #include "jvme.h" #include "f1tdcLib.h" char *progName; void Usage(); int main(int argc, char *argv[]) { int iflag=0, stat=0, F1_SLOT=0; int inputchar=10; unsigned int f1_address=0; char *rbf_filename; printf("\nJLAB f1TDC Firmware Update\n"); printf("----------------------------\n"); progName = argv[0]; if(argc<3) { printf(" ERROR: Must specify two arguments\n"); Usage(); exit(-1); } else { rbf_filename = argv[1]; f1_address = (unsigned int) strtoll(argv[2],NULL,16)&0xffffffff; } stat = f1FirmwareReadFile(rbf_filename); if(stat != OK) exit(-1); vmeSetQuietFlag(1); stat = vmeOpenDefaultWindows(); if(stat != OK) goto CLOSE; iflag |= F1_SRSRC_SOFT; iflag |= F1_TRIGSRC_SOFT; iflag |= F1_CLKSRC_INT; iflag |= F1_IFLAG_NOINIT; iflag |= F1_IFLAG_NOFWCHECK; stat = f1Init(f1_address,0,1,iflag); if(stat != OK) goto CLOSE; F1_SLOT = f1Slot(0); int if1=0; unsigned int cfw=0; extern int nf1tdc; for(if1=0; if1 to continue... or q and to quit without update.\n"); inputchar = getchar(); if((inputchar == 113) || (inputchar == 81)) { printf(" Quitting without update.\n"); goto CLOSE; } stat = f1FirmwareEraseEPROM(F1_SLOT); if(stat != OK) goto CLOSE; stat = f1FirmwareDownloadConfigData(F1_SLOT,1); if(stat != OK) goto CLOSE; stat = f1FirmwareVerifyDownload(F1_SLOT,1); if(stat != OK) goto CLOSE; CLOSE: vmeCloseDefaultWindows(); return OK; } void Usage() { printf("\n"); printf("%s \n",progName); printf("\n"); }