Commit 13a8bff2 authored by Alén Arias Vázquez's avatar Alén Arias Vázquez 😎

first idea of diot status

parent 7f258ab3
Pipeline #3817 canceled with stages
in 2 minutes and 41 seconds
......@@ -37,6 +37,8 @@
#define READLINE_PROMPT "diot_util> "
#define FPGA_DEVICE_ADDR 0x80000000
#define RED_CHECK(x) x ? COLOR_RED: ""
#define RED_OFF(x) x ? COLOR_OFF: ""
......@@ -132,11 +134,66 @@ int cmd_exit(char *params)
exit(0);
}
int print_gw_info(void)
static void print_gw_info(void)
{
struct tm build_date_s;
char name_c[9] = { [0 ... 8] = 0 };
char build_date_c[80] = { [0 ... 79] = 0 };
char git_tag_c[9] = { [0 ... 8] = 0 };
char core_id_c[4] = { [0 ... 3] = 0 };
uintptr_t auxaddr = FPGA_DEVICE_ADDR;
int fd = open("/dev/mem", O_RDWR | O_SYNC);
if (fd < 0) {
perror("Failed in Open device");
return fd;
}
uint32_t * regs_32b = mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, auxaddr);
if (regs_32b == MAP_FAILED) {
close(fd);
perror("Failed in Mmap device");
return -2;
}
//! Read Core ID
uint32_t aux_core_id = bswap_32(regs_32b[16]);
memcpy(&core_id_c,&aux_core_id,4);
//! Read Project Name
uint64_t name_u64 = bswap_64(((uint64_t) regs_32b[18] << 32) + (uint64_t) regs_32b[17]);
memcpy(&name_c,&name_u64,8);
//! Read Build Date
time_t date = (time_t) regs_32b[19];
build_date_s = *localtime(&date);
strftime(build_date_c, sizeof(build_date_c), "%a %Y-%m-%d %H:%M:%S", &build_date_s);
//! Read String Tag
uint64_t git_tag_u64 = bswap_64(((uint64_t) regs_32b[35] << 32) + (uint64_t) regs_32b[34]);
memcpy(&git_tag_c,&git_tag_u64,8);
printf("Gateware version information:\n");
printf("VENDOR ID : %08x\n",regs_32b[0]);
printf("DEVICE ID : %08x\n",regs_32b[1]);
printf("VERSION : %08x\n",regs_32b[2]);
printf("Byte Order Map : %08x\n",regs_32b[3]);
printf("Source ID : %08x%08x%08x%08x\n",regs_32b[7],regs_32b[6],regs_32b[5],regs_32b[4]);
printf("Capability Mask : %08x\n",regs_32b[8]);
printf("UUID : %08x%08x%08x%08x\n",regs_32b[15],regs_32b[14],regs_32b[13],regs_32b[12]);
printf("IP CORE ID : %s\n",core_id_c);
printf("NAME : %s\n",name_c);
printf("BUILD DATE : %s\n",build_date_c);
printf("GIT HASH : %08x%08x%08x%08x%08x\n",regs_32b[24],regs_32b[23],regs_32b[22],regs_32b[21],regs_32b[20]);
printf("DNA : %08x%08x%08x\n",regs_32b[27],regs_32b[26],regs_32b[25]);
printf("GIT TAG : %s\n\n",git_tag_c);
close(fd);
return;
return 0;
}
static void print_slot_status(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment