@@ -110,12 +110,12 @@ bool AcqBoardOpalKelly::detectBoard()
110
110
}
111
111
else if (return_code == -1 ) // Opal Kelly library not found
112
112
{
113
- LOGC (" No Opal Kelly DLL found." );
113
+ LOGE (" No Opal Kelly DLL found." );
114
114
return false ;
115
115
}
116
116
else if (return_code == -2 )
117
117
{
118
- LOGC (" No Opal Kelly Acquisition Board found." );
118
+ LOGE (" No Opal Kelly Acquisition Board found." );
119
119
return false ;
120
120
}
121
121
@@ -144,11 +144,30 @@ bool AcqBoardOpalKelly::initializeBoard()
144
144
bitfilename += File::getSeparatorString ();
145
145
bitfilename += evalBoard->isUSB3 () ? " rhd2000_usb3.bit" : " rhd2000.bit" ;
146
146
147
- if (! evalBoard->uploadFpgaBitfile (bitfilename.toStdString ()))
147
+ if (! File (bitfilename). existsAsFile () || ! evalBoard->uploadFpgaBitfile (bitfilename.toStdString ()))
148
148
{
149
- LOGC (" Could not upload FPGA bitfile from " , bitfilename);
150
- deviceFound = false ;
151
- return false ;
149
+ // If the bitfile is not found in the executable directory or if the upload fails,
150
+ // try to load it from the saved state directory.
151
+
152
+ bitfilename = CoreServices::getSavedStateDirectory ().getFullPathName ();
153
+ bitfilename += File::getSeparatorString ();
154
+ bitfilename += " shared-api" + String (PLUGIN_API_VER);
155
+ bitfilename += File::getSeparatorString ();
156
+ bitfilename += evalBoard->isUSB3 () ? " rhd2000_usb3.bit" : " rhd2000.bit" ;
157
+
158
+ if (! evalBoard->uploadFpgaBitfile (bitfilename.toStdString ()))
159
+ {
160
+ AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
161
+ " Failed to upload FPGA bitfile" ,
162
+ " The Opal Kelly FPGA bitfile upload failed. Refer to the console for further details." ,
163
+ " OK" ,
164
+ nullptr ,
165
+ ModalCallbackFunction::create ([] (int ) {}));
166
+
167
+ LOGE (" Could not upload FPGA bitfile" );
168
+ deviceFound = false ;
169
+ return false ;
170
+ }
152
171
}
153
172
154
173
LOGC (" Successfully uploaded bitfile, initializing board..." );
0 commit comments