mmc-utils: Change the printing format of eMMC FW version
Currently, the printing format of eMMC firmware version
is char, That format will cause the 'eMMC Firmware
Version' of storage_info.txt to print the messy code.
This change can fix this issue.
BUG=b:172629974
TEST=emerge-zork or emerge-dedede sys-apps/mmc-utils and
cros deploy to DUT,check that the storage_info.txt do not
have any messy code.
Change-Id: I41ddb6a3bf2d693f91b8b1208abc292f10c6ad9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/mmc-utils/+/2605918
Tested-by: Xingyu Wu <wuxy20@lenovo.corp-partner.google.com>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
diff --git a/mmc_cmds.c b/mmc_cmds.c
index 04ffeab..0c6d69f 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -31,6 +31,7 @@
#include <stdint.h>
#include <assert.h>
#include <linux/fs.h> /* for BLKGETSIZE */
+#include <ctype.h>
#include "mmc.h"
#include "mmc_cmds.h"
@@ -1934,8 +1935,16 @@
}
if (ext_csd_rev >= 7) {
- printf("eMMC Firmware Version: %s\n",
- (char*)&ext_csd[EXT_CSD_FIRMWARE_VERSION]);
+ printf("eMMC Firmware Version: ");
+ for (int i = EXT_CSD_FIRMWARE_VERSION; i < EXT_CSD_PRE_EOL_INFO; i++) {
+ char c = ext_csd[i];
+
+ if (isprint(c))
+ printf("%c", c);
+ else if (c != 0)
+ printf("\\x%02x", c);
+ }
+ printf("\n");
printf("eMMC Life Time Estimation A [EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_A]: 0x%02x\n",
ext_csd[EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_A]);
printf("eMMC Life Time Estimation B [EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B]: 0x%02x\n",