square / pylink

Python Library for device debugging/programming via J-Link
https://pylink.readthedocs.io/en/latest/
Other
351 stars 128 forks source link

jlink.flash_bytes() return an unknow error -5 #146

Closed chanqueo closed 2 years ago

chanqueo commented 2 years ago

Can you tell me about the error -5 sometimes by jlink.flash_bytes() method ?

`../../../.local/lib/python3.8/site-packages/witef/interfaces.py:1676: in flash_bytes self.jlink.flash(data=data, addr=address, on_progress=self._on_flash_progress) ../../../.local/lib/python3.8/site-packages/pylink/jlink.py:173: in wrapper return func(self, *args, *kwargs) ../../../.local/lib/python3.8/site-packages/pylink/jlink.py:2195: in flash res = self.flash_write(addr, data, flags=flags) ../../../.local/lib/python3.8/site-packages/pylink/jlink.py:173: in wrapper return func(self, args, **kwargs) ../../../.local/lib/python3.8/site-packages/pylink/jlink.py:2756: in flash_write raise errors.JLinkFlashException(bytes_flashed) ../../../.local/lib/python3.8/site-packages/pylink/errors.py:38: in init message = self.to_string(code) ../../../.local/lib/python3.8/site-packages/pylink/enums.py:150: in to_string return super(JLinkFlashErrors, cls).to_string(error_code)


cls = <class 'pylink.errors.JLinkFlashException'>, error_code = -5

@classmethod
def to_string(cls, error_code):
    """Returns the string message for the given ``error_code``.

    Args:
      cls (JlinkGlobalErrors): the ``JLinkGlobalErrors`` class
      error_code (int): error code to convert

    Returns:
      An error string corresponding to the error code.

    Raises:
      ValueError: if the error code is invalid.
    """
    if error_code == cls.EMU_NO_CONNECTION:
        return 'No connection to emulator.'
    elif error_code == cls.EMU_COMM_ERROR:
        return 'Emulator connection error.'
    elif error_code == cls.DLL_NOT_OPEN:
        return 'DLL has not been opened.  Did you call \'.connect()\'?'
    elif error_code == cls.VCC_FAILURE:
        return 'Target system has no power.'
    elif error_code == cls.INVALID_HANDLE:
        return 'Given file / memory handle is invalid.'
    elif error_code == cls.NO_CPU_FOUND:
        return 'Could not find supported CPU.'
    elif error_code == cls.EMU_FEATURE_UNSUPPORTED:
        return 'Emulator does not support the selected feature.'
    elif error_code == cls.EMU_NO_MEMORY:
        return 'Emulator out of memory.'
    elif error_code == cls.TIF_STATUS_ERROR:
        return 'Target interface error.'
    elif error_code == cls.FLASH_PROG_COMPARE_FAILED:
        return 'Programmed data differs from source data.'
    elif error_code == cls.FLASH_PROG_PROGRAM_FAILED:
        return 'Programming error occured.'
    elif error_code == cls.FLASH_PROG_VERIFY_FAILED:
        return 'Error while verifying programmed data.'
    elif error_code == cls.OPEN_FILE_FAILED:
        return 'Specified file could not be opened.'
    elif error_code == cls.UNKNOWN_FILE_FORMAT:
        return 'File format of selected file is not supported.'
    elif error_code == cls.WRITE_TARGET_MEMORY_FAILED:
        return 'Could not write target memory.'
    elif error_code == cls.DEVICE_FEATURE_NOT_SUPPORTED:
        return 'Feature not supported by connected device.'
    elif error_code == cls.WRONG_USER_CONFIG:
        return 'User configured DLL parameters incorrectly.'
    elif error_code == cls.NO_TARGET_DEVICE_SELECTED:
        return 'User did not specify core to connect to.'
    elif error_code == cls.CPU_IN_LOW_POWER_MODE:
        return 'Target CPU is in low power mode.'
    elif error_code == cls.UNSPECIFIED_ERROR:
        return 'Unspecified error.'
  raise ValueError('Invalid error code: %d' % error_code)

E ValueError: Invalid error code: -5 `

hkpeprah commented 2 years ago

I'm not sure what that code is, unfortunately.

chanqueo commented 2 years ago

Ok thank you