From a452ae9dd9760ad549e96cb317756f14136fabca Mon Sep 17 00:00:00 2001 From: pettershao-ragilenetworks Date: Tue, 17 Jan 2023 22:59:38 +0800 Subject: [PATCH] update --- .../common/Makefile | 100 +++++----- .../common/app/dev_util/dfd_utest.c | 176 +++++++++--------- .../firmware_upgrade_ispvme/dfd_fpga_upg.c | 4 +- .../firmware_app_ispvme.c | 56 +++--- .../common/app/hw_test/hw_dram.c | 64 ++++--- .../common/app/hw_test/hw_i2c.c | 5 +- .../common/app/hw_test/hw_misc.c | 22 ++- .../common/app/hw_test/hw_usb.c | 15 +- 8 files changed, 241 insertions(+), 201 deletions(-) diff --git a/platform/centec-arm64/sonic-platform-modules-ragile/common/Makefile b/platform/centec-arm64/sonic-platform-modules-ragile/common/Makefile index 92ced575e375..e59e9f0033ba 100644 --- a/platform/centec-arm64/sonic-platform-modules-ragile/common/Makefile +++ b/platform/centec-arm64/sonic-platform-modules-ragile/common/Makefile @@ -1,50 +1,50 @@ -PWD = $(shell pwd) -CC ?=gcc -INSTALL_MOD_DIR ?=extra -KVERSION ?= $(shell uname -r) -KERNEL_SRC ?= /lib/modules/$(KVERSION) -EXTRA_CFLAGS:= -I$(M)/include -EXTRA_CFLAGS+= -Wall -ifdef ENABLE_GCOV -ifeq ($(ENABLE_GCOV), y) -EXTRA_CFLAGS+= -fprofile-arcs -ftest-coverage -lgcov -endif -endif # ENABLE_GCOV -SUB_BUILD_DIR = $(PWD)/build -DIR_KERNEL_SRC = $(PWD)/modules -SCRIPT_DIR = $(PWD)/script -SERVICE_DIR = $(PWD)/service -BLACK_DRIVER_CONF_DIR = $(PWD)/modprobe_conf - -app_dir = $(PWD)/app -app_build_dir = $(app_dir)/build -modules_build_dir = $(DIR_KERNEL_SRC)/build - -INSTALL_MODULE_DIR = $(SUB_BUILD_DIR)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR) -INSTALL_SCRIPT_DIR = $(SUB_BUILD_DIR)/usr/local/bin -INSTALL_SERVICE_DIR = $(SUB_BUILD_DIR)/lib/systemd/system -INSTALL_LIB_DIR = $(SUB_BUILD_DIR)/usr/lib/python3.9/dist-packages -INSTALL_BLACK_DRIVER = $(SUB_BUILD_DIR)/etc/modprobe.d -CTC_48GT4X_PHY_DIR = $(SUB_BUILD_DIR)/usr/share/sonic/device/arm64-ragile_ra-b6010-48gt4x-r0/RA-B6010-48GT4X -CTC_48GT4X_R_PHY_DIR = $(SUB_BUILD_DIR)/usr/share/sonic/device/arm64-ragile_ra-b6010-48gt4x-r-r0/RA-B6010-48GT4X-R - -all: - $(MAKE) -C $(app_dir) - $(MAKE) -C $(DIR_KERNEL_SRC) - @if [ ! -d ${INSTALL_MODULE_DIR} ]; then mkdir -p ${INSTALL_MODULE_DIR} ;fi - @if [ ! -d ${INSTALL_SCRIPT_DIR} ]; then mkdir -p ${INSTALL_SCRIPT_DIR} ;fi - @if [ ! -d ${INSTALL_SERVICE_DIR} ]; then mkdir -p ${INSTALL_SERVICE_DIR} ;fi - @if [ ! -d ${CTC_48GT4X_PHY_DIR} ]; then mkdir -p ${CTC_48GT4X_PHY_DIR}/phy_drv ;fi - @if [ ! -d ${CTC_48GT4X_R_PHY_DIR} ]; then mkdir -p ${CTC_48GT4X_R_PHY_DIR}/phy_drv ;fi - @if [ ! -d ${INSTALL_LIB_DIR} ]; then mkdir -p ${INSTALL_LIB_DIR} ;fi - @if [ -d $(PWD)/lib/ ]; then cp -r $(PWD)/lib/* ${INSTALL_LIB_DIR} ;fi - cp -r $(app_dir)/*.so $(CTC_48GT4X_PHY_DIR)/phy_drv - cp -r $(app_dir)/*.so $(CTC_48GT4X_R_PHY_DIR)/phy_drv - #cp -r $(app_build_dir)/module/*.ko $(INSTALL_MODULE_DIR) - cp -r $(modules_build_dir)/*.ko $(INSTALL_MODULE_DIR) - #cp -r $(app_dir)/build/app/* $(INSTALL_SCRIPT_DIR) - if [ -d $(SCRIPT_DIR) ]; then cp -r $(SCRIPT_DIR)/* $(INSTALL_SCRIPT_DIR) ;fi - if [ -d $(SERVICE_DIR) ]; then cp -r $(SERVICE_DIR)/* $(INSTALL_SERVICE_DIR) ;fi - @if [ -d $(INSTALL_SCRIPT_DIR) ]; then chmod +x $(INSTALL_SCRIPT_DIR)/* ;fi -clean: - rm -rf $(SUB_BUILD_DIR) +PWD = $(shell pwd) +CC ?=gcc +INSTALL_MOD_DIR ?=extra +KVERSION ?= $(shell uname -r) +KERNEL_SRC ?= /lib/modules/$(KVERSION) +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall +ifdef ENABLE_GCOV +ifeq ($(ENABLE_GCOV), y) +EXTRA_CFLAGS+= -fprofile-arcs -ftest-coverage -lgcov +endif +endif # ENABLE_GCOV +SUB_BUILD_DIR = $(PWD)/build +DIR_KERNEL_SRC = $(PWD)/modules +SCRIPT_DIR = $(PWD)/script +SERVICE_DIR = $(PWD)/service +BLACK_DRIVER_CONF_DIR = $(PWD)/modprobe_conf + +app_dir = $(PWD)/app +app_build_dir = $(app_dir)/build +modules_build_dir = $(DIR_KERNEL_SRC)/build + +INSTALL_MODULE_DIR = $(SUB_BUILD_DIR)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR) +INSTALL_SCRIPT_DIR = $(SUB_BUILD_DIR)/usr/local/bin +INSTALL_SERVICE_DIR = $(SUB_BUILD_DIR)/lib/systemd/system +INSTALL_LIB_DIR = $(SUB_BUILD_DIR)/usr/lib/python3.9/dist-packages +INSTALL_BLACK_DRIVER = $(SUB_BUILD_DIR)/etc/modprobe.d +CTC_48GT4X_PHY_DIR = $(SUB_BUILD_DIR)/usr/share/sonic/device/arm64-ragile_ra-b6010-48gt4x-r0/RA-B6010-48GT4X +CTC_48GT4X_R_PHY_DIR = $(SUB_BUILD_DIR)/usr/share/sonic/device/arm64-ragile_ra-b6010-48gt4x-r-r0/RA-B6010-48GT4X-R + +all: + $(MAKE) -C $(app_dir) + $(MAKE) -C $(DIR_KERNEL_SRC) + @if [ ! -d ${INSTALL_MODULE_DIR} ]; then mkdir -p ${INSTALL_MODULE_DIR} ;fi + @if [ ! -d ${INSTALL_SCRIPT_DIR} ]; then mkdir -p ${INSTALL_SCRIPT_DIR} ;fi + @if [ ! -d ${INSTALL_SERVICE_DIR} ]; then mkdir -p ${INSTALL_SERVICE_DIR} ;fi + @if [ ! -d ${CTC_48GT4X_PHY_DIR} ]; then mkdir -p ${CTC_48GT4X_PHY_DIR}/phy_drv ;fi + @if [ ! -d ${CTC_48GT4X_R_PHY_DIR} ]; then mkdir -p ${CTC_48GT4X_R_PHY_DIR}/phy_drv ;fi + @if [ ! -d ${INSTALL_LIB_DIR} ]; then mkdir -p ${INSTALL_LIB_DIR} ;fi + @if [ -d $(PWD)/lib/ ]; then cp -r $(PWD)/lib/* ${INSTALL_LIB_DIR} ;fi + cp -r $(app_dir)/*.so $(CTC_48GT4X_PHY_DIR)/phy_drv + cp -r $(app_dir)/*.so $(CTC_48GT4X_R_PHY_DIR)/phy_drv + #cp -r $(app_build_dir)/module/*.ko $(INSTALL_MODULE_DIR) + cp -r $(modules_build_dir)/*.ko $(INSTALL_MODULE_DIR) + #cp -r $(app_dir)/build/app/* $(INSTALL_SCRIPT_DIR) + if [ -d $(SCRIPT_DIR) ]; then cp -r $(SCRIPT_DIR)/* $(INSTALL_SCRIPT_DIR) ;fi + if [ -d $(SERVICE_DIR) ]; then cp -r $(SERVICE_DIR)/* $(INSTALL_SERVICE_DIR) ;fi + @if [ -d $(INSTALL_SCRIPT_DIR) ]; then chmod +x $(INSTALL_SCRIPT_DIR)/* ;fi +clean: + rm -rf $(SUB_BUILD_DIR) diff --git a/platform/centec-arm64/sonic-platform-modules-ragile/common/app/dev_util/dfd_utest.c b/platform/centec-arm64/sonic-platform-modules-ragile/common/app/dev_util/dfd_utest.c index aa6fa5575df5..18b4834cf312 100644 --- a/platform/centec-arm64/sonic-platform-modules-ragile/common/app/dev_util/dfd_utest.c +++ b/platform/centec-arm64/sonic-platform-modules-ragile/common/app/dev_util/dfd_utest.c @@ -42,12 +42,14 @@ static int g_sys_page_size; void dfd_utest_print_cmd(int argc, char* argv[]) { int i; - + char tmp[128]; + for (i = 1; i < argc; i++) { if (i != 1) { printf(" "); } - printf("%s", argv[i]); + snprintf(tmp, sizeof(tmp), "%s", argv[i]); + printf("%s", tmp); } return; } @@ -57,7 +59,7 @@ void dfd_utest_print_all_help(void) int i, tbl_size; tbl_size = sizeof(g_dfd_unit_test) / sizeof(g_dfd_unit_test[0]); - + for (i = 0; i < tbl_size; i++) { printf("%-20s\t\t\t%s\r\n", g_dfd_unit_test[i].type_str, g_dfd_unit_test[i].help_info); } @@ -86,18 +88,18 @@ void dfd_utest_printf_single_help(int utest_type) void dfd_utest_printf_reg(uint8_t *buf, int buf_len, uint16_t offset_addr) { int i, j, tmp; - + j = offset_addr % 16; tmp = j; offset_addr -= j; printf("\n "); - + for (i = 0; i < 16; i++) { printf("%2x ", i); } - + for (i = 0; i < buf_len + j; i++) { - if ((i % 16) == 0) { + if ((i % 16) == 0) { printf("\n0x%08x ", offset_addr); offset_addr = offset_addr + 16; } @@ -115,7 +117,7 @@ void dfd_utest_printf_reg(uint8_t *buf, int buf_len, uint16_t offset_addr) #define I2C_RETRIES 0x0701 #define I2C_TIMEOUT 0x0702 -#define I2C_RDWR 0x0707 +#define I2C_RDWR 0x0707 #define I2C_SLAVE 0x0703 /* Use this slave address */ @@ -137,12 +139,12 @@ struct i2c_msg struct i2c_rdwr_ioctl_data { struct i2c_msg *msgs; - int nmsgs; /* The number of nmsgs determines how many start signals there are. + int nmsgs; /* The number of nmsgs determines how many start signals there are. For "single start timing", take 1 */ }; - + #define DFD_I2C_SHORT_ADDR_TYPE 0 -#define DFD_I2C_RETRY_SLEEP_TIME (10000) /* 10ms */ +#define DFD_I2C_RETRY_SLEEP_TIME (10000) /* 10ms */ #define DFD_I2C_RETRY_TIME (50000 / DFD_I2C_RETRY_SLEEP_TIME) /* 50ms */ /* i2c_smbus_xfer read or write markers */ #define I2C_SMBUS_READ 1 @@ -222,10 +224,10 @@ int32_t dfd_read_port_i2c_one_time_smbus(char *i2c_name, uint16_t dev_addr, uint DFD_DEBUG_ERROR("i2c_num = NULL, recv_buf = NULL\r\n"); return -1; } - + DFD_DEBUG_DBG("i2c name: %s, dev_addr: 0x%x, offset_addr: 0x%x, size: %d, addr_type: %d.\n", i2c_name, dev_addr, offset_addr, size, addr_type); - + rv = 0; fd = open(i2c_name, O_RDWR | O_SYNC); if (fd < 0) { @@ -241,10 +243,10 @@ int32_t dfd_read_port_i2c_one_time_smbus(char *i2c_name, uint16_t dev_addr, uint for (i = 0 ;i < size; i++) { data.byte = 0; ioctl_data.read_write = I2C_SMBUS_READ; - ioctl_data.command = (offset_addr + i); + ioctl_data.command = (offset_addr + i); ioctl_data.size = I2C_SMBUS_BYTE_DATA; ioctl_data.data= &data; - + rc = ioctl(fd, I2C_SMBUS, &ioctl_data); if (rc < 0) { DFD_DEBUG_ERROR("read, I2C_SMBUS failed: %d.\n", errno); @@ -253,7 +255,7 @@ int32_t dfd_read_port_i2c_one_time_smbus(char *i2c_name, uint16_t dev_addr, uint } *(recv_buf + i) = data.byte; } - fail: + fail: close(fd); err: return rv; @@ -267,9 +269,9 @@ int32_t dfd_read_port_i2c_one_time_smbus(char *i2c_name, uint16_t dev_addr, uint * @offset_addr: offset address * @recv_buf: read buffer * @size: the size of read buf - * @addr_type: 0:single byte offset access 1:2 byte offset access + * @addr_type: 0:single byte offset access 1:2 byte offset access * - * return: return 0 or positive value on success,return negative vlaue on failure + * return: return 0 or positive value on success,return negative vlaue on failure */ int32_t dfd_read_port_i2c_one_time(char *i2c_name, uint16_t dev_addr, uint16_t offset_addr, uint8_t *recv_buf, int32_t size, int addr_type) @@ -279,15 +281,15 @@ int32_t dfd_read_port_i2c_one_time(char *i2c_name, uint16_t dev_addr, uint16_t o struct i2c_rdwr_ioctl_data ioctl_data; struct i2c_msg msgs[2]; uint8_t buf[2]; - + if (i2c_name == NULL || recv_buf == NULL) { DFD_DEBUG_ERROR("i2c_num = NULL, recv_buf = NULL\r\n"); return -1; } - + DFD_DEBUG_DBG("i2c name %s, dev_addr 0x%x, offset_addr 0x%x, size %d, addr_type %d.\n", i2c_name, dev_addr, offset_addr, size, addr_type); - + rv = 0; fd = open(i2c_name, O_RDWR | O_SYNC); if (fd < 0) { @@ -296,15 +298,15 @@ int32_t dfd_read_port_i2c_one_time(char *i2c_name, uint16_t dev_addr, uint16_t o } memset(&ioctl_data, 0, sizeof(ioctl_data)); memset(msgs, 0, sizeof(msgs)); - memset(buf, 0, sizeof(buf)); - if (ioctl(fd, I2C_SLAVE, dev_addr) < 0) { - /* open failed */ + memset(buf, 0, sizeof(buf)); + if (ioctl(fd, I2C_SLAVE, dev_addr) < 0) { + /* open failed */ DFD_DEBUG_ERROR("%s %dioctl fail(ret:%d, errno:%s)!\r\n", __func__ , __LINE__, rv, strerror(errno)); rv = -1; goto fail; } - - buf[0] = (uint8_t)(offset_addr); + + buf[0] = (uint8_t)(offset_addr); msgs[0].addr= dev_addr; msgs[0].len= 2; msgs[0].buf= buf; @@ -314,7 +316,7 @@ int32_t dfd_read_port_i2c_one_time(char *i2c_name, uint16_t dev_addr, uint16_t o msgs[1].buf= recv_buf; ioctl_data.nmsgs= 1; ioctl_data.msgs= msgs; - + rv = ioctl(fd, I2C_RDWR, &ioctl_data); if(rv < 0) { DFD_DEBUG_ERROR("%s %dioctl fail(ret:%d, errno:%s)!\r\n", __func__ , __LINE__, rv, strerror(errno)); @@ -326,8 +328,8 @@ int32_t dfd_read_port_i2c_one_time(char *i2c_name, uint16_t dev_addr, uint16_t o fail: close(fd); return rv; - - + + } /** @@ -370,7 +372,7 @@ int32_t dfd_read_port_i2c(char *i2c_name, uint16_t dev_addr, uint16_t offset_add * * return: return 0 or positive value on success,return negative value on failure */ -int32_t dfd_write_port_i2c_one_time(char *i2c_name, uint16_t dev_addr, uint16_t offset_addr, +int32_t dfd_write_port_i2c_one_time(char *i2c_name, uint16_t dev_addr, uint16_t offset_addr, uint8_t *write_buf, int32_t size,int addr_type) { int32_t fd, rv; @@ -384,7 +386,7 @@ int32_t dfd_write_port_i2c_one_time(char *i2c_name, uint16_t dev_addr, uint16_t DFD_DEBUG_ERROR("i2c_num = NULL \r\n"); return -1; } - + if (size <= 0) { DFD_DEBUG_ERROR("error:size\n"); return -1; @@ -403,13 +405,13 @@ int32_t dfd_write_port_i2c_one_time(char *i2c_name, uint16_t dev_addr, uint16_t DFD_DEBUG_ERROR("i2c open fail fd %d\n", fd); return -1; } - + if (ioctl(fd, I2C_SLAVE_FORCE, dev_addr) < 0) { DFD_DEBUG_ERROR("ioctl, I2C_SLAVE failed: %d.\n", errno); rv = -1; goto fail; } - + for (index = 0; index < size; index++) { data.byte = *(write_buf + index); ioctl_data.read_write = I2C_SMBUS_WRITE; @@ -424,7 +426,7 @@ int32_t dfd_write_port_i2c_one_time(char *i2c_name, uint16_t dev_addr, uint16_t DFD_DEBUG_DBG("ret:%d value:0x%02x\n", rv, data.byte); usleep(5000); /* SMBUS will fail to write multiple bytes without delay, here the delay is 5ms (experience value) */ } - + fail: close(fd); return rv; @@ -440,7 +442,7 @@ int32_t dfd_write_port_i2c_one_time(char *i2c_name, uint16_t dev_addr, uint16_t * * return: return 0 or positive value on success,return negative value on failure */ -int32_t dfd_write_port_i2c(char *i2c_name, uint16_t dev_addr, uint16_t offset_addr, +int32_t dfd_write_port_i2c(char *i2c_name, uint16_t dev_addr, uint16_t offset_addr, uint8_t *write_buf, int32_t size) { int i; @@ -476,14 +478,14 @@ static int dfd_read_io_port(uint16_t offset_addr, uint8_t *recv_buf, int32_t siz printf("lseek failed ret %d.\n", ret); goto exit; } - + ret = read(fd, recv_buf, size); if (ret != size) { printf("read failed ret %d size %d.\n", ret, size); ret = -1; goto exit; } - + exit: close(fd); return ret; @@ -505,14 +507,14 @@ static int dfd_write_io_port(uint16_t offset_addr, uint8_t *write_buf, int32_t s printf("lseek failed ret %d.\n", ret); goto exit; } - + ret = write(fd, write_buf, size); if (ret != size) { printf("write failed ret %d size %d.\n", ret, size); ret = -1; goto exit; } - + exit: close(fd); return ret; @@ -609,7 +611,7 @@ int dfd_utest_i2c_rd(int argc, char* argv[]) char *stopstring; int num, i2c_bus; char i2c_path[32]; - + if (argc != 6) { DFD_DEBUG_ERROR("params error\n"); dfd_utest_printf_single_help(DFD_UTEST_ITEM_I2C_RD); @@ -638,7 +640,7 @@ int dfd_utest_i2c_rd(int argc, char* argv[]) dfd_utest_printf_reg(value, num, offset_addr); -exit: +exit: return DFD_RV_MODE_NOTSUPPORT; } @@ -652,7 +654,7 @@ int dfd_utest_i2c_wr(int argc, char* argv[]) char i2c_path[32]; uint8_t wr_len,i; uint8_t wr_value[DFD_UTEST_MAX_RD_NUM]; - + if (argc < 6) { DFD_DEBUG_ERROR("Input invalid.\n"); dfd_utest_printf_single_help(DFD_UTEST_ITEM_I2C_WR); @@ -668,19 +670,19 @@ int dfd_utest_i2c_wr(int argc, char* argv[]) wr_value[i] = strtol(argv[5+i], &stopstring, 16); DFD_DEBUG_DBG(" index :%d value %x\n", i , wr_value[i]); } - + dfd_utest_print_cmd(argc, argv); - + printf(":\n"); snprintf(i2c_path, sizeof(i2c_path), "/dev/i2c-%d", i2c_bus); - + ret = dfd_write_port_i2c(i2c_path, dev_addr, offset_addr, wr_value, wr_len); if (ret < 0) { printf("failed ret %d\n", ret); } else { printf("success\n"); } -exit: +exit: return DFD_RV_MODE_NOTSUPPORT; } @@ -691,7 +693,7 @@ int dfd_utest_io_rd(int argc, char* argv[]) uint16_t offset_addr; char *stopstring; int num; - + if (argc != 4) { DFD_DEBUG_ERROR("params error\n"); dfd_utest_printf_single_help(DFD_UTEST_ITEM_IO_RD); @@ -717,7 +719,7 @@ int dfd_utest_io_rd(int argc, char* argv[]) dfd_utest_printf_reg(value, num, offset_addr); -exit: +exit: return DFD_RV_MODE_NOTSUPPORT; } @@ -728,7 +730,7 @@ int dfd_utest_io_wr(int argc, char* argv[]) char *stopstring; int32_t wr_len,i; uint8_t wr_value[DFD_UTEST_MAX_RD_NUM]; - + if (argc < 4) { DFD_DEBUG_ERROR("Input invalid.\n"); dfd_utest_printf_single_help(DFD_UTEST_ITEM_IO_WR); @@ -741,16 +743,16 @@ int dfd_utest_io_wr(int argc, char* argv[]) dfd_utest_printf_single_help(DFD_UTEST_ITEM_IO_WR); goto exit; } - + offset_addr = strtol(argv[2], &stopstring, 16); for (i = 0; i < wr_len; i++) { wr_value[i] = strtol(argv[3 + i], &stopstring, 16); DFD_DEBUG_DBG(" index :%d value %x\n", i , wr_value[i]); } - + dfd_utest_print_cmd(argc, argv); - + printf(":\n"); ret = dfd_write_io_port(offset_addr, wr_value, wr_len); if (ret < 0) { @@ -769,7 +771,7 @@ int dfd_utest_phymem_rd(int argc, char* argv[]) off_t offset_addr; char *stopstring; int num; - + if (argc != 5) { DFD_DEBUG_ERROR("params error\n"); dfd_utest_printf_single_help(DFD_UTEST_ITEM_PHYMEM_RD); @@ -796,7 +798,7 @@ int dfd_utest_phymem_rd(int argc, char* argv[]) dfd_utest_printf_reg(value, num, offset_addr); -exit: +exit: return DFD_RV_MODE_NOTSUPPORT; } @@ -807,7 +809,7 @@ int dfd_utest_phymem_wr(int argc, char* argv[]) char *stopstring; int32_t wr_len,i; uint8_t wr_value[DFD_UTEST_MAX_RD_NUM]; - + if (argc < 5) { DFD_DEBUG_ERROR("Input invalid.\n"); dfd_utest_printf_single_help(DFD_UTEST_ITEM_PHYMEM_WR); @@ -828,9 +830,9 @@ int dfd_utest_phymem_wr(int argc, char* argv[]) wr_value[i] = strtol(argv[4 + i], &stopstring, 16); DFD_DEBUG_DBG(" index :%d value %x\n", i , wr_value[i]); } - + dfd_utest_print_cmd(argc, argv); - + printf(":\n"); ret = dfd_process_mem(DEV_MEM_NAME, 1, width, offset_addr, wr_value, wr_len); if (ret < 0) { @@ -849,13 +851,13 @@ int dfd_utest_kmem_rd(int argc, char* argv[]) uint16_t offset_addr; char *stopstring; int num; - + if (argc != 5) { DFD_DEBUG_ERROR("params error\n"); dfd_utest_printf_single_help(DFD_UTEST_ITEM_KMEM_RD); goto exit; } - + width = strtol(argv[2], &stopstring, 10); offset_addr = strtol(argv[3], &stopstring, 16); num = strtol(argv[4], &stopstring, 10); @@ -876,7 +878,7 @@ int dfd_utest_kmem_rd(int argc, char* argv[]) dfd_utest_printf_reg(value, num, offset_addr); -exit: +exit: return DFD_RV_MODE_NOTSUPPORT; } @@ -887,7 +889,7 @@ int dfd_utest_kmem_wr(int argc, char* argv[]) char *stopstring; int32_t wr_len,i; uint8_t wr_value[DFD_UTEST_MAX_RD_NUM]; - + if (argc < 5) { DFD_DEBUG_ERROR("Input invalid.\n"); dfd_utest_printf_single_help(DFD_UTEST_ITEM_KMEM_WR); @@ -900,7 +902,7 @@ int dfd_utest_kmem_wr(int argc, char* argv[]) dfd_utest_printf_single_help(DFD_UTEST_ITEM_KMEM_WR); goto exit; } - + width = strtol(argv[2], &stopstring, 10); offset_addr = strtol(argv[3], &stopstring, 16); @@ -908,9 +910,9 @@ int dfd_utest_kmem_wr(int argc, char* argv[]) wr_value[i] = strtol(argv[4 + i], &stopstring, 16); DFD_DEBUG_DBG(" index :%d value %x\n", i , wr_value[i]); } - + dfd_utest_print_cmd(argc, argv); - + printf(":\n"); ret = dfd_process_mem(DEV_KMEM_NAME, 1, width, offset_addr, wr_value, wr_len); if (ret < 0) { @@ -928,12 +930,12 @@ static unsigned long dfd_utest_get_file_size(const char *path) struct stat statbuff; if (stat(path, &statbuff) < 0) { - filesize = -1; + filesize = -1; } else { - filesize = statbuff.st_size; + filesize = statbuff.st_size; } - return filesize; + return filesize; } @@ -951,7 +953,7 @@ int dfd_utest_i2c_file_wr(int argc, char* argv[]) int len; int bpt; /* byte per times*/ int page_left; - + if (argc != 7) { printf("Input invalid.\n"); dfd_utest_printf_single_help(DFD_UTEST_ITEM_I2C_FILE_WR); @@ -966,7 +968,7 @@ int dfd_utest_i2c_file_wr(int argc, char* argv[]) if ((bpt <= 0) || (bpt > DFD_UTEST_MAX_RD_NUM)) { bpt = DFD_UTEST_MAX_RD_NUM; - } + } if ((bpt & (bpt - 1)) != 0) { printf("Bytes per times %d isn't power of two.\n",bpt); @@ -984,7 +986,7 @@ int dfd_utest_i2c_file_wr(int argc, char* argv[]) printf("open file[%s] fail.\n", file_name); goto exit; } - + dfd_utest_print_cmd(argc, argv); printf(":\n"); @@ -1016,7 +1018,7 @@ int dfd_utest_i2c_file_wr(int argc, char* argv[]) printf("success\n"); } -exit: +exit: return DFD_RV_MODE_NOTSUPPORT; } @@ -1031,16 +1033,16 @@ int dfd_utest_sysfs_file_wr(int argc, char* argv[]) unsigned long filesize; int fd, file_fd; uint8_t wr_buf[DFD_UTEST_MAX_WR_NUM]; - int len, write_len;; + int len, write_len;; int i; - + if (argc != 5) { printf("Input invalid.\n"); dfd_utest_printf_single_help(DFD_UTEST_ITEM_SYSFS_FILE_WR); goto exit; } - + sysfs_loc = argv[2]; offset_addr = strtol(argv[3], &stopstring, 16); file_name = argv[4]; @@ -1056,7 +1058,7 @@ int dfd_utest_sysfs_file_wr(int argc, char* argv[]) printf("open file[%s] fail.\n", file_name); goto exit; } - + fd = open(sysfs_loc, O_RDWR | O_SYNC); if (fd < 0) { printf("open file[%s] fail.\n", sysfs_loc); @@ -1078,7 +1080,7 @@ int dfd_utest_sysfs_file_wr(int argc, char* argv[]) } else { len = filesize; } - + memset(wr_buf, 0, DFD_UTEST_MAX_WR_NUM); len = read(file_fd, wr_buf, len); for (i = 0; i < DFD_I2C_RETRY_TIME; i++) { @@ -1090,12 +1092,12 @@ int dfd_utest_sysfs_file_wr(int argc, char* argv[]) } break; } - + if(i == DFD_I2C_RETRY_TIME) { printf("write file[%s] fail, offset = 0x%x, len = %d,write_len =%d\n", sysfs_loc, offset_addr, len, write_len); ret = -1; goto fail; - } + } offset_addr += len; filesize -= len; usleep(5000); @@ -1103,14 +1105,14 @@ int dfd_utest_sysfs_file_wr(int argc, char* argv[]) printf("success\n"); close(file_fd); - close(fd); + close(fd); return DFD_RV_OK; fail: close(file_fd); open_dev_err: close(fd); -exit: +exit: return DFD_RV_MODE_NOTSUPPORT; } @@ -1122,15 +1124,15 @@ int dfd_utest_sysfs_file_rd(int argc, char* argv[]) char *stopstring; int fd; uint8_t rd_buf[DFD_UTEST_MAX_RD_NUM]; - int len, read_len;; + int len, read_len;; + - if (argc != 5) { printf("Input invalid.\n"); dfd_utest_printf_single_help(DFD_UTEST_ITEM_SYSFS_FILE_RD); goto exit; } - + sysfs_loc = argv[2]; offset_addr = strtol(argv[3], &stopstring, 16); len = strtol(argv[4], &stopstring, 10); @@ -1139,7 +1141,7 @@ int dfd_utest_sysfs_file_rd(int argc, char* argv[]) printf("Input num %d exceed max 256.\n", len); goto exit; } - + fd = open(sysfs_loc, O_RDONLY); if (fd < 0) { printf("open file[%s] fail.\n", sysfs_loc); @@ -1154,7 +1156,7 @@ int dfd_utest_sysfs_file_rd(int argc, char* argv[]) printf("lseek failed ret %d.\n", ret); goto fail; } - + memset(rd_buf, 0, DFD_UTEST_MAX_RD_NUM); read_len = read(fd, rd_buf, len); if (read_len != len) { @@ -1167,7 +1169,7 @@ int dfd_utest_sysfs_file_rd(int argc, char* argv[]) fail: close(fd); -exit: +exit: return DFD_RV_MODE_NOTSUPPORT; } @@ -1197,7 +1199,7 @@ void dfd_utest_cmd_main(int argc, char* argv[]) dfd_utest_print_all_help(); return; } - + pfunc = dfd_utest_get_proc_func(argv[1]); if (pfunc == NULL) { DFD_DEBUG_DBG("utest type %s in not support.\n", utest_type_str); diff --git a/platform/centec-arm64/sonic-platform-modules-ragile/common/app/firmware_upgrade/firmware_upgrade_ispvme/dfd_fpga_upg.c b/platform/centec-arm64/sonic-platform-modules-ragile/common/app/firmware_upgrade/firmware_upgrade_ispvme/dfd_fpga_upg.c index 645d09379803..7b0fb7e25f70 100644 --- a/platform/centec-arm64/sonic-platform-modules-ragile/common/app/firmware_upgrade/firmware_upgrade_ispvme/dfd_fpga_upg.c +++ b/platform/centec-arm64/sonic-platform-modules-ragile/common/app/firmware_upgrade/firmware_upgrade_ispvme/dfd_fpga_upg.c @@ -536,7 +536,7 @@ int dfd_fpga_upg_set_erase_p4e(dfd_pci_dev_priv_t *pci_priv, int spi_addr) return -1; } - /* write erase address */ + /* write erase address */ val = spi_addr; addr = pci_priv->fpga_upg_base + FPGA_UPG_ADDR_REG; ret = dfd_fpga_upg_write_word(pci_priv, addr, val); @@ -1398,7 +1398,7 @@ int dfd_fpga_upgrade_dump_flash(int argc, char* argv[]) if (strcmp(argv[5], "print") != 0) { is_print = 0; memset(filename, 0, DFD_FPGA_UPGRADE_BUFF_SIZE); - strncpy(filename, argv[5], (DFD_FPGA_UPGRADE_BUFF_SIZE - 1)); + snprintf(filename, sizeof(filename), "%s", argv[5]); fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, S_IRWXG|S_IRWXU|S_IRWXO); if (fd < 0) { printf("open file %s fail(err:%d)!\r\n", filename, errno); diff --git a/platform/centec-arm64/sonic-platform-modules-ragile/common/app/firmware_upgrade/firmware_upgrade_ispvme/firmware_app_ispvme.c b/platform/centec-arm64/sonic-platform-modules-ragile/common/app/firmware_upgrade/firmware_upgrade_ispvme/firmware_app_ispvme.c index fc6e3cd9a9ec..3a4885a50f1c 100644 --- a/platform/centec-arm64/sonic-platform-modules-ragile/common/app/firmware_upgrade/firmware_upgrade_ispvme/firmware_app_ispvme.c +++ b/platform/centec-arm64/sonic-platform-modules-ragile/common/app/firmware_upgrade/firmware_upgrade_ispvme/firmware_app_ispvme.c @@ -5,7 +5,7 @@ * firmware_app.c * Original Author : support@ragilenetworks.com, 2013-10-23 * - * firmware upgrade + * firmware upgrade * * History * v1.0 chenwendai(support@ragilenetworks.com) 2013-10-23 Initial version. @@ -94,7 +94,7 @@ static firmware_card_info_t g_card_info[] = { }, }, - + { .dev_type = AS13_48F8H, .slot_num = 1, @@ -174,7 +174,7 @@ static firmware_card_info_t g_card_info[] = { .jtag_1 = GPIO(-1, 1,1) }, }, - }, + }, { .dev_type = AS14_128H, .slot_num = 5, @@ -253,7 +253,7 @@ static firmware_card_info_t g_card_info[] = { }, }, - + { .dev_type = AS23_128H, .slot_num = 5, @@ -614,7 +614,7 @@ static firmware_card_info_t g_card_info[] = { .jtag_3 = GPIO(-1, 1,1) .jtag_2 = GPIO(-1, 0,1) .jtag_1 = GPIO(-1, 1,1) - + }, /* slot 2 */ { @@ -793,7 +793,7 @@ static firmware_card_info_t g_card_info[] = { .jtag_1 = GPIO(-1, 1,1) }, }, - + }, { @@ -1056,7 +1056,7 @@ static int dfd_my_type = 0; static int is_vme_file(char *file_name) { char *tmp; - + tmp = strchr(file_name, '.'); if (strcmp(tmp, ".bin") == 0) { return 0; @@ -1091,7 +1091,7 @@ int drv_get_my_dev_type(void) if (read_len > 0) { type = strtoul(rbuf, NULL, 0); } - close(fd); + close(fd); dfd_my_type = type; @@ -1512,7 +1512,7 @@ static int firmware_upgrade_set_gpio_info(int slot) ret = -1; goto gpio_info_err; } - + gpio_info = &(hw_info->gpio_info[slot]); cmd_info.size = sizeof(firmware_upg_gpio_info_t); cmd_info.data = (void *)gpio_info; @@ -1524,7 +1524,7 @@ static int firmware_upgrade_set_gpio_info(int slot) gpio_info_err: if (ret < 0) { - dbg_print(is_debug_on, "Failed due to:set gpio info.\n"); + dbg_print(is_debug_on, "Failed due to:set gpio info.\n"); } close(fd); @@ -1545,7 +1545,7 @@ static int firmware_upgrade_one_file(int argc, char *argv[]) char tmp[FIRMWARE_FILE_DIR_LEN]; memset(&info, 0, sizeof(name_info_t)); - + info.slot = strtoul(argv[3], NULL, 10); strncpy(info.chip_name, argv[4], FIRMWARE_NAME_LEN - 1); @@ -1569,7 +1569,7 @@ static int firmware_upgrade_one_file(int argc, char *argv[]) dbg_print(is_debug_on, "unknow file\n"); return FIRMWARE_FAILED; } - } + } else if (strcmp(argv[2], FIRMWARE_FPGA_NAME) == 0) { /* FPGA upgrade */ info.type = FIRMWARE_FPGA; ret = dfd_fpga_upgrade_do_upgrade(argv[1]); @@ -1577,7 +1577,7 @@ static int firmware_upgrade_one_file(int argc, char *argv[]) dbg_print(is_debug_on, "Failed to get upgrade type: %s.\n", argv[2]); return ERR_FW_UPGRADE; } - + upgrade_err: if (ret != FIRMWARE_SUCCESS){ dbg_print(is_debug_on, "Failed to upgrade: %s.\n", argv[1]); @@ -1701,9 +1701,13 @@ static int firmware_upgrade_read_chip(int argc, char *argv[]) static int firmware_upgrade_test_fpga(int argc, char *argv[]) { int ret; + char tmp1[128]; + char tmp2[128]; if ((strcmp(argv[1], FIRMWARE_FPGA_NAME) != 0) || (strcmp(argv[2], FIRMWARE_FPGA_TEST) != 0)) { - printf( "fpga test:Failed to Input ERR Parm, argv[1]:%s, agrv[2]:%s\n", argv[1], argv[2]); + snprintf(tmp1, sizeof(tmp1), "%s", argv[1]); + snprintf(tmp2, sizeof(tmp2), "%s", argv[2]); + printf( "fpga test:Failed to Input ERR Parm, argv[1]:%s, agrv[2]:%s\n", tmp1, tmp2); return FIRMWARE_FAILED; } ret = dfd_fpga_upgrade_test(); @@ -1715,25 +1719,29 @@ static int firmware_upgrade_test_chip(int argc, char *argv[]) int ret,dev_type,slot; int err_ret=0; firmware_card_info_t *hw_info; - + char tmp1[128]; + char tmp2[128]; + if ((strcmp(argv[1], FIRMWARE_CPLD_NAME) != 0) || (strcmp(argv[2], FIRMWARE_CPLD_TEST) != 0)) { - printf( "gpio test:Failed to Input ERR Parm, argv[1]:%s, agrv[2]:%s\n", argv[1], argv[2]); + snprintf(tmp1, sizeof(tmp1), "%s", argv[1]); + snprintf(tmp2, sizeof(tmp2), "%s", argv[2]); + printf( "gpio test:Failed to Input ERR Parm, argv[1]:%s, agrv[2]:%s\n",tmp1, tmp2); return FIRMWARE_FAILED; } - + dev_type = drv_get_my_dev_type(); /* get the type of card first */ if (dev_type < 0) { printf("gpio test:drv_get_my_dev_type failed ret 0x%x.\n", dev_type); return FIRMWARE_FAILED; } - + hw_info = firmware_get_card_info(dev_type); /* get the detail information of card */ if (hw_info == NULL) { printf( "gpio test:card type 0x%x don't support firmware.\n", dev_type); return FIRMWARE_FAILED; - } - + } + for(slot = 0; slot < hw_info->slot_num; slot++){ ret = firmware_upgrade_set_gpio_info(slot); /* set GPIO information */ if(ret < 0){ @@ -1772,7 +1780,7 @@ int main(int argc, char *argv[]) dbg_print(is_debug_on, "failed to init dfd ret %d.", ret); return ERR_FW_UPGRADE; } -#endif +#endif /* dump fpga flash operation */ if (argc == 6) { if (strcmp(argv[1], "fpga_dump_flash") == 0) { @@ -1795,8 +1803,8 @@ int main(int argc, char *argv[]) printf("| CPLD Upgrade failed! |\n"); else if(strcmp(argv[2], FIRMWARE_FPGA_NAME) == 0) printf("| FPGA Upgrade failed! |\n"); - else - printf("| Failed to get upgrade type! |\n"); + else + printf("| Failed to get upgrade type! |\n"); printf("+================================+\n"); dbg_print(is_debug_on, "Failed to upgrade a firmware file: %s.\n", argv[1]); return ret; @@ -1834,7 +1842,7 @@ int main(int argc, char *argv[]) return FIRMWARE_SUCCESS; } - + if (argc == 3) { if (strcmp(argv[1], FIRMWARE_FPGA_NAME) == 0) { ret = firmware_upgrade_test_fpga(argc, argv); diff --git a/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_dram.c b/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_dram.c index e720490f52ba..d9e73cd44102 100644 --- a/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_dram.c +++ b/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_dram.c @@ -35,7 +35,10 @@ static ulong mem_test_data2 = sizeof(ulong) == 4 ? 0xAAAAAAAAUL : 0xAAAAAAAAAAAA int dram_wr_main(int argc, char **argv) { - printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, argv[0]); + char tmp[128]; + + snprintf(tmp, sizeof(tmp), "%s", argv[0]); + printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, tmp); return 0; } @@ -78,7 +81,10 @@ int dram_rd_main(int argc, char **argv) int dram_chk_main(int argc, char **argv) { - printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, argv[0]); + char tmp[128]; + + snprintf(tmp, sizeof(tmp), "%s", argv[0]); + printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, tmp); return 0; } @@ -222,7 +228,7 @@ int platform_get_sys_memory_size_form_cmdline(unsigned int *sys_memory_size) char *start; char *mem_start_string; char mem_size_buf[FAC_MEM_SIZE_BUF_LEN]; - + /* MEMORY information area start character string */ mem_start_string = "RAMSZ="; /* get the memory size from the /proc/octeon_info file */ @@ -238,7 +244,7 @@ int platform_get_sys_memory_size_form_cmdline(unsigned int *sys_memory_size) start = strstr(mem_size_buf, mem_start_string); if (start != NULL) { start = start + strlen(mem_start_string); - *sys_memory_size = strtoul(start, NULL, 10); + *sys_memory_size = strtoul(start, NULL, 10); FAC_LOG_DBG(GRTD_LOG_DEBUG, "MEM:Mem size[%d MB]\n", *sys_memory_size); return FAC_TEST_OK; } else { @@ -251,7 +257,7 @@ int platform_get_sys_memory_size_form_cmdline(unsigned int *sys_memory_size) * platform_simple_get_mem_space - get space for memory test * @buf: start address pointer * @size: space size - * + * * return: FAC_TEST_FAIL | FAC_TEST_OK */ static int platform_simple_get_mem_space(void **buf, size_t *size) @@ -274,32 +280,32 @@ static int platform_simple_get_mem_space(void **buf, size_t *size) } *size = wantsize; alignedsize = wantsize; - + fflush(stdout); if (do_mlock && wantsize) { fflush(stdout); - + if ((size_t) start % pagesize) { aligned = (void *) ((size_t) start & pagesizemask) + pagesize; alignedsize -= ((size_t) aligned - (size_t) start); } else { aligned = start; } - + FAC_LOG_DBG(GRTD_LOG_DEBUG, "trying mlock ...start[0x%lx], size[0x%x]", (ulong)start, (int)alignedsize); /* Try mlock */ if (mlock(aligned, alignedsize) < 0) { switch(errno) { - case EAGAIN: + case EAGAIN: FAC_LOG_DBG(GRTD_LOG_ERR, "over system/pre-process limit, reducing...\n"); free(start); start = NULL; wantsize -= pagesize; break; - case ENOMEM: - FAC_LOG_DBG(GRTD_LOG_ERR, "too many pages, reducing...\n"); - free(start); + case ENOMEM: + FAC_LOG_DBG(GRTD_LOG_ERR, "too many pages, reducing...\n"); + free(start); start = NULL; wantsize -= pagesize; break; @@ -309,7 +315,7 @@ static int platform_simple_get_mem_space(void **buf, size_t *size) do_mlock = 0; free(start); start = NULL; - wantsize = FAC_MEM_TEST_SIZE; + wantsize = FAC_MEM_TEST_SIZE; break; default: FAC_LOG_DBG(GRTD_LOG_ERR, "failed for unknown reason.\n"); @@ -324,7 +330,7 @@ static int platform_simple_get_mem_space(void **buf, size_t *size) done_mem = 1; } } - + if (!wantsize) { FAC_LOG_DBG(GRTD_LOG_ERR, "MEM ERROR:Malloc space failed\n"); return FAC_TEST_FAIL; @@ -339,7 +345,7 @@ static int platform_simple_get_mem_space(void **buf, size_t *size) } static int platform_simple_check_addrline(ulong *start, size_t size, char *desc) -{ +{ ulong *p1; ulong j; size_t i; @@ -350,14 +356,14 @@ static int platform_simple_check_addrline(ulong *start, size_t size, char *desc) fflush(stdout); for (j = 0; j < 2; j++) { p1 = start; - + fflush(stdout); for (i = 0; i < size; i += sizeof(ulong), p1++) { *((volatile ulong *)p1) = ((((j + i) % 2) == 0) ? (ulong)p1 : ~((ulong)p1)); } - + fflush(stdout); - + p1 = start; for (i = 0; i < size; i += sizeof(ulong), p1++) { if (*((volatile ulong *)p1) != (((j + i) % 2) == 0 ? (ulong)p1 : ~((ulong)p1))) { @@ -372,7 +378,7 @@ static int platform_simple_check_addrline(ulong *start, size_t size, char *desc) } } fflush(stdout); - + FAC_LOG_DBG(GRTD_LOG_DEBUG, "MEM:addr line check OK!\n"); return FAC_TEST_OK; } @@ -393,7 +399,7 @@ static int platform_simple_check_data(ulong *start, size_t size, char *desc) fflush(stdout); for (j = 0; j < size; j += sizeof(ulong), p1++) { *((volatile ulong *)p1) = data; - } + } fflush(stdout); p1 = start; for (j = 0; j < size; j += sizeof(ulong), p1++) { @@ -429,7 +435,7 @@ static int platform_simple_check_data(ulong *start, size_t size, char *desc) return FAC_TEST_FAIL; } } - fflush(stdout); + fflush(stdout); FAC_LOG_DBG(GRTD_LOG_DEBUG, "MEM:Bus Noise Test END!\n"); return check_error; } @@ -453,13 +459,13 @@ static int platform_simple_sdram_ecc_detect() i = 0; core_num = 0; ecc_error = 0; - + /* Open MTD device file */ if ((fp = fopen("/proc/interrupts", "r")) == NULL) { FAC_LOG_DBG(GRTD_LOG_ERR, "Fopen /proc/interrupts fail!\t err_no[%d]\n", errno); return FAC_TEST_FAIL; } - + memset(file_line, 0, FAC_FILE_LINE_LEN); /* Find the name of the MTD device that can be used for production testing in each line of the MTD file */ while (fgets(file_line, FAC_FILE_LINE_LEN, fp) != NULL) { @@ -477,7 +483,7 @@ static int platform_simple_sdram_ecc_detect() return ecc_error; find: FAC_LOG_DBG(GRTD_LOG_DEBUG, "ECC: Get ecc info[%s]\n", file_line); - /* Get the number of the MTD device name that can be tested in production, + /* Get the number of the MTD device name that can be tested in production, the device name and device partition size separator is a colon */ c = ':'; if ((loc = strchr(file_line, c))!= NULL) { @@ -490,9 +496,9 @@ static int platform_simple_sdram_ecc_detect() FAC_LOG_DBG(GRTD_LOG_DEBUG, "ECC: cpu %d ecc error num: %d\n", i, temp); i++; } - + } - + fclose(fp); FAC_LOG_DBG(GRTD_LOG_DEBUG, "ECC: ecc error num: %d\n", ecc_error); return ecc_error; @@ -524,7 +530,7 @@ int platform_simple_sys_memory_test(char *desc) } else { aligned = buf; } - + /* check the address line */ if (platform_simple_check_addrline((ulong *)aligned, alignedsize, desc) != FAC_TEST_OK) { FAC_LOG_DBG(GRTD_LOG_ERR, "MEM ERROR:Check address line failed!\n"); @@ -645,7 +651,7 @@ static int platform_get_mem_space(void **buf, size_t *size) /* * platform_free_mem_space - free the memory requested by the memory test - * + * * Return void: */ static void platform_free_mem_space(void *buf, size_t size) @@ -657,7 +663,7 @@ static void platform_free_mem_space(void *buf, size_t size) /** * platform_complex_sys_memory_test - memory test * @sdram_test: output, memory test result details - * @kaoji: input, whether to copy the machine currently * + * @kaoji: input, whether to copy the machine currently * * Return int: FAC_TEST_FAIL | FAC_TEST_OK */ int platform_complex_sys_memory_test(char *desc, int kaoji) diff --git a/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_i2c.c b/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_i2c.c index 03a5499fab4d..4b5b53dda79b 100644 --- a/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_i2c.c +++ b/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_i2c.c @@ -484,7 +484,10 @@ int i2c_chk_main(int argc, char **argv) int i2c_reset_main(int argc, char **argv) { - printf("not support %s argc:%d, \r\n", argv[0], argc); + char tmp[128]; + + snprintf(tmp, sizeof(tmp), "%s", argv[0]); + printf("not support %s argc:%d, \r\n", tmp, argc); return 0; } diff --git a/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_misc.c b/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_misc.c index 84ac093c32e6..6f8fccc0087f 100644 --- a/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_misc.c +++ b/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_misc.c @@ -148,28 +148,40 @@ static int mdio_arg_parse(int argc, char **argv, int reload_main(int argc, char **argv) { - printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, argv[0]); + char tmp[128]; + + snprintf(tmp, sizeof(tmp), "%s", argv[0]); + printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, tmp); return 0; } int sys_info_main(int argc, char **argv) { - printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, argv[0]); + char tmp[128]; + + snprintf(tmp, sizeof(tmp), "%s", argv[0]); + printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, tmp); return 0; } int mem_dump_main(int argc, char **argv) { - printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, argv[0]); + char tmp[128]; + + snprintf(tmp, sizeof(tmp), "%s", argv[0]); + printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, tmp); return 0; } int cache_flush_main(int argc, char **argv) { - printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, argv[0]); + char tmp[128]; + + snprintf(tmp, sizeof(tmp), "%s", argv[0]); + printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, tmp); return 0; } @@ -713,7 +725,7 @@ int lpc_cpld_rd8_main(int argc, char **argv) printf("\r\n"); } } - + printf("\r\n"); return 0; diff --git a/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_usb.c b/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_usb.c index a55d017df2c4..8c307c2b2ff1 100644 --- a/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_usb.c +++ b/platform/centec-arm64/sonic-platform-modules-ragile/common/app/hw_test/hw_usb.c @@ -25,20 +25,29 @@ int usb_write_main(int argc, char **argv) { - printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, argv[0]); + char tmp[128]; + + snprintf(tmp, sizeof(tmp), "%s", argv[0]); + printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, tmp); return 0; } int usb_read_main(int argc, char **argv) { - printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, argv[0]); + char tmp[128]; + + snprintf(tmp, sizeof(tmp), "%s", argv[0]); + printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, tmp); return 0; } int usb_check_main(int argc, char **argv) { - printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, argv[0]); + char tmp[128]; + + snprintf(tmp, sizeof(tmp), "%s", argv[0]); + printf("%s, %d, %d, %s\r\n", __FUNCTION__, __LINE__, argc, tmp); return 0; }