diff --git a/file_io.c b/file_io.c index d87bf5e..e4df5e4 100644 --- a/file_io.c +++ b/file_io.c @@ -518,7 +518,11 @@ int ScanDirectory(char* path, unsigned long mode, char *extension, unsigned char } else if (de->d_type == DT_REG) { + //skip non-selectable files if (!strcasecmp(de->d_name, "menu.rbf")) continue; + if (!strcasecmp(de->d_name, "boot.rom")) continue; + if (!strcasecmp(de->d_name, "boot.vhd")) continue; + if (extlen > 0) { int len = strlen(de->d_name); diff --git a/user_io.c b/user_io.c index a3ae77d..65bc356 100644 --- a/user_io.c +++ b/user_io.c @@ -140,6 +140,7 @@ static void user_io_read_core_name() void user_io_detect_core_type() { char *name; + char mainpath[32]; core_name[0] = 0; core_type = (fpga_core_id() & 0xFF); @@ -218,12 +219,20 @@ void user_io_detect_core_type() } // check if there's a .rom present - strcpy(name + strlen(name) - 3, "ROM"); - user_io_file_tx(name, 0); + sprintf(mainpath, "%s/boot.rom", user_io_get_core_name()); + if (!user_io_file_tx(mainpath, 0)) + { + strcpy(name + strlen(name) - 3, "ROM"); + user_io_file_tx(name, 0); + } // check if there's a .vhd present - strcpy(name + strlen(name) - 3, "VHD"); - user_io_file_mount(name); + sprintf(mainpath, "%s/boot.vhd", user_io_get_core_name()); + if (!user_io_file_mount(mainpath)) + { + strcpy(name + strlen(name) - 3, "VHD"); + user_io_file_mount(name); + } } // release reset @@ -561,7 +570,7 @@ void user_io_set_index(unsigned char index) DisableFpga(); } -void user_io_file_mount(char *name) +int user_io_file_mount(char *name) { int writable = FileCanWrite(name); @@ -570,7 +579,7 @@ void user_io_file_mount(char *name) { sd_image.size = 0; printf("Failed to open file %s\n", name); - return; + return 0; } printf("Mount %s as %s\n", name, writable ? "read-write" : "read-only"); @@ -594,14 +603,15 @@ void user_io_file_mount(char *name) // notify core of possible sd image change spi_uio_cmd8(UIO_SET_SDSTAT, 0); + return 1; } -void user_io_file_tx(char* name, unsigned char index) +int user_io_file_tx(char* name, unsigned char index) { fileTYPE f; static uint8_t buf[512]; - if (!FileOpen(&f, name)) return; + if (!FileOpen(&f, name)) return 0; unsigned long bytes2send = f.size; @@ -650,6 +660,7 @@ void user_io_file_tx(char* name, unsigned char index) DisableFpga(); iprintf("\n"); + return 1; } // 8 bit cores have a config string telling the firmware how diff --git a/user_io.h b/user_io.h index 643dd1e..ea67b0f 100644 --- a/user_io.h +++ b/user_io.h @@ -158,11 +158,11 @@ void user_io_osd_key_enable(char); void user_io_serial_tx(char *, uint16_t); char *user_io_8bit_get_string(char); unsigned long user_io_8bit_set_status(unsigned long, unsigned long); -void user_io_file_tx(char *, unsigned char); +int user_io_file_tx(char *, unsigned char); void user_io_sd_set_config(void); char user_io_dip_switch1(void); char user_io_serial_status(serial_status_t *, uint8_t); -void user_io_file_mount(char *name); +int user_io_file_mount(char *name); char *user_io_get_core_name(); char is_menu_core();