Skip to content

Commit

Permalink
Release 1.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria Wisniewska committed May 26, 2023
1 parent 2facbeb commit b75d067
Show file tree
Hide file tree
Showing 209 changed files with 23,540 additions and 1,041 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.10.0
current_version = 1.10.1
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<suffix>.*))?
serialize =
{major}.{minor}.{patch}.{suffix}
Expand Down
2 changes: 1 addition & 1 deletion SW_Content_Register_SPSDK.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NXP Software Content Register

Package: NXP SPSDK
Version: 1.10.0
Version: 1.10.1
Outgoing License: BSD-3-Clause
License Files: LICENSE
Type of content: Source code
Expand Down
4 changes: 4 additions & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.wy-nav-content {
max-width: 75% !important;
}

.wy-table-responsive table td {
white-space: normal;
}
3 changes: 1 addition & 2 deletions docs/apps/elftosb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ User Guide - elftosb
This user guide describes how to use *elftosb* application. *elftosb* is a tool for generating TrustZone,
Master Boot Image and Secure Binary images.

For more information about the supported binary images and how to configure them visit page
:ref:`Supported binary images`
Refer to the chapter supported binary images for more information.

----------------------------
Legacy elftosb documentation
Expand Down
299 changes: 0 additions & 299 deletions docs/apps/images.rst

This file was deleted.

3 changes: 1 addition & 2 deletions docs/apps/nxpimage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ Master Boot Image and Secure Binary images. This tool is successor of obsolete *
replace *elftosb* is bring clear and more usable user interface to application that is used to create various kind
of NXP images. To keep backward compatibility as much as possible the configuration files has been kept as is.

For more information about the supported binary images and how to configure them visit page
:ref:`Supported binary images`
Refer to the chapter supported binary images for more information.

----------------------
Command line interface
Expand Down
272 changes: 261 additions & 11 deletions docs/exts/generate_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,36 @@
# Script for the automated generation of schemas documentation for elftosb/nxpimage
import os
from typing import Any, Dict, List, Sequence
import yaml

import jsonschema2md

from spsdk.image.mbimg import get_all_mbi_classes
from spsdk.sbfile.sb31.images import SecureBinary31

from spsdk.image.ahab.ahab_container import AHABImage
from spsdk.image.bee import BeeNxp
from spsdk.image.bootable_image.bimg import BootableImage, FCB, XMCD
from spsdk.utils.crypto.otfad import OtfadNxp
from spsdk.utils.crypto.iee import IeeNxp
from spsdk.sbfile.sb31.images import SecureBinary31, SB3_SCH_FILE, DATABASE_FILE
from spsdk.sbfile.sb2.sb_21_helper import cmds as sb2_cmds
from spsdk.utils.schema_validator import ConfigTemplate, SPSDKMerger
from pytablewriter import MarkdownTableWriter

DOC_PATH = os.path.abspath(".")
SCHEMAS_DIR = os.path.join(DOC_PATH, "_prebuild")
SCHEMAS_FILE = os.path.join(SCHEMAS_DIR, "schemas.inc")
DOC_DIR = os.path.join(DOC_PATH, "_prebuild")
MBI_SCHEMAS_FILE = os.path.join(DOC_DIR, "schemas.inc")
SB3_SCHEMAS_FILE = os.path.join(DOC_DIR, "schemas_sb3.inc")
AHAB_SCHEMAS_FILE = os.path.join(DOC_DIR, "ahab_schemas.inc")
OTFAD_SCHEMAS_FILE = os.path.join(DOC_DIR, "otfad_schemas.inc")
IEE_SCHEMAS_FILE = os.path.join(DOC_DIR, "iee_schemas.inc")
BEE_SCHEMAS_FILE = os.path.join(DOC_DIR, "bee_schemas.inc")
FCB_SCHEMAS_FILE = os.path.join(DOC_DIR, "fcb_schemas.inc")
XMCD_SCHEMAS_FILE = os.path.join(DOC_DIR, "xmcd_schemas.inc")
BOOTABLE_SCHEMAS_FILE = os.path.join(DOC_DIR, "bootable_schemas.inc")
SB2_TABLE_FILE = os.path.join(DOC_DIR, "table_sb21.inc")
SB3_TABLE_FILE = os.path.join(DOC_DIR, "table_sb31.inc")
BOOTABLE_TABLE_FILE = os.path.join(DOC_DIR, "table_bootable.inc")


