diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index c49d6201b6fb54..fb68a3276c705a 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -28,7 +28,7 @@ from builders.mw320 import MW320App, MW320Builder from builders.nrf import NrfApp, NrfBoard, NrfConnectBuilder from builders.nuttx import NuttXApp, NuttXBoard, NuttXBuilder -from builders.nxp import NxpApp, NxpBoard, NxpBoardVariant, NxpBuilder, NxpBuildSystem, NxpOsUsed +from builders.nxp import NxpApp, NxpBoard, NxpBoardVariant, NxpBuilder, NxpBuildSystem, NxpLogLevel, NxpOsUsed from builders.openiotsdk import OpenIotSdkApp, OpenIotSdkBuilder, OpenIotSdkCryptoBackend from builders.qpg import QpgApp, QpgBoard, QpgBuilder from builders.stm32 import stm32App, stm32Board, stm32Builder @@ -562,6 +562,10 @@ def BuildNxpTarget(): target.AppendModifier(name="iw416", iw416_transceiver=True).OnlyIfRe('rt1060') target.AppendModifier(name="w8801", w8801_transceiver=True).OnlyIfRe('rt1060') target.AppendModifier(name="iwx12", iwx12_transceiver=True).OnlyIfRe('rt1060|rt1170') + target.AppendModifier(name="log-all", log_level=NxpLogLevel.ALL).ExceptIfRe("-log-(progress|error|none)") + target.AppendModifier(name="log-progress", log_level=NxpLogLevel.PROGRESS).ExceptIfRe("-log-(all|error|none)") + target.AppendModifier(name="log-error", log_level=NxpLogLevel.ERROR).ExceptIfRe("-log-(progress|all|none)") + target.AppendModifier(name="log-none", log_level=NxpLogLevel.NONE).ExceptIfRe("-log-(progress|error|all)") return target diff --git a/scripts/build/builders/nxp.py b/scripts/build/builders/nxp.py index 6070a18fd0ba60..91155f20c96f7b 100644 --- a/scripts/build/builders/nxp.py +++ b/scripts/build/builders/nxp.py @@ -158,6 +158,14 @@ def BuildRoot(self, root, board, os_env): return os.path.join(root, 'examples', self.ExampleName(), 'nxp', board.FolderName(os_env)) +class NxpLogLevel(Enum): + DEFAULT = auto() # default everything + ALL = auto() # enable all logging + PROGRESS = auto() # progress and above + ERROR = auto() # error and above + NONE = auto() # no chip_logging at all + + class NxpBuilder(GnBuilder): def __init__(self, @@ -187,7 +195,9 @@ def __init__(self, disable_pairing_autostart: bool = False, iw416_transceiver: bool = False, w8801_transceiver: bool = False, - iwx12_transceiver: bool = False): + iwx12_transceiver: bool = False, + log_level: NxpLogLevel = NxpLogLevel.DEFAULT, + ): super(NxpBuilder, self).__init__( root=app.BuildRoot(root, board, os_env), runner=runner) @@ -217,12 +227,16 @@ def __init__(self, self.iw416_transceiver = iw416_transceiver self.w8801_transceiver = w8801_transceiver self.iwx12_transceiver = iwx12_transceiver + if self.low_power and log_level != NxpLogLevel.NONE: + logging.warning("Switching log level to 'NONE' for low power build") + log_level = NxpLogLevel.NONE + self.log_level = log_level def GnBuildArgs(self): args = [] if self.low_power: - args.append('chip_with_low_power=1 chip_logging=false') + args.append('chip_with_low_power=1') if self.board == NxpBoard.K32W0: args.append('chip_pw_tokenizer_logging=false chip_with_OM15082=0') @@ -244,6 +258,31 @@ def GnBuildArgs(self): if self.enable_rotating_id: args.append('chip_enable_rotating_device_id=1 chip_enable_additional_data_advertising=1') + if self.log_level == NxpLogLevel.DEFAULT: + pass + elif self.log_level == NxpLogLevel.ALL: + args.append("chip_logging=true") + args.append("chip_error_logging=true") + args.append("chip_progress_logging=true") + args.append("chip_detail_logging=true") + args.append("chip_automation_logging=true") + elif self.log_level == NxpLogLevel.PROGRESS: + args.append("chip_logging=true") + args.append("chip_error_logging=true") + args.append("chip_progress_logging=true") + args.append("chip_detail_logging=false") + args.append("chip_automation_logging=false") + elif self.log_level == NxpLogLevel.ERROR: + args.append("chip_logging=true") + args.append("chip_error_logging=true") + args.append("chip_progress_logging=false") + args.append("chip_detail_logging=false") + args.append("chip_automation_logging=false") + elif self.log_level == NxpLogLevel.NONE: + args.append("chip_logging=false") + else: + raise Exception("Unknown log level: %r", self.log_level) + if self.has_sw_version_2: args.append('nxp_software_version=2') diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index 3a1c592d2ae609..65755878191856 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -13,7 +13,7 @@ linux-{x64,arm64}-{rpc-console,all-clusters,all-clusters-minimal,chip-tool,therm linux-x64-efr32-test-runner[-clang] imx-{chip-tool,lighting-app,thermostat,all-clusters-app,all-clusters-minimal-app,ota-provider-app}[-release] infineon-psoc6-{lock,light,all-clusters,all-clusters-minimal}[-ota][-updateimage][-trustm] -nxp-{k32w0,k32w1,rt1060,rt1170,rw61x,rw61x_eth,mcxw71}-{zephyr,freertos}-{lighting,contact-sensor,lock-app,all-clusters,laundry-washer,thermostat}[-factory][-low-power][-lit][-fro32k][-smu2][-dac-conversion][-rotating-id][-sw-v2][-ota][-wifi][-ethernet][-thread][-matter-shell][-data-model-disabled][-data-model-enabled][-factory-build][-frdm][-cmake][-evkc][-iw416][-w8801][-iwx12] +nxp-{k32w0,k32w1,rt1060,rt1170,rw61x,rw61x_eth,mcxw71}-{zephyr,freertos}-{lighting,contact-sensor,lock-app,all-clusters,laundry-washer,thermostat}[-factory][-low-power][-lit][-fro32k][-smu2][-dac-conversion][-rotating-id][-sw-v2][-ota][-wifi][-ethernet][-thread][-matter-shell][-data-model-disabled][-data-model-enabled][-factory-build][-frdm][-cmake][-evkc][-iw416][-w8801][-iwx12][-log-all][-log-progress][-log-error][-log-none] mbed-cy8cproto_062_4343w-{lock,light,all-clusters,all-clusters-minimal,pigweed,ota-requestor,shell}[-release][-develop][-debug][-data-model-disabled][-data-model-enabled] mw320-all-clusters-app nrf-{nrf5340dk,nrf52840dk,nrf52840dongle}-{all-clusters,all-clusters-minimal,lock,light,light-switch,shell,pump,pump-controller,window-covering}[-rpc][-data-model-disabled][-data-model-enabled]