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

Merge remote-tracking branch 'origin/master' into gw_add_gbit_links

parents 50770cf2 a292404f
Pipeline #3974 failed with stages
in 116 minutes and 15 seconds
#!/usr/bin/make
# ##############################################################################
# Settings
DOCKER_NAME=vivado
DOCKER_NAME=vivado-template
DOCKERFILE_PATH=docker
XILINX_TOOLS=/opt/Xilinx
XIL_VER?=2019.2
......
......@@ -111,7 +111,6 @@ fetch: \
# check the availability of commands
$(XSCT_BIN) $(BOOTGEN_BIN) $(PETALINUX_BUILD_BIN) $(PETALINUX_CONFIG_BIN):
$(if $(shell which $@),,$(error "$(@) not found"))
############################## u-boot #########################################
......@@ -231,12 +230,12 @@ fsbl_config: bootfw_patch $(XSCT_BIN) $(GW_XSA)
$(VT)echo -e "$(CO)Configuring fsbl...$(NC)" $(LOGT)
# gives erros like:
# WARNING: sysconfig command is DEPRECATED.
#
#
# Only one system configuration will be allowed in a platform.
# If no system configuration is present, creating a domain will create the system configuration.
#
# ERROR:set_bsp_conf set periph_type_overrides {{BOARD template}}: Cannot set Property "periph_type_overrides" with {BOARD template}
#
#
# ERROR:set_bsp_conf set periph_type_overrides {{BOARD template}}: Cannot set Property "periph_type_overrides" with {BOARD template}
#
# ERROR: Could not find the bsp config parameter.
# to get the list of valida parameters on "os" run "bsp listparams -os"
# to get the list of valida parameters on "processor" instance run "bsp listparams -proc"
......@@ -289,12 +288,12 @@ pmufw_config: bootfw_patch $(XSCT_BIN) $(GW_XSA)
$(VT)echo -e "$(CO)Configuring pmufw...$(NC)" $(LOGT)
# gives erros like:
# WARNING: sysconfig command is DEPRECATED.
#
#
# Only one system configuration will be allowed in a platform.
# If no system configuration is present, creating a domain will create the system configuration.
#
# ERROR:set_bsp_conf set periph_type_overrides {{BOARD template}}: Cannot set Property "periph_type_overrides" with {BOARD template}
#
#
# ERROR:set_bsp_conf set periph_type_overrides {{BOARD template}}: Cannot set Property "periph_type_overrides" with {BOARD template}
#
# ERROR: Could not find the bsp config parameter.
# to get the list of valida parameters on "os" run "bsp listparams -os"
# to get the list of valida parameters on "processor" instance run "bsp listparams -proc"
......@@ -655,7 +654,6 @@ bootbin_distclean:
$(V) rm -f _done/bootbin_artifacts _done/bootbin_build _done/bootbin_config $(LOG)
$(VT)echo -e "$(CO)Distclean boot.bin... done$(NC)" $(LOGT)
############################## boot image (image.ub) ##########################
image_ub: image_ub_artifacts
......
......@@ -1914,8 +1914,8 @@ CONFIG_VT_CONSOLE_SLEEP=y
CONFIG_HW_CONSOLE=y
CONFIG_VT_HW_CONSOLE_BINDING=y
CONFIG_UNIX98_PTYS=y
CONFIG_LEGACY_PTYS=y
CONFIG_LEGACY_PTY_COUNT=256
# CONFIG_LEGACY_PTYS is not set
# CONFIG_LEGACY_PTY_COUNT is not set
# CONFIG_SERIAL_NONSTANDARD is not set
# CONFIG_NOZOMI is not set
# CONFIG_N_GSM is not set
......
......@@ -83,7 +83,7 @@ index 15f95dd4488c..2d9fef5c5300 100644
}
static const struct i2c_device_id monimod_id[] = {
@@ -62,6 +90,134 @@ static struct i2c_driver monimod_driver = {
@@ -62,6 +90,133 @@ static struct i2c_driver monimod_driver = {
module_i2c_driver(monimod_driver);
......@@ -105,14 +105,13 @@ index 15f95dd4488c..2d9fef5c5300 100644
+ NULL, "%llx\n");
+
+
+static int monimod_debugfs_get_dword(void *data, u64 *val)
+static int monimod_debugfs_get_block_dword(void *data, u64 *val)
+{
+ int rc;
+ struct pmbus_debugfs_entry *entry = data;
+ u8 tmp[4];
+
+ rc = i2c_smbus_read_i2c_block_data(entry->client, entry->reg,
+ sizeof(tmp), tmp);
+ rc = i2c_smbus_read_block_data(entry->client, entry->reg, tmp);
+ if (rc < 0)
+ return rc;
+
......@@ -120,8 +119,8 @@ index 15f95dd4488c..2d9fef5c5300 100644
+
+ return 0;
+}
+DEFINE_DEBUGFS_ATTRIBUTE(monimod_debugfs_ops_get_dword,
+ monimod_debugfs_get_dword, NULL, "%lld\n");
+DEFINE_DEBUGFS_ATTRIBUTE(monimod_debugfs_ops_get_block_dword,
+ monimod_debugfs_get_block_dword, NULL, "%lld\n");
+
+static ssize_t monimod_debugfs_get_fw_type(struct file *file, char __user *buf,
+ size_t count, loff_t *ppos)
......@@ -189,14 +188,14 @@ index 15f95dd4488c..2d9fef5c5300 100644
+ entries[idx].reg = MONIMOD_REG_UPTIME_SECS;
+ debugfs_create_file("uptime_secs", 0444, monimod_dir,
+ &entries[idx++],
+ &monimod_debugfs_ops_get_dword);
+ &monimod_debugfs_ops_get_block_dword);
+
+ /* Create debugfs entry for tmr_error_cnt */
+ entries[idx].client = client;
+ entries[idx].reg = MONIMOD_REG_TMR_ERROR_CNT;
+ debugfs_create_file("tmr_error_cnt", 0444, monimod_dir,
+ &entries[idx++],
+ &monimod_debugfs_ops_get_dword);
+ &monimod_debugfs_ops_get_block_dword);
+
+ /* Create debugfs entry for use_pec */
+ entries[idx].client = client;
......
From a0662987d13c464ba98f1cc5582a4d4657a8740c Mon Sep 17 00:00:00 2001
From: Adam Wujek <dev_public@wujek.eu>
Date: Mon, 4 Jul 2022 19:43:07 +0200
Subject: [PATCH] hwmon: (monimod) check PMBUS_MFR_MODEL at load
Signed-off-by: Adam Wujek <dev_public@wujek.eu>
---
drivers/hwmon/pmbus/monimod.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/hwmon/pmbus/monimod.c b/drivers/hwmon/pmbus/monimod.c
index 7cf7430b0998..501bfdea5145 100644
--- a/drivers/hwmon/pmbus/monimod.c
+++ b/drivers/hwmon/pmbus/monimod.c
@@ -25,6 +25,8 @@
#define MONIMOD_FW_TYPE_BOOTLOADER 1
#define MONIMOD_FW_TYPE_MAIN 2
+#define MONIMOD_MFR_MODEL_MAIN_FW "DI/OT MoniMod"
+#define MONIMOD_MFR_MODEL_BOOTLOADER "DI/OT MoniMod (bl)"
#define MONIMOD_REG_BOOT_NEW_FW 0xD5
#define MONIMOD_REG_UPTIME_SECS 0xD7
@@ -59,15 +61,44 @@ static int monimod_probe(struct i2c_client *client,
{
int ret;
int probe_ret;
+ u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1];
probe_ret = pmbus_do_probe(client, id, &monimod_info);
+
+ ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, block_buffer);
+ if (ret < 0) {
+ dev_err(&client->dev, "Failed to read Manufacturer MODEL\n");
+ return ret;
+ }
+
+ block_buffer[ret] = '\0';
+ /* Check first if the monimod is in bootloader mode, to give more
+ * descriptive information */
+ if (!strcmp(block_buffer, MONIMOD_MFR_MODEL_BOOTLOADER)) {
+ dev_err(&client->dev, "Monimod in the bootloader mode, refuse "
+ "to register. Please switch to main mode.\n");
+ return -ENODEV;
+ }
+
+ /* In bootloader mode, STATUS_BYTE does not exists. Give a hint about
+ * bootloader mode (above) before failing. */
if (probe_ret < 0)
return probe_ret;
+ /* Check first if MFR model match */
+ if (ret != strlen(MONIMOD_MFR_MODEL_MAIN_FW)
+ || strcmp(block_buffer, MONIMOD_MFR_MODEL_MAIN_FW)) {
+ dev_err(&client->dev, "Unsupported Manufacturer Model. "
+ "Read %s, Expected %s\n", block_buffer,
+ MONIMOD_MFR_MODEL_MAIN_FW);
+ return -ENODEV;
+ }
ret = monimod_debugfs(client);
if (ret)
dev_warn(&client->dev, "Failed to register debugfs\n");
+ dev_info(&client->dev, "Registered Monimod\n");
+
return probe_ret;
}
--
2.17.1
From 40e05200593af06633f64ab0effff052eee6f076 Mon Sep 17 00:00:00 2001
From: Mans Rullgard <mans@mansr.com>
Date: Sat, 13 Jun 2020 11:41:09 +0100
Subject: [PATCH] i2c: core: check returned size of emulated smbus block read
If the i2c bus driver ignores the I2C_M_RECV_LEN flag (as some of
them do), it is possible for an I2C_SMBUS_BLOCK_DATA read issued
on some random device to return an arbitrary value in the first
byte (and nothing else). When this happens, i2c_smbus_xfer_emulated()
will happily write past the end of the supplied data buffer, thus
causing Bad Things to happen. To prevent this, check the size
before copying the data block and return an error if it is too large.
Fixes: 209d27c3b167 ("i2c: Emulate SMBus block read over I2C")
Signed-off-by: Mans Rullgard <mans@mansr.com>
[wsa: use better errno]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
---
drivers/i2c/i2c-core-smbus.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c
index 56bb840142e3..f5c9787992e9 100644
--- a/drivers/i2c/i2c-core-smbus.c
+++ b/drivers/i2c/i2c-core-smbus.c
@@ -495,6 +495,13 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
break;
case I2C_SMBUS_BLOCK_DATA:
case I2C_SMBUS_BLOCK_PROC_CALL:
+ if (msg[1].buf[0] > I2C_SMBUS_BLOCK_MAX) {
+ dev_err(&adapter->dev,
+ "Invalid block size returned: %d\n",
+ msg[1].buf[0]);
+ status = -EPROTO;
+ goto cleanup;
+ }
for (i = 0; i < msg[1].buf[0] + 1; i++)
data->block[i] = msg[1].buf[i];
break;
--
2.17.1
From 314e1aae7a9ec863dc09e0529ff1c5f1f7bc20b0 Mon Sep 17 00:00:00 2001
From: Adam Wujek <dev_public@wujek.eu>
Date: Fri, 1 Jul 2022 01:31:07 +0200
Subject: [PATCH] fdt_support: add uboot version to FDT
Under /chosen/uboot_version
Signed-off-by: Adam Wujek <dev_public@wujek.eu>
---
common/fdt_support.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 2b3f811bbd..630fe3ebc5 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -16,6 +16,7 @@
#include <fdt_support.h>
#include <exports.h>
#include <fdtdec.h>
+#include <version.h>
/**
* fdt_getprop_u32_default_node - Return a node's property or a default
@@ -332,6 +333,14 @@ int fdt_chosen(void *fdt)
}
}
+ err = fdt_setprop(fdt, nodeoffset, "uboot_version", PLAIN_VERSION,
+ strlen(PLAIN_VERSION) + 1);
+ if (err < 0) {
+ printf("WARNING: could not set uboot_version %s.\n",
+ fdt_strerror(err));
+ return err;
+ }
+
return fdt_fixup_stdout(fdt, nodeoffset);
}
--
2.17.1
......@@ -32,6 +32,8 @@ SRC_URI = " \
file://term.h \
file://util.c \
file://util.h \
file://fpga_device.h \
file://fpga_device.c \
"
DEPENDS = "libgpiod readline lmsensors i2c-tools"
......@@ -47,7 +49,6 @@ do_compile() {
do_install() {
install -d ${D}${bindir}
install -m 0755 ${S}/diot_util ${D}${bindir}
}
do_compile_prepend() {
......
......@@ -13,6 +13,7 @@ APP_OBJS = \
fru_utils.o \
term.o \
util.o \
fpga_device.o \
LDLIBS+=-lgpiod -lreadline -lsensors -li2c
CFLAGS+=-Wall -ggdb -g -O2 \
......
......@@ -29,14 +29,18 @@
#include "util.h"
#include "fru_utils.h"
#include "fpga_device.h"
#define DTB_HW_VER_FILE "/sys/firmware/devicetree/base/chosen/hw_ver"
#define DTB_MODEBOOT_FILE "/sys/firmware/devicetree/base/chosen/modeboot"
#define DTB_UIMAGE_SOURCE_FILE "/sys/firmware/devicetree/base/chosen/uimage_source"
#define DTB_RESET_REASON_FILE "/sys/firmware/devicetree/base/chosen/reset_reason"
#define DTB_UBOOT_VERSION_FILE "/sys/firmware/devicetree/base/chosen/uboot_version"
#define READLINE_PROMPT "diot_util> "
#define FPGA_DEVICE_ADDR 0x80000000
#define RED_CHECK(x) x ? COLOR_RED: ""
#define RED_OFF(x) x ? COLOR_OFF: ""
......@@ -69,7 +73,6 @@ struct string_map boot_mode_db[] = {
{ "nandboot", "nand" },
};
struct command_entry commands_list[] = {
{ .cmd_name = "status", .cmd_func = cmd_print_status, .cmd_help_string = "Print status\n", .cmd_params = NULL},
{ .cmd_name = "exit", .cmd_func = cmd_exit, .cmd_help_string = "quit program\n", .cmd_params = NULL},
......@@ -87,25 +90,33 @@ struct command_entry commands_list[] = {
{ .cmd_name = "fantray", .cmd_func = cmd_fantray, .cmd_help_string = "Commands for fantray module. Type \"help "
"fantray\" for more information about "
"subcommands\n", .cmd_params = NULL},
{ .cmd_name = "gateware", .cmd_func = cmd_fpga, .cmd_help_string = "Print information related to the gateware. Type help for more information\n", .cmd_params = NULL},
{ .cmd_name = NULL }
};
int cmd_help(char *params)
{
struct command_entry *entry = commands_list;
struct command_entry *entry;
char buf[50];
/* Print fantray's help if requested */
if (params && !strncmp(params, "fantray", strlen("fantray")))
entry = commands_list_fantray;
printf("diot_util for HW version %d\n", SB_VER);
printf("Avaiable commands:\n");
printf("Available commands:\n");
if (params && !strncmp(params, "fantray", strlen("fantray"))) {
/* Print fantray's help if requested */
entry = commands_list_fantray;
} else if (params && !strncmp(params, "gateware", strlen("gateware"))) {
/* Print gateware if requested */
entry = commands_list_fpga_device;
} else {
entry = commands_list;
}
while (entry->cmd_name) {
sprintf(buf, "%s %s", entry->cmd_name,
entry->cmd_params ? entry->cmd_params : "");
printf("%-18s - %s", buf, entry->cmd_help_string);
entry++;
sprintf(buf, "%s %s", entry->cmd_name,
entry->cmd_params ? entry->cmd_params : "");
printf("%-18s - %s", buf, entry->cmd_help_string);
entry++;
}
return 0;
......@@ -113,12 +124,15 @@ int cmd_help(char *params)
int cmd_version(char *params)
{
char buff[100];
printf("diot_util version information:\n");
printf("HW version: %d\n", SB_VER);
printf("GIT commit id: %s\n", __GIT_VER__);
printf("Build date: %s\n", __DATE__);
printf("Build time: %s\n", __TIME__);
printf("Built by: %s\n", __GIT_USR__);
printf("Uboot version: %s\n", get_file_content(DTB_UBOOT_VERSION_FILE, buff, sizeof(buff)));
return 0;
}
......@@ -375,6 +389,9 @@ int cmd_print_status(char *params)
printf("----------------------------+--------------+\n");
printf("\n");
get_fpga_status(false);
printf("\n");
print_slot_status();
printf("\n");
print_fmc_status();
......@@ -472,7 +489,7 @@ int main(int argc, char **argv)
/* Copy command like readline would do */
line_read = strndup(curr_script_cmd, cmd_len);
}
} else {
} else {
/* Get a line from the user. */
line_read = readline (READLINE_PROMPT);
}
......@@ -532,6 +549,9 @@ int main(int argc, char **argv)
char *
command_name_generator_fantray(const char *text, int state);
char *
command_name_generator_gateware(const char *text, int state);
char **
command_completion(const char *text, int start, int end)
{
......@@ -539,13 +559,17 @@ command_completion(const char *text, int start, int end)
rl_attempted_completion_over = 1;
/* Call completion function if the first word */
if (start == 0)
return rl_completion_matches(text, command_name_generator);
if (start == 0){
return rl_completion_matches(text, command_name_generator);
}
if (!strncmp(rl_line_buffer, "fantray load_fw", strlen("fantray load_fw"))) {
return rl_completion_matches(text, rl_filename_completion_function);
return rl_completion_matches(text, rl_filename_completion_function);
}
if (!strncmp(rl_line_buffer, "fantray", strlen("fantray"))) {
return rl_completion_matches(text, command_name_generator_fantray);
return rl_completion_matches(text, command_name_generator_fantray);
}
if (!strncmp(rl_line_buffer, "gateware", strlen("gateware"))) {
return rl_completion_matches(text, command_name_generator_gateware);
}
return NULL;
}
......@@ -589,3 +613,23 @@ char *command_name_generator_fantray(const char *text, int state)
return NULL;
}
/* command name generator for gateware */
char *command_name_generator_gateware(const char *text, int state)
{
static int list_index, len;
char *name;
if (!state) {
list_index = 0;
len = strlen(text);
}
while ((commands_list_fpga_device[list_index].cmd_name) && (name = commands_list_fpga_device[list_index++].cmd_name)) {
if (strncmp(name, text, len) == 0) {
return strdup(name);
}
}
return NULL;
}
\ No newline at end of file
......@@ -28,6 +28,8 @@
#include "util.h"
#define FANTRAY_FW_MAX_SIZE 0x3E000
#define UC_RESET_MAGIC 0x5A
#define BOOT_NEW_FW_MAGIC 0xAD
static int cmd_fantray_status(char *params);
static int cmd_fantray_reset(char *params);
......@@ -113,6 +115,7 @@ static int fantray_i2c_reset(void)
{
int i2cbus, i2c_file;
int ret = 0;
int use_pec;
i2cbus = atoi(FANTRAY_I2C);
i2c_file = open_i2c_dev(i2cbus);
......@@ -124,7 +127,21 @@ static int fantray_i2c_reset(void)
goto out;
}
ret = i2c_smbus_write_byte_data(i2c_file, FANTRAY_I2C_REG_RESET, 1);
/* If PEC is used by Monimod, it has to be used here too, otherwise writes
* are silently rejected */
/* Read PEC */
use_pec = i2c_smbus_read_byte_data(i2c_file, FANTRAY_I2C_REG_PEC);
if (use_pec > 0) {
/* PEC enabled, use it */
if (ioctl(i2c_file, I2C_PEC, 1) < 0) {
printf("Error: Could not set PEC: %s\n", strerror(errno));
} else {
printf("Using PEC\n");
}
}
ret = i2c_smbus_write_byte_data(i2c_file, FANTRAY_I2C_REG_RESET,
UC_RESET_MAGIC);
out:
close(i2c_file);
......@@ -512,6 +529,7 @@ static int cmd_fantray_load_fw(char *params)
char *p;
FILE *fw_file = NULL;
int errno_local;
int use_pec;
diot_error_clear();
......@@ -581,14 +599,34 @@ static int cmd_fantray_load_fw(char *params)
if (ret == FANTRAY_FW_TYPE_MAIN) {
printf("Fantray in main mode. Switching to bootloader mode\n");
/* If PEC is used by Monimod, it has to be used here too otherwise
* writes are silently rejected */
/* Read PEC */
use_pec = i2c_smbus_read_byte_data(i2c_file, FANTRAY_I2C_REG_PEC);
if (use_pec > 0) {
/* PEC enabled, use it */
if (ioctl(i2c_file, I2C_PEC, 1) < 0) {
printf("Error: Could not set PEC: %s\n", strerror(errno));
use_pec = 0;
} else {
printf("Using PEC\n");
}
}
/* Switch to boot loader */
ret = i2c_smbus_write_byte_data(i2c_file, FANTRAY_I2C_REG_BOOT_NEW_FW,
1);
BOOT_NEW_FW_MAGIC);
if (ret < 0) {
printf("Error: unable to set boot mode of the Fantray!\n");
goto close_i2c;
}
/* Disable PEC if was enabled */
if (use_pec > 0 && ioctl(i2c_file, I2C_PEC, 0) < 0) {
printf("Error: Could not set PEC: %s\n", strerror(errno));
use_pec = 0;
}
/* Let the bootloader to start */
sleep(2);
/* Confirm that bootloader is started */
......@@ -616,7 +654,8 @@ static int cmd_fantray_load_fw(char *params)
printf("Switching Fantray to main firmware mode\n");
/* Switch to main firmware */
ret = i2c_smbus_write_byte_data(i2c_file, FANTRAY_I2C_REG_BOOT_NEW_FW, 1);
ret = i2c_smbus_write_byte_data(i2c_file, FANTRAY_I2C_REG_BOOT_NEW_FW,
BOOT_NEW_FW_MAGIC);
if (ret < 0) {
printf("Error: unable to set the boot mode of the Fantray!\n");
goto close_i2c;
......
......@@ -36,6 +36,7 @@
#define FANTRAY_I2C_REG_LOCAL_FW_CHKSUM 0xD4
#define FANTRAY_I2C_REG_BOOT_NEW_FW 0xD5
#define FANTRAY_I2C_REG_RESET 0xD6
#define FANTRAY_I2C_REG_PEC 0xD9
#define FANTRAY_FW_TYPE_BOOTLOADER 0x1
#define FANTRAY_FW_TYPE_MAIN 0x2
......
/******************************************************************************/
/*
*
* @file fpga_device.c
*
* Functions to plot the FPGA Device info
*
******************************************************************************/
/***************************** Include Files **********************************/
#include "fpga_device.h"
/************************** Functions Prototype *******************************/
static int cmd_fpga_status (char *params);
/******************************** Structs *************************************/
struct command_entry commands_list_fpga_device[] = {
{ .cmd_name = "status", .cmd_func = cmd_fpga_status, .cmd_help_string = "Get all the information about FPGA convention\n", .cmd_params = "<all>"},
{ .cmd_name = NULL }
};
/******************************* Functions ************************************/
/******************************************************************************/
/**
* This function print the information related with FPGA convention
*
******************************************************************************/
int get_fpga_status(bool full_info){
struct tm build_date_s;
char core_id_c[4] = { [0 ... 3] = 0 };
char name_c[9] = { [0 ... 8] = 0 };
char build_date_c[80] = { [0 ... 79] = 0 };
char git_tag_c[9] = { [0 ... 8] = 0 };
uintptr_t auxaddr = c_ADDR_IP_CORE;
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, c_SIZE_BYTES, PROT_READ | PROT_WRITE, MAP_SHARED, fd, auxaddr);
if (regs_32b == MAP_FAILED) {
close(fd);
perror("Failed in Mmap device");
return -2;
}
printf("Gateware information\n");
if (full_info) {
//! Read Core ID
uint32_t aux_core_id = bswap_32(regs_32b[c_ADDR_CORE_ID]);
memcpy(&core_id_c,&aux_core_id,4);
//! Read Project Name
uint64_t name_u64 = bswap_64(((uint64_t) regs_32b[c_ADDR_NAME_MSB] << 32) + (uint64_t) regs_32b[c_ADDR_NAME_LSB]);
memcpy(&name_c,&name_u64,8);
}
//! Read Build Date
time_t date = (time_t) regs_32b[c_ADDR_BUILD_T];
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[c_ADDR_TAG_MSB] << 32) + (uint64_t) regs_32b[c_ADDR_TAG_LSB]);
memcpy(&git_tag_c,&git_tag_u64,8);
if (full_info) {
printf("VENDOR ID : %08x\n",regs_32b[c_ADDR_VENDOR_ID]);
printf("DEVICE ID : %08x\n",regs_32b[c_ADDR_DEVICE_ID]);
printf("VERSION : %08x\n",regs_32b[c_ADDR_VERSION]);
printf("Byte Order Map : %08x\n",regs_32b[c_ADDR_BYTE_ORD_MARK]);
printf("Source ID : %08x%08x%08x%08x\n",regs_32b[c_ADDR_SOURCE_ID_3],regs_32b[c_ADDR_SOURCE_ID_2],regs_32b[c_ADDR_SOURCE_ID_1],regs_32b[c_ADDR_SOURCE_ID_0]);
printf("Capability Mask : %08x\n",regs_32b[c_ADDR_CAP_MASK]);
printf("UUID : %08x%08x%08x%08x\n",regs_32b[c_ADDR_VENDOR_UUID_3],regs_32b[c_ADDR_VENDOR_UUID_2],regs_32b[c_ADDR_VENDOR_UUID_1],regs_32b[c_ADDR_VENDOR_UUID_0]);
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[c_ADDR_HASH_4],regs_32b[c_ADDR_HASH_3],regs_32b[c_ADDR_HASH_2],regs_32b[c_ADDR_HASH_1],regs_32b[c_ADDR_HASH_0]);
printf("GIT TAG : %s\n",git_tag_c);
printf("DNA : %08x%08x%08x\n",regs_32b[c_ADDR_DNA_2],regs_32b[c_ADDR_DNA_1],regs_32b[c_ADDR_DNA_0]);
} else {
printf("BUILD DATE : %s\n",build_date_c);
printf("GIT HASH : %08x%08x%08x%08x%08x\n",regs_32b[c_ADDR_HASH_4],regs_32b[c_ADDR_HASH_3],regs_32b[c_ADDR_HASH_2],regs_32b[c_ADDR_HASH_1],regs_32b[c_ADDR_HASH_0]);
printf("GIT TAG : %s\n",git_tag_c);
}
munmap(regs_32b, c_SIZE_BYTES);
close(fd);
return 0;
}
/******************************************************************************/
/**
* This function implemets subcommand status related with FPGA information
*
******************************************************************************/
static int cmd_fpga_status(char *params) {
int ret = 0;
char *aux_params = NULL;
if (!params || !(*params)) {
printf("case no params \n");
ret = get_fpga_status(false);
} else {
aux_params = strchr(params, ' ');
if (!aux_params || !(*aux_params)) {
if (!strncmp(params, "all", strlen("all"))) {
ret = get_fpga_status(true);
} else {
cmd_help("gateware");
}
} else {
cmd_help("gateware");
}
}
if (ret != 0) {
perror("Command gateware status failed");
}
return ret;
}
/******************************************************************************/
/**
* This function search for subcommands related with FPGA information
*
******************************************************************************/
int cmd_fpga (char *params) {
struct command_entry *entry;
char *cmd_start_p = params;
int ret = 0;
int cmd_len;
if (!params || !(*params)) {
printf("Please provide subcommand for the gateware command\n");
cmd_help("gateware");
ret = -ENOENT;
} else {
params = strchr(params, ' ');
if (params) {
cmd_len = params - cmd_start_p;
/* skip spaces for params */
while (*params && (*params == ' ')) {
params++;
}
} else {
cmd_len = strlen(cmd_start_p);
}
entry = commands_list_fpga_device;
while (entry && entry->cmd_name) {
if (cmd_len == strlen(entry->cmd_name) && !strncmp(entry->cmd_name, cmd_start_p, cmd_len)) {
ret = entry->cmd_func(params);
break;
}
entry++;
}
if (!(entry && entry->cmd_name)) {
printf("Commad \"%s\" not found\n", cmd_start_p);
ret = -ENOENT;
}
}
return ret;
}
\ No newline at end of file
/** @file fpga_device.h
*
* @brief Library for FPGA device Convention
*
* @author alen.arias.vazquez@cern.ch
* @date 12/05/2022
* @url https://ohwr.org/project/fpga-dev-id/wikis/home
*
*/
#ifndef __FPGA_DEVICE_H
#define __FPGA_DEVICE_H
#ifdef __cplusplus
extern "C" {
#endif
/***************************** Include Files **********************************/
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <byteswap.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <errno.h>
#include <stdbool.h>
#include "diot_util.h"
/************************** Constant Definitions ******************************/
/***************** Macros (Inline Functions) Definitions **********************/
#define c_ADDR_VENDOR_ID 0x00
#define c_ADDR_DEVICE_ID 0x01
#define c_ADDR_VERSION 0x02
#define c_ADDR_BYTE_ORD_MARK 0x03
#define c_ADDR_SOURCE_ID_0 0x04
#define c_ADDR_SOURCE_ID_1 0x05
#define c_ADDR_SOURCE_ID_2 0x06
#define c_ADDR_SOURCE_ID_3 0x07
#define c_ADDR_CAP_MASK 0x08
#define c_ADDR_VENDOR_UUID_0 0x0C
#define c_ADDR_VENDOR_UUID_1 0x0D
#define c_ADDR_VENDOR_UUID_2 0x0E
#define c_ADDR_VENDOR_UUID_3 0x0F
#define c_ADDR_CORE_ID 0x10
#define c_ADDR_NAME_LSB 0x11
#define c_ADDR_NAME_MSB 0x12
#define c_ADDR_BUILD_T 0x13
#define c_ADDR_HASH_0 0x14
#define c_ADDR_HASH_1 0x15
#define c_ADDR_HASH_2 0x16
#define c_ADDR_HASH_3 0x17
#define c_ADDR_HASH_4 0x18
#define c_ADDR_DNA_0 0x19
#define c_ADDR_DNA_1 0x1A
#define c_ADDR_DNA_2 0x1B
#define c_ADDR_TAG_LSB 0x1C
#define c_ADDR_TAG_MSB 0x1D
#define c_ADDR_IP_CORE 0x80000000
#define c_SIZE_BYTES c_ADDR_TAG_MSB*4
/**************************** Type Definitions ********************************/
/******************************** Structs *************************************/
extern struct command_entry commands_list_fpga_device[];
/************************** Variable Definitions ******************************/
/************************** Function Prototypes *******************************/
int cmd_fpga (char *params);
int get_fpga_status(bool full_info);
#ifdef __cplusplus
}
#endif
#endif /* __FPGA_DEVICE_H */
# Remove run-time dependency of python3-pycparser on cpp and cpp-symlinks
#
# python3-pytest depends on python3-attrs->python3-cryptography->python3-pycparser
# but features used in pytest do not need cpp nor cpp-symlinks.
# This reduces the size of rootfs image by ~8MB
RDEPENDS_${PN}_remove = "cpp cpp-symlinks "
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