def get_schema(schemas: List[Dict[str, Any]]) -> Dict:
Expand Down Expand Up @@ -53,15 +73,20 @@ def parse_schema(schema: Dict) -> Sequence[str]:
return parser.parse_schema(schema)


def append_schema(parsed: Sequence[str], template: str) -> None:
def append_schema(
parsed: Sequence[str],
template: str,
file: str,
) -> None:
"""Appends schema and template to the markdown document
:param parsed: sequence of MD strings
:param template: string with YAML to be appended to the doc
:param file: schema file
"""
if not os.path.exists(SCHEMAS_DIR):
os.makedirs(SCHEMAS_DIR)
with open(SCHEMAS_FILE, "a+") as f:
if not os.path.exists(DOC_DIR):
os.makedirs(DOC_DIR)
with open(file, "a+") as f:
del parsed[1] # remove subtitle
f.writelines(parsed)
f.write("\n")
Expand Down Expand Up @@ -95,36 +120,261 @@ def get_template(schemas: Dict, name: str) -> str:

def get_mbi_doc() -> None:
"""Get doc for MBI classes."""
if os.path.exists(MBI_SCHEMAS_FILE):
os.remove(MBI_SCHEMAS_FILE)
image_classes = get_all_mbi_classes()
for cls in image_classes:
validation_schemas = cls.get_validation_schemas()
schema = get_schema(validation_schemas)
schema["title"] = cls.__name__
parsed_schema = parse_schema(schema)
template = get_template([schema], f"YAML template {cls.__name__}")
append_schema(parsed_schema, template)
append_schema(parsed_schema, template, MBI_SCHEMAS_FILE)


def get_sb3_table() -> None:
"""Generates table with SB3 supported commands"""
# Load the YAML files
with open(DATABASE_FILE, "r") as file:
devices_yaml = yaml.safe_load(file)

with open(SB3_SCH_FILE, "r") as file:
commands_yaml = yaml.safe_load(file)

headers = ["Command", "Command Description"]
values = []
supported_commands = {}
devices = []

# Iterate over the devices in the devices YAML data
for device, device_data in devices_yaml["devices"].items():
# Check if the device has a device alias
if "device_alias" in device_data:
device_alias = device_data["device_alias"]
# Get the supported commands from the device alias
supported_commands[device] = devices_yaml["devices"][device_alias]["attributes"][
"supported_commands"
]
else:
supported_commands[device] = device_data["attributes"]["supported_commands"]
devices.append(device)
headers.extend(devices)
commands = commands_yaml["sb3_commands"]["properties"]["commands"]["items"]["oneOf"]

for command in commands:
properties = command["properties"]
command_name = list(properties.keys())[0]
description = properties[command_name]["description"]
vals = [command_name, description]

for device in devices:
if command_name in supported_commands[device]:
supported = "YES"
else:
supported = "NO"
vals.append(supported)
values.append(vals)

write_table(headers, values, "List of SB 3.1 supported commands", SB3_TABLE_FILE)


def get_sb3_doc() -> None:
"""Get doc for SB3 configurations."""
# Get validation schemas DOC
if os.path.exists(SB3_SCHEMAS_FILE):
os.remove(SB3_SCHEMAS_FILE)
families = SecureBinary31.get_supported_families()
for fam in families:
validation_schemas = SecureBinary31.get_validation_schemas(fam)
schema = get_schema(validation_schemas)
schema["title"] = f"{SecureBinary31.__name__} for {fam}"
parsed_schema = parse_schema(schema)
template = get_template([schema], f"YAML template {SecureBinary31.__name__} for {fam}")
append_schema(parsed_schema, template)
append_schema(parsed_schema, template, SB3_SCHEMAS_FILE)


def get_ahab_doc() -> None:
"""Get doc for AHAB configurations."""
# Get validation schemas DOC
if os.path.exists(AHAB_SCHEMAS_FILE):
os.remove(AHAB_SCHEMAS_FILE)
validation_schemas = AHABImage.get_validation_schemas()
schema = get_schema(validation_schemas)
schema["title"] = f"{AHABImage.__name__}"
parsed_schema = parse_schema(schema)
template = get_template([schema], f"AHAB template {AHABImage.__name__}")
append_schema(parsed_schema, template, AHAB_SCHEMAS_FILE)


def get_otfad_doc() -> None:
"""Get doc for OTFAD configurations."""
# Get validation schemas DOC
if os.path.exists(OTFAD_SCHEMAS_FILE):
os.remove(OTFAD_SCHEMAS_FILE)
families = OtfadNxp.get_supported_families()
for fam in families:
validation_schemas = OtfadNxp.get_validation_schemas(fam)
schema = get_schema(validation_schemas)
schema["title"] = f"OTFAD template for {fam}"
parsed_schema = parse_schema(schema)
template = get_template([schema], f"OTFAD template for {fam}")
append_schema(parsed_schema, template, OTFAD_SCHEMAS_FILE)


def get_iee_doc() -> None:
"""Get doc for AHAB configurations."""
# Get validation schemas DOC
if os.path.exists(IEE_SCHEMAS_FILE):
os.remove(IEE_SCHEMAS_FILE)
families = IeeNxp.get_supported_families()
for fam in families:
validation_schemas = IeeNxp.get_validation_schemas(fam)
schema = get_schema(validation_schemas)
schema["title"] = f"IEE template for {fam}"
parsed_schema = parse_schema(schema)
template = get_template([schema], f"IEE template for {fam}")
append_schema(parsed_schema, template, IEE_SCHEMAS_FILE)


def get_bee_doc() -> None:
"""Get doc for AHAB configurations."""
# Get validation schemas DOC
if os.path.exists(BEE_SCHEMAS_FILE):
os.remove(BEE_SCHEMAS_FILE)
validation_schemas = BeeNxp.get_validation_schemas()
schema = get_schema(validation_schemas)
schema["title"] = f"{BeeNxp.__name__}"
parsed_schema = parse_schema(schema)
template = get_template([schema], f"BEE template")
append_schema(parsed_schema, template, BEE_SCHEMAS_FILE)


def get_bootable_image() -> None:
"""Get bootable image schemas."""
if os.path.exists(BOOTABLE_SCHEMAS_FILE):
os.remove(BOOTABLE_SCHEMAS_FILE)
families = BootableImage.get_supported_families()
for fam in families:
memories = BootableImage.get_supported_memory_types(fam)
for mem in memories:
validation_schemas = BootableImage.get_validation_schemas(fam, mem)
schema = get_schema(validation_schemas)
schema["title"] = f"Bootable Image template for {fam} and {mem}"
parsed_schema = parse_schema(schema)
template = get_template([schema], f"Bootable Image template for {fam} and {mem}")
append_schema(parsed_schema, template, BOOTABLE_SCHEMAS_FILE)


def get_bootable_image_table() -> None:
"""Get bootable image table."""
values = []
families = BootableImage.get_supported_families()
for fam in families:
supported_memory = BootableImage.get_supported_memory_types(fam)
for mem in supported_memory:
config = BootableImage.get_memory_type_config(fam, mem)
values.append([fam, mem, "```" + str(config) + "```"])

write_table(
["Family", "Memory Type", "Offsets"],
values,
"List of devices and supported memory types",
BOOTABLE_TABLE_FILE,
)


