Skip to content
Snippets Groups Projects
Commit d8693d92 authored by Your Name's avatar Your Name
Browse files

Added CPU autodetection

parent 3be975f7
No related branches found
No related tags found
No related merge requests found
......@@ -71,3 +71,8 @@ run
load ../../test_2
run
exit
mem 0xFFFFF000
quit
exit
exit
exit
......@@ -18,4 +18,26 @@ const uint32_t ADDRESSES[SUPPORTED_CPUS][DEFINED_ADDRESSES] = {
{ 0x40000000, 0xFF900000, 0xE0000000, 0xFF904010 }
};
#define AHB_PNP 0xFFFFF000
#define DEV_GAISLER_LEON3 0x003
#define DEV_GAISLER_LEON3DSU 0x004
#define DEV_GAISLER_LEON4 0x048
#define DEV_GAISLER_LEON4DSU 0x049
#define DEV_GAISLER_LEON3FT 0x053
#define KNOWN_CPUS 5
const uint32_t CPU_MAP[KNOWN_CPUS][2] = {
{ DEV_GAISLER_LEON3, 0 },
{ DEV_GAISLER_LEON3DSU, 0 },
{ DEV_GAISLER_LEON4, 1 },
{ DEV_GAISLER_LEON4DSU, 1 },
{ DEV_GAISLER_LEON3FT, 0 }
};
extern const char *CPU_NAMES[];
#define amba_pnp_device(id) (((id) >> 12) & 0xfff)
#endif
const char* CPU_NAMES[] = { "LEON 3", "LEON 4" };
......@@ -71,6 +71,26 @@ FT_STATUS open_device(DWORD device_index, int cpu_type)
return ftStatus;
}
// Try to autodetect CPU type
if (device.cpu_type == -1) {
printf("Autodetecting CPU...");
DWORD cpu = amba_pnp_device(ioread32(AHB_PNP));
for(int i = 0; i < KNOWN_CPUS; i++) {
if (cpu == CPU_MAP[i][0]) {
device.cpu_type = CPU_MAP[i][1];
printf("%s CPU found!\n", CPU_NAMES[device.cpu_type]);
break;
}
}
if (device.cpu_type == -1) {
printf("Unknown cpu type: %03x ... Try to explicitly indicate a cpu with -cpu_type\n", cpu);
exit(-1);
}
}
// Move this to another step?
init_core_1(); // Initialize core 1 (this will run all the programs)
//_initCore2(); // Initialize core 2 (this will be idle)
......
......@@ -87,6 +87,7 @@ void showHelp()
printf("\t -help: \t This list of all available commands\n");
printf("\t -info: \t Version numbers and driver info\n");
printf("\t -list: \t List all available FTDI devices\n");
printf("\t -cpu_tye <num>: \t 0 for LEON 3 and 1 for LEON4 autodetection used of omitted \n");
printf("\t -jtag <num>: \t Open console with jtag device\n\n");
}
......@@ -110,7 +111,7 @@ int main(int argc, char *argv[])
}
int i = 1;
int cpu_type = 0;
int cpu_type = -1;
int device_index = 0;
while(i < argc) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment