From bf85eaab4868f9306042a70bd7a80217d204f065 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Thu, 30 May 2024 15:04:17 -0400 Subject: [PATCH 1/3] Fix builds for MG24 --- tools/build_project.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/build_project.py b/tools/build_project.py index 6c72b48a..c34eb220 100755 --- a/tools/build_project.py +++ b/tools/build_project.py @@ -323,6 +323,10 @@ def main(): args.build_dir / "config/sl_memory_config.h", args.build_dir / "config/sl_board_control_config.h", args.build_dir / "config/FreeRTOSConfig.h", + # Hardware-specific startup config + args.build_dir / "config/sl_device_init_lfxo_config.h", + args.build_dir / "config/sl_device_init_hfxo_config.h", + args.build_dir / "config/sl_device_init_dcdc_config.h", ], ): try: From c05228c40e8e8d3473896144638912bc41b638cf Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Thu, 30 May 2024 17:00:15 -0400 Subject: [PATCH 2/3] Compute chip-specific config files in a generic way --- tools/build_project.py | 78 ++++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 22 deletions(-) diff --git a/tools/build_project.py b/tools/build_project.py index c34eb220..fc790f98 100755 --- a/tools/build_project.py +++ b/tools/build_project.py @@ -15,7 +15,6 @@ import logging import pathlib import argparse -import itertools import contextlib import subprocess import multiprocessing @@ -39,6 +38,14 @@ """, flags=re.IGNORECASE | re.VERBOSE, ) + +GRAPH_COMPONENT_REGEX = re.compile(r"^(\w+)|- (\w+)", flags=re.MULTILINE) +CHIP_SPECIFIC_COMPONENTS = { + "sl_system": "sl_system", + "sl_memory": "sl_memory", + # There are only a few components whose filename doesn't match the component name + "freertos": "freertos_kernel", +} LOGGER = logging.getLogger(__name__) yaml = YAML(typ="safe") @@ -141,6 +148,43 @@ def git(*args: str) -> str: return commit_id +def determine_chip_specific_config_filenames( + slcp_path: pathlib.Path, sdk: pathlib.Path, slc: str +) -> list[str]: + """Determine the chip-specific config files to remove.""" + proc = subprocess.run( + [slc, "graph", "-p", str(slcp_path.absolute()), "--sdk", str(sdk.absolute())], + cwd=str(slcp_path.parent), + check=True, + text=True, + capture_output=True, + ) + + all_components = {a or b for a, b in GRAPH_COMPONENT_REGEX.findall(proc.stdout)} + + # Some configs don't seem to be present explicitly in the component graph + config_files = {"sl_memory_config.h"} + + # List all of the SLCC files. There are neary 4,000. + slcc_paths = {slcc.stem.lower(): slcc for slcc in sdk.glob("**/*.slcc")} + + for component_id in all_components: + if CHIP_SPECIFIC_REGEX.match(component_id): + pass + elif component_id in CHIP_SPECIFIC_COMPONENTS: + component_id = CHIP_SPECIFIC_COMPONENTS[component_id] + else: + continue + + slcc = yaml.load(slcc_paths[component_id.lower()].read_text()) + + for config_file in slcc.get("config_file", []): + path = pathlib.PurePosixPath(config_file["path"]).name + config_files.add(path) + + return config_files + + def main(): parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter @@ -313,27 +357,6 @@ def main(): # Delete the original project file (args.build_dir / base_project_slcp.name).unlink() - # Delete config files that must be regenerated by the SDK. - # XXX: This is fragile: you cannot force `slc` to always overwrite these files! - for filename in itertools.chain( - # RAIL config - (args.build_dir / "config").glob("sl_rail_*.h"), - [ - # Z-Wave board and stack config - args.build_dir / "config/sl_memory_config.h", - args.build_dir / "config/sl_board_control_config.h", - args.build_dir / "config/FreeRTOSConfig.h", - # Hardware-specific startup config - args.build_dir / "config/sl_device_init_lfxo_config.h", - args.build_dir / "config/sl_device_init_hfxo_config.h", - args.build_dir / "config/sl_device_init_dcdc_config.h", - ], - ): - try: - filename.unlink() - except FileNotFoundError: - pass - # Write the new project SLCP file with (args.build_dir / f"{base_project_name}.slcp").open("w") as f: yaml.dump(output_project, f) @@ -373,6 +396,17 @@ def main(): print(f"Project SDK version {base_project['sdk']['version']} not found") sys.exit(1) + print("Building component graph and identifying board-specific files") + for name in determine_chip_specific_config_filenames( + slcp_path=base_project_slcp, sdk=sdk, slc=slc + ): + try: + (args.build_dir / f"config/{name}").unlink() + except FileNotFoundError: + pass + else: + print(f"Deleted device-specific config: {name}") + # Find the toolchain required by the project slps_path = (args.build_dir / base_project_name).with_suffix(".slps") slps_xml = ElementTree.parse(slps_path) From 40e1010e17260c54e12a34e607f47a1c4b647489 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Thu, 30 May 2024 17:08:24 -0400 Subject: [PATCH 3/3] Remove unnecessary PTI config --- manifests/skyconnect_ncp-uart-hw.yaml | 1 - manifests/skyconnect_ot-rcp.yaml | 1 - manifests/skyconnect_rcp-uart-802154.yaml | 1 - manifests/yellow_ncp-uart-hw.yaml | 1 - manifests/yellow_ot-rcp.yaml | 1 - manifests/yellow_rcp-uart-802154.yaml | 1 - 6 files changed, 6 deletions(-) diff --git a/manifests/skyconnect_ncp-uart-hw.yaml b/manifests/skyconnect_ncp-uart-hw.yaml index fc0e2890..fd04c863 100644 --- a/manifests/skyconnect_ncp-uart-hw.yaml +++ b/manifests/skyconnect_ncp-uart-hw.yaml @@ -9,7 +9,6 @@ gbl: baudrate: 115200 configuration: - SL_RAIL_UTIL_PTI_MODE: RAIL_PTI_MODE_DISABLED SL_IOSTREAM_USART_VCOM_BAUDRATE: 115200 SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE: usartHwFlowControlCtsAndRts diff --git a/manifests/skyconnect_ot-rcp.yaml b/manifests/skyconnect_ot-rcp.yaml index 168c8d09..8a6e5c6d 100644 --- a/manifests/skyconnect_ot-rcp.yaml +++ b/manifests/skyconnect_ot-rcp.yaml @@ -9,7 +9,6 @@ gbl: baudrate: 460800 configuration: - SL_RAIL_UTIL_PTI_MODE: RAIL_PTI_MODE_DISABLED SL_UARTDRV_USART_VCOM_BAUDRATE: 460800 c_defines: diff --git a/manifests/skyconnect_rcp-uart-802154.yaml b/manifests/skyconnect_rcp-uart-802154.yaml index c6ab5c9d..ea263f97 100644 --- a/manifests/skyconnect_rcp-uart-802154.yaml +++ b/manifests/skyconnect_rcp-uart-802154.yaml @@ -9,7 +9,6 @@ gbl: baudrate: 460800 configuration: - SL_RAIL_UTIL_PTI_MODE: RAIL_PTI_MODE_DISABLED SL_CPC_DRV_UART_VCOM_BAUDRATE: 460800 c_defines: diff --git a/manifests/yellow_ncp-uart-hw.yaml b/manifests/yellow_ncp-uart-hw.yaml index d2fda810..118a5fb2 100644 --- a/manifests/yellow_ncp-uart-hw.yaml +++ b/manifests/yellow_ncp-uart-hw.yaml @@ -13,7 +13,6 @@ add_components: instance: [board_activity] configuration: - SL_RAIL_UTIL_PTI_MODE: RAIL_PTI_MODE_DISABLED SL_IOSTREAM_USART_VCOM_BAUDRATE: 115200 SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE: usartHwFlowControlCtsAndRts diff --git a/manifests/yellow_ot-rcp.yaml b/manifests/yellow_ot-rcp.yaml index c0a60b6a..d795c46c 100644 --- a/manifests/yellow_ot-rcp.yaml +++ b/manifests/yellow_ot-rcp.yaml @@ -13,7 +13,6 @@ add_components: instance: [board_activity] configuration: - SL_RAIL_UTIL_PTI_MODE: RAIL_PTI_MODE_DISABLED SL_UARTDRV_USART_VCOM_BAUDRATE: 460800 c_defines: diff --git a/manifests/yellow_rcp-uart-802154.yaml b/manifests/yellow_rcp-uart-802154.yaml index 23cc65bd..cc8fb465 100644 --- a/manifests/yellow_rcp-uart-802154.yaml +++ b/manifests/yellow_rcp-uart-802154.yaml @@ -12,7 +12,6 @@ add_components: instance: [board_activity] configuration: - SL_RAIL_UTIL_PTI_MODE: RAIL_PTI_MODE_DISABLED SL_CPC_DRV_UART_VCOM_BAUDRATE: 460800 c_defines: