def build_target_firmware(self, parent_test): """ Build test firmware for the board Login credentials must have been set with set_build_login. """ prebuilt = self._target_dir is not None build_login = (self._username is not None and self._password is not None) assert prebuilt or build_login if prebuilt: destdir = self._target_dir else: destdir = 'tmp' build_name = board_id_to_build_target[self.get_board_id()] name_base = os.path.normpath(destdir + os.sep + build_name) self._target_hex_path = name_base + '.hex' self._target_bin_path = name_base + '.bin' # Build target test image if a prebuild location is not specified if not prebuilt: test_info = parent_test.create_subtest('build_target_test_firmware') if not os.path.isdir(destdir): os.mkdir(destdir) # Remove previous build files if os.path.isfile(self._target_hex_path): os.remove(self._target_hex_path) if os.path.isfile(self._target_bin_path): os.remove(self._target_bin_path) test_info.info('Starting remote build') start = time.time() built_file = mbedapi.build_repo(self._username, self._password, TEST_REPO, build_name, destdir) stop = time.time() test_info.info("Build took %s seconds" % (stop - start)) extension = os.path.splitext(built_file)[1].lower() assert extension == '.hex' or extension == '.bin' if extension == '.hex': intel_hex = IntelHex(built_file) # Only supporting devices with the starting # address at 0 currently assert intel_hex.minaddr() == 0 intel_hex.tobinfile(self._target_bin_path) os.rename(built_file, self._target_hex_path) if extension == '.bin': intel_hex = IntelHex() intel_hex.loadbin(built_file, offset=0) intel_hex.tofile(self._target_hex_path, 'hex') os.rename(built_file, self._target_bin_path) # Assert that required files are present assert os.path.isfile(self._target_hex_path) assert os.path.isfile(self._target_bin_path) self._target_firmware_present = True
def build_target_bundle(directory, username, password, parent_test=None): """Build target firmware package""" if parent_test is None: parent_test = TestInfoStub() target_names = info.TARGET_NAME_TO_BOARD_ID.keys() for build_name in target_names: name_base = os.path.normpath(directory + os.sep + build_name) target_hex_path = name_base + '.hex' target_bin_path = name_base + '.bin' # Build target test image test_info = parent_test.create_subtest('Building target %s' % build_name) if not os.path.isdir(directory): os.mkdir(directory) # Remove previous build files if os.path.isfile(target_hex_path): os.remove(target_hex_path) if os.path.isfile(target_bin_path): os.remove(target_bin_path) test_info.info('Starting remote build') start = time.time() built_file = mbedapi.build_repo(username, password, TEST_REPO, build_name, directory) stop = time.time() test_info.info("Build took %s seconds" % (stop - start)) extension = os.path.splitext(built_file)[1].lower() assert extension == '.hex' or extension == '.bin' if extension == '.hex': intel_hex = IntelHex(built_file) # Only supporting devices with the starting # address at 0 currently assert intel_hex.minaddr() == 0 intel_hex.tobinfile(target_bin_path) os.rename(built_file, target_hex_path) if extension == '.bin': intel_hex = IntelHex() intel_hex.loadbin(built_file, offset=0) intel_hex.tofile(target_hex_path, 'hex') os.rename(built_file, target_bin_path) # Assert that required files are present assert os.path.isfile(target_hex_path) assert os.path.isfile(target_bin_path)
def build_target_bundle(directory, username, password, parent_test=None): """Build target firmware package""" if parent_test is None: parent_test = TestInfoStub() target_names = info.TARGET_WITH_COMPILE_API_LIST for build_name in target_names: name_base = os.path.normpath(directory + os.sep + build_name) target_hex_path = name_base + '.hex' target_bin_path = name_base + '.bin' # Build target test image test_info = parent_test.create_subtest('Building target %s' % build_name) if not os.path.isdir(directory): os.mkdir(directory) # Remove previous build files if os.path.isfile(target_hex_path): os.remove(target_hex_path) if os.path.isfile(target_bin_path): os.remove(target_bin_path) test_info.info('Starting remote build') start = time.time() built_file = mbedapi.build_repo(username, password, TEST_REPO, build_name, directory) stop = time.time() test_info.info("Build took %s seconds" % (stop - start)) extension = os.path.splitext(built_file)[1].lower() assert extension == '.hex' or extension == '.bin' if extension == '.hex': intel_hex = IntelHex(built_file) # Only supporting devices with the starting # address at 0 currently assert intel_hex.minaddr() == 0 intel_hex.tobinfile(target_bin_path) os.rename(built_file, target_hex_path) if extension == '.bin': intel_hex = IntelHex() intel_hex.loadbin(built_file, offset=0) intel_hex.tofile(target_hex_path, 'hex') os.rename(built_file, target_bin_path) # Assert that required files are present assert os.path.isfile(target_hex_path) assert os.path.isfile(target_bin_path)