Repostiory containing DAPLink source code with Reset Pin workaround for HANI_IOT board.
Upstream: https://github.com/ARMmbed/DAPLink
tools/make_update_yml.py@0:01f31e923fe2, 2020-04-07 (annotated)
- 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?
User | Revision | Line number | New 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 logging |
Pawel Zarembski |
0:01f31e923fe2 | 20 | |
Pawel Zarembski |
0:01f31e923fe2 | 21 | logging.basicConfig(format='Line: %(lineno)d %(message)s') |
Pawel Zarembski |
0:01f31e923fe2 | 22 | logger = logging.getLogger('yaml gen') |
Pawel Zarembski |
0:01f31e923fe2 | 23 | logger.setLevel(logging.DEBUG) |
Pawel Zarembski |
0:01f31e923fe2 | 24 | |
Pawel Zarembski |
0:01f31e923fe2 | 25 | |
Pawel Zarembski |
0:01f31e923fe2 | 26 | class DefaultList(list): |
Pawel Zarembski |
0:01f31e923fe2 | 27 | def sort(self, *args, **kwargs): |
Pawel Zarembski |
0:01f31e923fe2 | 28 | pass |
Pawel Zarembski |
0:01f31e923fe2 | 29 | |
Pawel Zarembski |
0:01f31e923fe2 | 30 | class TargetList(list): |
Pawel Zarembski |
0:01f31e923fe2 | 31 | def sort(self, *args, **kwargs): |
Pawel Zarembski |
0:01f31e923fe2 | 32 | pass |
Pawel Zarembski |
0:01f31e923fe2 | 33 | |
Pawel Zarembski |
0:01f31e923fe2 | 34 | class InstructionList(list): |
Pawel Zarembski |
0:01f31e923fe2 | 35 | def sort(self, *args, **kwargs): |
Pawel Zarembski |
0:01f31e923fe2 | 36 | pass |
Pawel Zarembski |
0:01f31e923fe2 | 37 | |
Pawel Zarembski |
0:01f31e923fe2 | 38 | |
Pawel Zarembski |
0:01f31e923fe2 | 39 | #instruction steps for firmware |
Pawel Zarembski |
0:01f31e923fe2 | 40 | InstructionsText = { |
Pawel Zarembski |
0:01f31e923fe2 | 41 | 'default':InstructionList([ |
Pawel Zarembski |
0:01f31e923fe2 | 42 | ('windows', [ |
Pawel Zarembski |
0:01f31e923fe2 | 43 | '1. Download the firmware file.', |
Pawel Zarembski |
0:01f31e923fe2 | 44 | '2. While holding down the boards reset button, connect the boards USB debug port to the computer. It should enumerate and mount as `BOOTLOADER` or `MAINTENANCE`. For boards that enumerate as `BOOTLOADER` [see our blog to determine if an update for the DAPLink bootloader is available.](https://os.mbed.com/blog/entry/DAPLink-bootloader-update/)', |
Pawel Zarembski |
0:01f31e923fe2 | 45 | '3. Drag-and-drop the firmware file onto the mounted drive.', |
Pawel Zarembski |
0:01f31e923fe2 | 46 | '4. Wait for the file copy operation to complete.', |
Pawel Zarembski |
0:01f31e923fe2 | 47 | '5. Power cycle the board. It will now enumerate and mount as `DAPLINK` or the name of the board.' |
Pawel Zarembski |
0:01f31e923fe2 | 48 | ]), |
Pawel Zarembski |
0:01f31e923fe2 | 49 | ('osx', [ |
Pawel Zarembski |
0:01f31e923fe2 | 50 | '1. Download the firmware file.', |
Pawel Zarembski |
0:01f31e923fe2 | 51 | '2. While holding down the boards reset button, connect the boards USB debug port to the computer. It should enumerate as `BOOTLOADER` or `MAINTENANCE`. For boards that enumerate as `BOOTLOADER` [see our blog to determine if an update for the DAPLink bootloader is available.](https://os.mbed.com/blog/entry/DAPLink-bootloader-update/)', |
Pawel Zarembski |
0:01f31e923fe2 | 52 | '3. In a terminal execute', |
Pawel Zarembski |
0:01f31e923fe2 | 53 | ' - `sudo mount -u -w -o sync /Volumes/MAINTENANCE ; cp -X <path to firmware file> /Volumes/MAINTENANCE/`', |
Pawel Zarembski |
0:01f31e923fe2 | 54 | ' - Note: If your drive does not mount as `MAINTENANCE` make sure to change this to match the name of the mounted disk attached to your system.', |
Pawel Zarembski |
0:01f31e923fe2 | 55 | '4. Wait for the file copy operation to complete.', |
Pawel Zarembski |
0:01f31e923fe2 | 56 | '5. Power cycle the board. It will now enumerate and mount as `DAPLINK` or the name of the board.' |
Pawel Zarembski |
0:01f31e923fe2 | 57 | ]), |
Pawel Zarembski |
0:01f31e923fe2 | 58 | ('linux', [ |
Pawel Zarembski |
0:01f31e923fe2 | 59 | '1. Download the firmware file.', |
Pawel Zarembski |
0:01f31e923fe2 | 60 | '2. While holding down the boards reset button, connect the boards USB debug port to the computer. It should enumerate as `BOOTLOADER` or `MAINTENANCE`. For boards that enumerate as `BOOTLOADER` [see our blog to determine if an update for the DAPLink bootloader is available.](https://os.mbed.com/blog/entry/DAPLink-bootloader-update/)', |
Pawel Zarembski |
0:01f31e923fe2 | 61 | '3. In a terminal execute', |
Pawel Zarembski |
0:01f31e923fe2 | 62 | ' - `cp <path to firmware file> <MAINTENANCE> && sync`', |
Pawel Zarembski |
0:01f31e923fe2 | 63 | ' - Note: make sure to change `MAINTENANCE` to the name of the mount point of the drive on your system.', |
Pawel Zarembski |
0:01f31e923fe2 | 64 | '4. Power cycle the board. It will now enumerate and mount as `DAPLINK` or the name of the board.' |
Pawel Zarembski |
0:01f31e923fe2 | 65 | ]) |
Pawel Zarembski |
0:01f31e923fe2 | 66 | ]), |
Pawel Zarembski |
0:01f31e923fe2 | 67 | 'lpc11u35':InstructionList([ |
Pawel Zarembski |
0:01f31e923fe2 | 68 | ('windows', [ |
Pawel Zarembski |
0:01f31e923fe2 | 69 | '1. Download the firmware file.', |
Pawel Zarembski |
0:01f31e923fe2 | 70 | '2. While holding down the boards reset button, connect the boards USB debug port to the computer. It should enumerate and mount as `CRP DISABLD`', |
Pawel Zarembski |
0:01f31e923fe2 | 71 | '3. Delete the file named `firmware.bin`, then drag and drop or copy the new bin file', |
Pawel Zarembski |
0:01f31e923fe2 | 72 | '4. Wait for the file copy operation to complete.', |
Pawel Zarembski |
0:01f31e923fe2 | 73 | '5. Power cycle the board. It will now enumerate and mount as `DAPLINK` or the name of the board.' |
Pawel Zarembski |
0:01f31e923fe2 | 74 | ]), |
Pawel Zarembski |
0:01f31e923fe2 | 75 | ('osx', [ |
Pawel Zarembski |
0:01f31e923fe2 | 76 | '1. Download the firmware file.', |
Pawel Zarembski |
0:01f31e923fe2 | 77 | '2. While holding down the boards reset button, connect the boards USB debug port to the computer. It should enumerate and mount as `CRP DISABLD`', |
Pawel Zarembski |
0:01f31e923fe2 | 78 | '3. Delete the file named `firmware.bin`', |
Pawel Zarembski |
0:01f31e923fe2 | 79 | '4. In a terminal execute', |
Pawel Zarembski |
0:01f31e923fe2 | 80 | ' - `sudo mount -u -w -o sync /Volumes/CRP\ DISABLD ; rm /Volumes/CRP\ DISABLD/firmware.bin && cp -X <path to firmware file> /Volumes/CRP\ DISABLD/`', |
Pawel Zarembski |
0:01f31e923fe2 | 81 | '5. Wait for the file copy operation to complete.', |
Pawel Zarembski |
0:01f31e923fe2 | 82 | '6. Power cycle the board. It will now enumerate and mount as `DAPLINK` or the name of the board.' |
Pawel Zarembski |
0:01f31e923fe2 | 83 | ]), |
Pawel Zarembski |
0:01f31e923fe2 | 84 | ('linux', [ |
Pawel Zarembski |
0:01f31e923fe2 | 85 | '1. Download the firmware file.', |
Pawel Zarembski |
0:01f31e923fe2 | 86 | '2. While holding down the boards reset button, connect the boards USB debug port to the computer. It should enumerate and mount as `CRP DISABLD`', |
Pawel Zarembski |
0:01f31e923fe2 | 87 | '3. Delete the file named `firmware.bin`', |
Pawel Zarembski |
0:01f31e923fe2 | 88 | '4. In a terminal execute', |
Pawel Zarembski |
0:01f31e923fe2 | 89 | ' - `cp <path to firmware file> <CRP DISABLD> && sync`', |
Pawel Zarembski |
0:01f31e923fe2 | 90 | ' - Note: make sure to change `CRP DISABLD` to the name of the mount point on your system.', |
Pawel Zarembski |
0:01f31e923fe2 | 91 | '5. Power cycle the board. It will now enumerate and mount as `DAPLINK` or the name of the board.' |
Pawel Zarembski |
0:01f31e923fe2 | 92 | ]) |
Pawel Zarembski |
0:01f31e923fe2 | 93 | ]) |
Pawel Zarembski |
0:01f31e923fe2 | 94 | |
Pawel Zarembski |
0:01f31e923fe2 | 95 | } |
Pawel Zarembski |
0:01f31e923fe2 | 96 | |
Pawel Zarembski |
0:01f31e923fe2 | 97 | |
Pawel Zarembski |
0:01f31e923fe2 | 98 | def string_writer(element): |
Pawel Zarembski |
0:01f31e923fe2 | 99 | if type(element) is str: |
Pawel Zarembski |
0:01f31e923fe2 | 100 | return element |
Pawel Zarembski |
0:01f31e923fe2 | 101 | elif type(element) is int: |
Pawel Zarembski |
0:01f31e923fe2 | 102 | return "_0x%04i" % element |
Pawel Zarembski |
0:01f31e923fe2 | 103 | else: |
Pawel Zarembski |
0:01f31e923fe2 | 104 | return None |
Pawel Zarembski |
0:01f31e923fe2 | 105 | |
Pawel Zarembski |
0:01f31e923fe2 | 106 | |
Pawel Zarembski |
0:01f31e923fe2 | 107 | def yml_object_parser(f, entry, level, tabs): |
Pawel Zarembski |
0:01f31e923fe2 | 108 | header = " " * level * tabs |
Pawel Zarembski |
0:01f31e923fe2 | 109 | if type(entry) is list: |
Pawel Zarembski |
0:01f31e923fe2 | 110 | for element in entry: |
Pawel Zarembski |
0:01f31e923fe2 | 111 | yml_object_parser(f, element, level, tabs); |
Pawel Zarembski |
0:01f31e923fe2 | 112 | |
Pawel Zarembski |
0:01f31e923fe2 | 113 | elif type(entry) is dict: |
Pawel Zarembski |
0:01f31e923fe2 | 114 | for key in entry: |
Pawel Zarembski |
0:01f31e923fe2 | 115 | f.write('-' + ' ' * (level * tabs -1) + string_writer(key) + ": "); |
Pawel Zarembski |
0:01f31e923fe2 | 116 | value = string_writer(entry[key]) |
Pawel Zarembski |
0:01f31e923fe2 | 117 | if value is not None: |
Pawel Zarembski |
0:01f31e923fe2 | 118 | f.write(value) |
Pawel Zarembski |
0:01f31e923fe2 | 119 | f.write('\n') |
Pawel Zarembski |
0:01f31e923fe2 | 120 | else: |
Pawel Zarembski |
0:01f31e923fe2 | 121 | f.write('\n') |
Pawel Zarembski |
0:01f31e923fe2 | 122 | yml_object_parser(f, entry[key], level + 1, tabs); |
Pawel Zarembski |
0:01f31e923fe2 | 123 | |
Pawel Zarembski |
0:01f31e923fe2 | 124 | |
Pawel Zarembski |
0:01f31e923fe2 | 125 | elif type(entry) is DefaultList: |
Pawel Zarembski |
0:01f31e923fe2 | 126 | for target in entry: |
Pawel Zarembski |
0:01f31e923fe2 | 127 | if type(target) is tuple: |
Pawel Zarembski |
0:01f31e923fe2 | 128 | #print target |
Pawel Zarembski |
0:01f31e923fe2 | 129 | f.write(" " * level * tabs + string_writer(target[0]) + ": "); |
Pawel Zarembski |
0:01f31e923fe2 | 130 | value = string_writer(target[1]) |
Pawel Zarembski |
0:01f31e923fe2 | 131 | if value is not None: |
Pawel Zarembski |
0:01f31e923fe2 | 132 | f.write(value) |
Pawel Zarembski |
0:01f31e923fe2 | 133 | f.write('\n') |
Pawel Zarembski |
0:01f31e923fe2 | 134 | else: |
Pawel Zarembski |
0:01f31e923fe2 | 135 | f.write('\n') |
Pawel Zarembski |
0:01f31e923fe2 | 136 | yml_object_parser(f, target[1], level + 1, tabs); |
Pawel Zarembski |
0:01f31e923fe2 | 137 | else: |
Pawel Zarembski |
0:01f31e923fe2 | 138 | logger.error("Not expecting input type %s %s " % (type(target), str(target))) |
Pawel Zarembski |
0:01f31e923fe2 | 139 | |
Pawel Zarembski |
0:01f31e923fe2 | 140 | elif type(entry) is TargetList: |
Pawel Zarembski |
0:01f31e923fe2 | 141 | #print "found TargetList" |
Pawel Zarembski |
0:01f31e923fe2 | 142 | for target in entry: |
Pawel Zarembski |
0:01f31e923fe2 | 143 | if type(target) is tuple: |
Pawel Zarembski |
0:01f31e923fe2 | 144 | #print target |
Pawel Zarembski |
0:01f31e923fe2 | 145 | f.write(" " * (level-1) * tabs + string_writer(target[0]) + ": "); |
Pawel Zarembski |
0:01f31e923fe2 | 146 | value = string_writer(target[1]) |
Pawel Zarembski |
0:01f31e923fe2 | 147 | if value is not None: |
Pawel Zarembski |
0:01f31e923fe2 | 148 | f.write(value) |
Pawel Zarembski |
0:01f31e923fe2 | 149 | f.write('\n') |
Pawel Zarembski |
0:01f31e923fe2 | 150 | else: |
Pawel Zarembski |
0:01f31e923fe2 | 151 | f.write('\n') |
Pawel Zarembski |
0:01f31e923fe2 | 152 | yml_object_parser(f, target[1], level, tabs); |
Pawel Zarembski |
0:01f31e923fe2 | 153 | else: |
Pawel Zarembski |
0:01f31e923fe2 | 154 | logger.error("Not expecting input type %s %s " % (type(target), str(target))) |
Pawel Zarembski |
0:01f31e923fe2 | 155 | |
Pawel Zarembski |
0:01f31e923fe2 | 156 | elif type(entry) is InstructionList: |
Pawel Zarembski |
0:01f31e923fe2 | 157 | #print "found InstructionList" |
Pawel Zarembski |
0:01f31e923fe2 | 158 | for target in entry: |
Pawel Zarembski |
0:01f31e923fe2 | 159 | if type(target) is tuple: |
Pawel Zarembski |
0:01f31e923fe2 | 160 | f.write(" " * level * tabs + string_writer(target[0]) + ": |\n") |
Pawel Zarembski |
0:01f31e923fe2 | 161 | if type(target[1]) is list: |
Pawel Zarembski |
0:01f31e923fe2 | 162 | for texts in target[1]: |
Pawel Zarembski |
0:01f31e923fe2 | 163 | f.write(" " * (level + 1) * tabs + string_writer(texts) + "\n") |
Pawel Zarembski |
0:01f31e923fe2 | 164 | else: |
Pawel Zarembski |
0:01f31e923fe2 | 165 | logger.error("Not expecting input type %s %s " % (type(target[1]), str(target[1]))) |
Pawel Zarembski |
0:01f31e923fe2 | 166 | else: |
Pawel Zarembski |
0:01f31e923fe2 | 167 | logger.error("Not expecting input type %s %s " % (type(target), str(target))) |
Pawel Zarembski |
0:01f31e923fe2 | 168 | else: |
Pawel Zarembski |
0:01f31e923fe2 | 169 | logger.error("Not expecting input type %s %s " % (type(entry), str(entry))) |
Pawel Zarembski |
0:01f31e923fe2 | 170 | |
Pawel Zarembski |
0:01f31e923fe2 | 171 | |
Pawel Zarembski |
0:01f31e923fe2 | 172 | def make_update_yml_file(file_loc, entries, explicit_start=False, tab=2): |
Pawel Zarembski |
0:01f31e923fe2 | 173 | with open(file_loc, "w") as yml_file: |
Pawel Zarembski |
0:01f31e923fe2 | 174 | if explicit_start is True: |
Pawel Zarembski |
0:01f31e923fe2 | 175 | yml_file.write("---\n") |
Pawel Zarembski |
0:01f31e923fe2 | 176 | yml_object_parser(yml_file, entries, 1, tab); |