-
Notifications
You must be signed in to change notification settings - Fork 3k
Additions to TF-M source integration #9772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,4 @@ | ||
{ | ||
"name": "tfm", | ||
"config": { | ||
"handle_pool_size": { | ||
"help": "maximum number of handles that can be opened at the same time", | ||
"macro_name": "TFM_CONN_HANDLE_MAX_NUM", | ||
"value": 10 | ||
}, | ||
"rot_pool_size": { | ||
"help": "maximum number of RoT services allowed", | ||
"macro_name": "TFM_SPM_MAX_ROT_SERV_NUM", | ||
"value": 20 | ||
}, | ||
"message_pool_size": { | ||
"help": "maximum number of RoT services allowed", | ||
"macro_name": "TFM_MSG_QUEUE_MAX_MSG_NUM", | ||
"value": 10 | ||
} | ||
} | ||
"name": "tfm-s", | ||
"macros": ["MBED_FAULT_HANDLER_DISABLED", "BYPASS_NVSTORE_CHECK=1"] | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "tfm", | ||
"macros": [ | ||
"TFM_PSA_API", "MBED_TZ_DEFAULT_ACCESS=1" | ||
], | ||
"config": { | ||
"level": { | ||
"help": "TFM security level", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this suppose to mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is one TFM properties This is an internal TFM config, and a prep for the future when we will have a greater level of memory separation. |
||
"macro_name": "TFM_LVL", | ||
"value": 1 | ||
}, | ||
"handle_pool_size": { | ||
"help": "maximum number of handles that can be opened at the same time", | ||
"macro_name": "TFM_CONN_HANDLE_MAX_NUM", | ||
"value": 10 | ||
}, | ||
"rot_pool_size": { | ||
"help": "maximum number of RoT services allowed", | ||
"macro_name": "TFM_SPM_MAX_ROT_SERV_NUM", | ||
"value": 20 | ||
}, | ||
"message_pool_size": { | ||
"help": "maximum number of active messages allowed", | ||
"macro_name": "TFM_MSG_QUEUE_MAX_MSG_NUM", | ||
"value": 10 | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ fuzzywuzzy>=0.11,<=0.17 | |
pyelftools>=0.24,<=0.25 | ||
git+https://github.com/armmbed/[email protected] | ||
icetea>=1.2.1,<1.3 | ||
pycryptodome>=3.7.2,<=3.7.3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright (c) 2017-2018 ARM Limited | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from .assemble import Assembly | ||
|
||
__all__ = [ | ||
'Assembly' | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#! /usr/bin/env python3 | ||
# | ||
# Copyright 2017 Linaro Limited | ||
# Copyright (c) 2017-2018, Arm Limited. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
""" | ||
Assemble multiple images into a single image that can be flashed on the device. | ||
""" | ||
|
||
import argparse | ||
import errno | ||
import io | ||
import re | ||
import os | ||
import shutil | ||
|
||
offset_re = re.compile(r"^#define ([0-9A-Z_]+)_IMAGE_OFFSET\s+((0x)?[0-9a-fA-F]+)") | ||
size_re = re.compile(r"^#define ([0-9A-Z_]+)_IMAGE_MAX_SIZE\s+((0x)?[0-9a-fA-F]+)") | ||
|
||
class Assembly(): | ||
def __init__(self, layout_path, output): | ||
self.output = output | ||
self.layout_path = layout_path | ||
self.find_slots() | ||
try: | ||
os.unlink(output) | ||
except OSError as e: | ||
if e.errno != errno.ENOENT: | ||
raise | ||
|
||
def find_slots(self): | ||
offsets = {} | ||
sizes = {} | ||
|
||
if os.path.isabs(self.layout_path): | ||
configFile = self.layout_path | ||
else: | ||
scriptsDir = os.path.dirname(os.path.abspath(__file__)) | ||
configFile = os.path.join(scriptsDir, self.layout_path) | ||
|
||
with open(configFile, 'r') as fd: | ||
for line in fd: | ||
m = offset_re.match(line) | ||
if m is not None: | ||
offsets[m.group(1)] = int(m.group(2), 0) | ||
m = size_re.match(line) | ||
if m is not None: | ||
sizes[m.group(1)] = int(m.group(2), 0) | ||
|
||
if 'SECURE' not in offsets: | ||
raise Exception("Image config does not have secure partition") | ||
|
||
if 'NON_SECURE' not in offsets: | ||
raise Exception("Image config does not have non-secure partition") | ||
|
||
self.offsets = offsets | ||
self.sizes = sizes | ||
|
||
def add_image(self, source, partition): | ||
with open(self.output, 'ab') as ofd: | ||
ofd.seek(0, os.SEEK_END) | ||
pos = ofd.tell() | ||
if pos > self.offsets[partition]: | ||
raise Exception("Partitions not in order, unsupported") | ||
if pos < self.offsets[partition]: | ||
ofd.write(b'\xFF' * (self.offsets[partition] - pos)) | ||
statinfo = os.stat(source) | ||
if statinfo.st_size > self.sizes[partition]: | ||
raise Exception("Image {} is too large for partition".format(source)) | ||
with open(source, 'rb') as rfd: | ||
shutil.copyfileobj(rfd, ofd, 0x10000) | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument('-l', '--layout', required=True, | ||
help='Location of the memory layout file') | ||
parser.add_argument('-s', '--secure', required=True, | ||
help='Unsigned secure image') | ||
parser.add_argument('-n', '--non_secure', | ||
help='Unsigned non-secure image') | ||
parser.add_argument('-o', '--output', required=True, | ||
help='Filename to write full image to') | ||
|
||
args = parser.parse_args() | ||
output = Assembly(args.layout, args.output) | ||
|
||
|
||
output.add_image(args.secure, "SECURE") | ||
output.add_image(args.non_secure, "NON_SECURE") | ||
|
||
if __name__ == '__main__': | ||
main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it appropriate to disable the fault handler in a library? I looked for a justification for this change in the commit message but I didn't find one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when building TFM we are not using parts of mbed-os
Some of those parts are the fault handlers, and this is because TFM implements their own
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good enough for me!