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 f2e5d5c13f16addd3f0edca203a1653b68449056 Author: Eren Terzioglu <[email protected]> AuthorDate: Wed Nov 20 13:03:29 2024 +0100 apps/nxdiag: Add dignostic info logging support during build on nxdiag example for Espressif devices --- system/nxdiag/Kconfig | 6 ++++ system/nxdiag/Makefile | 4 +++ tools/host_sysinfo.py | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) diff --git a/system/nxdiag/Kconfig b/system/nxdiag/Kconfig index ceec711f8..904c9c08e 100644 --- a/system/nxdiag/Kconfig +++ b/system/nxdiag/Kconfig @@ -74,4 +74,10 @@ config SYSTEM_NXDIAG_ESPRESSIF_CHIP ---help--- Enable Espressif-specific information about chip. Chip must be connected during build process. +config SYSTEM_NXDIAG_ESPRESSIF_VERBOSE + bool "Espressif Verbose" + default n + ---help--- + Enable printing Espressif-specific information about chip during build. + endif # SYSTEM_NXDIAG diff --git a/system/nxdiag/Makefile b/system/nxdiag/Makefile index 0da0a0a84..e757901a8 100644 --- a/system/nxdiag/Makefile +++ b/system/nxdiag/Makefile @@ -93,6 +93,10 @@ ifeq ($(CONFIG_SYSTEM_NXDIAG_ESPRESSIF_CHIP),y) NXDIAG_FLAGS += --espressif_chip endif +ifeq ($(CONFIG_SYSTEM_NXDIAG_ESPRESSIF_VERBOSE),y) +NXDIAG_FLAGS += --espressif_verbose +endif + endif # Common build diff --git a/tools/host_sysinfo.py b/tools/host_sysinfo.py index 2d25a0e0f..65479d780 100755 --- a/tools/host_sysinfo.py +++ b/tools/host_sysinfo.py @@ -234,6 +234,56 @@ def get_espressif_hal_version(hal_dir): return hal_version +def espressif_verbose(info, esp_logs): + """ + Prepare and print information on build screen. + + Args: + info (dict): Information dictionary of build system. + esp_logs (str): Information string of espressif specific features. + + Returns: + None. + """ + esp_verbose = "=" * 79 + "\n" + + esp_verbose += "NuttX RTOS info: {}\n\n".format(info["OS_VERSION"]) + if args.flags: + esp_verbose += "NuttX CFLAGS: {}\n\n".format(info["NUTTX_CFLAGS"]) + esp_verbose += "NuttX CXXFLAGS: {}\n\n".format(info["NUTTX_CXXFLAGS"]) + esp_verbose += "NuttX LDFLAGS: {}\n\n".format(info["NUTTX_LDFLAGS"]) + + if args.config: + esp_verbose += "NuttX configuration options: \n" + for i in range(len(info["NUTTX_CONFIG"])): + esp_verbose += " " + info["NUTTX_CONFIG"][i].replace('"', '\\"') + "\n" + esp_verbose += "\n\n" + + if args.path: + esp_verbose += "Host system PATH: \n" + for i in range(len(info["SYSTEM_PATH"])): + esp_verbose += " " + info["SYSTEM_PATH"][i] + "\n" + esp_verbose += "\n\n" + + if args.packages: + esp_verbose += "Host system installed packages: \n" + for i in range(len(info["INSTALLED_PACKAGES"])): + esp_verbose += " " + info["INSTALLED_PACKAGES"][i] + "\n" + esp_verbose += "\n\n" + + if args.modules: + esp_verbose += "Host system installed python modules: \n" + for i in range(len(info["PYTHON_MODULES"])): + esp_verbose += " " + info["PYTHON_MODULES"][i] + "\n" + esp_verbose += "\n\n" + + esp_verbose += "Espressif specific information: \n\n" + esp_verbose += esp_logs + esp_verbose += "=" * 79 + "\n" + + eprint(esp_verbose) + + # Common functions # @@ -602,9 +652,12 @@ def generate_header(args): len(info["ESPRESSIF_BOOTLOADER"]) ) output += "static const char *ESPRESSIF_BOOTLOADER[ESPRESSIF_BOOTLOADER_ARRAY_SIZE] =\n{\n" + build_output = "Bootloader version:\n" for key, value in info["ESPRESSIF_BOOTLOADER"].items(): output += ' "{}: {}",\n'.format(key, value) + build_output += " {}: {},\n".format(key, value) output += "};\n\n" + build_output += "\n\n" # Espressif toolchain version @@ -613,9 +666,12 @@ def generate_header(args): len(info["ESPRESSIF_TOOLCHAIN"]) ) output += "static const char *ESPRESSIF_TOOLCHAIN[ESPRESSIF_TOOLCHAIN_ARRAY_SIZE] =\n{\n" + build_output += "Toolchain version:\n" for key, value in info["ESPRESSIF_TOOLCHAIN"].items(): output += ' "{}: {}",\n'.format(key, value) + build_output += " {}: {},\n".format(key, value) output += "};\n\n" + build_output += "\n\n" # Espressif esptool version @@ -625,6 +681,9 @@ def generate_header(args): output += 'static const char ESPRESSIF_ESPTOOL[] = "{}";\n\n'.format( info["ESPRESSIF_ESPTOOL"].split("-")[1] ) + build_output += "Esptool version: {}\n\n".format( + info["ESPRESSIF_ESPTOOL"].split("-")[1] + ) # Espressif HAL version @@ -632,40 +691,53 @@ def generate_header(args): output += 'static const char ESPRESSIF_HAL[] = "{}";\n\n'.format( info["ESPRESSIF_HAL"] ) + build_output += "HAL version: {}\n\n".format(info["ESPRESSIF_HAL"]) if args.espressif_chip and info["ESPRESSIF_ESPTOOL"] not in "Not found": info["ESPRESSIF_CHIP_ID"] = get_espressif_chip_id() output += 'static const char ESPRESSIF_CHIP_ID[] = "{}";\n\n'.format( info["ESPRESSIF_CHIP_ID"] ) + build_output += "CHIP ID: = {}\n\n".format(info["ESPRESSIF_CHIP_ID"]) info["ESPRESSIF_FLASH_ID"] = get_espressif_flash_id() output += "#define ESPRESSIF_FLASH_ID_ARRAY_SIZE {}\n".format( len(info["ESPRESSIF_FLASH_ID"]) ) output += "static const char *ESPRESSIF_FLASH_ID[ESPRESSIF_FLASH_ID_ARRAY_SIZE] =\n{\n" + build_output += "Flash ID:\n" for each_item in info["ESPRESSIF_FLASH_ID"]: output += ' "{}",\n'.format(each_item) + build_output += " {}\n".format(each_item) output += "};\n\n" + build_output += "\n\n" info["ESPRESSIF_SECURITY_INFO"] = get_espressif_security_info() output += "#define ESPRESSIF_SECURITY_INFO_ARRAY_SIZE {}\n".format( len(info["ESPRESSIF_SECURITY_INFO"]) ) output += "static const char *ESPRESSIF_SECURITY_INFO[ESPRESSIF_SECURITY_INFO_ARRAY_SIZE] =\n{\n" + build_output += "Security information: \n" for each_item in info["ESPRESSIF_SECURITY_INFO"]: output += ' "{}",\n'.format(each_item) + build_output += " {}\n".format(each_item) output += "};\n\n" + build_output += "\n\n" info["ESPRESSIF_FLASH_STAT"] = get_espressif_flash_status() output += 'static const char ESPRESSIF_FLASH_STAT[] = "{}";\n\n'.format( info["ESPRESSIF_FLASH_STAT"] ) + build_output += "Flash status: {}\n\n".format(info["ESPRESSIF_FLASH_STAT"]) info["ESPRESSIF_MAC_ADDR"] = get_espressif_mac_address() output += 'static const char ESPRESSIF_MAC_ADDR[] = "{}";\n\n'.format( info["ESPRESSIF_MAC_ADDR"] ) + build_output += "MAC address: {}\n\n".format(info["ESPRESSIF_MAC_ADDR"]) + + if args.espressif_verbose: + espressif_verbose(info, build_output) output += "#endif /* __SYSTEM_INFO_H */\n" @@ -703,6 +775,9 @@ if __name__ == "__main__": --espressif_chip: Get Espressif specific information about chip. Requires device connection during build. + --espressif_verbose: + Enable printing Espressif-specific information about + chip during build. """ # Generic arguments @@ -766,6 +841,12 @@ if __name__ == "__main__": help="Get Espressif specific information about chip. Requires device connection during build.", ) + parser.add_argument( + "--espressif_verbose", + action="store_true", + help="Enable printing Espressif-specific information about chip during build", + ) + # Parse arguments if len(sys.argv) == 1:
