Example #1
0
  def load_ihx(self, filepath):
    """
    Load IntelHex file and set status to indicate if file was
    successfully loaded.

    Parameters
    ----------
    filepath : string
      Path to IntelHex file.
    """
    try:
      self.ihx = IntelHex(filepath)
      self.status = os.path.split(filepath)[1]
    except HexRecordError:
      self.clear('Error: File is not a valid Intel HEX File')

    # Check that address ranges are valid for self._flash_type.
    ihx_addrs = flash.ihx_ranges(self.ihx)
    if self._flash_type == "M25":
      try:
        sectors = flash.sectors_used(ihx_addrs, flash.m25_addr_sector_map)
      except IndexError:
        self.clear('Error: HEX File contains restricted address ' + \
                        '(STM Firmware File Chosen?)')
    elif self._flash_type == "STM":
      try:
        sectors = flash.sectors_used(ihx_addrs, flash.stm_addr_sector_map)
      except:
        self.clear('Error: HEX File contains restricted address ' + \
                        '(NAP Firmware File Chosen?)')
Example #2
0
    def load_ihx(self, filepath):
        """
    Load IntelHex file and set status to indicate if file was
    successfully loaded.

    Parameters
    ----------
    filepath : string
      Path to IntelHex file.
    """
        try:
            self.ihx = IntelHex(filepath)
            self.status = os.path.split(filepath)[1]
        except HexRecordError:
            self.clear('Error: File is not a valid Intel HEX File')

        # Check that address ranges are valid for self._flash_type.
        ihx_addrs = flash.ihx_ranges(self.ihx)
        if self._flash_type == "M25":
            try:
                sectors = flash.sectors_used(ihx_addrs,
                                             flash.m25_addr_sector_map)
            except IndexError:
                self.clear('Error: HEX File contains restricted address ' + \
                                '(STM Firmware File Chosen?)')
        elif self._flash_type == "STM":
            try:
                sectors = flash.sectors_used(ihx_addrs,
                                             flash.stm_addr_sector_map)
            except:
                self.clear('Error: HEX File contains restricted address ' + \
                                '(NAP Firmware File Chosen?)')