1 /*
2  * Copyright 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #define LOG_TAG "dumpstate"
18 
19 #include "DumpstateDevice.h"
20 
21 #include <android-base/file.h>
22 #include <android-base/properties.h>
23 #include <android-base/unique_fd.h>
24 #include <cutils/properties.h>
25 #include <hidl/HidlBinderSupport.h>
26 
27 #include <log/log.h>
28 #include <string.h>
29 
30 #define _SVID_SOURCE
31 #include <dirent.h>
32 
33 #include "DumpstateUtil.h"
34 
35 #define MODEM_LOG_PREFIX_PROPERTY "ro.vendor.radio.log_prefix"
36 #define MODEM_LOG_LOC_PROPERTY "ro.vendor.radio.log_loc"
37 #define MODEM_LOGGING_SWITCH "persist.vendor.radio.smlog_switch"
38 
39 #define DIAG_MDLOG_PERSIST_PROPERTY "persist.vendor.sys.modem.diag.mdlog"
40 #define DIAG_MDLOG_PROPERTY "vendor.sys.modem.diag.mdlog"
41 #define DIAG_MDLOG_STATUS_PROPERTY "vendor.sys.modem.diag.mdlog_on"
42 
43 #define DIAG_MDLOG_NUMBER_BUGREPORT "persist.vendor.sys.modem.diag.mdlog_br_num"
44 
45 #define UFS_BOOTDEVICE "ro.boot.bootdevice"
46 
47 #define TCPDUMP_NUMBER_BUGREPORT "persist.vendor.tcpdump.log.br_num"
48 #define TCPDUMP_PERSIST_PROPERTY "persist.vendor.tcpdump.log.alwayson"
49 
50 #define MODEM_EFS_DUMP_PROPERTY "vendor.sys.modem.diag.efsdump"
51 
52 #define HW_VERSION_PROPERTY "ro.boot.hardware.revision"
53 
54 using android::os::dumpstate::CommandOptions;
55 using android::os::dumpstate::DumpFileToFd;
56 using android::os::dumpstate::PropertiesHelper;
57 using android::os::dumpstate::RunCommandToFd;
58 
59 namespace android {
60 namespace hardware {
61 namespace dumpstate {
62 namespace V1_0 {
63 namespace implementation {
64 
65 #define DIAG_LOG_PREFIX "diag_log_"
66 #define TCPDUMP_LOG_PREFIX "tcpdump"
67 #define EXTENDED_LOG_PREFIX "extended_log_"
68 
dumpLogs(int fd,std::string srcDir,std::string destDir,int maxFileNum,const char * logPrefix)69 void DumpstateDevice::dumpLogs(int fd, std::string srcDir, std::string destDir,
70                                int maxFileNum, const char *logPrefix) {
71     struct dirent **dirent_list = NULL;
72     int num_entries = scandir(srcDir.c_str(),
73                               &dirent_list,
74                               0,
75                               (int (*)(const struct dirent **, const struct dirent **)) alphasort);
76     if (!dirent_list) {
77         return;
78     } else if (num_entries <= 0) {
79         return;
80     }
81 
82     int copiedFiles = 0;
83 
84     for (int i = num_entries - 1; i >= 0; i--) {
85         ALOGD("Found %s\n", dirent_list[i]->d_name);
86 
87         if (0 != strncmp(dirent_list[i]->d_name, logPrefix, strlen(logPrefix))) {
88             continue;
89         }
90 
91         if ((copiedFiles >= maxFileNum) && (maxFileNum != -1)) {
92             ALOGD("Skipped %s\n", dirent_list[i]->d_name);
93             continue;
94         }
95 
96         copiedFiles++;
97 
98         CommandOptions options = CommandOptions::WithTimeout(120).Build();
99         std::string srcLogFile = srcDir + "/" + dirent_list[i]->d_name;
100         std::string destLogFile = destDir + "/" + dirent_list[i]->d_name;
101 
102         std::string copyCmd = "/vendor/bin/cp " + srcLogFile + " " + destLogFile;
103 
104         ALOGD("Copying %s to %s\n", srcLogFile.c_str(), destLogFile.c_str());
105         RunCommandToFd(fd, "CP DIAG LOGS", { "/vendor/bin/sh", "-c", copyCmd.c_str() }, options);
106     }
107 
108     while (num_entries--) {
109         free(dirent_list[num_entries]);
110     }
111 
112     free(dirent_list);
113 }
114 
dumpModem(int fd,int fdModem)115 void DumpstateDevice::dumpModem(int fd, int fdModem)
116 {
117     std::string modemLogDir = android::base::GetProperty(MODEM_LOG_LOC_PROPERTY, "");
118     if (modemLogDir.empty()) {
119         ALOGD("No modem log place is set");
120         return;
121     }
122 
123     std::string filePrefix = android::base::GetProperty(MODEM_LOG_PREFIX_PROPERTY, "");
124 
125     if (filePrefix.empty()) {
126         ALOGD("Modem log prefix is not set");
127         return;
128     }
129 
130     const std::string modemLogCombined = modemLogDir + "/" + filePrefix + "all.tar";
131     const std::string modemLogAllDir = modemLogDir + "/modem_log";
132 
133     RunCommandToFd(fd, "MKDIR MODEM LOG", {"/vendor/bin/mkdir", "-p", modemLogAllDir.c_str()}, CommandOptions::WithTimeout(2).Build());
134 
135     if (!PropertiesHelper::IsUserBuild()) {
136         RunCommandToFd(fd, "MODEM RFS INFO", {"/vendor/bin/find /data/vendor/rfs/mpss/OEMFI/"}, CommandOptions::WithTimeout(2).Build());
137         RunCommandToFd(fd, "MODEM DIAG SYSTEM PROPERTIES", {"/vendor/bin/getprop | grep vendor.sys.modem.diag"}, CommandOptions::WithTimeout(2).Build());
138 
139         android::base::SetProperty(MODEM_EFS_DUMP_PROPERTY, "true");
140 
141         const std::string diagLogDir = "/data/vendor/radio/diag_logs/logs";
142         const std::string tcpdumpLogDir = "/data/vendor/tcpdump_logger/logs";
143         const std::string extendedLogDir = "/data/vendor/radio/extended_logs";
144         const std::vector <std::string> rilAndNetmgrLogs
145             {
146                 "/data/vendor/radio/ril_log0",
147                 "/data/vendor/radio/ril_log0_old",
148                 "/data/vendor/radio/ril_log1",
149                 "/data/vendor/radio/ril_log1_old",
150                 "/data/vendor/radio/qmi_fw_log",
151                 "/data/vendor/radio/qmi_fw_log_old",
152                 "/data/vendor/radio/imsdatadaemon_log",
153                 "/data/vendor/radio/imsdatadaemon_log_old",
154                 "/data/vendor/netmgr/netmgr_log",
155                 "/data/vendor/netmgr/netmgr_log_old",
156                 "/data/vendor/radio/power_anomaly_data.txt",
157                 "/data/vendor/radio/diag_logs/diag_trace.txt",
158                 "/data/vendor/radio/diag_logs/diag_trace_old.txt",
159                 "/data/vendor/radio/diag_logs/logs/diag_poweron_log.qmdl",
160                 "/data/vendor/radio/metrics_data",
161                 "/data/vendor/ssrlog/ssr_log.txt",
162                 "/data/vendor/ssrlog/ssr_log_old.txt",
163                 "/data/vendor/rfs/mpss/modem_efs",
164                 "/sys/kernel/debug/ipa/ipa_statistics_msg"
165             };
166 
167         bool smlogEnabled = android::base::GetBoolProperty(MODEM_LOGGING_SWITCH, false) && !access("/vendor/bin/smlog_dump", X_OK);
168         bool diagLogEnabled = android::base::GetBoolProperty(DIAG_MDLOG_PERSIST_PROPERTY, false);
169         bool tcpdumpEnabled = android::base::GetBoolProperty(TCPDUMP_PERSIST_PROPERTY, false);
170 
171         if (smlogEnabled) {
172             RunCommandToFd(fd, "SMLOG DUMP", {"smlog_dump", "-d", "-o", modemLogAllDir.c_str()}, CommandOptions::WithTimeout(10).Build());
173         } else if (diagLogEnabled) {
174             bool diagLogStarted = android::base::GetBoolProperty( DIAG_MDLOG_STATUS_PROPERTY, false);
175 
176             if (diagLogStarted) {
177                 android::base::SetProperty(DIAG_MDLOG_PROPERTY, "false");
178                 ALOGD("Stopping diag_mdlog...\n");
179                 if (android::base::WaitForProperty(DIAG_MDLOG_STATUS_PROPERTY, "false", std::chrono::seconds(20))) {
180                     ALOGD("diag_mdlog exited");
181                 } else {
182                     ALOGE("Waited mdlog timeout after 20 second");
183                 }
184             } else {
185                 ALOGD("diag_mdlog is not running");
186             }
187 
188             dumpLogs(fd, diagLogDir, modemLogAllDir, android::base::GetIntProperty(DIAG_MDLOG_NUMBER_BUGREPORT, 100), DIAG_LOG_PREFIX);
189 
190             if (diagLogStarted) {
191                 ALOGD("Restarting diag_mdlog...");
192                 android::base::SetProperty(DIAG_MDLOG_PROPERTY, "true");
193             }
194         }
195 
196         if (tcpdumpEnabled) {
197             dumpLogs(fd, tcpdumpLogDir, modemLogAllDir, android::base::GetIntProperty(TCPDUMP_NUMBER_BUGREPORT, 5), TCPDUMP_LOG_PREFIX);
198         }
199 
200         for (const auto& logFile : rilAndNetmgrLogs) {
201             RunCommandToFd(fd, "CP MODEM LOG", {"/vendor/bin/cp", logFile.c_str(), modemLogAllDir.c_str()}, CommandOptions::WithTimeout(2).Build());
202         }
203 
204         dumpLogs(fd, extendedLogDir, modemLogAllDir, 100, EXTENDED_LOG_PREFIX);
205         android::base::SetProperty(MODEM_EFS_DUMP_PROPERTY, "false");
206     }
207 
208     RunCommandToFd(fd, "TAR LOG", {"/vendor/bin/tar", "cvf", modemLogCombined.c_str(), "-C", modemLogAllDir.c_str(), "."}, CommandOptions::WithTimeout(120).Build());
209     RunCommandToFd(fd, "CHG PERM", {"/vendor/bin/chmod", "a+w", modemLogCombined.c_str()}, CommandOptions::WithTimeout(2).Build());
210 
211     std::vector<uint8_t> buffer(65536);
212     android::base::unique_fd fdLog(TEMP_FAILURE_RETRY(open(modemLogCombined.c_str(), O_RDONLY | O_CLOEXEC | O_NONBLOCK)));
213 
214     if (fdLog >= 0) {
215         while (1) {
216             ssize_t bytes_read = TEMP_FAILURE_RETRY(read(fdLog, buffer.data(), buffer.size()));
217 
218             if (bytes_read == 0) {
219                 break;
220             } else if (bytes_read < 0) {
221                 ALOGD("read(%s): %s\n", modemLogCombined.c_str(), strerror(errno));
222                 break;
223             }
224 
225             ssize_t result = TEMP_FAILURE_RETRY(write(fdModem, buffer.data(), bytes_read));
226 
227             if (result != bytes_read) {
228                 ALOGD("Failed to write %ld bytes, actually written: %ld", bytes_read, result);
229                 break;
230             }
231         }
232     }
233 
234     RunCommandToFd(fd, "RM MODEM DIR", { "/vendor/bin/rm", "-r", modemLogAllDir.c_str()}, CommandOptions::WithTimeout(2).Build());
235     RunCommandToFd(fd, "RM LOG", { "/vendor/bin/rm", modemLogCombined.c_str()}, CommandOptions::WithTimeout(2).Build());
236 }
237 
DumpTouch(int fd)238 static void DumpTouch(int fd) {
239     const char touch_spi_path[] = "/sys/class/spi_master/spi1/spi1.0";
240     char cmd[256];
241 
242     snprintf(cmd, sizeof(cmd), "%s/appid", touch_spi_path);
243     if (!access(cmd, R_OK)) {
244         // Touch firmware version
245         DumpFileToFd(fd, "STM touch firmware version", cmd);
246 
247         // Touch controller status
248         snprintf(cmd, sizeof(cmd), "%s/status", touch_spi_path);
249         DumpFileToFd(fd, "STM touch status", cmd);
250 
251         // Mutual raw data
252         snprintf(cmd, sizeof(cmd),
253                  "echo 13 00 > %s/stm_fts_cmd && cat %s/stm_fts_cmd",
254                  touch_spi_path, touch_spi_path);
255         RunCommandToFd(fd, "Mutual Raw", {"/vendor/bin/sh", "-c", cmd});
256 
257         // Mutual strength data
258         snprintf(cmd, sizeof(cmd),
259                  "echo 17 > %s/stm_fts_cmd && cat %s/stm_fts_cmd",
260                  touch_spi_path, touch_spi_path);
261         RunCommandToFd(fd, "Mutual Strength", {"/vendor/bin/sh", "-c", cmd});
262 
263         // Self raw data
264         snprintf(cmd, sizeof(cmd),
265                  "echo 15 00 > %s/stm_fts_cmd && cat %s/stm_fts_cmd",
266                  touch_spi_path, touch_spi_path);
267         RunCommandToFd(fd, "Self Raw", {"/vendor/bin/sh", "-c", cmd});
268     }
269 
270     if (!access("/proc/fts/driver_test", R_OK)) {
271         RunCommandToFd(fd, "Mutual Raw Data",
272                        {"/vendor/bin/sh", "-c",
273                         "echo 23 00 > /proc/fts/driver_test && "
274                         "cat /proc/fts/driver_test"});
275         RunCommandToFd(fd, "Mutual Baseline Data",
276                        {"/vendor/bin/sh", "-c",
277                         "echo 23 03 > /proc/fts/driver_test && "
278                         "cat /proc/fts/driver_test"});
279         RunCommandToFd(fd, "Mutual Strength Data",
280                        {"/vendor/bin/sh", "-c",
281                         "echo 23 02 > /proc/fts/driver_test && "
282                         "cat /proc/fts/driver_test"});
283         RunCommandToFd(fd, "Self Raw Data",
284                        {"/vendor/bin/sh", "-c",
285                         "echo 24 00 > /proc/fts/driver_test && "
286                         "cat /proc/fts/driver_test"});
287         RunCommandToFd(fd, "Self Baseline Data",
288                        {"/vendor/bin/sh", "-c",
289                         "echo 24 03 > /proc/fts/driver_test && "
290                         "cat /proc/fts/driver_test"});
291         RunCommandToFd(fd, "Self Strength Data",
292                        {"/vendor/bin/sh", "-c",
293                         "echo 24 02 > /proc/fts/driver_test && "
294                         "cat /proc/fts/driver_test"});
295         RunCommandToFd(fd, "Mutual Compensation",
296                        {"/vendor/bin/sh", "-c",
297                         "echo 32 10 > /proc/fts/driver_test && "
298                         "cat /proc/fts/driver_test"});
299         RunCommandToFd(fd, "Self Compensation",
300                        {"/vendor/bin/sh", "-c",
301                         "echo 33 12 > /proc/fts/driver_test && "
302                         "cat /proc/fts/driver_test"});
303         RunCommandToFd(fd, "Golden Mutual Raw Data",
304                        {"/vendor/bin/sh", "-c",
305                         "echo 34 > /proc/fts/driver_test && "
306                         "cat /proc/fts/driver_test"});
307     }
308 }
309 
DumpDisplay(int fd)310 static void DumpDisplay(int fd) {
311     DumpFileToFd(fd, "PANEL VENDOR NAME", "/sys/class/panel_info/panel0/panel_vendor_name");
312     DumpFileToFd(fd, "PANEL SN", "/sys/class/panel_info/panel0/serial_number");
313     DumpFileToFd(fd, "PANEL EXTRA INFO", "/sys/class/panel_info/panel0/panel_extinfo");
314 
315     const std::string pmic_regmap_path = "/sys/kernel/debug/regmap/spmi0-05";
316     using android::base::WriteStringToFile;
317 
318     if (WriteStringToFile("0x80", pmic_regmap_path + "/count", true) &&
319             WriteStringToFile("0xE000", pmic_regmap_path + "/address", true)) {
320         DumpFileToFd(fd, "OLEDB Register Dump", pmic_regmap_path + "/data");
321     } else {
322 	dprintf(fd, "Unable to print OLEDB Register Dump\n");
323     }
324 
325     if (WriteStringToFile("0x80", pmic_regmap_path + "/count", true) &&
326             WriteStringToFile("0xDE00", pmic_regmap_path + "/address", true)) {
327         DumpFileToFd(fd, "ELVDD Register Dump", pmic_regmap_path + "/data");
328     } else {
329 	dprintf(fd, "Unable to print ELVDD Register Dump\n");
330     }
331 
332     if (WriteStringToFile("0x60", pmic_regmap_path + "/count", true) &&
333             WriteStringToFile("0xDC00", pmic_regmap_path + "/address", true)) {
334         DumpFileToFd(fd, "ELVSS Register Dump", pmic_regmap_path + "/data");
335     } else {
336 	dprintf(fd, "Unable to print ELVSS Register Dump\n");
337     }
338 }
339 
DumpF2FS(int fd)340 static void DumpF2FS(int fd) {
341     DumpFileToFd(fd, "F2FS", "/sys/kernel/debug/f2fs/status");
342     DumpFileToFd(fd, "F2FS - fragmentation", "/proc/fs/f2fs/dm-3/segment_info");
343 }
344 
DumpUFS(int fd)345 static void DumpUFS(int fd) {
346     DumpFileToFd(fd, "UFS model", "/sys/block/sda/device/model");
347     DumpFileToFd(fd, "UFS rev", "/sys/block/sda/device/rev");
348     DumpFileToFd(fd, "UFS size", "/sys/block/sda/size");
349     DumpFileToFd(fd, "UFS show_hba", "/sys/kernel/debug/ufshcd0/show_hba");
350     DumpFileToFd(fd, "UFS err_stats", "/sys/kernel/debug/ufshcd0/stats/err_stats");
351     DumpFileToFd(fd, "UFS io_stats", "/sys/kernel/debug/ufshcd0/stats/io_stats");
352     DumpFileToFd(fd, "UFS req_stats", "/sys/kernel/debug/ufshcd0/stats/req_stats");
353 
354     std::string bootdev = android::base::GetProperty(UFS_BOOTDEVICE, "");
355     if (!bootdev.empty()) {
356         DumpFileToFd(fd, "UFS Slow IO Read", "/sys/devices/platform/soc/" + bootdev + "/slowio_read_cnt");
357         DumpFileToFd(fd, "UFS Slow IO Write", "/sys/devices/platform/soc/" + bootdev + "/slowio_write_cnt");
358         DumpFileToFd(fd, "UFS Slow IO Unmap", "/sys/devices/platform/soc/" + bootdev + "/slowio_unmap_cnt");
359         DumpFileToFd(fd, "UFS Slow IO Sync", "/sys/devices/platform/soc/" + bootdev + "/slowio_sync_cnt");
360 
361         std::string ufs_health = "for f in $(find /sys/devices/platform/soc/" + bootdev + "/health -type f); do if [[ -r $f && -f $f ]]; then echo --- $f; cat $f; echo ''; fi; done";
362         RunCommandToFd(fd, "UFS health", {"/vendor/bin/sh", "-c", ufs_health.c_str()});
363     }
364 }
365 
DumpPower(int fd)366 static void DumpPower(int fd) {
367     RunCommandToFd(fd, "Power Stats Times", {"/vendor/bin/sh", "-c",
368                    "echo -n \"Boot: \" && /vendor/bin/uptime -s &&"
369                    "echo -n \"Now: \" && date"});
370     DumpFileToFd(fd, "Sleep Stats", "/sys/power/system_sleep/stats");
371     DumpFileToFd(fd, "Power Management Stats", "/sys/power/rpmh_stats/master_stats");
372     DumpFileToFd(fd, "WLAN Power Stats", "/sys/kernel/wlan/power_stats");
373 }
374 
375 // Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow.
dumpstateBoard(const hidl_handle & handle)376 Return<void> DumpstateDevice::dumpstateBoard(const hidl_handle& handle) {
377     // Exit when dump is completed since this is a lazy HAL.
378     addPostCommandTask([]() {
379         exit(0);
380     });
381 
382     if (handle == nullptr || handle->numFds < 1) {
383         ALOGE("no FDs\n");
384         return Void();
385     }
386 
387     int fd = handle->data[0];
388     if (fd < 0) {
389         ALOGE("invalid FD: %d\n", handle->data[0]);
390         return Void();
391     }
392 
393     RunCommandToFd(fd, "Notify modem", {"/vendor/bin/modem_svc", "-s"}, CommandOptions::WithTimeout(1).Build());
394     RunCommandToFd(fd, "VENDOR PROPERTIES", {"/vendor/bin/getprop"});
395     DumpFileToFd(fd, "SoC serial number", "/sys/devices/soc0/serial_number");
396     DumpFileToFd(fd, "CPU present", "/sys/devices/system/cpu/present");
397     DumpFileToFd(fd, "CPU online", "/sys/devices/system/cpu/online");
398     DumpTouch(fd);
399     DumpDisplay(fd);
400 
401     DumpF2FS(fd);
402     DumpUFS(fd);
403 
404     DumpFileToFd(fd, "INTERRUPTS", "/proc/interrupts");
405 
406     DumpPower(fd);
407 
408     DumpFileToFd(fd, "LL-Stats", "/d/wlan0/ll_stats");
409     DumpFileToFd(fd, "WLAN Connect Info", "/d/wlan0/connect_info");
410     DumpFileToFd(fd, "WLAN Offload Info", "/d/wlan0/offload_info");
411     DumpFileToFd(fd, "WLAN Roaming Stats", "/d/wlan0/roam_stats");
412     DumpFileToFd(fd, "ICNSS Stats", "/d/icnss/stats");
413     DumpFileToFd(fd, "SMD Log", "/d/ipc_logging/smd/log");
414     RunCommandToFd(fd, "ION HEAPS", {"/vendor/bin/sh", "-c", "for d in $(ls -d /d/ion/*); do for f in $(ls $d); do echo --- $d/$f; cat $d/$f; done; done"});
415     DumpFileToFd(fd, "dmabuf info", "/d/dma_buf/bufinfo");
416     DumpFileToFd(fd, "dmabuf process info", "/d/dma_buf/dmaprocs");
417     RunCommandToFd(fd, "Temperatures", {"/vendor/bin/sh", "-c", "for f in /sys/class/thermal/thermal* ; do type=`cat $f/type` ; temp=`cat $f/temp` ; echo \"$type: $temp\" ; done"});
418     RunCommandToFd(fd, "Cooling Device Current State", {"/vendor/bin/sh", "-c", "for f in /sys/class/thermal/cooling* ; do type=`cat $f/type` ; temp=`cat $f/cur_state` ; echo \"$type: $temp\" ; done"});
419     RunCommandToFd(
420         fd, "LMH info",
421         {"/vendor/bin/sh", "-c",
422          "for f in /sys/bus/platform/drivers/msm_lmh_dcvs/*qcom,limits-dcvs@*/lmh_freq_limit; do "
423          "state=`cat $f` ; echo \"$f: $state\" ; done"});
424     RunCommandToFd(fd, "CPU time-in-state", {"/vendor/bin/sh", "-c", "for cpu in /sys/devices/system/cpu/cpu*; do f=$cpu/cpufreq/stats/time_in_state; if [ ! -f $f ]; then continue; fi; echo $f:; cat $f; done"});
425     RunCommandToFd(fd, "CPU cpuidle", {"/vendor/bin/sh", "-c", "for cpu in /sys/devices/system/cpu/cpu*; do for d in $cpu/cpuidle/state*; do if [ ! -d $d ]; then continue; fi; echo \"$d: `cat $d/name` `cat $d/desc` `cat $d/time` `cat $d/usage`\"; done; done"});
426     RunCommandToFd(fd, "Airbrush debug info", {"/vendor/bin/sh", "-c", "for f in `ls /sys/devices/platform/soc/c84000.i2c/i2c-*/*-0066/@(*curr|temperature|vbat)`; do echo \"$f: `cat $f`\" ; done; file=/sys/devices/platform/soc/soc:abc-sm/mapped_chip_state; echo \"$file: `cat $file`\"; file=/sys/devices/platform/soc/soc:abc-sm/state_stats; echo \"$file: `cat $file`\""});
427     DumpFileToFd(fd, "MDP xlogs", "/data/vendor/display/mdp_xlog");
428     DumpFileToFd(fd, "TCPM logs", "/d/tcpm/usbpd0");
429     DumpFileToFd(fd, "PD Engine", "/d/logbuffer/usbpd");
430     DumpFileToFd(fd, "PPS", "/d/logbuffer/pps");
431     DumpFileToFd(fd, "BMS", "/d/logbuffer/ssoc");
432     DumpFileToFd(fd, "smblib", "/d/logbuffer/smblib");
433     DumpFileToFd(fd, "batt_ce", "/d/logbuffer/batt_ce");
434     DumpFileToFd(fd, "WLC logs", "/d/logbuffer/wireless");
435     DumpFileToFd(fd, "ipc-local-ports", "/d/msm_ipc_router/dump_local_ports");
436     RunCommandToFd(fd, "USB Device Descriptors", {"/vendor/bin/sh", "-c", "cd /sys/bus/usb/devices/1-1 && cat product && cat bcdDevice; cat descriptors | od -t x1 -w16 -N96"});
437     RunCommandToFd(fd, "Power supply properties", {"/vendor/bin/sh", "-c", "for f in `ls /sys/class/power_supply/*/uevent` ; do echo \"------ $f\\n`cat $f`\\n\" ; done"});
438     RunCommandToFd(fd, "PMIC Votables", {"/vendor/bin/sh", "-c", "cat /sys/kernel/debug/pmic-votable/*/status"});
439     DumpFileToFd(fd, "Charger Stats", "/sys/class/power_supply/battery/charge_details");
440     DumpFileToFd(fd, "Maxim FG History", "/dev/maxfg_history");
441 
442     std::string hwVersion = android::base::GetProperty(HW_VERSION_PROPERTY, "");
443     if (hwVersion == "PROTO1.0" || hwVersion == "PROTO1.1" || hwVersion == "EVT1.0") {
444         RunCommandToFd(fd, "Maxim FG registers", {"/vendor/bin/sh", "-c", "cat /d/regmap/1-0036/registers"});
445         RunCommandToFd(fd, "Maxim FG NV RAM", {"/vendor/bin/sh", "-c", "cat /d/regmap/1-000b/registers"});
446     } else {
447         RunCommandToFd(fd, "Maxim FG registers", {"/vendor/bin/sh", "-c", "cat /d/regmap/2-0036/registers"});
448         RunCommandToFd(fd, "Maxim FG NV RAM", {"/vendor/bin/sh", "-c", "cat /d/regmap/2-000b/registers"});
449     }
450 
451     RunCommandToFd(fd, "Google Charger", {"/vendor/bin/sh", "-c", "cd /d/google_charger/; for f in `ls pps_*` ; do echo \"$f: `cat $f`\" ; done"});
452     RunCommandToFd(fd, "Google Battery", {"/vendor/bin/sh", "-c", "cd /d/google_battery/; for f in `ls ssoc_*` ; do echo \"$f: `cat $f`\" ; done"});
453     DumpFileToFd(fd, "WLC VER", "/sys/devices/platform/soc/880000.i2c/i2c-1/1-0061/version");
454     DumpFileToFd(fd, "WLC STATUS", "/sys/devices/platform/soc/880000.i2c/i2c-1/1-0061/status");
455 
456     RunCommandToFd(fd, "eSIM Status", {"/vendor/bin/sh", "-c", "od -t x1 /sys/firmware/devicetree/base/chosen/cdt/cdb2/esim"});
457     DumpFileToFd(fd, "Modem Stat", "/data/vendor/modem_stat/debug.txt");
458     DumpFileToFd(fd, "Pixel trace", "/d/tracing/instances/pixel-trace/trace");
459 
460     // Slower dump put later in case stuck the rest of dump
461     // Timeout after 3s as TZ log missing EOF
462     RunCommandToFd(fd, "QSEE logs", {"/vendor/bin/sh", "-c", "/vendor/bin/timeout 3 cat /d/tzdbg/qsee_log"});
463     RunCommandToFd(fd, "TZ logs", {"/vendor/bin/sh", "-c", "/vendor/bin/timeout 3 cat /d/tzdbg/log"});
464     RunCommandToFd(fd, "HYP logs", {"/vendor/bin/sh", "-c", "/vendor/bin/timeout 3 cat /d/tzdbg/hyp_log"});
465     if (handle->numFds < 2) {
466         ALOGE("no FD for modem\n");
467     } else {
468         int fdModem = handle->data[1];
469         dumpModem(fd, fdModem);
470     }
471 
472     // Citadel info
473     RunCommandToFd(fd, "Citadel VERSION", {"/vendor/bin/hw/citadel_updater", "-lv"});
474     RunCommandToFd(fd, "Citadel STATS", {"/vendor/bin/hw/citadel_updater", "--stats"});
475     RunCommandToFd(fd, "Citadel BOARDID", {"/vendor/bin/hw/citadel_updater", "--board_id"});
476 
477     // Keep this at the end as very long on not for humans
478     DumpFileToFd(fd, "WLAN FW Log Symbol Table", "/vendor/firmware/Data.msc");
479 
480     // Report Knowles framework info
481     RunCommandToFd(fd, "KN version", {"/vendor/bin/sh", "-c", "for f in `ls -d /sys/devices/platform/soc/a8c000.spi/spi_master/spi5/spi5.0/iaxxx/*_version` ; do echo \"------ $f\\n`cat $f`\\n\" ; done"});
482     return Void();
483 }
484 
485 }  // namespace implementation
486 }  // namespace V1_0
487 }  // namespace dumpstate
488 }  // namespace hardware
489 }  // namespace android
490