Skip to content

Commit 5e2fc18

Browse files
eren-terziogluxiaoxiang781216
authored andcommitted
tools/Unix.mk: Add host_info target to print nxdiag output
Nxdiag examples scripts modified to print system information without building and flashing nxdiag application to get report about system without reflash or reconfigure.
1 parent 57e54b3 commit 5e2fc18

File tree

5 files changed

+1190
-2
lines changed

5 files changed

+1190
-2
lines changed

Documentation/applications/system/nxdiag/index.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ It also can be used to run a tests to verify that the vendor's tools are properl
77

88
Its primary purpose is to gather information that can be used to debug problems and ease the process of reporting bugs for uninexperienced users.
99

10-
This tool uses a Python script (``apps/tools/host_sysinfo.py``) to gather information about the host system during build and a C
10+
This tool uses a Python script (``nuttx/tools/host_info_dump.py``) to gather information about the host system during build and a C
1111
program to gather information about the NuttX system and display all available information. For more information about the python
12-
script, check the command line options and code comments of ``host_sysinfo.py``.
12+
script, check the command line options and code comments of ``host_info_dump.py``.
13+
14+
Alternatively, ``host_info`` target can be used without enabling nxdiag application and reflashing to get information about system.
15+
Target can work after configuration step and prints information about the NuttX and host systems.
1316

1417
.. note:: Nxdiag requires Python 3.6 or later. On Linux distributions, the ``distro`` Python module is
1518
recommended as it provides more accurate information about the host system.

tools/Unix.mk

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ all: $(BIN)
162162
.PHONY: context clean_context config oldconfig menuconfig nconfig qconfig gconfig export subdir_clean clean subdir_distclean distclean apps_clean apps_distclean
163163
.PHONY: pass1 pass1dep
164164
.PHONY: pass2 pass2dep
165+
.PHONY: host_info checkpython3
165166

166167
# Target used to copy include/nuttx/lib/math.h. If CONFIG_ARCH_MATH_H is
167168
# defined, then there is an architecture specific math.h header file
@@ -618,6 +619,35 @@ bootloader:
618619
clean_bootloader:
619620
$(Q) $(MAKE) -C $(ARCH_SRC) clean_bootloader
620621

622+
checkpython3:
623+
@if [ -z "$$(which python3)" ]; then \
624+
echo "ERROR: python3 not found in PATH"; \
625+
echo " Please install python3 or fix the PATH"; \
626+
exit 1; \
627+
fi
628+
629+
# host_info target flags to get diagnostic info without building nxdiag application
630+
631+
SYSINFO_PARSE_FLAGS = "$(realpath $(TOPDIR))"
632+
SYSINFO_PARSE_FLAGS += "-finclude/sysinfo.h"
633+
634+
SYSINFO_FLAGS = "-c"
635+
SYSINFO_FLAGS += "-p"
636+
SYSINFO_FLAGS += -f \""$(shell echo '$(CFLAGS)' | sed 's/"/\\\\\\"/g')"\"
637+
SYSINFO_FLAGS += \""$(shell echo '$(CXXFLAGS)' | sed 's/"/\\\\\\"/g')"\"
638+
SYSINFO_FLAGS += \""$(shell echo '$(LDFLAGS)' | sed 's/"/\\\\\\"/g')"\"
639+
SYSINFO_FLAGS += "--target_info"
640+
641+
# host_info: Parse nxdiag example output file (sysinfo.h) and print
642+
643+
host_info: checkpython3
644+
@if [[ ! -f "include/sysinfo.h" ]]; then \
645+
echo "file sysinfo.h not exists"; \
646+
python3 $(TOPDIR)$(DELIM)tools$(DELIM)host_info_dump.py $(SYSINFO_FLAGS) \
647+
$(realpath $(TOPDIR)) > include/sysinfo.h; \
648+
fi
649+
@python3 $(TOPDIR)$(DELIM)tools$(DELIM)host_info_parse.py $(SYSINFO_PARSE_FLAGS)
650+
621651
# pass1dep: Create pass1 build dependencies
622652
# pass2dep: Create pass2 build dependencies
623653

@@ -801,6 +831,7 @@ endif
801831
$(call DELFILE, .config.orig)
802832
$(call DELFILE, .config.backup)
803833
$(call DELFILE, .gdbinit)
834+
$(call DELFILE, include/sysinfo.h)
804835

805836
# Application housekeeping targets. The APPDIR variable refers to the user
806837
# application directory. A sample apps/ directory is included with NuttX,

0 commit comments

Comments
 (0)