Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
make_update_yml.py
00001 # 00002 # DAPLink Interface Firmware 00003 # Copyright (c) 2009-2018, ARM Limited, All Rights Reserved 00004 # SPDX-License-Identifier: Apache-2.0 00005 # 00006 # Licensed under the Apache License, Version 2.0 (the "License"); you may 00007 # not use this file except in compliance with the License. 00008 # You may obtain a copy of the License at 00009 # 00010 # http://www.apache.org/licenses/LICENSE-2.0 00011 # 00012 # Unless required by applicable law or agreed to in writing, software 00013 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00014 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 # See the License for the specific language governing permissions and 00016 # limitations under the License. 00017 # 00018 00019 import logging 00020 00021 logging.basicConfig(format='Line: %(lineno)d %(message)s') 00022 logger = logging.getLogger('yaml gen') 00023 logger.setLevel(logging.DEBUG) 00024 00025 00026 class DefaultList(list): 00027 def sort(self, *args, **kwargs): 00028 pass 00029 00030 class TargetList(list): 00031 def sort(self, *args, **kwargs): 00032 pass 00033 00034 class InstructionList(list): 00035 def sort(self, *args, **kwargs): 00036 pass 00037 00038 00039 #instruction steps for firmware 00040 InstructionsText = { 00041 'default':InstructionList([ 00042 ('windows', [ 00043 '1. Download the firmware file.', 00044 '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/)', 00045 '3. Drag-and-drop the firmware file onto the mounted drive.', 00046 '4. Wait for the file copy operation to complete.', 00047 '5. Power cycle the board. It will now enumerate and mount as `DAPLINK` or the name of the board.' 00048 ]), 00049 ('osx', [ 00050 '1. Download the firmware file.', 00051 '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/)', 00052 '3. In a terminal execute', 00053 ' - `sudo mount -u -w -o sync /Volumes/MAINTENANCE ; cp -X <path to firmware file> /Volumes/MAINTENANCE/`', 00054 ' - 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.', 00055 '4. Wait for the file copy operation to complete.', 00056 '5. Power cycle the board. It will now enumerate and mount as `DAPLINK` or the name of the board.' 00057 ]), 00058 ('linux', [ 00059 '1. Download the firmware file.', 00060 '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/)', 00061 '3. In a terminal execute', 00062 ' - `cp <path to firmware file> <MAINTENANCE> && sync`', 00063 ' - Note: make sure to change `MAINTENANCE` to the name of the mount point of the drive on your system.', 00064 '4. Power cycle the board. It will now enumerate and mount as `DAPLINK` or the name of the board.' 00065 ]) 00066 ]), 00067 'lpc11u35':InstructionList([ 00068 ('windows', [ 00069 '1. Download the firmware file.', 00070 '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`', 00071 '3. Delete the file named `firmware.bin`, then drag and drop or copy the new bin file', 00072 '4. Wait for the file copy operation to complete.', 00073 '5. Power cycle the board. It will now enumerate and mount as `DAPLINK` or the name of the board.' 00074 ]), 00075 ('osx', [ 00076 '1. Download the firmware file.', 00077 '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`', 00078 '3. Delete the file named `firmware.bin`', 00079 '4. In a terminal execute', 00080 ' - `sudo mount -u -w -o sync /Volumes/CRP\ DISABLD ; rm /Volumes/CRP\ DISABLD/firmware.bin && cp -X <path to firmware file> /Volumes/CRP\ DISABLD/`', 00081 '5. Wait for the file copy operation to complete.', 00082 '6. Power cycle the board. It will now enumerate and mount as `DAPLINK` or the name of the board.' 00083 ]), 00084 ('linux', [ 00085 '1. Download the firmware file.', 00086 '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`', 00087 '3. Delete the file named `firmware.bin`', 00088 '4. In a terminal execute', 00089 ' - `cp <path to firmware file> <CRP DISABLD> && sync`', 00090 ' - Note: make sure to change `CRP DISABLD` to the name of the mount point on your system.', 00091 '5. Power cycle the board. It will now enumerate and mount as `DAPLINK` or the name of the board.' 00092 ]) 00093 ]) 00094 00095 } 00096 00097 00098 def string_writer(element): 00099 if type(element) is str: 00100 return element 00101 elif type(element) is int: 00102 return "_0x%04i" % element 00103 else: 00104 return None 00105 00106 00107 def yml_object_parser(f, entry, level, tabs): 00108 header = " " * level * tabs 00109 if type(entry) is list: 00110 for element in entry: 00111 yml_object_parser(f, element, level, tabs); 00112 00113 elif type(entry) is dict: 00114 for key in entry: 00115 f.write('-' + ' ' * (level * tabs -1) + string_writer(key) + ": "); 00116 value = string_writer(entry[key]) 00117 if value is not None: 00118 f.write(value) 00119 f.write('\n') 00120 else: 00121 f.write('\n') 00122 yml_object_parser(f, entry[key], level + 1, tabs); 00123 00124 00125 elif type(entry) is DefaultList: 00126 for target in entry: 00127 if type(target) is tuple: 00128 #print target 00129 f.write(" " * level * tabs + string_writer(target[0]) + ": "); 00130 value = string_writer(target[1]) 00131 if value is not None: 00132 f.write(value) 00133 f.write('\n') 00134 else: 00135 f.write('\n') 00136 yml_object_parser(f, target[1], level + 1, tabs); 00137 else: 00138 logger.error("Not expecting input type %s %s " % (type(target), str(target))) 00139 00140 elif type(entry) is TargetList: 00141 #print "found TargetList" 00142 for target in entry: 00143 if type(target) is tuple: 00144 #print target 00145 f.write(" " * (level-1) * tabs + string_writer(target[0]) + ": "); 00146 value = string_writer(target[1]) 00147 if value is not None: 00148 f.write(value) 00149 f.write('\n') 00150 else: 00151 f.write('\n') 00152 yml_object_parser(f, target[1], level, tabs); 00153 else: 00154 logger.error("Not expecting input type %s %s " % (type(target), str(target))) 00155 00156 elif type(entry) is InstructionList: 00157 #print "found InstructionList" 00158 for target in entry: 00159 if type(target) is tuple: 00160 f.write(" " * level * tabs + string_writer(target[0]) + ": |\n") 00161 if type(target[1]) is list: 00162 for texts in target[1]: 00163 f.write(" " * (level + 1) * tabs + string_writer(texts) + "\n") 00164 else: 00165 logger.error("Not expecting input type %s %s " % (type(target[1]), str(target[1]))) 00166 else: 00167 logger.error("Not expecting input type %s %s " % (type(target), str(target))) 00168 else: 00169 logger.error("Not expecting input type %s %s " % (type(entry), str(entry))) 00170 00171 00172 def make_update_yml_file(file_loc, entries, explicit_start=False, tab=2): 00173 with open(file_loc, "w") as yml_file: 00174 if explicit_start is True: 00175 yml_file.write("---\n") 00176 yml_object_parser(yml_file, entries, 1, tab);
Generated on Tue Jul 12 2022 15:37:20 by
