diff --git a/board/nm/common/nbhw_env.c b/board/nm/common/nbhw_env.c index 9dcd56111a..86c990af84 100644 --- a/board/nm/common/nbhw_env.c +++ b/board/nm/common/nbhw_env.c @@ -18,7 +18,8 @@ void find_and_set_active_partition(void) void set_console(void) { - char buf[50] = "\0"; + char buf[6]; + char consolefile[] = "/root/boot/consoledev"; char *defaultconsole = env_get("defaultconsole"); #if defined(CONFIG_PRE_CONSOLE_BUFFER) @@ -26,8 +27,14 @@ void set_console(void) read_file_set_blk_dev("mmc", "0:3", FS_TYPE_EXT); - len = read_file("/root/boot/consoledev", buf, 16); - if ((len != 5) || (strstr(buf, "tty")!=buf) || ((buf[4]<'0') && (buf[4]>'1'))) { + len = get_file_size(consolefile); + if (len>=5) { + read_file(consolefile, buf, sizeof(buf)); + buf[sizeof(buf)-1] = 0; + if ((strstr(buf, "tty")!=buf) || ((buf[4]<'0') && (buf[4]>'1'))) { + buf[0] = 0; + } + } else { buf[0] = 0; } diff --git a/board/nm/common/nbhw_fileaccess.c b/board/nm/common/nbhw_fileaccess.c index acaecb55d7..1f7ece1312 100644 --- a/board/nm/common/nbhw_fileaccess.c +++ b/board/nm/common/nbhw_fileaccess.c @@ -14,6 +14,22 @@ void read_file_set_blk_dev(const char *ifname, l_fstype = fstype; } +int get_file_size(const char* filename) +{ + loff_t filesize = 0; + + if (fs_set_blk_dev("mmc", "0:3", FS_TYPE_EXT) != 0) { + puts("Error, can not set blk device\n"); + return -1; + } + + if (fs_size(filename, &filesize)) { + return -1; + } + + return filesize; +} + int read_file(const char* filename, char *buf, int size) { loff_t filesize = 0; diff --git a/board/nm/common/nbhw_fileaccess.h b/board/nm/common/nbhw_fileaccess.h index fb2f73a448..e1d9b717ca 100644 --- a/board/nm/common/nbhw_fileaccess.h +++ b/board/nm/common/nbhw_fileaccess.h @@ -9,7 +9,25 @@ #define FILEACCESS_H #include +/** + * Query the file size of a file in the file system + * + * @param filename [input] Name of the file including path + * @return File size of -1, if the file does not exist + */ +int get_file_size(const char* filename); + +/** + * Read a file from file system + * + * @param filename [input] Name of the file including path + * @param buf [input] Buffer to store the file + * @param size [input] Maximum number of bytes to be read. + * must be bigger than size of file. + * @return Number of read bytes or -1 on error + */ int read_file(const char* filename, char *buf, int size); + void read_file_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype); diff --git a/board/nm/common/nbhw_fpga_gpio.c b/board/nm/common/nbhw_fpga_gpio.c index c6552477c4..d4e83c6d59 100644 --- a/board/nm/common/nbhw_fpga_gpio.c +++ b/board/nm/common/nbhw_fpga_gpio.c @@ -823,7 +823,7 @@ static int nbhw_fpga_bind(struct udevice *dev) /* Get memory region for fpga */ priv->regs = (struct mvebu_gpio_regs *)devfdt_get_addr(dev); - printf("FPGA Regs: %p\n", priv->regs); + debug("FPGA Regs: %p\n", priv->regs); return 0; } diff --git a/board/nm/nbhw18_v2/board.c b/board/nm/nbhw18_v2/board.c index eb11307ec2..d7b93a2c96 100644 --- a/board/nm/nbhw18_v2/board.c +++ b/board/nm/nbhw18_v2/board.c @@ -124,12 +124,12 @@ static void read_eeprom_serdes_config(void) goto fail; } - printf("Valid user serdes config found\n"); + printf("Using user defined serdes config override\n"); return; fail: memset(&eeprom_serdes_config, 0xff, sizeof(eeprom_serdes_config)); - printf("No user serdes config found\n"); + printf("Using default serdes config (No user defined override)\n"); return; }