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-2016, 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 """
Pawel Zarembski 0:01f31e923fe2 20 Copy release files from the uvision build directories into a release package
Pawel Zarembski 0:01f31e923fe2 21
Pawel Zarembski 0:01f31e923fe2 22 This script is intended to be called the script creating a daplink build.
Pawel Zarembski 0:01f31e923fe2 23 """
Pawel Zarembski 0:01f31e923fe2 24 from __future__ import absolute_import
Pawel Zarembski 0:01f31e923fe2 25 from __future__ import print_function
Pawel Zarembski 0:01f31e923fe2 26
Pawel Zarembski 0:01f31e923fe2 27 import os
Pawel Zarembski 0:01f31e923fe2 28 import shutil
Pawel Zarembski 0:01f31e923fe2 29 import glob
Pawel Zarembski 0:01f31e923fe2 30 import argparse
Pawel Zarembski 0:01f31e923fe2 31
Pawel Zarembski 0:01f31e923fe2 32 from subprocess import check_output, CalledProcessError
Pawel Zarembski 0:01f31e923fe2 33
Pawel Zarembski 0:01f31e923fe2 34 COPY_PATTERN_LIST = [
Pawel Zarembski 0:01f31e923fe2 35 "%s_crc*.bin",
Pawel Zarembski 0:01f31e923fe2 36 "%s_crc*.hex",
Pawel Zarembski 0:01f31e923fe2 37 "%s_crc*.txt",
Pawel Zarembski 0:01f31e923fe2 38 ]
Pawel Zarembski 0:01f31e923fe2 39 OPTIONAL_COPY_PATTERN_LIST = [
Pawel Zarembski 0:01f31e923fe2 40 "%s.axf",
Pawel Zarembski 0:01f31e923fe2 41 "%s.elf",
Pawel Zarembski 0:01f31e923fe2 42 "%s_crc*.c",
Pawel Zarembski 0:01f31e923fe2 43 "%s.build_log.htm",
Pawel Zarembski 0:01f31e923fe2 44 "%s.map",
Pawel Zarembski 0:01f31e923fe2 45 "%s.htm",
Pawel Zarembski 0:01f31e923fe2 46 "%s_map.html",
Pawel Zarembski 0:01f31e923fe2 47 ]
Pawel Zarembski 0:01f31e923fe2 48
Pawel Zarembski 0:01f31e923fe2 49 TOOL_DIR = {
Pawel Zarembski 0:01f31e923fe2 50 'uvision' : { 'proj_dir': os.path.join('projectfiles', 'uvision') , 'rel_dir' : 'uvision_release', 'build_dir' : 'build' },
Pawel Zarembski 0:01f31e923fe2 51 'mbedcli' : { 'proj_dir': 'BUILD' , 'rel_dir' : 'mbedcli_release', 'build_dir' : 'ARM-CUSTOM_PROFILE' }
Pawel Zarembski 0:01f31e923fe2 52 }
Pawel Zarembski 0:01f31e923fe2 53
Pawel Zarembski 0:01f31e923fe2 54 def generate_info_files(dir):
Pawel Zarembski 0:01f31e923fe2 55
Pawel Zarembski 0:01f31e923fe2 56 output_info_file = os.path.join(os.path.normpath(dir),'git_info.txt')
Pawel Zarembski 0:01f31e923fe2 57 output_requirements_file = os.path.join(os.path.normpath(dir),'build_requirements.txt')
Pawel Zarembski 0:01f31e923fe2 58
Pawel Zarembski 0:01f31e923fe2 59 # Get the git SHA.
Pawel Zarembski 0:01f31e923fe2 60 try:
Pawel Zarembski 0:01f31e923fe2 61 git_sha = check_output("git rev-parse --verify HEAD", shell=True)
Pawel Zarembski 0:01f31e923fe2 62 git_sha = git_sha.decode().strip()
Pawel Zarembski 0:01f31e923fe2 63 except:
Pawel Zarembski 0:01f31e923fe2 64 print("ERROR - failed to get git SHA, do you have git.exe in your PATH environment variable?")
Pawel Zarembski 0:01f31e923fe2 65 return 1
Pawel Zarembski 0:01f31e923fe2 66
Pawel Zarembski 0:01f31e923fe2 67 # Check are there any local, uncommitted modifications.
Pawel Zarembski 0:01f31e923fe2 68 try:
Pawel Zarembski 0:01f31e923fe2 69 check_output("git diff --no-ext-diff --quiet --exit-code", shell=True)
Pawel Zarembski 0:01f31e923fe2 70 except (CalledProcessError, OSError):
Pawel Zarembski 0:01f31e923fe2 71 git_has_changes = '1'
Pawel Zarembski 0:01f31e923fe2 72 else:
Pawel Zarembski 0:01f31e923fe2 73 git_has_changes = '0'
Pawel Zarembski 0:01f31e923fe2 74
Pawel Zarembski 0:01f31e923fe2 75 # Get the requirements version.
Pawel Zarembski 0:01f31e923fe2 76 try:
Pawel Zarembski 0:01f31e923fe2 77 pip_freeze = check_output("pip list", shell=True).decode().strip()
Pawel Zarembski 0:01f31e923fe2 78 except:
Pawel Zarembski 0:01f31e923fe2 79 print("ERROR - failed requirements, pip not installed?")
Pawel Zarembski 0:01f31e923fe2 80 return 1
Pawel Zarembski 0:01f31e923fe2 81
Pawel Zarembski 0:01f31e923fe2 82
Pawel Zarembski 0:01f31e923fe2 83 # Create the version files
Pawel Zarembski 0:01f31e923fe2 84 try:
Pawel Zarembski 0:01f31e923fe2 85 with open(output_info_file, 'w+') as file:
Pawel Zarembski 0:01f31e923fe2 86 file.write(git_sha + '\n' + 'Uncommitted Changes:' + git_has_changes + '\n' )
Pawel Zarembski 0:01f31e923fe2 87 with open(output_requirements_file, 'w+') as file:
Pawel Zarembski 0:01f31e923fe2 88 file.write(pip_freeze)
Pawel Zarembski 0:01f31e923fe2 89 except IOError:
Pawel Zarembski 0:01f31e923fe2 90 print("Error - failed to write information and version files")
Pawel Zarembski 0:01f31e923fe2 91 return 1;
Pawel Zarembski 0:01f31e923fe2 92 return 0
Pawel Zarembski 0:01f31e923fe2 93
Pawel Zarembski 0:01f31e923fe2 94
Pawel Zarembski 0:01f31e923fe2 95 def main():
Pawel Zarembski 0:01f31e923fe2 96 """Copy imporant files for the current release"""
Pawel Zarembski 0:01f31e923fe2 97 parser = argparse.ArgumentParser(description='Copy imporant files for the current release')
Pawel Zarembski 0:01f31e923fe2 98 parser.add_argument('--project-tool', type=str, default='uvision', choices=['uvision', 'mbedcli'], help='Choose from uvision and mbedcli')
Pawel Zarembski 0:01f31e923fe2 99 args = parser.parse_args()
Pawel Zarembski 0:01f31e923fe2 100
Pawel Zarembski 0:01f31e923fe2 101 self_path = os.path.abspath(__file__)
Pawel Zarembski 0:01f31e923fe2 102 tools_dir = os.path.dirname(self_path)
Pawel Zarembski 0:01f31e923fe2 103 daplink_dir = os.path.dirname(tools_dir)
Pawel Zarembski 0:01f31e923fe2 104
Pawel Zarembski 0:01f31e923fe2 105 if os.path.basename(tools_dir) != "tools":
Pawel Zarembski 0:01f31e923fe2 106 print("Error - this script must be run from the tools directory")
Pawel Zarembski 0:01f31e923fe2 107 exit(-1)
Pawel Zarembski 0:01f31e923fe2 108
Pawel Zarembski 0:01f31e923fe2 109 proj_dir = os.path.join(daplink_dir, TOOL_DIR[args.project_tool]['proj_dir'])
Pawel Zarembski 0:01f31e923fe2 110 rel_dir = os.path.join(daplink_dir, TOOL_DIR[args.project_tool]['rel_dir'])
Pawel Zarembski 0:01f31e923fe2 111 build_dir = TOOL_DIR[args.project_tool]['build_dir']
Pawel Zarembski 0:01f31e923fe2 112 # Make sure uvision dir is present
Pawel Zarembski 0:01f31e923fe2 113 if not os.path.isdir(proj_dir):
Pawel Zarembski 0:01f31e923fe2 114 print("Error - uvision directory '%s' missing" % proj_dir)
Pawel Zarembski 0:01f31e923fe2 115 exit(-1)
Pawel Zarembski 0:01f31e923fe2 116
Pawel Zarembski 0:01f31e923fe2 117 # Clean release dir is present
Pawel Zarembski 0:01f31e923fe2 118 if os.path.isdir(rel_dir):
Pawel Zarembski 0:01f31e923fe2 119 shutil.rmtree(rel_dir)
Pawel Zarembski 0:01f31e923fe2 120
Pawel Zarembski 0:01f31e923fe2 121 os.mkdir(rel_dir)
Pawel Zarembski 0:01f31e923fe2 122
Pawel Zarembski 0:01f31e923fe2 123 generate_info_files(rel_dir)
Pawel Zarembski 0:01f31e923fe2 124
Pawel Zarembski 0:01f31e923fe2 125 project_list = os.listdir(proj_dir)
Pawel Zarembski 0:01f31e923fe2 126 for project in project_list:
Pawel Zarembski 0:01f31e923fe2 127 src_dir = os.path.join(proj_dir, project, build_dir)
Pawel Zarembski 0:01f31e923fe2 128 dest_dir = os.path.join(rel_dir, project.lower())
Pawel Zarembski 0:01f31e923fe2 129
Pawel Zarembski 0:01f31e923fe2 130 #only copy a built project
Pawel Zarembski 0:01f31e923fe2 131 if not os.path.exists(src_dir):
Pawel Zarembski 0:01f31e923fe2 132 continue
Pawel Zarembski 0:01f31e923fe2 133
Pawel Zarembski 0:01f31e923fe2 134 # File must not have been copied already
Pawel Zarembski 0:01f31e923fe2 135 if os.path.exists(dest_dir):
Pawel Zarembski 0:01f31e923fe2 136 print("Error - package dir '%s' alread exists" % dest_dir)
Pawel Zarembski 0:01f31e923fe2 137 exit(-1)
Pawel Zarembski 0:01f31e923fe2 138 os.mkdir(dest_dir)
Pawel Zarembski 0:01f31e923fe2 139
Pawel Zarembski 0:01f31e923fe2 140 for file_pattern in COPY_PATTERN_LIST:
Pawel Zarembski 0:01f31e923fe2 141 file_name = file_pattern % project.lower()
Pawel Zarembski 0:01f31e923fe2 142 file_source = os.path.join(src_dir, file_name)
Pawel Zarembski 0:01f31e923fe2 143 for file_wild in glob.glob(file_source):
Pawel Zarembski 0:01f31e923fe2 144 shutil.copy(file_wild, dest_dir)
Pawel Zarembski 0:01f31e923fe2 145 for file_pattern in OPTIONAL_COPY_PATTERN_LIST:
Pawel Zarembski 0:01f31e923fe2 146 file_name = file_pattern % project.lower()
Pawel Zarembski 0:01f31e923fe2 147 file_source = os.path.join(src_dir, file_name)
Pawel Zarembski 0:01f31e923fe2 148 for file_wild in glob.glob(file_source):
Pawel Zarembski 0:01f31e923fe2 149 shutil.copy(file_wild, dest_dir)
Pawel Zarembski 0:01f31e923fe2 150
Pawel Zarembski 0:01f31e923fe2 151 main()