Lines Matching full:self
69 def __init__(self): argument
70 self.TAG_TO_NAME = {
73 self.bindesc_gen_tag(self.TYPE_STR, 0x800): 'APP_VERSION_STRING',
74 self.bindesc_gen_tag(self.TYPE_UINT, 0x801): 'APP_VERSION_MAJOR',
75 self.bindesc_gen_tag(self.TYPE_UINT, 0x802): 'APP_VERSION_MINOR',
76 self.bindesc_gen_tag(self.TYPE_UINT, 0x803): 'APP_VERSION_PATCHLEVEL',
77 self.bindesc_gen_tag(self.TYPE_UINT, 0x804): 'APP_VERSION_NUMBER',
78 self.bindesc_gen_tag(self.TYPE_STR, 0x900): 'KERNEL_VERSION_STRING',
79 self.bindesc_gen_tag(self.TYPE_UINT, 0x901): 'KERNEL_VERSION_MAJOR',
80 self.bindesc_gen_tag(self.TYPE_UINT, 0x902): 'KERNEL_VERSION_MINOR',
81 self.bindesc_gen_tag(self.TYPE_UINT, 0x903): 'KERNEL_VERSION_PATCHLEVEL',
82 self.bindesc_gen_tag(self.TYPE_UINT, 0x904): 'KERNEL_VERSION_NUMBER',
83 self.bindesc_gen_tag(self.TYPE_UINT, 0xa00): 'BUILD_TIME_YEAR',
84 self.bindesc_gen_tag(self.TYPE_UINT, 0xa01): 'BUILD_TIME_MONTH',
85 self.bindesc_gen_tag(self.TYPE_UINT, 0xa02): 'BUILD_TIME_DAY',
86 self.bindesc_gen_tag(self.TYPE_UINT, 0xa03): 'BUILD_TIME_HOUR',
87 self.bindesc_gen_tag(self.TYPE_UINT, 0xa04): 'BUILD_TIME_MINUTE',
88 self.bindesc_gen_tag(self.TYPE_UINT, 0xa05): 'BUILD_TIME_SECOND',
89 self.bindesc_gen_tag(self.TYPE_UINT, 0xa06): 'BUILD_TIME_UNIX',
90 self.bindesc_gen_tag(self.TYPE_STR, 0xa07): 'BUILD_DATE_TIME_STRING',
91 self.bindesc_gen_tag(self.TYPE_STR, 0xa08): 'BUILD_DATE_STRING',
92 self.bindesc_gen_tag(self.TYPE_STR, 0xa09): 'BUILD_TIME_STRING',
93 self.bindesc_gen_tag(self.TYPE_STR, 0xb00): 'HOST_NAME',
94 self.bindesc_gen_tag(self.TYPE_STR, 0xb01): 'C_COMPILER_NAME',
95 self.bindesc_gen_tag(self.TYPE_STR, 0xb02): 'C_COMPILER_VERSION',
96 self.bindesc_gen_tag(self.TYPE_STR, 0xb03): 'CXX_COMPILER_NAME',
97 self.bindesc_gen_tag(self.TYPE_STR, 0xb04): 'CXX_COMPILER_VERSION',
99 self.NAME_TO_TAG = {v: k for k, v in self.TAG_TO_NAME.items()}
109 def do_add_parser(self, parser_adder): argument
110 parser = parser_adder.add_parser(self.name,
111 help=self.help,
112 description=self.description)
118 dump_parser.add_argument('--file-type', type=str, choices=self.EXTENSIONS, help='File type')
126 … search_parser.add_argument('--file-type', type=str, choices=self.EXTENSIONS, help='File type')
137 custom_search_parser.add_argument('--file-type', type=str, choices=self.EXTENSIONS,
148 def dump(self, args): argument
149 image = self.get_image_data(args.file)
151 descriptors = self.parse_descriptors(image)
153 if tag in self.TAG_TO_NAME:
154 tag = self.TAG_TO_NAME[tag]
155 log.inf(f'{tag}', self.bindesc_repr(value))
157 def list(self, args): argument
158 for tag in self.TAG_TO_NAME.values():
161 def common_search(self, args, search_term): argument
162 image = self.get_image_data(args.file)
164 descriptors = self.parse_descriptors(image)
168 log.inf(self.bindesc_repr(value))
172 def search(self, args): argument
174 search_term = self.NAME_TO_TAG[args.descriptor]
178 self.common_search(args, search_term)
180 def custom_search(self, args): argument
182 'STR': self.TYPE_STR,
183 'UINT': self.TYPE_UINT,
184 'BYTES': self.TYPE_BYTES
186 custom_tag = self.bindesc_gen_tag(custom_type, int(args.id, 16))
187 self.common_search(args, custom_tag)
189 def do_run(self, args, _): argument
194 self.is_big_endian = args.big_endian
195 self.file_type = self.guess_file_type(args)
196 subcmd = getattr(self, args.subcmd)
199 def get_image_data(self, file_name): argument
200 if self.file_type == 'bin':
204 if self.file_type == 'hex':
207 if self.file_type == 'uf2':
211 if self.file_type == 'elf':
227 def parse_descriptors(self, image): argument
228 magic = struct.pack('>Q' if self.is_big_endian else 'Q', self.MAGIC)
236 current_tag = self.bytes_to_short(image[index:index+2])
237 while current_tag != self.DESCRIPTORS_END:
239 length = self.bytes_to_short(image[index:index+2])
243 tag_type = self.bindesc_get_type(current_tag)
244 if tag_type == self.TYPE_STR:
246 elif tag_type == self.TYPE_UINT:
247 decoded_data = self.bytes_to_uint(data)
248 elif tag_type == self.TYPE_BYTES:
256 index = self.align(index, 4)
257 current_tag = self.bytes_to_short(image[index:index+2])
261 def guess_file_type(self, args): argument
270 for extension in self.EXTENSIONS:
293 def bytes_to_uint(self, b): argument
294 return struct.unpack('>I' if self.is_big_endian else 'I', b)[0]
296 def bytes_to_short(self, b): argument
297 return struct.unpack('>H' if self.is_big_endian else 'H', b)[0]