MCPcopy Create free account
hub / github.com/ARMmbed/DAPLink / DAPLinkFirmware

Class DAPLinkFirmware

test/firmware.py:68–147  ·  view source on GitHub ↗

Class to abstract access to a daplink firmware image

Source from the content-addressed store, hash-verified

66
67
68class DAPLinkFirmware(Firmware):
69 """Class to abstract access to a daplink firmware image"""
70
71 _IF_RE = re.compile("^([a-z0-9]+)([_a-z0-9]*)_if$")
72 _BL_RE = re.compile("^([a-z0-9]+)([_a-z0-9]*)_bl$")
73
74 def __init__(self, name, bundle, directory):
75 self._name = name
76 self._bundle = bundle
77 self._directory = directory
78 self._valid = False
79
80 # Set type
81 self._type = None
82 string_hic = None
83 match = self._IF_RE.match(name)
84 if match:
85 string_hic = match.group(1)
86 self._type = self.TYPE.INTERFACE
87 match = self._BL_RE.match(name)
88 if match:
89 string_hic = match.group(1)
90 self._type = self.TYPE.BOOTLOADER
91 if self._type is None:
92 assert False, 'Bad project name "%s"' % name
93
94 # Set HIC
95 assert string_hic in info.HIC_STRING_TO_ID, 'Unknown HIC "%s" must ' \
96 'be added to HIC_STRING_TO_ID in info.py' % string_hic
97 self._hic_id = info.HIC_STRING_TO_ID[string_hic]
98
99 # Check firmware name and type
100 assert self._type in self.TYPE, "Invalid type %s" % self._type
101 if self._type is self.TYPE.INTERFACE:
102 if name not in info.FIRMWARE_SET:
103 print('Warning: board "%s" no entry in SUPPORTED_CONFIGURATIONS in info.py' % name)
104
105 # Set file paths
106 self._bin_path = self._directory + os.sep + '%s_crc.bin' % name
107 self._hex_path = self._directory + os.sep + '%s_crc.hex' % name
108 self._bin_path = os.path.abspath(self._bin_path)
109 self._hex_path = os.path.abspath(self._hex_path)
110 if not os.path.isfile(self._bin_path):
111 return # Failure
112 if not os.path.isfile(self._hex_path):
113 return # Failure
114
115 self._valid = True
116
117 def __str__(self):
118 return "Name=%s" % (self.name)
119
120 @property
121 def valid(self):
122 """Set to True if the firmware is valid"""
123 return self._valid
124
125 @property

Callers 2

__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected