1+ #!/usr/bin/env python3
2+
3+ """
4+ Wrapper around imx_cfg_utils.py to provide arguments to module
5+ """
6+ import argparse
7+ import datetime
8+ import pathlib
9+ import sys
10+ from errno import ENOTDIR , EINVAL
11+
12+ import imx_cfg_utils
13+
14+
15+ HELPSTR = """
16+ Processes NXP iMX.RT signal configuration files
17+
18+ Given a processor folder, generates the SOC level gpio DTSI mux options used
19+ within Zephyr. These definitions should be copied where appropriate.
20+
21+ This tool is intended to be used with the configuration data downloaded
22+ from NXP's website. One way to extract this config data is to use the
23+ MCUXpresso configuration tool to download processor defintions, locate
24+ those defintions on the disk. Alternatively, individual processor config
25+ data packs can be downloaded from the MCUXpresso SDK builder tool. Either way,
26+ the path to the 'processors' directory must be provided as the 'cfg-tool-root'
27+ parameter.
28+ """
29+
30+
31+ parser = argparse .ArgumentParser (description = HELPSTR ,
32+ formatter_class = argparse .RawDescriptionHelpFormatter )
33+ parser .add_argument ('processor_root' , metavar = 'PROC_ROOT' ,
34+ type = str ,
35+ help = 'folder with processor signal configuration files' )
36+
37+ args = parser .parse_args ()
38+
39+ # Attempt to locate the signal XML files we will generate from
40+ proc_root = pathlib .Path (args .processor_root ) / 'ksdk2_0'
41+ if not proc_root .exists ():
42+ print (f"Error: Path { args .processor_root } provided for processor root is invalid" )
43+ sys .exit (EINVAL )
44+ # Iterate through all processor package signal.xml files
45+ for package_root in proc_root .iterdir ():
46+ signal_path = package_root / 'signal_configuration.xml'
47+ # Check if this is a processor package folder
48+ if signal_path .exists ():
49+ # Generate SOC GPIO file
50+ util = imx_cfg_utils .NXPSdkUtil (str (package_root ))
51+ out_path = f"./{ util .get_part_num ().lower ()} -gpio.dtsi"
52+ util .write_gpio_mux (out_path )
53+ print (f"Wrote SOC GPIO file to { out_path } " )
54+
0 commit comments