Merge branch 'master' of https://github.com/google/OpenSK into mingxguo-fuzzing

This commit is contained in:
mingxguo27
2020-08-13 17:20:15 +00:00
3 changed files with 29 additions and 26 deletions

View File

@@ -22,7 +22,7 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip setuptools wheel python -m pip install --upgrade pip setuptools wheel
pip install 'tockloader==1.4' pylint pip install 'tockloader==1.5' pylint
- name: Register matcher - name: Register matcher
run: echo ::add-matcher::./.github/python_matcher.json run: echo ::add-matcher::./.github/python_matcher.json
- name: Test code with pylint - name: Test code with pylint

View File

@@ -255,7 +255,6 @@ class RemoveConstAction(argparse.Action):
class OpenSKInstaller: class OpenSKInstaller:
def __init__(self, args): def __init__(self, args):
colorama.init()
self.args = args self.args = args
# Where all the TAB files should go # Where all the TAB files should go
self.tab_folder = os.path.join("target", "tab") self.tab_folder = os.path.join("target", "tab")
@@ -454,14 +453,10 @@ class OpenSKInstaller:
self.args.application, str(e))) self.args.application, str(e)))
def get_padding(self): def get_padding(self):
fake_header = tbfh.TBFHeader("") padding = tbfh.TBFHeaderPadding(
fake_header.version = 2
fake_header.fields["header_size"] = 0x10
fake_header.fields["total_size"] = (
SUPPORTED_BOARDS[self.args.board].app_address - SUPPORTED_BOARDS[self.args.board].app_address -
SUPPORTED_BOARDS[self.args.board].padding_address) SUPPORTED_BOARDS[self.args.board].padding_address)
fake_header.fields["flags"] = 0 return padding.get_binary()
return fake_header.get_binary()
def install_tock_os(self): def install_tock_os(self):
board_props = SUPPORTED_BOARDS[self.args.board] board_props = SUPPORTED_BOARDS[self.args.board]
@@ -543,7 +538,7 @@ class OpenSKInstaller:
tock.open() tock.open()
app_found = False app_found = False
with tock._start_communication_with_board(): with tock._start_communication_with_board():
apps = [app.name for app in tock._extract_all_app_headers()] apps = [app.get_name() for app in tock._extract_all_app_headers()]
app_found = expected_app in apps app_found = expected_app in apps
return app_found return app_found
@@ -582,16 +577,17 @@ class OpenSKInstaller:
"architecture {}".format(board_props.arch))) "architecture {}".format(board_props.arch)))
app_hex = intelhex.IntelHex() app_hex = intelhex.IntelHex()
app_hex.frombytes( app_hex.frombytes(
app_tab.extract_app(board_props.arch).get_binary(), app_tab.extract_app(board_props.arch).get_binary(
board_props.app_address),
offset=board_props.app_address) offset=board_props.app_address)
final_hex.merge(app_hex) final_hex.merge(app_hex)
info("Generating all-merged HEX file: {}".format(dest_file)) info("Generating all-merged HEX file: {}".format(dest_file))
final_hex.tofile(dest_file, format="hex") final_hex.tofile(dest_file, format="hex")
def check_prerequisites(self): def check_prerequisites(self):
if not tockloader.__version__.startswith("1.4."): if not tockloader.__version__.startswith("1.5."):
fatal(("Your version of tockloader seems incompatible: found {}, " fatal(("Your version of tockloader seems incompatible: found {}, "
"expected 1.4.x.".format(tockloader.__version__))) "expected 1.5.x.".format(tockloader.__version__)))
if self.args.programmer == "jlink": if self.args.programmer == "jlink":
assert_mandatory_binary("JLinkExe") assert_mandatory_binary("JLinkExe")
@@ -620,18 +616,6 @@ class OpenSKInstaller:
assert_python_library("intelhex") assert_python_library("intelhex")
def run(self): def run(self):
if self.args.listing == "boards":
print(os.linesep.join(get_supported_boards()))
return 0
if self.args.listing == "programmers":
print(os.linesep.join(PROGRAMMERS))
return 0
if self.args.listing:
# Missing check?
fatal("Listing {} is not implemented.".format(self.args.listing))
self.check_prerequisites() self.check_prerequisites()
self.update_rustc_if_needed() self.update_rustc_if_needed()
@@ -729,9 +713,23 @@ class OpenSKInstaller:
def main(args): def main(args):
colorama.init()
# Make sure the current working directory is the right one before running # Make sure the current working directory is the right one before running
os.chdir(os.path.realpath(os.path.dirname(__file__))) os.chdir(os.path.realpath(os.path.dirname(__file__)))
if args.listing == "boards":
print(os.linesep.join(get_supported_boards()))
return 0
if args.listing == "programmers":
print(os.linesep.join(PROGRAMMERS))
return 0
if args.listing:
# Missing check?
fatal("Listing {} is not implemented.".format(args.listing))
OpenSKInstaller(args).run() OpenSKInstaller(args).run()
@@ -875,7 +873,12 @@ if __name__ == "__main__":
help=("When set, the output of elf2tab is appended to this file."), help=("When set, the output of elf2tab is appended to this file."),
) )
apps_group = main_parser.add_mutually_exclusive_group(required=True) # Start parsing to know if we're going to list things or not.
partial_args, _ = main_parser.parse_known_args()
# We only need the apps_group if we have a board set
apps_group = main_parser.add_mutually_exclusive_group(
required=(partial_args.board is not None))
apps_group.add_argument( apps_group.add_argument(
"--no-app", "--no-app",
dest="application", dest="application",

View File

@@ -38,7 +38,7 @@ source tools/gen_key_materials.sh
generate_crypto_materials N generate_crypto_materials N
rustup install $(head -n 1 rust-toolchain) rustup install $(head -n 1 rust-toolchain)
pip3 install --user --upgrade 'tockloader==1.4' six intelhex pip3 install --user --upgrade 'tockloader==1.5' six intelhex
rustup target add thumbv7em-none-eabi rustup target add thumbv7em-none-eabi
# Install dependency to create applications. # Install dependency to create applications.