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 argparse
Pawel Zarembski 0:01f31e923fe2 20 import yaml
Pawel Zarembski 0:01f31e923fe2 21 import sys
Pawel Zarembski 0:01f31e923fe2 22 import logging
Pawel Zarembski 0:01f31e923fe2 23 from generate_custom_cli_files import generate_custom_targets
Pawel Zarembski 0:01f31e923fe2 24 from generate_custom_cli_files import generate_custom_profile
Pawel Zarembski 0:01f31e923fe2 25 from generate_mbedignore import generate_mbedignore
Pawel Zarembski 0:01f31e923fe2 26
Pawel Zarembski 0:01f31e923fe2 27 logging.basicConfig(format='Line: %(lineno)d %(message)s')
Pawel Zarembski 0:01f31e923fe2 28 logger = logging.getLogger('yaml gen')
Pawel Zarembski 0:01f31e923fe2 29 logger.setLevel(logging.DEBUG)
Pawel Zarembski 0:01f31e923fe2 30
Pawel Zarembski 0:01f31e923fe2 31 def parse_yaml_dicts(input_dicts, output_dicts):
Pawel Zarembski 0:01f31e923fe2 32 for key in input_dicts:
Pawel Zarembski 0:01f31e923fe2 33 if key in output_dicts: #merge
Pawel Zarembski 0:01f31e923fe2 34 if type(output_dicts[key]) is dict:
Pawel Zarembski 0:01f31e923fe2 35 parse_yaml_dicts(input_dicts[key], output_dicts[key])
Pawel Zarembski 0:01f31e923fe2 36 elif type(output_dicts[key]) is list:
Pawel Zarembski 0:01f31e923fe2 37 output_dicts[key].extend(input_dicts[key])
Pawel Zarembski 0:01f31e923fe2 38 else:
Pawel Zarembski 0:01f31e923fe2 39 logger.error('Wrong type', typeof(output_dicts[key]))
Pawel Zarembski 0:01f31e923fe2 40 else:
Pawel Zarembski 0:01f31e923fe2 41 output_dicts[key] = input_dicts[key]
Pawel Zarembski 0:01f31e923fe2 42
Pawel Zarembski 0:01f31e923fe2 43 def parse_yaml_files(list_of_list, data_dict):
Pawel Zarembski 0:01f31e923fe2 44 if type(list_of_list) is list:
Pawel Zarembski 0:01f31e923fe2 45 for entry in list_of_list:
Pawel Zarembski 0:01f31e923fe2 46 if type(entry) is list:
Pawel Zarembski 0:01f31e923fe2 47 parse_yaml_files(entry, data_dict)
Pawel Zarembski 0:01f31e923fe2 48 elif type(entry) is str and entry.endswith('.yaml'):
Pawel Zarembski 0:01f31e923fe2 49 try:
Pawel Zarembski 0:01f31e923fe2 50 with open(entry, 'r') as yaml_file:
Pawel Zarembski 0:01f31e923fe2 51 yaml_entries = yaml.load(yaml_file)
Pawel Zarembski 0:01f31e923fe2 52 parse_yaml_dicts(yaml_entries, data_dict)
Pawel Zarembski 0:01f31e923fe2 53
Pawel Zarembski 0:01f31e923fe2 54 except yaml.YAMLError as ex:
Pawel Zarembski 0:01f31e923fe2 55 logger.error("Found yaml parse error", ex)
Pawel Zarembski 0:01f31e923fe2 56 else:
Pawel Zarembski 0:01f31e923fe2 57 logger.error('Wrong type', typeof(entry))
Pawel Zarembski 0:01f31e923fe2 58 else:
Pawel Zarembski 0:01f31e923fe2 59 logger.error('Wrong type', typeof(list_of_list))
Pawel Zarembski 0:01f31e923fe2 60
Pawel Zarembski 0:01f31e923fe2 61 def generate_mbedcli_files(projects_yaml, target_project):
Pawel Zarembski 0:01f31e923fe2 62 with open(projects_yaml, 'r') as top_yaml:
Pawel Zarembski 0:01f31e923fe2 63 try:
Pawel Zarembski 0:01f31e923fe2 64 build_data = {}
Pawel Zarembski 0:01f31e923fe2 65 topdict = yaml.load(top_yaml)
Pawel Zarembski 0:01f31e923fe2 66 for dict_key in topdict:
Pawel Zarembski 0:01f31e923fe2 67 if dict_key == 'projects':
Pawel Zarembski 0:01f31e923fe2 68 for project in topdict[dict_key]:
Pawel Zarembski 0:01f31e923fe2 69 if project == target_project:
Pawel Zarembski 0:01f31e923fe2 70 parse_yaml_files(topdict[dict_key][project], build_data)
Pawel Zarembski 0:01f31e923fe2 71 generate_custom_targets(project, build_data)
Pawel Zarembski 0:01f31e923fe2 72 generate_custom_profile(build_data)
Pawel Zarembski 0:01f31e923fe2 73 generate_mbedignore(build_data)
Pawel Zarembski 0:01f31e923fe2 74 break
Pawel Zarembski 0:01f31e923fe2 75 break
Pawel Zarembski 0:01f31e923fe2 76 except yaml.YAMLError as ex:
Pawel Zarembski 0:01f31e923fe2 77 logger.error("Found yaml parse error", ex)
Pawel Zarembski 0:01f31e923fe2 78
Pawel Zarembski 0:01f31e923fe2 79 if __name__ == "__main__":
Pawel Zarembski 0:01f31e923fe2 80 parser = argparse.ArgumentParser(description='projects.yaml file parser')
Pawel Zarembski 0:01f31e923fe2 81 parser.add_argument("--projects_yaml", type=str, default='projects.yaml', help="top projects.yaml file")
Pawel Zarembski 0:01f31e923fe2 82 parser.add_argument("--target_project", type=str, help="target project to be compiled")
Pawel Zarembski 0:01f31e923fe2 83 args = parser.parse_args()
Pawel Zarembski 0:01f31e923fe2 84
Pawel Zarembski 0:01f31e923fe2 85 if not args.target_project or args.target_project is '':
Pawel Zarembski 0:01f31e923fe2 86 sys.exit('Need a target project to compile DAPLink!')
Pawel Zarembski 0:01f31e923fe2 87
Pawel Zarembski 0:01f31e923fe2 88 generate_mbedcli_files(args.projects_yaml, args.target_project)