Creating a custom WPC Service adapter#
This chapter is for those users, who wish not to use EL2GO, but rather have their own solution.
To help you getting started with creating a custom Service, we have a Cookiecutter template located in: <spsdk_repo>/examples/templates/cookiecutter-spsdk-wpc-service-plugin.zip
This template will create a Python project, containing a plugin for SPSDK
Install cookiecutter:
pip install cookiecutterCreate your project:
cookiecutter <spsdk_repo>/examples/plugins/templates/cookiecutter-spsdk-wpc-service-plugin.zipfollow the prompts
your project will be created in the current working directory
Class representing your adapter will be located in:
<your_project_name/your_project_name/your_project_name.py>Implement necessary methods
get_validation_schemasUse this method to provide JSON validation schema for your class (parameters for the
__init__method)Schema will be used when instantiating your class using configuration data via
.load_from_configmethodThis schema will be also used to generate configuration file using
nxpwpc get-template
get_wpc_certThis method is the bread and butter of your adapter
Here is where you’ll implement the process of getting the WPC Certificate Chain
Install your plugin into virtual environment where you have SPSDK
pip install (--editable) <path/to/your/project>The
--editableflag is used for development purposes. It will allow you to develop your plugin without a need to re-install your plugin after every change
Verify your plugin was picked-up by SPSDK
nxpwpc get-template --helpYou should see the name of your plugin in
--service-typeoptionName of the plugin is set during project creation, also defined in your class as
identifierattribute
Example#
Commands below will create a new WPC Service Plugin Python project.
!pip install cookiecutter
!cookiecutter ../plugins/templates/cookiecutter-spsdk-wpc-service-plugin.zip --overwrite-if-exists --replay --replay-file cookiecutter-replay-file.json
!pip install -e my_wpc_service_plugin --no-deps
Looking in indexes: https://pypi.org/simple, https://nl2-nxrm.sw.nxp.com/repository/spsdk_pypi/simple/
Collecting cookiecutter
Using cached cookiecutter-2.6.0-py3-none-any.whl.metadata (7.3 kB)
Requirement already satisfied: binaryornot>=0.4.4 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from cookiecutter) (0.4.4)
Requirement already satisfied: Jinja2<4.0.0,>=2.7 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from cookiecutter) (3.1.6)
Requirement already satisfied: click<9.0.0,>=7.0 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from cookiecutter) (8.1.8)
Requirement already satisfied: pyyaml>=5.3.1 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from cookiecutter) (6.0.2)
Requirement already satisfied: python-slugify>=4.0.0 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from cookiecutter) (8.0.4)
Requirement already satisfied: requests>=2.23.0 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from cookiecutter) (2.32.3)
Requirement already satisfied: arrow in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from cookiecutter) (1.3.0)
Requirement already satisfied: rich in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from cookiecutter) (14.0.0)
Requirement already satisfied: chardet>=3.0.2 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from binaryornot>=0.4.4->cookiecutter) (5.2.0)
Requirement already satisfied: colorama in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from click<9.0.0,>=7.0->cookiecutter) (0.4.6)
Requirement already satisfied: MarkupSafe>=2.0 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from Jinja2<4.0.0,>=2.7->cookiecutter) (3.0.2)
Requirement already satisfied: text-unidecode>=1.3 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from python-slugify>=4.0.0->cookiecutter) (1.3)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from requests>=2.23.0->cookiecutter) (3.4.1)
Requirement already satisfied: idna<4,>=2.5 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from requests>=2.23.0->cookiecutter) (3.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from requests>=2.23.0->cookiecutter) (2.4.0)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from requests>=2.23.0->cookiecutter) (2025.1.31)
Requirement already satisfied: python-dateutil>=2.7.0 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from arrow->cookiecutter) (2.9.0.post0)
Requirement already satisfied: types-python-dateutil>=2.8.10 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from arrow->cookiecutter) (2.9.0.20241206)
Requirement already satisfied: markdown-it-py>=2.2.0 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from rich->cookiecutter) (3.0.0)
Requirement already satisfied: pygments<3.0.0,>=2.13.0 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from rich->cookiecutter) (2.19.1)
Requirement already satisfied: mdurl~=0.1 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from markdown-it-py>=2.2.0->rich->cookiecutter) (0.1.2)
Requirement already satisfied: six>=1.5 in c:\users\nxa17573\repos\spsdk-master\venv\lib\site-packages (from python-dateutil>=2.7.0->arrow->cookiecutter) (1.17.0)
Using cached cookiecutter-2.6.0-py3-none-any.whl (39 kB)
Installing collected packages: cookiecutter
Successfully installed cookiecutter-2.6.0
Looking in indexes: https://pypi.org/simple, https://nl2-nxrm.sw.nxp.com/repository/spsdk_pypi/simple/
Obtaining my_wpc_service_plugin
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Checking if build backend supports build_editable: started
Checking if build backend supports build_editable: finished with status 'done'
Getting requirements to build editable: started
Getting requirements to build editable: finished with status 'done'
Preparing editable metadata (pyproject.toml): started
Preparing editable metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: my_wpc_service_plugin
Building editable for my_wpc_service_plugin (pyproject.toml): started
Building editable for my_wpc_service_plugin (pyproject.toml): finished with status 'done'
Created wheel for my_wpc_service_plugin: filename=my_wpc_service_plugin-0.1.0-0.editable-py3-none-any.whl size=5726 sha256=fbcecae3d1606064d825614dbcc08c4685862cec4d7b66882d3e0bc6db87bd01
Stored in directory: C:\Users\nxa17573\AppData\Local\Temp\pip-ephem-wheel-cache-7fkpqx7a\wheels\ff\f0\88\3db2e91aca21d66acd109a6e1d564c72abb529658091b3694b
Successfully built my_wpc_service_plugin
Installing collected packages: my_wpc_service_plugin
Successfully installed my_wpc_service_plugin-0.1.0
!nxpwpc get-template --help
Help for nested command: 'get-template'
Command Hierarchy: nxpwpc ▶ get-template
──────────────────────── Root command (nxpwpc) help ────────────────────────
Options:
-v, --verbose Print more detailed information
-vv, --debug Display more debugging information.
--version Show the version and exit.
--help Show this message and exit.
─────────────────────── Command (get-template) help ───────────────────────
Generate a configuration template.
Usage: nxpwpc get-template [OPTIONS]
Options:
-st, --service-type [el2go|mywpc]
Name of the WPC service type. [required]
-tt, --target-type [mboot|model]
Name of the MCU target type. [required]
-f, --family [mwct2015s|mwct2012|mwct2016s|mwct2014s..., and more. Use 'get-families' command to show all.]
[required] Select the chip family.
-r, --revision TEXT Chip revision; if not specified, most recent
one will be used
-o, --output FILE Path to a file, where to store the output.
[required]
--force Force overwriting of existing files.
--help Show this message and exit.
Please note the mywpc service type above
!nxpwpc get-template -st mywpc -tt model -f mwct2d17s -o config_with_plugin.yaml --force
The WPC template for mwct2d17s, Revision: latest has been saved into config_with_plugin.yaml YAML file
Please note the service_parameters section of config_with_plugin.yaml.
Keys param1 and param2 are coming from .get_validation_schemas method from the plugin.
When instantiating the plugin class using .load_from_config, these two keys will will be passed to the __init__ method.