def flash(self, binary_location=None, forceflash=None):
        if not Flash:
            self.logger.error("Mbed-flasher not installed!")
            raise ImportError("Mbed-flasher not installed!")
        try:
            self.build = Build.init(binary_location)
        except NotImplementedError as error:
            self.logger.error("Build initialization failed. "
                              "Check your build location.")
            self.logger.debug(error)
            raise DutConnectionError(error)
        if not self._flash_needed(forceflash=forceflash):
            self.logger.info("Skipping flash, not needed.")
            return True
        logger = get_external_logger("mbed-flasher", "FLS")
        flasher = Flash(logger=logger)
        if not self.device:
            self.logger.error("Trying to flash device but device is not there?")
            return False
        try:
            buildfile = self.build.get_file()
            if not buildfile:
                raise DutConnectionError("Binary {} not found".format(buildfile))
            self.logger.info('Flashing dev: %s', self.device['target_id'])
            target_id = self.device.get("target_id")
            retcode = flasher.flash(build=buildfile, target_id=target_id,
                                    device_mapping_table=[self.device])
        except FLASHER_ERRORS as error:
            if error.__class__ == NotImplementedError:
                self.logger.error("Flashing not supported for this platform!")
            elif error.__class__ == SyntaxError:
                self.logger.error("target_id required by mbed-flasher!")
            if FlashError is not None:
                if error.__class__ == FlashError:
                    self.logger.error("Flasher raised the following error: %s Error code: %i",
                                      error.message, error.return_code)
            raise DutConnectionError(error)
        if retcode == 0:
            self.dutinformation.build_binary_sha1 = self.build.sha1
            return True
        self.dutinformation.build_binary_sha1 = None
        return False