def get_fcb_doc() -> None:
"""Get doc for FCB configurations."""
# Get validation schemas DOC
if os.path.exists(FCB_SCHEMAS_FILE):
os.remove(FCB_SCHEMAS_FILE)
families = FCB.get_supported_families()
for fam in families:
memories = FCB.get_supported_memory_types(fam)
for mem in memories:
validation_schemas = FCB.get_validation_schemas(fam, mem)
schema = get_schema(validation_schemas)
schema["title"] = f"FCB template for {fam} and {mem}"
parsed_schema = parse_schema(schema)
template = get_template([schema], f"FCB template for {fam} and {mem}")
append_schema(parsed_schema, template, FCB_SCHEMAS_FILE)


def get_xmcd_doc() -> None:
"""Get doc for XMCD configurations."""
# Get validation schemas DOC
if os.path.exists(XMCD_SCHEMAS_FILE):
os.remove(XMCD_SCHEMAS_FILE)
families = XMCD.get_supported_families()
for fam in families:
memories = XMCD.get_supported_memory_types(fam)
for mem in memories:
validation_schemas = XMCD.get_validation_schemas(fam, mem, "full")
schema = get_schema(validation_schemas)
schema["title"] = f"XMCD template for {fam} and {mem}"
parsed_schema = parse_schema(schema)
template = get_template([schema], f"XMCD template for {fam} and {mem}")
append_schema(parsed_schema, template, XMCD_SCHEMAS_FILE)


def write_table(header: List[str], values: List[List[str]], table_name: str, table_file_path: str):
"""Write MD table to file using pytablewriter
:param header: table header
:param values: values to be writter
:param table_name: Name of the table
:param table_file_path: Path to the file
"""
writer = MarkdownTableWriter(
table_name=table_name,
headers=header,
value_matrix=values,
)

if not os.path.exists(DOC_DIR):
os.makedirs(DOC_DIR)

with open(table_file_path, "w") as f:
writer.stream = f
writer.write_table()


def get_sb2_doc() -> None:
"""Get doc for SB2 commands."""
doc_lst = []
for key, val in sb2_cmds.items():
doc = [
line.strip()
for line in val.__doc__.split("\n\n")
if not (line.strip().startswith(":") or line.strip().startswith("Returns"))
]
doc_lst.append([key, doc[0], r"<code>" + doc[1].replace("\n", "<br>") + r"</code>"])
write_table(
["Command", "Description", "Example"],
doc_lst,
"Supported commands for SB2.1",
SB2_TABLE_FILE,
)


def main():
print("Running generate schemas script")
if os.path.exists(SCHEMAS_FILE):
os.remove(SCHEMAS_FILE)
if os.path.exists(MBI_SCHEMAS_FILE):
os.remove(MBI_SCHEMAS_FILE)
print("Existing schemas file has been removed")

get_mbi_doc()
get_sb3_doc()
get_sb2_doc()
get_sb3_table()
get_ahab_doc()
get_otfad_doc()
get_iee_doc()
get_bee_doc()
get_bootable_image()
get_bootable_image_table()
get_fcb_doc()
get_xmcd_doc()
print("Finished running")


Expand Down
23 changes: 23 additions & 0 deletions docs/images/ahab.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
------
AHAB
------

AHAB (Advanced High Assurance Boot) is a container format supported on some devices. A configuration file in YAML or
JSON is used to instruct nxpimage how the output should look like.

AHAB container is not supported by elftosb tool.

Example of use for export
``nxpimage ahab export "path\to\config\file.yaml"``

Example of use for parse binary AHAB container
``nxpimage ahab parse -b "my_ahab_container.bin" "path\to_parsed_data"``

The full AHAB configuration template could be generated by nxpimage tool "get_template" sub-command for family that supports AHAB, example:
``nxpimage ahab get-template -f rt118x ./my_config_templates``

Supported configuration options
================================

.. include:: ../_prebuild/ahab_schemas.inc
:parser: myst_parser.sphinx_
Loading

0 comments on commit b75d067

Please sign in to comment.