This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 95a8c43b739f7c8bbf0f4fb85ead986ef23580d0
Author: Eren Terzioglu <[email protected]>
AuthorDate: Fri Nov 22 13:38:23 2024 +0100

    apps/nxdiag: Add dignostic info without esptool support for Espressif 
devices
---
 system/nxdiag/Kconfig  |  7 +++++++
 system/nxdiag/Makefile |  4 ++++
 system/nxdiag/nxdiag.c | 31 +++++++++++++++++++++++++++++--
 tools/host_sysinfo.py  | 15 +++++++++++++++
 4 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/system/nxdiag/Kconfig b/system/nxdiag/Kconfig
index 904c9c08e..2c04ae83c 100644
--- a/system/nxdiag/Kconfig
+++ b/system/nxdiag/Kconfig
@@ -74,6 +74,13 @@ config SYSTEM_NXDIAG_ESPRESSIF_CHIP
        ---help---
                Enable Espressif-specific information about chip. Chip must be 
connected during build process.
 
+config SYSTEM_NXDIAG_ESPRESSIF_CHIP_WO_TOOL
+       bool "Espressif Chip info without esptool"
+       depends on SYSTEM_NXDIAG_ESPRESSIF_CHIP
+       default n
+       ---help---
+               Enable Espressif-specific information about chip without using 
esptool.
+
 config SYSTEM_NXDIAG_ESPRESSIF_VERBOSE
        bool "Espressif Verbose"
        default n
diff --git a/system/nxdiag/Makefile b/system/nxdiag/Makefile
index e757901a8..931c6c3a2 100644
--- a/system/nxdiag/Makefile
+++ b/system/nxdiag/Makefile
@@ -90,7 +90,11 @@ NXDIAG_FLAGS += --espressif "$(TOPDIR)" "$(HALDIR)"
 endif
 
 ifeq ($(CONFIG_SYSTEM_NXDIAG_ESPRESSIF_CHIP),y)
+ifneq ($(CONFIG_SYSTEM_NXDIAG_ESPRESSIF_CHIP_WO_TOOL),y)
 NXDIAG_FLAGS += --espressif_chip
+else
+NXDIAG_FLAGS += --espressif_chip_runtime
+endif
 endif
 
 ifeq ($(CONFIG_SYSTEM_NXDIAG_ESPRESSIF_VERBOSE),y)
diff --git a/system/nxdiag/nxdiag.c b/system/nxdiag/nxdiag.c
index b7d94ff7e..dae2a342b 100644
--- a/system/nxdiag/nxdiag.c
+++ b/system/nxdiag/nxdiag.c
@@ -32,6 +32,9 @@
 #include <nuttx/version.h>
 
 #include "sysinfo.h"
+#ifdef CONFIG_SYSTEM_NXDIAG_ESPRESSIF_CHIP_WO_TOOL
+#include <fcntl.h>
+#endif
 
 /****************************************************************************
  * Private Data
@@ -224,6 +227,11 @@ static void print_usage(char *prg)
 
 int main(int argc, char *argv[])
 {
+#ifdef CONFIG_SYSTEM_NXDIAG_ESPRESSIF_CHIP_WO_TOOL
+  int fd;
+  int ret;
+#endif
+
   if (argc == 1 || !are_valid_args(argc, argv))
     {
       print_usage(argv[0]);
@@ -346,6 +354,7 @@ int main(int argc, char *argv[])
       printf("Esptool version: %s\n\n", ESPRESSIF_ESPTOOL);
       printf("HAL version: %s\n\n", ESPRESSIF_HAL);
 #ifdef CONFIG_SYSTEM_NXDIAG_ESPRESSIF_CHIP
+#ifndef CONFIG_SYSTEM_NXDIAG_ESPRESSIF_CHIP_WO_TOOL
       printf("CHIP ID: %s\n\n", ESPRESSIF_CHIP_ID);
       printf("Flash ID:\n");
       print_array(ESPRESSIF_FLASH_ID, ESPRESSIF_FLASH_ID_ARRAY_SIZE);
@@ -354,8 +363,26 @@ int main(int argc, char *argv[])
                   ESPRESSIF_SECURITY_INFO_ARRAY_SIZE);
       printf("Flash status: %s\n\n", ESPRESSIF_FLASH_STAT);
       printf("MAC address: %s\n\n", ESPRESSIF_MAC_ADDR);
-#endif
-#endif
+#else
+      fd = open("/dev/nxdiag", O_RDONLY);
+      if (fd < 0)
+        {
+          printf("Failed to open device\n");
+          return ERROR;
+        }
+
+      ret = read(fd, ESPRESSIF_INFO, ESPRESSIF_INFO_SIZE);
+      if (ret <= 0)
+        {
+          printf("Failed to read device\n");
+          return ERROR;
+        }
+
+      printf("%s\n\n", ESPRESSIF_INFO);
+
+#endif /* CONFIG_SYSTEM_NXDIAG_ESPRESSIF_CHIP_WO_TOOL */
+#endif /* CONFIG_SYSTEM_NXDIAG_ESPRESSIF_CHIP */
+#endif /* CONFIG_SYSTEM_NXDIAG_ESPRESSIF */
     }
 
   return 0;
diff --git a/tools/host_sysinfo.py b/tools/host_sysinfo.py
index 65479d780..f5212c18b 100755
--- a/tools/host_sysinfo.py
+++ b/tools/host_sysinfo.py
@@ -736,9 +736,14 @@ def generate_header(args):
             )
             build_output += "MAC address:  
{}\n\n".format(info["ESPRESSIF_MAC_ADDR"])
 
+        elif args.espressif_chip_runtime:
+            output += "#define ESPRESSIF_INFO_SIZE 384\n"
+            output += 'static char 
ESPRESSIF_INFO[ESPRESSIF_TOOLCHAIN_ARRAY_SIZE] =\n{\n  0\n};\n\n'
+
         if args.espressif_verbose:
             espressif_verbose(info, build_output)
 
+
     output += "#endif /* __SYSTEM_INFO_H */\n"
 
     return output
@@ -775,6 +780,10 @@ if __name__ == "__main__":
             --espressif_chip:
                         Get Espressif specific information about chip.
                         Requires device connection during build.
+            --espressif_chip_runtime:
+                        Get Espressif specific information about chip
+                        on runtime.
+                        Requires device connection during build.
             --espressif_verbose:
                         Enable printing Espressif-specific information about
                         chip during build.
@@ -841,6 +850,12 @@ if __name__ == "__main__":
         help="Get Espressif specific information about chip. Requires device 
connection during build.",
     )
 
+    parser.add_argument(
+        "--espressif_chip_runtime",
+        action="store_true",
+        help="Get Espressif specific information about chip on runtime. 
Requires device connection during build.",
+    )
+
     parser.add_argument(
         "--espressif_verbose",
         action="store_true",

Reply via email to