Skip to content

Commit

Permalink
Fix EFR32MG24 build by purging more chip-specific config files (#67)
Browse files Browse the repository at this point in the history
* Fix builds for MG24

* Compute chip-specific config files in a generic way

* Remove unnecessary PTI config
  • Loading branch information
puddly authored Jun 1, 2024
1 parent 14f5146 commit 2acb02c
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 24 deletions.
1 change: 0 additions & 1 deletion manifests/skyconnect_ncp-uart-hw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion manifests/skyconnect_ot-rcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion manifests/skyconnect_rcp-uart-802154.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion manifests/yellow_ncp-uart-hw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion manifests/yellow_ot-rcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion manifests/yellow_rcp-uart-802154.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
74 changes: 56 additions & 18 deletions tools/build_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import logging
import pathlib
import argparse
import itertools
import contextlib
import subprocess
import multiprocessing
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -313,23 +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",
],
):
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)
Expand Down Expand Up @@ -369,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)
Expand Down

0 comments on commit 2acb02c

Please sign in to comment.