Repostiory containing DAPLink source code with Reset Pin workaround for HANI_IOT board.

Upstream: https://github.com/ARMmbed/DAPLink

Committer:
Pawel Zarembski
Date:
Tue Apr 07 12:55:42 2020 +0200
Revision:
0:01f31e923fe2
hani: DAPLink with reset workaround

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pawel Zarembski 0:01f31e923fe2 1 #
Pawel Zarembski 0:01f31e923fe2 2 # DAPLink Interface Firmware
Pawel Zarembski 0:01f31e923fe2 3 # Copyright (c) 2009-2018, ARM Limited, All Rights Reserved
Pawel Zarembski 0:01f31e923fe2 4 # SPDX-License-Identifier: Apache-2.0
Pawel Zarembski 0:01f31e923fe2 5 #
Pawel Zarembski 0:01f31e923fe2 6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
Pawel Zarembski 0:01f31e923fe2 7 # not use this file except in compliance with the License.
Pawel Zarembski 0:01f31e923fe2 8 # You may obtain a copy of the License at
Pawel Zarembski 0:01f31e923fe2 9 #
Pawel Zarembski 0:01f31e923fe2 10 # http://www.apache.org/licenses/LICENSE-2.0
Pawel Zarembski 0:01f31e923fe2 11 #
Pawel Zarembski 0:01f31e923fe2 12 # Unless required by applicable law or agreed to in writing, software
Pawel Zarembski 0:01f31e923fe2 13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
Pawel Zarembski 0:01f31e923fe2 14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Pawel Zarembski 0:01f31e923fe2 15 # See the License for the specific language governing permissions and
Pawel Zarembski 0:01f31e923fe2 16 # limitations under the License.
Pawel Zarembski 0:01f31e923fe2 17 #
Pawel Zarembski 0:01f31e923fe2 18
Pawel Zarembski 0:01f31e923fe2 19 import os
Pawel Zarembski 0:01f31e923fe2 20 import shutil
Pawel Zarembski 0:01f31e923fe2 21 import subprocess
Pawel Zarembski 0:01f31e923fe2 22 from generate_mbedcli_files import generate_mbedcli_files
Pawel Zarembski 0:01f31e923fe2 23
Pawel Zarembski 0:01f31e923fe2 24 def call_and_copy_output(args):
Pawel Zarembski 0:01f31e923fe2 25 try:
Pawel Zarembski 0:01f31e923fe2 26 process = subprocess.Popen(args, stdout=None, stderr=subprocess.STDOUT)
Pawel Zarembski 0:01f31e923fe2 27 process.wait()
Pawel Zarembski 0:01f31e923fe2 28 if process.returncode != 0:
Pawel Zarembski 0:01f31e923fe2 29 print("Error - mbed compile!")
Pawel Zarembski 0:01f31e923fe2 30 exit(process.returncode)
Pawel Zarembski 0:01f31e923fe2 31 except (OSError, ValueError) as e:
Pawel Zarembski 0:01f31e923fe2 32 print("Error - Cannot do mbed compile")
Pawel Zarembski 0:01f31e923fe2 33 print(e.output)
Pawel Zarembski 0:01f31e923fe2 34 exit(1)
Pawel Zarembski 0:01f31e923fe2 35
Pawel Zarembski 0:01f31e923fe2 36 def mbedcli_run(daplink_dir, build_folder, project, toolchain, clean, verbosity):
Pawel Zarembski 0:01f31e923fe2 37 generate_mbedcli_files(os.path.join(daplink_dir, "projects.yaml"), project)
Pawel Zarembski 0:01f31e923fe2 38 project_dir=os.path.join(daplink_dir, build_folder, project.upper())
Pawel Zarembski 0:01f31e923fe2 39 if clean is True and os.path.exists(project_dir):
Pawel Zarembski 0:01f31e923fe2 40 print("Deleting %s" % project_dir)
Pawel Zarembski 0:01f31e923fe2 41 shutil.rmtree(project_dir, ignore_errors=True)
Pawel Zarembski 0:01f31e923fe2 42 args = ["mbed", "compile", "-m", project, "-t", toolchain, "--profile", "custom_profile.json"]
Pawel Zarembski 0:01f31e923fe2 43 if verbosity is not None:
Pawel Zarembski 0:01f31e923fe2 44 args.append("-" + "v" * verbosity)
Pawel Zarembski 0:01f31e923fe2 45 call_and_copy_output(args)
Pawel Zarembski 0:01f31e923fe2 46 cli_name_out = os.path.basename(daplink_dir)
Pawel Zarembski 0:01f31e923fe2 47 build_dir = os.path.join(project_dir, toolchain+"-CUSTOM_PROFILE")
Pawel Zarembski 0:01f31e923fe2 48 for file in os.listdir(build_dir):
Pawel Zarembski 0:01f31e923fe2 49 if file.startswith(cli_name_out):
Pawel Zarembski 0:01f31e923fe2 50 rename_file = os.path.join(build_dir, file.replace(cli_name_out, project, 1))
Pawel Zarembski 0:01f31e923fe2 51 if os.path.exists(rename_file):
Pawel Zarembski 0:01f31e923fe2 52 os.remove(rename_file)
Pawel Zarembski 0:01f31e923fe2 53 os.rename(os.path.join(build_dir, file), rename_file)
Pawel Zarembski 0:01f31e923fe2 54 cli_hex_output = os.path.join(build_dir, project + ".hex")
Pawel Zarembski 0:01f31e923fe2 55 crc_file_output = os.path.join(build_dir, project + "_crc")
Pawel Zarembski 0:01f31e923fe2 56 return (cli_hex_output,crc_file_output)