mirror of
https://github.com/mist-devel/mist-firmware.git
synced 2026-01-11 23:43:04 +00:00
Fallback to root directory when RBFNAME from ARC file is not found
This commit is contained in:
parent
58727f49a2
commit
23ab2f6b74
31
fpga.c
31
fpga.c
@ -271,7 +271,7 @@ unsigned char ConfigureFpga(const char *name)
|
||||
if (f_open(&file, name, FA_READ) != FR_OK)
|
||||
{
|
||||
iprintf("No FPGA configuration file found!\r");
|
||||
FatalError(ERROR_BITSTREAM_OPEN);
|
||||
return ERROR_BITSTREAM_OPEN;
|
||||
}
|
||||
|
||||
iprintf("FPGA bitstream file %s opened, file size = %llu\r", name, f_size(&file));
|
||||
@ -297,7 +297,7 @@ unsigned char ConfigureFpga(const char *name)
|
||||
ALTERA_STOP_CONFIG
|
||||
iprintf("FPGA NSTATUS is NOT high!\r");
|
||||
f_close(&file);
|
||||
FatalError(ERROR_UPDATE_INIT_FAILED);
|
||||
return ERROR_UPDATE_INIT_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,7 +322,7 @@ unsigned char ConfigureFpga(const char *name)
|
||||
|
||||
if (f_read(&file, sector_buffer, SECTOR_BUFFER_SIZE, &br) != FR_OK) {
|
||||
f_close(&file);
|
||||
FatalError(ERROR_READ_BITSTREAM_FAILED);
|
||||
return ERROR_READ_BITSTREAM_FAILED;
|
||||
}
|
||||
|
||||
ptr = sector_buffer;
|
||||
@ -342,7 +342,7 @@ unsigned char ConfigureFpga(const char *name)
|
||||
|
||||
iprintf("FPGA NSTATUS is NOT high!\r");
|
||||
f_close(&file);
|
||||
FatalError(ERROR_UPDATE_PROGRESS_FAILED);
|
||||
return ERROR_UPDATE_PROGRESS_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -357,10 +357,10 @@ unsigned char ConfigureFpga(const char *name)
|
||||
// check if DONE is high
|
||||
if (!ALTERA_DONE_STATE) {
|
||||
iprintf("FPGA Configuration done but contains error... CONF_DONE is LOW\r");
|
||||
FatalError(ERROR_UPDATE_FAILED);
|
||||
return ERROR_UPDATE_FAILED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Start initialization */
|
||||
/* Clock another extra DCLK cycles while initialization is in progress
|
||||
through internal oscillator or driving clock cycles into CLKUSR pin */
|
||||
@ -383,10 +383,10 @@ unsigned char ConfigureFpga(const char *name)
|
||||
|
||||
iprintf("FPGA Initialization finish but contains error: NSTATUS is %s and CONF_DONE is %s.\r",
|
||||
ALTERA_NSTATUS_STATE?"HIGH":"LOW", ALTERA_DONE_STATE?"HIGH":"LOW" );
|
||||
FatalError(ERROR_UPDATE_FAILED);
|
||||
return ERROR_UPDATE_FAILED;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return ERROR_NONE;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -913,7 +913,7 @@ unsigned char GetFPGAStatus(void)
|
||||
}
|
||||
|
||||
|
||||
void fpga_init(const char *name) {
|
||||
unsigned char fpga_init(const char *name) {
|
||||
unsigned long time = GetRTTC();
|
||||
int loaded_from_usb = USB_LOAD_VAR;
|
||||
unsigned char ct;
|
||||
@ -927,15 +927,11 @@ void fpga_init(const char *name) {
|
||||
USB_LOAD_VAR = 0;
|
||||
|
||||
if((loaded_from_usb != USB_LOAD_VALUE) && !user_io_dip_switch1()) {
|
||||
unsigned char err = ConfigureFpga(name);
|
||||
if (err != ERROR_NONE) return err;
|
||||
|
||||
if (ConfigureFpga(name)) {
|
||||
time = GetRTTC() - time;
|
||||
iprintf("FPGA configured in %lu ms\r", time);
|
||||
} else {
|
||||
// should not reach this code
|
||||
iprintf("FPGA configuration failed\r");
|
||||
FatalError(ERROR_UPDATE_FAILED);
|
||||
}
|
||||
time = GetRTTC() - time;
|
||||
iprintf("FPGA configured in %lu ms\r", time);
|
||||
}
|
||||
|
||||
// wait max 100 msec for a valid core type
|
||||
@ -1024,4 +1020,5 @@ void fpga_init(const char *name) {
|
||||
if(user_io_core_type() == CORE_TYPE_ARCHIE) {
|
||||
puts("Running archimedes setup");
|
||||
} // end of archimedes setup
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
2
fpga.h
2
fpga.h
@ -3,7 +3,7 @@
|
||||
|
||||
#include "fat_compat.h"
|
||||
|
||||
void fpga_init(const char *name);
|
||||
unsigned char fpga_init(const char *name);
|
||||
unsigned char ConfigureFpga(const char*);
|
||||
void SendFile(FIL *file);
|
||||
void SendFileEncrypted(FIL *file,unsigned char *key,int keysize);
|
||||
|
||||
6
main.c
6
main.c
@ -219,14 +219,16 @@ int main(void)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char err;
|
||||
if(mod < 0 || !strlen(arc_get_rbfname())) {
|
||||
fpga_init(NULL); // error opening default ARC, try with default RBF
|
||||
err = fpga_init(NULL); // error opening default ARC, try with default RBF
|
||||
} else {
|
||||
user_io_set_core_mod(mod);
|
||||
strncpy(s, arc_get_rbfname(), sizeof(s)-5);
|
||||
strcat(s,".RBF");
|
||||
fpga_init(s);
|
||||
err = fpga_init(s);
|
||||
}
|
||||
if (err != ERROR_NONE) FatalError(err);
|
||||
|
||||
usb_dev_open();
|
||||
|
||||
|
||||
13
menu.c
13
menu.c
@ -363,6 +363,8 @@ static char CoreFileSelected(uint8_t idx, const char *SelectedName) {
|
||||
OsdCoreNameSet(SelectedName);
|
||||
|
||||
char mod = 0;
|
||||
char arc = 0;
|
||||
unsigned char err;
|
||||
const char *extension = GetExtension(SelectedName);
|
||||
const char *rbfname = SelectedName;
|
||||
arc_reset();
|
||||
@ -376,12 +378,19 @@ static char CoreFileSelected(uint8_t idx, const char *SelectedName) {
|
||||
strcpy(s, arc_get_rbfname());
|
||||
strcat(s, ".RBF");
|
||||
rbfname = (char*) &s;
|
||||
arc = 1;
|
||||
}
|
||||
user_io_reset();
|
||||
user_io_set_core_mod(mod);
|
||||
// reset fpga with core
|
||||
fpga_init(rbfname);
|
||||
|
||||
err = fpga_init(rbfname);
|
||||
if (err == ERROR_BITSTREAM_OPEN && arc) {
|
||||
strcpy(s, "/");
|
||||
strcat(s, arc_get_rbfname());
|
||||
strcat(s, ".RBF");
|
||||
err = fpga_init(s);
|
||||
}
|
||||
if (err != ERROR_NONE) FatalError(err);
|
||||
// De-init joysticks to allow re-ordering for new core
|
||||
StateReset();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user