├── software ├── tools │ ├── pymcuprog │ │ ├── libs │ │ │ ├── pyedbglib │ │ │ │ ├── util │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── print_helpers.py │ │ │ │ │ └── binary.py │ │ │ │ ├── protocols │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── dapwrapper.py │ │ │ │ ├── hidtransport │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── hidtransportfactory.py │ │ │ │ │ └── toolinfo.py │ │ │ │ ├── pyedbglib_errors.py │ │ │ │ └── __init__.py │ │ │ ├── pymcuprog │ │ │ │ ├── deviceinfo │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── devices │ │ │ │ │ │ ├── __init__.py │ │ │ │ │ │ ├── attiny202.py │ │ │ │ │ │ ├── attiny204.py │ │ │ │ │ │ ├── attiny212.py │ │ │ │ │ │ ├── attiny214.py │ │ │ │ │ │ ├── attiny402.py │ │ │ │ │ │ ├── attiny404.py │ │ │ │ │ │ ├── attiny406.py │ │ │ │ │ │ ├── attiny412.py │ │ │ │ │ │ ├── attiny414.py │ │ │ │ │ │ ├── attiny416.py │ │ │ │ │ │ ├── attiny417.py │ │ │ │ │ │ ├── attiny804.py │ │ │ │ │ │ ├── attiny806.py │ │ │ │ │ │ ├── attiny807.py │ │ │ │ │ │ ├── attiny814.py │ │ │ │ │ │ ├── attiny816.py │ │ │ │ │ │ ├── attiny817.py │ │ │ │ │ │ ├── attiny1604.py │ │ │ │ │ │ ├── attiny1606.py │ │ │ │ │ │ ├── attiny1607.py │ │ │ │ │ │ ├── attiny1614.py │ │ │ │ │ │ ├── attiny1616.py │ │ │ │ │ │ ├── attiny1617.py │ │ │ │ │ │ ├── attiny1624.py │ │ │ │ │ │ ├── attiny1626.py │ │ │ │ │ │ ├── attiny1627.py │ │ │ │ │ │ ├── attiny3216.py │ │ │ │ │ │ ├── attiny3217.py │ │ │ │ │ │ ├── attiny3224.py │ │ │ │ │ │ ├── attiny3226.py │ │ │ │ │ │ ├── attiny3227.py │ │ │ │ │ │ ├── attiny424.py │ │ │ │ │ │ ├── attiny426.py │ │ │ │ │ │ ├── attiny427.py │ │ │ │ │ │ ├── attiny824.py │ │ │ │ │ │ ├── attiny826.py │ │ │ │ │ │ └── attiny827.py │ │ │ │ │ ├── eraseflags.py │ │ │ │ │ ├── memorynames.py │ │ │ │ │ └── deviceinfokeys.py │ │ │ │ ├── serialupdi │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── timeout.py │ │ │ │ │ ├── constants.py │ │ │ │ │ └── physical.py │ │ │ │ ├── version.py │ │ │ │ ├── toolconnection.py │ │ │ │ ├── progress_bar.py │ │ │ │ ├── logging.yaml │ │ │ │ ├── pymcuprog_errors.py │ │ │ │ └── __init__.py │ │ │ ├── yaml │ │ │ │ ├── loader.py │ │ │ │ ├── nodes.py │ │ │ │ ├── events.py │ │ │ │ ├── error.py │ │ │ │ ├── dumper.py │ │ │ │ ├── tokens.py │ │ │ │ ├── cyaml.py │ │ │ │ ├── serializer.py │ │ │ │ └── composer.py │ │ │ ├── intelhex │ │ │ │ ├── getsizeof.py │ │ │ │ └── compat.py │ │ │ └── serial │ │ │ │ ├── __init__.py │ │ │ │ ├── rs485.py │ │ │ │ └── aio.py │ │ └── readme.txt │ └── avrdude │ │ └── readme.txt ├── include │ ├── dev │ │ ├── attiny402 │ │ │ ├── avrxmega3 │ │ │ │ └── short-calls │ │ │ │ │ ├── crtattiny402.o │ │ │ │ │ └── libattiny402.a │ │ │ └── device-specs │ │ │ │ └── specs-attiny402 │ │ └── attiny412 │ │ │ ├── avrxmega3 │ │ │ └── short-calls │ │ │ │ ├── crtattiny412.o │ │ │ │ └── libattiny412.a │ │ │ └── device-specs │ │ │ └── specs-attiny412 │ └── component-version.h └── makefile ├── hardware ├── PocketRadio_BOM.tsv ├── PocketRadio_gerber.zip └── PocketRadio_schematic.pdf ├── 3dprint ├── PocketRadio_case_12mm.stl ├── PocketRadio_case_20mm.stl ├── PocketRadio_case_25mm.stl ├── PocketRadio_case_30mm.stl ├── PocketRadio_case_12mm.fcstd ├── PocketRadio_case_20mm.fcstd ├── PocketRadio_case_25mm.fcstd └── PocketRadio_case_30mm.fcstd ├── documentation ├── PocketRadio_pic1.jpg ├── PocketRadio_pic2.jpg ├── PocketRadio_pic3.jpg ├── PocketRadio_pic4.jpg ├── PocketRadio_pic5.jpg ├── PocketRadio_pic6.jpg ├── PocketRadio_pic7.jpg ├── PocketRadio_pic8.jpg ├── PocketRadio_pic9.jpg ├── PocketRadio_pic10.jpg ├── PocketRadio_pic11.jpg └── PocketRadio_wiring.png └── LICENSE /software/tools/pymcuprog/libs/pyedbglib/util/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pyedbglib/protocols/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/serialupdi/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pyedbglib/hidtransport/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hardware/PocketRadio_BOM.tsv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/hardware/PocketRadio_BOM.tsv -------------------------------------------------------------------------------- /hardware/PocketRadio_gerber.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/hardware/PocketRadio_gerber.zip -------------------------------------------------------------------------------- /3dprint/PocketRadio_case_12mm.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/3dprint/PocketRadio_case_12mm.stl -------------------------------------------------------------------------------- /3dprint/PocketRadio_case_20mm.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/3dprint/PocketRadio_case_20mm.stl -------------------------------------------------------------------------------- /3dprint/PocketRadio_case_25mm.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/3dprint/PocketRadio_case_25mm.stl -------------------------------------------------------------------------------- /3dprint/PocketRadio_case_30mm.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/3dprint/PocketRadio_case_30mm.stl -------------------------------------------------------------------------------- /documentation/PocketRadio_pic1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/documentation/PocketRadio_pic1.jpg -------------------------------------------------------------------------------- /documentation/PocketRadio_pic2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/documentation/PocketRadio_pic2.jpg -------------------------------------------------------------------------------- /documentation/PocketRadio_pic3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/documentation/PocketRadio_pic3.jpg -------------------------------------------------------------------------------- /documentation/PocketRadio_pic4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/documentation/PocketRadio_pic4.jpg -------------------------------------------------------------------------------- /documentation/PocketRadio_pic5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/documentation/PocketRadio_pic5.jpg -------------------------------------------------------------------------------- /documentation/PocketRadio_pic6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/documentation/PocketRadio_pic6.jpg -------------------------------------------------------------------------------- /documentation/PocketRadio_pic7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/documentation/PocketRadio_pic7.jpg -------------------------------------------------------------------------------- /documentation/PocketRadio_pic8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/documentation/PocketRadio_pic8.jpg -------------------------------------------------------------------------------- /documentation/PocketRadio_pic9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/documentation/PocketRadio_pic9.jpg -------------------------------------------------------------------------------- /hardware/PocketRadio_schematic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/hardware/PocketRadio_schematic.pdf -------------------------------------------------------------------------------- /3dprint/PocketRadio_case_12mm.fcstd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/3dprint/PocketRadio_case_12mm.fcstd -------------------------------------------------------------------------------- /3dprint/PocketRadio_case_20mm.fcstd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/3dprint/PocketRadio_case_20mm.fcstd -------------------------------------------------------------------------------- /3dprint/PocketRadio_case_25mm.fcstd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/3dprint/PocketRadio_case_25mm.fcstd -------------------------------------------------------------------------------- /3dprint/PocketRadio_case_30mm.fcstd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/3dprint/PocketRadio_case_30mm.fcstd -------------------------------------------------------------------------------- /documentation/PocketRadio_pic10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/documentation/PocketRadio_pic10.jpg -------------------------------------------------------------------------------- /documentation/PocketRadio_pic11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/documentation/PocketRadio_pic11.jpg -------------------------------------------------------------------------------- /documentation/PocketRadio_wiring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/documentation/PocketRadio_wiring.png -------------------------------------------------------------------------------- /software/tools/avrdude/readme.txt: -------------------------------------------------------------------------------- 1 | Description: Modified avrdude config file to work with jtag2updi 2 | Source: https://github.com/ElTangas/jtag2updi 3 | License: MIT License 4 | -------------------------------------------------------------------------------- /software/include/dev/attiny402/avrxmega3/short-calls/crtattiny402.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/software/include/dev/attiny402/avrxmega3/short-calls/crtattiny402.o -------------------------------------------------------------------------------- /software/include/dev/attiny402/avrxmega3/short-calls/libattiny402.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/software/include/dev/attiny402/avrxmega3/short-calls/libattiny402.a -------------------------------------------------------------------------------- /software/include/dev/attiny412/avrxmega3/short-calls/crtattiny412.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/software/include/dev/attiny412/avrxmega3/short-calls/crtattiny412.o -------------------------------------------------------------------------------- /software/include/dev/attiny412/avrxmega3/short-calls/libattiny412.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wagiminator/ATtiny412-PocketRadio/HEAD/software/include/dev/attiny412/avrxmega3/short-calls/libattiny412.a -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/version.py: -------------------------------------------------------------------------------- 1 | """ This file was generated when pymcuprog was built """ 2 | VERSION = '3.6.4.86' 3 | COMMIT_ID = '6224623cfc85c5e7cb6b1df8419b72c338c223f9' 4 | BUILD_DATE = '2020-11-09 14:49:15 +0000' 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. 2 | To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send 3 | a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 4 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/readme.txt: -------------------------------------------------------------------------------- 1 | Description: pymcuprog - python-based serial-updi programmer, modified by Spence Konde and Quentin Bolsee 2 | Source: https://pypi.org/project/pymcuprog/ 3 | https://github.com/SpenceKonde/DxCore 4 | License: MIT License 5 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pyedbglib/util/print_helpers.py: -------------------------------------------------------------------------------- 1 | """Generating string representations of variables for nice printouts""" 2 | 3 | def bytelist_to_hex_string(bytelist): 4 | """ 5 | :param bytelist: list of byte values 6 | :return: String representation of the bytelist with each item as a byte value on the format 0xXX 7 | """ 8 | return '[' + ', '.join("0x%02X" % x for x in bytelist) + ']' 9 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pyedbglib/pyedbglib_errors.py: -------------------------------------------------------------------------------- 1 | """ 2 | pyedbglib specific exceptions 3 | """ 4 | 5 | class PyedbglibError(Exception): 6 | """ 7 | Base class for all pyedbglib specific exceptions 8 | """ 9 | 10 | def __init__(self, msg=None, code=0): 11 | super(PyedbglibError, self).__init__(msg) 12 | self.code = code 13 | 14 | class PyedbglibNotSupportedError(PyedbglibError): 15 | """ 16 | Signals that an attempted operation is not supported 17 | """ 18 | 19 | def __init__(self, msg=None, code=0): 20 | super(PyedbglibNotSupportedError, self).__init__(msg) 21 | self.code = code 22 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/serialupdi/timeout.py: -------------------------------------------------------------------------------- 1 | """ 2 | Simple timer helper for UPDI stack 3 | """ 4 | import time 5 | 6 | #pylint: disable=too-few-public-methods 7 | class Timeout: 8 | """ 9 | Simple timeout helper in milliseconds. 10 | """ 11 | 12 | def __init__(self, timeout_ms): 13 | """ 14 | Start the expired counter instantly 15 | :param timeout_ms: milliseconds to count 16 | """ 17 | 18 | self.timeout_ms = timeout_ms 19 | self.start_time = time.time() 20 | 21 | def expired(self): 22 | """ 23 | Check if the timeout has expired 24 | """ 25 | return time.time() - self.start_time > self.timeout_ms / 1000.0 26 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pyedbglib/protocols/dapwrapper.py: -------------------------------------------------------------------------------- 1 | """Wrapper for any protocol over CMSIS-DAP""" 2 | 3 | from logging import getLogger 4 | 5 | 6 | class DapWrapper(object): 7 | """Base class for any CMSIS-DAP protocol wrapper""" 8 | 9 | def __init__(self, transport): 10 | self.logger = getLogger(__name__) 11 | self.transport = transport 12 | self.logger.debug("Created DapWrapper") 13 | 14 | def dap_command_response(self, packet): 15 | """ 16 | Send a command, receive a response 17 | 18 | :param packet: bytes to send 19 | :return: response received 20 | """ 21 | return self.transport.hid_transfer(packet) 22 | 23 | def dap_command_write(self, packet): 24 | """ 25 | Send a packet 26 | 27 | :param packet: packed data to sent 28 | :return: bytes sent 29 | """ 30 | return self.transport.hid_write(packet) 31 | 32 | def dap_command_read(self): 33 | """ 34 | Receive data 35 | 36 | :return: data received 37 | """ 38 | return self.transport.hid_read() 39 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/eraseflags.py: -------------------------------------------------------------------------------- 1 | """ 2 | Definitions of erase related flags for the device models 3 | """ 4 | import inspect 5 | 6 | from pymcuprog.utils import enum 7 | 8 | # Flag used to specify if a memory type will be erased by a chip erase (AVR) or the widest/default bulk erase (PIC) 9 | ChiperaseEffect = enum( 10 | ALWAYS_ERASED='always erased', 11 | CONDITIONALLY_ERASED_AVR='conditionally erased (depending upon EESAVE fuse setting)', 12 | CONDITIONALLY_ERASED_PIC='conditionally erased (depending upon Code Protect configuration bit(s) settings)', 13 | NOT_ERASED='not erased') 14 | 15 | def get_list_of_chiperase_effects(): 16 | """Return a list of all ChiperaseEffect values""" 17 | chiperase_effect_attributes = inspect.getmembers(ChiperaseEffect, lambda a: not inspect.isroutine(a)) 18 | chiperase_effect_values = [] 19 | for attribute in chiperase_effect_attributes: 20 | # Builtin routines always starts and ends with double underscore (__) 21 | if not (attribute[0].startswith('__') and attribute[0].endswith('__')): 22 | # Only the attribute values are returned 23 | chiperase_effect_values.append(attribute[1]) 24 | 25 | return chiperase_effect_values 26 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/memorynames.py: -------------------------------------------------------------------------------- 1 | #pylint: disable=too-few-public-methods 2 | """ 3 | Memory name definitions 4 | """ 5 | 6 | class MemoryNameAliases(object): 7 | """ 8 | Memory names that are actually not real memories but an alias for several memories 9 | """ 10 | ALL = 'all' 11 | 12 | class MemoryNames(object): 13 | """ 14 | Memory names corresponding to target device memories 15 | """ 16 | # Real memories 17 | FLASH = 'flash' 18 | CONFIG_WORD = 'config_words' 19 | USER_ID = 'user_id' 20 | USER_ROW = 'user_row' 21 | EEPROM = 'eeprom' 22 | FUSES = 'fuses' 23 | CALIBRATION_ROW = 'calibration_row' 24 | ICD = 'icd' 25 | LOCKBITS = 'lockbits' 26 | SIGNATURES = 'signatures' 27 | INTERNAL_SRAM = 'internal_sram' 28 | 29 | @classmethod 30 | def get_all(cls): 31 | """ 32 | Get a list of all memories representing actual device memories 33 | 34 | :return List of all memory names representing actual device memories 35 | """ 36 | all_memories = [] 37 | for attribute in dir(cls): 38 | if not attribute.startswith('__') and not callable(getattr(cls, attribute)): 39 | all_memories.append(getattr(cls, attribute)) 40 | 41 | return all_memories 42 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/yaml/loader.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = ['BaseLoader', 'SafeLoader', 'Loader'] 3 | 4 | from .reader import * 5 | from .scanner import * 6 | from .parser import * 7 | from .composer import * 8 | from .constructor import * 9 | from .resolver import * 10 | 11 | class BaseLoader(Reader, Scanner, Parser, Composer, BaseConstructor, BaseResolver): 12 | 13 | def __init__(self, stream): 14 | Reader.__init__(self, stream) 15 | Scanner.__init__(self) 16 | Parser.__init__(self) 17 | Composer.__init__(self) 18 | BaseConstructor.__init__(self) 19 | BaseResolver.__init__(self) 20 | 21 | class SafeLoader(Reader, Scanner, Parser, Composer, SafeConstructor, Resolver): 22 | 23 | def __init__(self, stream): 24 | Reader.__init__(self, stream) 25 | Scanner.__init__(self) 26 | Parser.__init__(self) 27 | Composer.__init__(self) 28 | SafeConstructor.__init__(self) 29 | Resolver.__init__(self) 30 | 31 | class Loader(Reader, Scanner, Parser, Composer, Constructor, Resolver): 32 | 33 | def __init__(self, stream): 34 | Reader.__init__(self, stream) 35 | Scanner.__init__(self) 36 | Parser.__init__(self) 37 | Composer.__init__(self) 38 | Constructor.__init__(self) 39 | Resolver.__init__(self) 40 | 41 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/toolconnection.py: -------------------------------------------------------------------------------- 1 | """ 2 | This module includes wrapper classes for Tool connection parameters 3 | """ 4 | 5 | #pylint: disable=too-few-public-methods 6 | class ToolConnection(object): 7 | """ 8 | Base class for ToolConnection classes used to wrap configuration parameters for tool connections 9 | """ 10 | 11 | #pylint: disable=too-few-public-methods 12 | class ToolUsbHidConnection(ToolConnection): 13 | """ 14 | Helper class wrapping configuration parameters for a connection to a USB HID tool 15 | """ 16 | serialnumber = None 17 | tool_name = None 18 | 19 | def __init__(self, serialnumber=None, tool_name=None): 20 | """ 21 | :param tool_name: Tool name as given in USB Product string. Some shortnames are also supported 22 | as defined in pyedbglib.hidtransport.toolinfo.py. Set to None if don't care 23 | :param serialnumber: USB serial number string. Set to None if don't care 24 | """ 25 | self.serialnumber = serialnumber 26 | self.tool_name = tool_name 27 | 28 | #pylint: disable=too-few-public-methods 29 | class ToolSerialConnection(ToolConnection): 30 | """ 31 | Helper class wrapping configuration parameters for a connection to a serial port 32 | """ 33 | serialport = None 34 | 35 | def __init__(self, serialport="COM1"): 36 | self.serialport = serialport 37 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/progress_bar.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import time 3 | 4 | 5 | class ProgressBar: 6 | def __init__(self, n_steps, width=50, hide=False): 7 | self.width = width 8 | self.n_steps = n_steps 9 | self.count_step = 0 10 | self.count_char = 0 11 | self.hide = hide 12 | self.print_start() 13 | 14 | def print_start(self): 15 | if not self.hide: 16 | sys.stdout.write("[%s]" % (" " * self.width)) 17 | sys.stdout.flush() 18 | 19 | def print_end(self): 20 | if not self.hide: 21 | sys.stdout.write("\n") 22 | sys.stdout.flush() 23 | 24 | def update(self): 25 | n1 = self.count_char 26 | n2 = self.width - self.count_char 27 | if not self.hide: 28 | sys.stdout.write("\r[" + "=" * n1 + " " * n2 + "] {}/{}".format(self.count_step, self.n_steps)) 29 | sys.stdout.flush() 30 | 31 | def step(self): 32 | self.count_step += 1 33 | count_char_new = self.width * self.count_step // self.n_steps 34 | 35 | if count_char_new > self.count_char: 36 | self.count_char = count_char_new 37 | self.update() 38 | 39 | if self.count_step == self.n_steps: 40 | self.print_end() 41 | 42 | 43 | def test(): 44 | n_steps = 100 45 | 46 | print("Starting...") 47 | 48 | b = ProgressBar(n_steps) 49 | 50 | for i in range(n_steps): 51 | time.sleep(0.01) 52 | b.step() 53 | 54 | print("done.") 55 | 56 | 57 | if __name__ == "__main__": 58 | test() 59 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/yaml/nodes.py: -------------------------------------------------------------------------------- 1 | 2 | class Node(object): 3 | def __init__(self, tag, value, start_mark, end_mark): 4 | self.tag = tag 5 | self.value = value 6 | self.start_mark = start_mark 7 | self.end_mark = end_mark 8 | def __repr__(self): 9 | value = self.value 10 | #if isinstance(value, list): 11 | # if len(value) == 0: 12 | # value = '' 13 | # elif len(value) == 1: 14 | # value = '<1 item>' 15 | # else: 16 | # value = '<%d items>' % len(value) 17 | #else: 18 | # if len(value) > 75: 19 | # value = repr(value[:70]+u' ... ') 20 | # else: 21 | # value = repr(value) 22 | value = repr(value) 23 | return '%s(tag=%r, value=%s)' % (self.__class__.__name__, self.tag, value) 24 | 25 | class ScalarNode(Node): 26 | id = 'scalar' 27 | def __init__(self, tag, value, 28 | start_mark=None, end_mark=None, style=None): 29 | self.tag = tag 30 | self.value = value 31 | self.start_mark = start_mark 32 | self.end_mark = end_mark 33 | self.style = style 34 | 35 | class CollectionNode(Node): 36 | def __init__(self, tag, value, 37 | start_mark=None, end_mark=None, flow_style=None): 38 | self.tag = tag 39 | self.value = value 40 | self.start_mark = start_mark 41 | self.end_mark = end_mark 42 | self.flow_style = flow_style 43 | 44 | class SequenceNode(CollectionNode): 45 | id = 'sequence' 46 | 47 | class MappingNode(CollectionNode): 48 | id = 'mapping' 49 | 50 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/logging.yaml: -------------------------------------------------------------------------------- 1 | version: 1 2 | disable_existing_loggers: False 3 | formatters: 4 | timestamped: 5 | format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s" 6 | detailed: 7 | format: "%(name)s - %(levelname)s - %(message)s" 8 | simple: 9 | format: "%(message)s" 10 | 11 | handlers: 12 | # Logging to the console is default to WARNING with detailed output: 13 | console: 14 | class: logging.StreamHandler 15 | level: WARNING 16 | formatter: detailed 17 | stream: ext://sys.stdout 18 | 19 | # Logging debug output to file 20 | # Handler disabled by default - for reference only 21 | debug_file_handler: 22 | class: logging.FileHandler 23 | level: DEBUG 24 | formatter: timestamped 25 | # File path will be user log directory for this application 26 | filename: debug.log 27 | encoding: utf8 28 | 29 | # Logging errors to file 30 | # Handler disabled by default - for reference only 31 | error_file_handler: 32 | class: logging.handlers.RotatingFileHandler 33 | level: ERROR 34 | formatter: timestamped 35 | # File path will be user log directory for this application 36 | filename: errors.log 37 | maxBytes: 10485760 # 10MB 38 | backupCount: 20 39 | encoding: utf8 40 | 41 | loggers: 42 | # pyedbglib library should be kept to critical errors to console only 43 | pyedbglib: 44 | level: ERROR 45 | handlers: [console] 46 | propagate: no 47 | 48 | root: 49 | # Default level is warning 50 | # this is increased with -v in CLI usage 51 | level: WARNING 52 | # Default handlers is console only 53 | handlers: [console] 54 | # Add debug_file_handler for debug output to file 55 | # Add error_file_handler for error output to file 56 | # See configuration in handlers section above 57 | #handlers: [console, debug_file_handler, error_file_handler] 58 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pyedbglib/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Python EDBG protocol communication library 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | pyedbglib is a low-level protocol library for communicating with 6 | Microchip CMSIS-DAP based debuggers. 7 | 8 | pyedbglib uses HIDAPI package with a USB-level driver such as libusb. 9 | 10 | The protocol library has no application usage on its own, but provides 11 | USB-protocol-level tool drivers to applications such as pymcuprog. 12 | In general a two-stage stack implementation is required for using pyedbglib: 13 | 14 | 1. Create transport HID layer 15 | 2. Create protocol implementation using this transport layer 16 | 17 | All protocols implemented in the library generally take the transport layer 18 | as a parameter to their constructors. 19 | 20 | To use pyedbglib as a library for applications, the following usage patterns 21 | can be used: 22 | 23 | Import and instantiate transport object: 24 | 25 | >>> from pyedbglib.hidtransport.hidtransportfactory import hid_transport 26 | >>> transport = hid_transport() 27 | 28 | Connect to any nEDBG tool. Serial number and product are optional, but must 29 | be provided if more than one matching unit is connected: 30 | 31 | >>> status = transport.connect(serial_number="", product="nedbg") 32 | 33 | Example of application using housekeeping protocol to read out the target voltage: 34 | 35 | >>> from pyedbglib.protocols.housekeepingprotocol import Jtagice3HousekeepingProtocol 36 | >>> housekeeper = Jtagice3HousekeepingProtocol(transport) 37 | >>> housekeeper.start_session() 38 | >>> voltage = housekeeper.get_le16(Jtagice3HousekeepingProtocol.HOUSEKEEPING_CONTEXT_ANALOG, 39 | Jtagice3HousekeepingProtocol.HOUSEKEEPING_ANALOG_VTREF) 40 | >>> voltage = voltage / 1000.0 41 | >>> housekeeper.end_session() 42 | >>> print ("Target is running at {0:.02f}V".format(voltage)) 43 | 44 | """ 45 | import logging 46 | logging.getLogger(__name__).addHandler(logging.NullHandler()) 47 | -------------------------------------------------------------------------------- /software/include/component-version.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Component version header file 5 | * 6 | * Copyright (c) 2021 Atmel Corporation, a wholly owned subsidiary of Microchip Technology Inc. 7 | * 8 | * \license_start 9 | * 10 | * \page License 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * 24 | * \license_stop 25 | * 26 | */ 27 | 28 | #ifndef _COMPONENT_VERSION_H_INCLUDED 29 | #define _COMPONENT_VERSION_H_INCLUDED 30 | 31 | #define COMPONENT_VERSION_MAJOR 2 32 | #define COMPONENT_VERSION_MINOR 7 33 | 34 | // 35 | // The COMPONENT_VERSION define is composed of the major and the minor version number. 36 | // 37 | // The last four digits of the COMPONENT_VERSION is the minor version with leading zeros. 38 | // The rest of the COMPONENT_VERSION is the major version. 39 | // 40 | #define COMPONENT_VERSION 20007 41 | 42 | // 43 | // The build number does not refer to the component, but to the build number 44 | // of the device pack that provides the component. 45 | // 46 | #define BUILD_NUMBER 128 47 | 48 | // 49 | // The COMPONENT_VERSION_STRING is a string (enclosed in ") that can be used for logging or embedding. 50 | // 51 | #define COMPONENT_VERSION_STRING "2.7" 52 | 53 | // 54 | // The COMPONENT_DATE_STRING contains a timestamp of when the pack was generated. 55 | // 56 | // The COMPONENT_DATE_STRING is written out using the following strftime pattern. 57 | // 58 | // "%Y-%m-%d %H:%M:%S" 59 | // 60 | // 61 | #define COMPONENT_DATE_STRING "2021-07-13 10:42:36" 62 | 63 | #endif/* #ifndef _COMPONENT_VERSION_H_INCLUDED */ 64 | 65 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/intelhex/getsizeof.py: -------------------------------------------------------------------------------- 1 | # Recursive version sys.getsizeof(). Extendable with custom handlers. 2 | # Code from http://code.activestate.com/recipes/577504/ 3 | # Created by Raymond Hettinger on Fri, 17 Dec 2010 (MIT) 4 | 5 | import sys 6 | from itertools import chain 7 | from collections import deque 8 | try: 9 | from reprlib import repr 10 | except ImportError: 11 | pass 12 | 13 | def total_size(o, handlers={}, verbose=False): 14 | """ Returns the approximate memory footprint an object and all of its contents. 15 | 16 | Automatically finds the contents of the following builtin containers and 17 | their subclasses: tuple, list, deque, dict, set and frozenset. 18 | To search other containers, add handlers to iterate over their contents: 19 | 20 | handlers = {SomeContainerClass: iter, 21 | OtherContainerClass: OtherContainerClass.get_elements} 22 | 23 | """ 24 | dict_handler = lambda d: chain.from_iterable(d.items()) 25 | all_handlers = {tuple: iter, 26 | list: iter, 27 | deque: iter, 28 | dict: dict_handler, 29 | set: iter, 30 | frozenset: iter, 31 | } 32 | all_handlers.update(handlers) # user handlers take precedence 33 | seen = set() # track which object id's have already been seen 34 | default_size = sys.getsizeof(0) # estimate sizeof object without __sizeof__ 35 | 36 | def sizeof(o): 37 | if id(o) in seen: # do not double count the same object 38 | return 0 39 | seen.add(id(o)) 40 | s = sys.getsizeof(o, default_size) 41 | 42 | if verbose: 43 | print(s, type(o), repr(o))#, file=stderr) 44 | 45 | for typ, handler in all_handlers.items(): 46 | if isinstance(o, typ): 47 | s += sum(map(sizeof, handler(o))) 48 | break 49 | return s 50 | 51 | return sizeof(o) 52 | 53 | 54 | ##### Example call ##### 55 | 56 | if __name__ == '__main__': 57 | #d = dict(a=1, b=2, c=3, d=[4,5,6,7], e='a string of chars') 58 | print("dict 3 elements") 59 | d = {0:0xFF, 1:0xEE, 2:0xCC} 60 | print(total_size(d, verbose=True)) 61 | 62 | #print("array 3 elements") 63 | #import array 64 | #print(total_size(array.array('B', b'\x01\x02\x03'))) 65 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pyedbglib/hidtransport/hidtransportfactory.py: -------------------------------------------------------------------------------- 1 | """ 2 | Factory for HID transport connections. 3 | 4 | Currently supports only Cython/HIDAPI 5 | """ 6 | 7 | import platform 8 | from logging import getLogger 9 | from ..pyedbglib_errors import PyedbglibNotSupportedError 10 | 11 | 12 | def hid_transport(library="hidapi"): 13 | """ 14 | Dispatch a transport layer for the OS in question 15 | 16 | The transport layer is typically used to connect to a tool and then it is passed in as a parameter when creating 17 | protocol objects. An example where the transport layer is used to create an instance of the housekeepingprotocol 18 | for communication with the nEDBG debugger:: 19 | 20 | from pyedbglib.hidtransport.hidtransportfactory import hid_transport 21 | transport = hid_transport() 22 | connect_status = False 23 | try: 24 | connect_status = transport.connect(serial_number='', product='nedbg') 25 | except IOError as error: 26 | print("Unable to connect to USB device ({})".format(error)) 27 | 28 | if not connect_status: 29 | print("Unable to connect to USB device") 30 | 31 | housekeeper = housekeepingprotocol.Jtagice3HousekeepingProtocol(transport) 32 | 33 | :param library: Transport library to use, currently only 'hidapi' is supported which will use the libusb hidapi 34 | :type library: string 35 | :returns: Instance of transport layer object 36 | :rtype: class:cyhidapi:CyHidApiTransport 37 | """ 38 | logger = getLogger(__name__) 39 | operating_system = platform.system().lower() 40 | logger.debug("HID transport using library '{:s}' on OS '{:s}'".format(library, operating_system)) 41 | 42 | # HID API is the primary transport 43 | if library == 'hidapi': 44 | hid_api_supported_os = ['windows', 'darwin', 'linux', 'linux2'] 45 | if operating_system in hid_api_supported_os: 46 | from .cyhidapi import CyHidApiTransport 47 | return CyHidApiTransport() 48 | 49 | msg = "System '{0:s}' not implemented for library '{1:s}'".format(operating_system, library) 50 | logger.error(msg) 51 | raise PyedbglibNotSupportedError(msg) 52 | 53 | # Other transports may include cmsis-dap DLL, atusbhid (dll or so) etc 54 | msg = "Transport library '{0}' not implemented.".format(library) 55 | logger.error(msg) 56 | raise PyedbglibNotSupportedError(msg) 57 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/pymcuprog_errors.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pymcuprog specific exceptions 3 | """ 4 | 5 | class PymcuprogError(Exception): 6 | """ 7 | Base class for all Pymcuprog specific exceptions 8 | """ 9 | 10 | def __init__(self, msg=None, code=0): 11 | super(PymcuprogError, self).__init__(msg) 12 | self.code = code 13 | 14 | class PymcuprogToolConfigurationError(PymcuprogError): 15 | """ 16 | Signals that a tool was incorrectly configured 17 | """ 18 | 19 | def __init__(self, msg=None, code=0): 20 | super(PymcuprogToolConfigurationError, self).__init__(msg) 21 | self.code = code 22 | 23 | class PymcuprogToolConnectionError(PymcuprogError): 24 | """ 25 | Signals that an attempted connect failed 26 | """ 27 | 28 | def __init__(self, msg=None, code=0): 29 | super(PymcuprogToolConnectionError, self).__init__(msg) 30 | self.code = code 31 | 32 | class PymcuprogNotSupportedError(PymcuprogError): 33 | """ 34 | Signals that an attempted operation is not supported 35 | """ 36 | 37 | def __init__(self, msg=None, code=0): 38 | super(PymcuprogNotSupportedError, self).__init__(msg) 39 | self.code = code 40 | 41 | class PymcuprogSessionError(PymcuprogError): 42 | """ 43 | Signals that a session is not active 44 | """ 45 | 46 | def __init__(self, msg=None, code=0): 47 | super(PymcuprogSessionError, self).__init__(msg) 48 | self.code = code 49 | 50 | class PymcuprogSessionConfigError(PymcuprogError): 51 | """ 52 | Signals that a session is not configured correctly 53 | """ 54 | 55 | def __init__(self, msg=None, code=0): 56 | super(PymcuprogSessionConfigError, self).__init__(msg) 57 | self.code = code 58 | 59 | 60 | class PymcuprogDeviceLockedError(PymcuprogError): 61 | """ 62 | Signals that the device is locked and a chip erase is required to unlock it 63 | """ 64 | 65 | def __init__(self, msg=None, code=0): 66 | super(PymcuprogDeviceLockedError, self).__init__(msg) 67 | self.code = code 68 | 69 | class PymcuprogEraseError(PymcuprogError): 70 | """ 71 | Signals that an erase can't be executed 72 | 73 | Either the erase is not possible or the erase can't be executed without side effects, 74 | i.e. erasing more memories than requested 75 | """ 76 | 77 | def __init__(self, msg=None, code=0): 78 | super(PymcuprogEraseError, self).__init__(msg) 79 | self.code = code 80 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/yaml/events.py: -------------------------------------------------------------------------------- 1 | 2 | # Abstract classes. 3 | 4 | class Event(object): 5 | def __init__(self, start_mark=None, end_mark=None): 6 | self.start_mark = start_mark 7 | self.end_mark = end_mark 8 | def __repr__(self): 9 | attributes = [key for key in ['anchor', 'tag', 'implicit', 'value'] 10 | if hasattr(self, key)] 11 | arguments = ', '.join(['%s=%r' % (key, getattr(self, key)) 12 | for key in attributes]) 13 | return '%s(%s)' % (self.__class__.__name__, arguments) 14 | 15 | class NodeEvent(Event): 16 | def __init__(self, anchor, start_mark=None, end_mark=None): 17 | self.anchor = anchor 18 | self.start_mark = start_mark 19 | self.end_mark = end_mark 20 | 21 | class CollectionStartEvent(NodeEvent): 22 | def __init__(self, anchor, tag, implicit, start_mark=None, end_mark=None, 23 | flow_style=None): 24 | self.anchor = anchor 25 | self.tag = tag 26 | self.implicit = implicit 27 | self.start_mark = start_mark 28 | self.end_mark = end_mark 29 | self.flow_style = flow_style 30 | 31 | class CollectionEndEvent(Event): 32 | pass 33 | 34 | # Implementations. 35 | 36 | class StreamStartEvent(Event): 37 | def __init__(self, start_mark=None, end_mark=None, encoding=None): 38 | self.start_mark = start_mark 39 | self.end_mark = end_mark 40 | self.encoding = encoding 41 | 42 | class StreamEndEvent(Event): 43 | pass 44 | 45 | class DocumentStartEvent(Event): 46 | def __init__(self, start_mark=None, end_mark=None, 47 | explicit=None, version=None, tags=None): 48 | self.start_mark = start_mark 49 | self.end_mark = end_mark 50 | self.explicit = explicit 51 | self.version = version 52 | self.tags = tags 53 | 54 | class DocumentEndEvent(Event): 55 | def __init__(self, start_mark=None, end_mark=None, 56 | explicit=None): 57 | self.start_mark = start_mark 58 | self.end_mark = end_mark 59 | self.explicit = explicit 60 | 61 | class AliasEvent(NodeEvent): 62 | pass 63 | 64 | class ScalarEvent(NodeEvent): 65 | def __init__(self, anchor, tag, implicit, value, 66 | start_mark=None, end_mark=None, style=None): 67 | self.anchor = anchor 68 | self.tag = tag 69 | self.implicit = implicit 70 | self.value = value 71 | self.start_mark = start_mark 72 | self.end_mark = end_mark 73 | self.style = style 74 | 75 | class SequenceStartEvent(CollectionStartEvent): 76 | pass 77 | 78 | class SequenceEndEvent(CollectionEndEvent): 79 | pass 80 | 81 | class MappingStartEvent(CollectionStartEvent): 82 | pass 83 | 84 | class MappingEndEvent(CollectionEndEvent): 85 | pass 86 | 87 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/yaml/error.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = ['Mark', 'YAMLError', 'MarkedYAMLError'] 3 | 4 | class Mark: 5 | 6 | def __init__(self, name, index, line, column, buffer, pointer): 7 | self.name = name 8 | self.index = index 9 | self.line = line 10 | self.column = column 11 | self.buffer = buffer 12 | self.pointer = pointer 13 | 14 | def get_snippet(self, indent=4, max_length=75): 15 | if self.buffer is None: 16 | return None 17 | head = '' 18 | start = self.pointer 19 | while start > 0 and self.buffer[start-1] not in '\0\r\n\x85\u2028\u2029': 20 | start -= 1 21 | if self.pointer-start > max_length/2-1: 22 | head = ' ... ' 23 | start += 5 24 | break 25 | tail = '' 26 | end = self.pointer 27 | while end < len(self.buffer) and self.buffer[end] not in '\0\r\n\x85\u2028\u2029': 28 | end += 1 29 | if end-self.pointer > max_length/2-1: 30 | tail = ' ... ' 31 | end -= 5 32 | break 33 | snippet = self.buffer[start:end] 34 | return ' '*indent + head + snippet + tail + '\n' \ 35 | + ' '*(indent+self.pointer-start+len(head)) + '^' 36 | 37 | def __str__(self): 38 | snippet = self.get_snippet() 39 | where = " in \"%s\", line %d, column %d" \ 40 | % (self.name, self.line+1, self.column+1) 41 | if snippet is not None: 42 | where += ":\n"+snippet 43 | return where 44 | 45 | class YAMLError(Exception): 46 | pass 47 | 48 | class MarkedYAMLError(YAMLError): 49 | 50 | def __init__(self, context=None, context_mark=None, 51 | problem=None, problem_mark=None, note=None): 52 | self.context = context 53 | self.context_mark = context_mark 54 | self.problem = problem 55 | self.problem_mark = problem_mark 56 | self.note = note 57 | 58 | def __str__(self): 59 | lines = [] 60 | if self.context is not None: 61 | lines.append(self.context) 62 | if self.context_mark is not None \ 63 | and (self.problem is None or self.problem_mark is None 64 | or self.context_mark.name != self.problem_mark.name 65 | or self.context_mark.line != self.problem_mark.line 66 | or self.context_mark.column != self.problem_mark.column): 67 | lines.append(str(self.context_mark)) 68 | if self.problem is not None: 69 | lines.append(self.problem) 70 | if self.problem_mark is not None: 71 | lines.append(str(self.problem_mark)) 72 | if self.note is not None: 73 | lines.append(self.note) 74 | return '\n'.join(lines) 75 | 76 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/deviceinfokeys.py: -------------------------------------------------------------------------------- 1 | #pylint: disable=too-few-public-methods 2 | """ 3 | Definitions of keys for device info dictionaries 4 | """ 5 | 6 | class DeviceInfoKeys(object): 7 | """ 8 | Base class with common device info keys 9 | """ 10 | 11 | NAME = 'name' 12 | ARCHITECTURE = 'architecture' 13 | INTERFACE = 'interface' 14 | DEVICE_ID = 'device_id' 15 | 16 | @classmethod 17 | def get_all(cls): 18 | """ 19 | Get a list of all keys 20 | 21 | :return List of all valid keys (baseclass and any subclass keys if run on a subclass) 22 | """ 23 | all_keys = [] 24 | for attribute in dir(cls): 25 | if not attribute.startswith('__') and not callable(getattr(cls, attribute)): 26 | all_keys.append(getattr(cls, attribute)) 27 | 28 | return all_keys 29 | 30 | class DeviceInfoKeysAvr(DeviceInfoKeys): 31 | """ 32 | Keys specific to AVR device info files 33 | """ 34 | 35 | NVMCTRL_BASE = 'nvmctrl_base' 36 | SYSCFG_BASE = 'syscfg_base' 37 | OCD_BASE = 'ocd_base' 38 | PROG_CLOCK_KHZ = 'prog_clock_khz' 39 | ADDRESS_SIZE = 'address_size' 40 | 41 | class DeviceInfoKeysAvr32(DeviceInfoKeys): 42 | """ 43 | Keys specific to 32-bit AVR device info files 44 | """ 45 | 46 | RESET_DOMAINS = 'reset_domains' 47 | 48 | class DeviceInfoKeysPic(DeviceInfoKeys): 49 | """ 50 | Keys specific to PIC device info files 51 | """ 52 | 53 | # This key should have _byte or _word ending in device info files to specify byte or word address 54 | # This ending will be removed by the getdeviceinfo function before returning the device info dictionary 55 | DEFAULT_BULK_ERASE_ADDRESS = 'default_bulk_erase_address' 56 | 57 | class DeviceMemoryInfoKeys(object): 58 | """ 59 | Keys for device memory info dictionary 60 | 61 | These keys are found in the dictionaries returned by DeviceMemoryInfo for each memory type 62 | """ 63 | NAME = 'name' 64 | ADDRESS = 'address' 65 | SIZE = 'size' 66 | PAGE_SIZE = 'page_size' 67 | WRITE_SIZE = 'write_size' 68 | READ_SIZE = 'read_size' 69 | ERASE_ADDRESS = 'erase_address' 70 | CHIPERASE_EFFECT = 'chiperase_effect' 71 | ISOLATED_ERASE = 'isolated_erase' 72 | HEXFILE_ADDRESS = 'hexfile_address' 73 | HEXFILE_SIZE = 'hexfile_size' 74 | VERIFY_MASK = 'verify_mask' 75 | 76 | @classmethod 77 | def get_all(cls): 78 | """ 79 | Get a list of all keys 80 | 81 | :return List of all valid keys (baseclass and any subclass keys if run on a subclass) 82 | """ 83 | all_keys = [] 84 | for attribute in dir(cls): 85 | if not attribute.startswith('__') and not callable(getattr(cls, attribute)): 86 | all_keys.append(getattr(cls, attribute)) 87 | 88 | return all_keys 89 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/yaml/dumper.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = ['BaseDumper', 'SafeDumper', 'Dumper'] 3 | 4 | from .emitter import * 5 | from .serializer import * 6 | from .representer import * 7 | from .resolver import * 8 | 9 | class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): 10 | 11 | def __init__(self, stream, 12 | default_style=None, default_flow_style=None, 13 | canonical=None, indent=None, width=None, 14 | allow_unicode=None, line_break=None, 15 | encoding=None, explicit_start=None, explicit_end=None, 16 | version=None, tags=None): 17 | Emitter.__init__(self, stream, canonical=canonical, 18 | indent=indent, width=width, 19 | allow_unicode=allow_unicode, line_break=line_break) 20 | Serializer.__init__(self, encoding=encoding, 21 | explicit_start=explicit_start, explicit_end=explicit_end, 22 | version=version, tags=tags) 23 | Representer.__init__(self, default_style=default_style, 24 | default_flow_style=default_flow_style) 25 | Resolver.__init__(self) 26 | 27 | class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): 28 | 29 | def __init__(self, stream, 30 | default_style=None, default_flow_style=None, 31 | canonical=None, indent=None, width=None, 32 | allow_unicode=None, line_break=None, 33 | encoding=None, explicit_start=None, explicit_end=None, 34 | version=None, tags=None): 35 | Emitter.__init__(self, stream, canonical=canonical, 36 | indent=indent, width=width, 37 | allow_unicode=allow_unicode, line_break=line_break) 38 | Serializer.__init__(self, encoding=encoding, 39 | explicit_start=explicit_start, explicit_end=explicit_end, 40 | version=version, tags=tags) 41 | SafeRepresenter.__init__(self, default_style=default_style, 42 | default_flow_style=default_flow_style) 43 | Resolver.__init__(self) 44 | 45 | class Dumper(Emitter, Serializer, Representer, Resolver): 46 | 47 | def __init__(self, stream, 48 | default_style=None, default_flow_style=None, 49 | canonical=None, indent=None, width=None, 50 | allow_unicode=None, line_break=None, 51 | encoding=None, explicit_start=None, explicit_end=None, 52 | version=None, tags=None): 53 | Emitter.__init__(self, stream, canonical=canonical, 54 | indent=indent, width=width, 55 | allow_unicode=allow_unicode, line_break=line_break) 56 | Serializer.__init__(self, encoding=encoding, 57 | explicit_start=explicit_start, explicit_end=explicit_end, 58 | version=version, tags=tags) 59 | Representer.__init__(self, default_style=default_style, 60 | default_flow_style=default_flow_style) 61 | Resolver.__init__(self) 62 | 63 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny202.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny202 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny202', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0040, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3f80, 33 | 'internal_sram_size_bytes': 0x0080, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x0800, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9123, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny204.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny204 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny204', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0040, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3f80, 33 | 'internal_sram_size_bytes': 0x0080, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x0800, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9122, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny212.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny212 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny212', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0040, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3f80, 33 | 'internal_sram_size_bytes': 0x0080, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x0800, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9121, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny214.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny214 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny214', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0040, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3f80, 33 | 'internal_sram_size_bytes': 0x0080, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x0800, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9120, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny402.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny402 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny402', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0080, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3f00, 33 | 'internal_sram_size_bytes': 0x0100, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x1000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9227, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny404.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny404 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny404', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0080, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3f00, 33 | 'internal_sram_size_bytes': 0x0100, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x1000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9226, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny406.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny406 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny406', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0080, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3f00, 33 | 'internal_sram_size_bytes': 0x0100, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x1000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9225, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny412.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny412 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny412', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0080, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3f00, 33 | 'internal_sram_size_bytes': 0x0100, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x1000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9223, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny414.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny414 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny414', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0080, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3f00, 33 | 'internal_sram_size_bytes': 0x0100, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x1000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9222, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny416.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny416 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny416', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0080, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3f00, 33 | 'internal_sram_size_bytes': 0x0100, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x1000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9221, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny417.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny417 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny417', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0080, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3f00, 33 | 'internal_sram_size_bytes': 0x0100, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x1000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9220, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny804.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny804 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny804', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0080, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3e00, 33 | 'internal_sram_size_bytes': 0x0200, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x2000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9325, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny806.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny806 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny806', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0080, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3e00, 33 | 'internal_sram_size_bytes': 0x0200, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x2000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9324, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny807.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny807 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny807', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0080, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3e00, 33 | 'internal_sram_size_bytes': 0x0200, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x2000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9323, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny814.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny814 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny814', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0080, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3e00, 33 | 'internal_sram_size_bytes': 0x0200, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x2000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9322, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny816.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny816 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny816', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0080, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3e00, 33 | 'internal_sram_size_bytes': 0x0200, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x2000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9321, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny817.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny817 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny817', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0080, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3e00, 33 | 'internal_sram_size_bytes': 0x0200, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x2000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9320, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny1604.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny1604 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny1604', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0100, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3c00, 33 | 'internal_sram_size_bytes': 0x0400, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x4000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9425, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny1606.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny1606 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny1606', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0100, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3c00, 33 | 'internal_sram_size_bytes': 0x0400, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x4000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9424, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny1607.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny1607 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny1607', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0100, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3c00, 33 | 'internal_sram_size_bytes': 0x0400, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x4000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9423, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny1614.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny1614 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny1614', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0100, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3800, 33 | 'internal_sram_size_bytes': 0x0800, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x4000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9422, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny1616.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny1616 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny1616', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0100, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3800, 33 | 'internal_sram_size_bytes': 0x0800, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x4000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9421, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny1617.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny1617 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny1617', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0100, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3800, 33 | 'internal_sram_size_bytes': 0x0800, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x4000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9420, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny1624.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny1624 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny1624', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0100, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3800, 33 | 'internal_sram_size_bytes': 0x0800, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x4000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E942A, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny1626.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny1626 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny1626', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0100, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3800, 33 | 'internal_sram_size_bytes': 0x0800, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x4000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9429, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny1627.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny1627 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny1627', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0100, 16 | 'eeprom_page_size_bytes': 0x20, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3800, 33 | 'internal_sram_size_bytes': 0x0800, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x40, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x20, 61 | 'user_row_page_size_bytes': 0x20, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x4000, 70 | 'flash_page_size_bytes': 0x40, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x40, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9428, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny3216.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny3216 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny3216', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0100, 16 | 'eeprom_page_size_bytes': 0x40, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3800, 33 | 'internal_sram_size_bytes': 0x0800, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x80, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x40, 61 | 'user_row_page_size_bytes': 0x40, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x8000, 70 | 'flash_page_size_bytes': 0x80, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x80, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9521, 84 | } 85 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny3217.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny3217 devices 4 | The following data was collected from device pack Microchip.ATtiny_DFP 2.4.111 5 | """ 6 | 7 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 8 | 9 | DEVICE_INFO = { 10 | 'name': 'attiny3217', 11 | 'architecture': 'avr8x', 12 | 13 | # eeprom 14 | 'eeprom_address_byte': 0x00001400, 15 | 'eeprom_size_bytes': 0x0100, 16 | 'eeprom_page_size_bytes': 0x40, 17 | 'eeprom_read_size_bytes': 1, 18 | 'eeprom_write_size_bytes': 1, 19 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 20 | 'eeprom_isolated_erase': True, 21 | 22 | # fuses 23 | 'fuses_address_byte': 0x00001280, 24 | 'fuses_size_bytes': 0xA, 25 | 'fuses_page_size_bytes': 1, 26 | 'fuses_read_size_bytes': 1, 27 | 'fuses_write_size_bytes': 1, 28 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 29 | 'fuses_isolated_erase': False, 30 | 31 | # internal_sram 32 | 'internal_sram_address_byte': 0x3800, 33 | 'internal_sram_size_bytes': 0x0800, 34 | 'internal_sram_page_size_bytes': 1, 35 | 'internal_sram_read_size_bytes': 1, 36 | 'internal_sram_write_size_bytes': 1, 37 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 38 | 'internal_sram_isolated_erase': False, 39 | 40 | # lockbits 41 | 'lockbits_address_byte': 0x0000128A, 42 | 'lockbits_size_bytes': 0x1, 43 | 'lockbits_page_size_bytes': 1, 44 | 'lockbits_read_size_bytes': 1, 45 | 'lockbits_write_size_bytes': 1, 46 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 47 | 'lockbits_isolated_erase': False, 48 | 49 | # signatures 50 | 'signatures_address_byte': 0x00001100, 51 | 'signatures_size_bytes': 0x3, 52 | 'signatures_page_size_bytes': 0x80, 53 | 'signatures_read_size_bytes': 1, 54 | 'signatures_write_size_bytes': 0, 55 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 56 | 'signatures_isolated_erase': False, 57 | 58 | # user_row 59 | 'user_row_address_byte': 0x00001300, 60 | 'user_row_size_bytes': 0x40, 61 | 'user_row_page_size_bytes': 0x40, 62 | 'user_row_read_size_bytes': 1, 63 | 'user_row_write_size_bytes': 1, 64 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 65 | 'user_row_isolated_erase': True, 66 | 67 | # flash 68 | 'flash_address_byte': 0x00008000, 69 | 'flash_size_bytes': 0x8000, 70 | 'flash_page_size_bytes': 0x80, 71 | 'flash_read_size_bytes': 2, 72 | 'flash_write_size_bytes': 0x80, 73 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 74 | 'flash_isolated_erase': True, 75 | 76 | # Some extra AVR specific fields 77 | 'nvmctrl_base': 0x00001000, 78 | 'syscfg_base': 0x00000F00, 79 | 'ocd_base': 0x00000F80, 80 | 'prog_clock_khz': 900, 81 | 'interface': 'UPDI', 82 | 'address_size': '16-bit', 83 | 'device_id': 0x1E9522, 84 | } 85 | -------------------------------------------------------------------------------- /software/include/dev/attiny402/device-specs/specs-attiny402: -------------------------------------------------------------------------------- 1 | # 2 | # Auto-generated specs for AVR device attiny402 (core avrxmega3, 16-bit SP, short-calls) 3 | # 4 | # Generated by : ./gcc/config/avr/gen-avr-mmcu-specs.c 5 | # Generated from : ./gcc/config/gcc.c 6 | # ./gcc/config/avr/specs.h 7 | # ./gcc/config/avr/avrlibc.h 8 | # Used by : avr-gcc compiler driver 9 | # Used for : building command options for sub-processes 10 | # 11 | # See 12 | # for a documentation of spec files. 13 | 14 | 15 | # If you intend to use an existing device specs file as a starting point 16 | # for a new device spec file, make sure you are copying from a specs 17 | # file for a device from the same core architecture and SP width. 18 | # See for a description 19 | # of how to use such own spec files. 20 | 21 | *avrlibc_startfile: 22 | crtattiny402.o%s 23 | 24 | *avrlibc_devicelib: 25 | %{!nodevicelib:-lattiny402} 26 | 27 | *cc1_n_flash: 28 | %{!mn-flash=*:-mn-flash=1} 29 | 30 | *cc1_rmw: 31 | %{mrmw} 32 | 33 | *cc1_errata_skip: 34 | %{!mskip-bug: -mno-skip-bug} 35 | 36 | *cc1_absdata: 37 | %{mabsdata} 38 | 39 | *asm_arch: 40 | -mmcu=avrxmega3 41 | 42 | *asm_relax: 43 | %{mrelax:--mlink-relax} 44 | 45 | *asm_rmw: 46 | %{mrmw} 47 | 48 | *asm_gccisr: 49 | %{!mno-gas-isr-prologues: -mgcc-isr} 50 | 51 | *asm_errata_skip: 52 | %{!mskip-bug: -mno-skip-bug} 53 | 54 | *link_pmem_wrap: 55 | 56 | 57 | *link_relax: 58 | %{mrelax:--relax} 59 | 60 | *link_arch: 61 | %{mmcu=*:-m%*} 62 | 63 | *link_data_start: 64 | -Tdata 0x803F00 65 | 66 | *link_text_start: 67 | 68 | 69 | *self_spec: 70 | % 80 | # #elif ... 81 | # 82 | # If no device macro is defined, AVR-LibC uses __AVR_DEV_LIB_NAME__ 83 | # as fallback to determine the name of the device header as 84 | # 85 | # "avr/io" + __AVR_DEV_LIB_NAME__ + ".h" 86 | # 87 | # If you provide your own specs file for a device not yet known to 88 | # AVR-LibC, you can now define the hook macro __AVR_DEV_LIB_NAME__ 89 | # as needed so that 90 | # 91 | # #include 92 | # 93 | # will include the desired device header. For ATmega8A the supplement 94 | # to *cpp would read 95 | # 96 | # -D__AVR_DEV_LIB_NAME__=m8a 97 | 98 | 99 | *cpp: 100 | -D__AVR_ATtiny402__ -D__AVR_DEVICE_NAME__=attiny402 -D__AVR_DEV_LIB_NAME__=tn402 101 | 102 | %rename link old_link 103 | 104 | *link: 105 | %(old_link)--defsym=__RODATA_PM_OFFSET__=0x8000 106 | 107 | # End of file 108 | -------------------------------------------------------------------------------- /software/include/dev/attiny412/device-specs/specs-attiny412: -------------------------------------------------------------------------------- 1 | # 2 | # Auto-generated specs for AVR device attiny412 (core avrxmega3, 16-bit SP, short-calls) 3 | # 4 | # Generated by : ./gcc/config/avr/gen-avr-mmcu-specs.c 5 | # Generated from : ./gcc/config/gcc.c 6 | # ./gcc/config/avr/specs.h 7 | # ./gcc/config/avr/avrlibc.h 8 | # Used by : avr-gcc compiler driver 9 | # Used for : building command options for sub-processes 10 | # 11 | # See 12 | # for a documentation of spec files. 13 | 14 | 15 | # If you intend to use an existing device specs file as a starting point 16 | # for a new device spec file, make sure you are copying from a specs 17 | # file for a device from the same core architecture and SP width. 18 | # See for a description 19 | # of how to use such own spec files. 20 | 21 | *avrlibc_startfile: 22 | crtattiny412.o%s 23 | 24 | *avrlibc_devicelib: 25 | %{!nodevicelib:-lattiny412} 26 | 27 | *cc1_n_flash: 28 | %{!mn-flash=*:-mn-flash=1} 29 | 30 | *cc1_rmw: 31 | %{mrmw} 32 | 33 | *cc1_errata_skip: 34 | %{!mskip-bug: -mno-skip-bug} 35 | 36 | *cc1_absdata: 37 | %{mabsdata} 38 | 39 | *asm_arch: 40 | -mmcu=avrxmega3 41 | 42 | *asm_relax: 43 | %{mrelax:--mlink-relax} 44 | 45 | *asm_rmw: 46 | %{mrmw} 47 | 48 | *asm_gccisr: 49 | %{!mno-gas-isr-prologues: -mgcc-isr} 50 | 51 | *asm_errata_skip: 52 | %{!mskip-bug: -mno-skip-bug} 53 | 54 | *link_pmem_wrap: 55 | 56 | 57 | *link_relax: 58 | %{mrelax:--relax} 59 | 60 | *link_arch: 61 | %{mmcu=*:-m%*} 62 | 63 | *link_data_start: 64 | -Tdata 0x803F00 65 | 66 | *link_text_start: 67 | 68 | 69 | *self_spec: 70 | % 80 | # #elif ... 81 | # 82 | # If no device macro is defined, AVR-LibC uses __AVR_DEV_LIB_NAME__ 83 | # as fallback to determine the name of the device header as 84 | # 85 | # "avr/io" + __AVR_DEV_LIB_NAME__ + ".h" 86 | # 87 | # If you provide your own specs file for a device not yet known to 88 | # AVR-LibC, you can now define the hook macro __AVR_DEV_LIB_NAME__ 89 | # as needed so that 90 | # 91 | # #include 92 | # 93 | # will include the desired device header. For ATmega8A the supplement 94 | # to *cpp would read 95 | # 96 | # -D__AVR_DEV_LIB_NAME__=m8a 97 | 98 | 99 | *cpp: 100 | -D__AVR_ATtiny412__ -D__AVR_DEVICE_NAME__=attiny412 -D__AVR_DEV_LIB_NAME__=tn412 101 | 102 | %rename link old_link 103 | 104 | *link: 105 | %(old_link)--defsym=__RODATA_PM_OFFSET__=0x8000 106 | 107 | # End of file 108 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/serialupdi/constants.py: -------------------------------------------------------------------------------- 1 | """ 2 | UPDI protocol constants 3 | """ 4 | # UPDI commands and control definitions 5 | UPDI_BREAK = 0x00 6 | 7 | UPDI_LDS = 0x00 8 | UPDI_STS = 0x40 9 | UPDI_LD = 0x20 10 | UPDI_ST = 0x60 11 | UPDI_LDCS = 0x80 12 | UPDI_STCS = 0xC0 13 | UPDI_REPEAT = 0xA0 14 | UPDI_KEY = 0xE0 15 | 16 | UPDI_PTR = 0x00 17 | UPDI_PTR_INC = 0x04 18 | UPDI_PTR_ADDRESS = 0x08 19 | 20 | UPDI_ADDRESS_8 = 0x00 21 | UPDI_ADDRESS_16 = 0x04 22 | UPDI_ADDRESS_24 = 0x08 23 | 24 | UPDI_DATA_8 = 0x00 25 | UPDI_DATA_16 = 0x01 26 | UPDI_DATA_24 = 0x02 27 | 28 | UPDI_KEY_SIB = 0x04 29 | UPDI_KEY_KEY = 0x00 30 | 31 | UPDI_KEY_64 = 0x00 32 | UPDI_KEY_128 = 0x01 33 | UPDI_KEY_256 = 0x02 34 | 35 | UPDI_SIB_8BYTES = UPDI_KEY_64 36 | UPDI_SIB_16BYTES = UPDI_KEY_128 37 | UPDI_SIB_32BYTES = UPDI_KEY_256 38 | 39 | UPDI_REPEAT_BYTE = 0x00 40 | UPDI_REPEAT_WORD = 0x01 41 | 42 | UPDI_PHY_SYNC = 0x55 43 | UPDI_PHY_ACK = 0x40 44 | 45 | UPDI_MAX_REPEAT_SIZE = (0xFF+1) # Repeat counter of 1-byte, with off-by-one counting 46 | 47 | # CS and ASI Register Address map 48 | UPDI_CS_STATUSA = 0x00 49 | UPDI_CS_STATUSB = 0x01 50 | UPDI_CS_CTRLA = 0x02 51 | UPDI_CS_CTRLB = 0x03 52 | UPDI_ASI_KEY_STATUS = 0x07 53 | UPDI_ASI_RESET_REQ = 0x08 54 | UPDI_ASI_CTRLA = 0x09 55 | UPDI_ASI_SYS_CTRLA = 0x0A 56 | UPDI_ASI_SYS_STATUS = 0x0B 57 | UPDI_ASI_CRC_STATUS = 0x0C 58 | 59 | UPDI_CTRLA_IBDLY_BIT = 7 60 | UPDI_CTRLB_CCDETDIS_BIT = 3 61 | UPDI_CTRLB_UPDIDIS_BIT = 2 62 | 63 | UPDI_KEY_NVM = b"NVMProg " 64 | UPDI_KEY_CHIPERASE = b"NVMErase" 65 | 66 | UPDI_ASI_STATUSA_REVID = 4 67 | UPDI_ASI_STATUSB_PESIG = 0 68 | 69 | UPDI_ASI_KEY_STATUS_CHIPERASE = 3 70 | UPDI_ASI_KEY_STATUS_NVMPROG = 4 71 | UPDI_ASI_KEY_STATUS_UROWWRITE = 5 72 | 73 | UPDI_ASI_SYS_STATUS_RSTSYS = 5 74 | UPDI_ASI_SYS_STATUS_INSLEEP = 4 75 | UPDI_ASI_SYS_STATUS_NVMPROG = 3 76 | UPDI_ASI_SYS_STATUS_UROWPROG = 2 77 | UPDI_ASI_SYS_STATUS_LOCKSTATUS = 0 78 | 79 | UPDI_RESET_REQ_VALUE = 0x59 80 | 81 | # FLASH CONTROLLER 82 | UPDI_NVMCTRL_CTRLA = 0x00 83 | UPDI_NVMCTRL_CTRLB = 0x01 84 | UPDI_NVMCTRL_STATUS = 0x02 85 | UPDI_NVMCTRL_INTCTRL = 0x03 86 | UPDI_NVMCTRL_INTFLAGS = 0x04 87 | UPDI_NVMCTRL_DATAL = 0x06 88 | UPDI_NVMCTRL_DATAH = 0x07 89 | UPDI_NVMCTRL_ADDRL = 0x08 90 | UPDI_NVMCTRL_ADDRH = 0x09 91 | 92 | # NVMCTRL v0 CTRLA 93 | UPDI_V0_NVMCTRL_CTRLA_NOP = 0x00 94 | UPDI_V0_NVMCTRL_CTRLA_WRITE_PAGE = 0x01 95 | UPDI_V0_NVMCTRL_CTRLA_ERASE_PAGE = 0x02 96 | UPDI_V0_NVMCTRL_CTRLA_ERASE_WRITE_PAGE = 0x03 97 | UPDI_V0_NVMCTRL_CTRLA_PAGE_BUFFER_CLR = 0x04 98 | UPDI_V0_NVMCTRL_CTRLA_CHIP_ERASE = 0x05 99 | UPDI_V0_NVMCTRL_CTRLA_ERASE_EEPROM = 0x06 100 | UPDI_V0_NVMCTRL_CTRLA_WRITE_FUSE = 0x07 101 | 102 | # NVMCTRL v1 CTRLA 103 | UPDI_V1_NVMCTRL_CTRLA_NOCMD = 0x00 104 | UPDI_V1_NVMCTRL_CTRLA_FLASH_WRITE = 0x02 105 | UPDI_V1_NVMCTRL_CTRLA_EEPROM_ERASE_WRITE = 0x13 106 | UPDI_V1_NVMCTRL_CTRLA_CHIP_ERASE = 0x20 107 | 108 | UPDI_NVM_STATUS_WRITE_ERROR = 2 109 | UPDI_NVM_STATUS_EEPROM_BUSY = 1 110 | UPDI_NVM_STATUS_FLASH_BUSY = 0 111 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny3224.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny3224 devices 4 | The following data would normally have been collected from device packs. 5 | But since Microchip hasn't done this, it was deduced from device packs by Spence Konde. 6 | """ 7 | 8 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 9 | 10 | DEVICE_INFO = { 11 | 'name': 'attiny3224', 12 | 'architecture': 'avr8x', 13 | 14 | # eeprom 15 | 'eeprom_address_byte': 0x00001400, 16 | 'eeprom_size_bytes': 0x0100, 17 | 'eeprom_page_size_bytes': 0x40, 18 | 'eeprom_read_size_bytes': 1, 19 | 'eeprom_write_size_bytes': 1, 20 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 21 | 'eeprom_isolated_erase': True, 22 | 23 | # fuses 24 | 'fuses_address_byte': 0x00001280, 25 | 'fuses_size_bytes': 0xA, 26 | 'fuses_page_size_bytes': 1, 27 | 'fuses_read_size_bytes': 1, 28 | 'fuses_write_size_bytes': 1, 29 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 30 | 'fuses_isolated_erase': False, 31 | 32 | # internal_sram 33 | 'internal_sram_address_byte': 0x3400, 34 | 'internal_sram_size_bytes': 0x0C00, 35 | 'internal_sram_page_size_bytes': 1, 36 | 'internal_sram_read_size_bytes': 1, 37 | 'internal_sram_write_size_bytes': 1, 38 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 39 | 'internal_sram_isolated_erase': False, 40 | 41 | # lockbits 42 | 'lockbits_address_byte': 0x0000128A, 43 | 'lockbits_size_bytes': 0x1, 44 | 'lockbits_page_size_bytes': 1, 45 | 'lockbits_read_size_bytes': 1, 46 | 'lockbits_write_size_bytes': 1, 47 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 48 | 'lockbits_isolated_erase': False, 49 | 50 | # signatures 51 | 'signatures_address_byte': 0x00001100, 52 | 'signatures_size_bytes': 0x3, 53 | 'signatures_page_size_bytes': 0x80, 54 | 'signatures_read_size_bytes': 1, 55 | 'signatures_write_size_bytes': 0, 56 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 57 | 'signatures_isolated_erase': False, 58 | 59 | # user_row 60 | 'user_row_address_byte': 0x00001300, 61 | 'user_row_size_bytes': 0x40, 62 | 'user_row_page_size_bytes': 0x40, 63 | 'user_row_read_size_bytes': 1, 64 | 'user_row_write_size_bytes': 1, 65 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 66 | 'user_row_isolated_erase': True, 67 | 68 | # flash 69 | 'flash_address_byte': 0x00008000, 70 | 'flash_size_bytes': 0x8000, 71 | 'flash_page_size_bytes': 0x80, 72 | 'flash_read_size_bytes': 2, 73 | 'flash_write_size_bytes': 0x80, 74 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 75 | 'flash_isolated_erase': True, 76 | 77 | # Some extra AVR specific fields 78 | 'nvmctrl_base': 0x00001000, 79 | 'syscfg_base': 0x00000F00, 80 | 'ocd_base': 0x00000F80, 81 | 'prog_clock_khz': 900, 82 | 'interface': 'UPDI', 83 | 'address_size': '16-bit', 84 | 'device_id': 0x1E9528, 85 | } 86 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny3226.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny3226 devices 4 | The following data would normally have been collected from device packs. 5 | But since Microchip hasn't done this, it was deduced from device packs by Spence Konde. 6 | """ 7 | 8 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 9 | 10 | DEVICE_INFO = { 11 | 'name': 'attiny3226', 12 | 'architecture': 'avr8x', 13 | 14 | # eeprom 15 | 'eeprom_address_byte': 0x00001400, 16 | 'eeprom_size_bytes': 0x0100, 17 | 'eeprom_page_size_bytes': 0x40, 18 | 'eeprom_read_size_bytes': 1, 19 | 'eeprom_write_size_bytes': 1, 20 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 21 | 'eeprom_isolated_erase': True, 22 | 23 | # fuses 24 | 'fuses_address_byte': 0x00001280, 25 | 'fuses_size_bytes': 0xA, 26 | 'fuses_page_size_bytes': 1, 27 | 'fuses_read_size_bytes': 1, 28 | 'fuses_write_size_bytes': 1, 29 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 30 | 'fuses_isolated_erase': False, 31 | 32 | # internal_sram 33 | 'internal_sram_address_byte': 0x3400, 34 | 'internal_sram_size_bytes': 0x0C00, 35 | 'internal_sram_page_size_bytes': 1, 36 | 'internal_sram_read_size_bytes': 1, 37 | 'internal_sram_write_size_bytes': 1, 38 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 39 | 'internal_sram_isolated_erase': False, 40 | 41 | # lockbits 42 | 'lockbits_address_byte': 0x0000128A, 43 | 'lockbits_size_bytes': 0x1, 44 | 'lockbits_page_size_bytes': 1, 45 | 'lockbits_read_size_bytes': 1, 46 | 'lockbits_write_size_bytes': 1, 47 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 48 | 'lockbits_isolated_erase': False, 49 | 50 | # signatures 51 | 'signatures_address_byte': 0x00001100, 52 | 'signatures_size_bytes': 0x3, 53 | 'signatures_page_size_bytes': 0x80, 54 | 'signatures_read_size_bytes': 1, 55 | 'signatures_write_size_bytes': 0, 56 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 57 | 'signatures_isolated_erase': False, 58 | 59 | # user_row 60 | 'user_row_address_byte': 0x00001300, 61 | 'user_row_size_bytes': 0x40, 62 | 'user_row_page_size_bytes': 0x40, 63 | 'user_row_read_size_bytes': 1, 64 | 'user_row_write_size_bytes': 1, 65 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 66 | 'user_row_isolated_erase': True, 67 | 68 | # flash 69 | 'flash_address_byte': 0x00008000, 70 | 'flash_size_bytes': 0x8000, 71 | 'flash_page_size_bytes': 0x80, 72 | 'flash_read_size_bytes': 2, 73 | 'flash_write_size_bytes': 0x80, 74 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 75 | 'flash_isolated_erase': True, 76 | 77 | # Some extra AVR specific fields 78 | 'nvmctrl_base': 0x00001000, 79 | 'syscfg_base': 0x00000F00, 80 | 'ocd_base': 0x00000F80, 81 | 'prog_clock_khz': 900, 82 | 'interface': 'UPDI', 83 | 'address_size': '16-bit', 84 | 'device_id': 0x1E9527, 85 | } 86 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny3227.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny3227 devices 4 | The following data would normally have been collected from device packs. 5 | But since Microchip hasn't done this, it was deduced from device packs by Spence Konde. 6 | """ 7 | 8 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 9 | 10 | DEVICE_INFO = { 11 | 'name': 'attiny3227', 12 | 'architecture': 'avr8x', 13 | 14 | # eeprom 15 | 'eeprom_address_byte': 0x00001400, 16 | 'eeprom_size_bytes': 0x0100, 17 | 'eeprom_page_size_bytes': 0x40, 18 | 'eeprom_read_size_bytes': 1, 19 | 'eeprom_write_size_bytes': 1, 20 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 21 | 'eeprom_isolated_erase': True, 22 | 23 | # fuses 24 | 'fuses_address_byte': 0x00001280, 25 | 'fuses_size_bytes': 0xA, 26 | 'fuses_page_size_bytes': 1, 27 | 'fuses_read_size_bytes': 1, 28 | 'fuses_write_size_bytes': 1, 29 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 30 | 'fuses_isolated_erase': False, 31 | 32 | # internal_sram 33 | 'internal_sram_address_byte': 0x3400, 34 | 'internal_sram_size_bytes': 0x0C00, 35 | 'internal_sram_page_size_bytes': 1, 36 | 'internal_sram_read_size_bytes': 1, 37 | 'internal_sram_write_size_bytes': 1, 38 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 39 | 'internal_sram_isolated_erase': False, 40 | 41 | # lockbits 42 | 'lockbits_address_byte': 0x0000128A, 43 | 'lockbits_size_bytes': 0x1, 44 | 'lockbits_page_size_bytes': 1, 45 | 'lockbits_read_size_bytes': 1, 46 | 'lockbits_write_size_bytes': 1, 47 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 48 | 'lockbits_isolated_erase': False, 49 | 50 | # signatures 51 | 'signatures_address_byte': 0x00001100, 52 | 'signatures_size_bytes': 0x3, 53 | 'signatures_page_size_bytes': 0x80, 54 | 'signatures_read_size_bytes': 1, 55 | 'signatures_write_size_bytes': 0, 56 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 57 | 'signatures_isolated_erase': False, 58 | 59 | # user_row 60 | 'user_row_address_byte': 0x00001300, 61 | 'user_row_size_bytes': 0x40, 62 | 'user_row_page_size_bytes': 0x40, 63 | 'user_row_read_size_bytes': 1, 64 | 'user_row_write_size_bytes': 1, 65 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 66 | 'user_row_isolated_erase': True, 67 | 68 | # flash 69 | 'flash_address_byte': 0x00008000, 70 | 'flash_size_bytes': 0x8000, 71 | 'flash_page_size_bytes': 0x80, 72 | 'flash_read_size_bytes': 2, 73 | 'flash_write_size_bytes': 0x80, 74 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 75 | 'flash_isolated_erase': True, 76 | 77 | # Some extra AVR specific fields 78 | 'nvmctrl_base': 0x00001000, 79 | 'syscfg_base': 0x00000F00, 80 | 'ocd_base': 0x00000F80, 81 | 'prog_clock_khz': 900, 82 | 'interface': 'UPDI', 83 | 'address_size': '16-bit', 84 | 'device_id': 0x1E9526, 85 | } 86 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny424.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny424 devices 4 | The following data would normally have been collected from device packs. 5 | But since Microchip hasn't done this, and his users were complaining, 6 | it was deduced from device packs by Spence Konde. 7 | """ 8 | 9 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 10 | 11 | DEVICE_INFO = { 12 | 'name': 'attiny424', 13 | 'architecture': 'avr8x', 14 | 15 | # eeprom 16 | 'eeprom_address_byte': 0x00001400, 17 | 'eeprom_size_bytes': 0x0080, 18 | 'eeprom_page_size_bytes': 0x20, 19 | 'eeprom_read_size_bytes': 1, 20 | 'eeprom_write_size_bytes': 1, 21 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 22 | 'eeprom_isolated_erase': True, 23 | 24 | # fuses 25 | 'fuses_address_byte': 0x00001280, 26 | 'fuses_size_bytes': 0xA, 27 | 'fuses_page_size_bytes': 1, 28 | 'fuses_read_size_bytes': 1, 29 | 'fuses_write_size_bytes': 1, 30 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 31 | 'fuses_isolated_erase': False, 32 | 33 | # internal_sram 34 | 'internal_sram_address_byte': 0x3e00, 35 | 'internal_sram_size_bytes': 0x0200, 36 | 'internal_sram_page_size_bytes': 1, 37 | 'internal_sram_read_size_bytes': 1, 38 | 'internal_sram_write_size_bytes': 1, 39 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 40 | 'internal_sram_isolated_erase': False, 41 | 42 | # lockbits 43 | 'lockbits_address_byte': 0x0000128A, 44 | 'lockbits_size_bytes': 0x1, 45 | 'lockbits_page_size_bytes': 1, 46 | 'lockbits_read_size_bytes': 1, 47 | 'lockbits_write_size_bytes': 1, 48 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 49 | 'lockbits_isolated_erase': False, 50 | 51 | # signatures 52 | 'signatures_address_byte': 0x00001100, 53 | 'signatures_size_bytes': 0x3, 54 | 'signatures_page_size_bytes': 0x40, 55 | 'signatures_read_size_bytes': 1, 56 | 'signatures_write_size_bytes': 0, 57 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 58 | 'signatures_isolated_erase': False, 59 | 60 | # user_row 61 | 'user_row_address_byte': 0x00001300, 62 | 'user_row_size_bytes': 0x20, 63 | 'user_row_page_size_bytes': 0x20, 64 | 'user_row_read_size_bytes': 1, 65 | 'user_row_write_size_bytes': 1, 66 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 67 | 'user_row_isolated_erase': True, 68 | 69 | # flash 70 | 'flash_address_byte': 0x00008000, 71 | 'flash_size_bytes': 0x1000, 72 | 'flash_page_size_bytes': 0x40, 73 | 'flash_read_size_bytes': 2, 74 | 'flash_write_size_bytes': 0x40, 75 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 76 | 'flash_isolated_erase': True, 77 | 78 | # Some extra AVR specific fields 79 | 'nvmctrl_base': 0x00001000, 80 | 'syscfg_base': 0x00000F00, 81 | 'ocd_base': 0x00000F80, 82 | 'prog_clock_khz': 900, 83 | 'interface': 'UPDI', 84 | 'address_size': '16-bit', 85 | 'device_id': 0x1E922C, 86 | } 87 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny426.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny426 devices 4 | The following data would normally have been collected from device packs. 5 | But since Microchip hasn't done this, and his users were complaining, 6 | it was deduced from device packs by Spence Konde. 7 | """ 8 | 9 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 10 | 11 | DEVICE_INFO = { 12 | 'name': 'attiny426', 13 | 'architecture': 'avr8x', 14 | 15 | # eeprom 16 | 'eeprom_address_byte': 0x00001400, 17 | 'eeprom_size_bytes': 0x0080, 18 | 'eeprom_page_size_bytes': 0x20, 19 | 'eeprom_read_size_bytes': 1, 20 | 'eeprom_write_size_bytes': 1, 21 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 22 | 'eeprom_isolated_erase': True, 23 | 24 | # fuses 25 | 'fuses_address_byte': 0x00001280, 26 | 'fuses_size_bytes': 0xA, 27 | 'fuses_page_size_bytes': 1, 28 | 'fuses_read_size_bytes': 1, 29 | 'fuses_write_size_bytes': 1, 30 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 31 | 'fuses_isolated_erase': False, 32 | 33 | # internal_sram 34 | 'internal_sram_address_byte': 0x3e00, 35 | 'internal_sram_size_bytes': 0x0200, 36 | 'internal_sram_page_size_bytes': 1, 37 | 'internal_sram_read_size_bytes': 1, 38 | 'internal_sram_write_size_bytes': 1, 39 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 40 | 'internal_sram_isolated_erase': False, 41 | 42 | # lockbits 43 | 'lockbits_address_byte': 0x0000128A, 44 | 'lockbits_size_bytes': 0x1, 45 | 'lockbits_page_size_bytes': 1, 46 | 'lockbits_read_size_bytes': 1, 47 | 'lockbits_write_size_bytes': 1, 48 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 49 | 'lockbits_isolated_erase': False, 50 | 51 | # signatures 52 | 'signatures_address_byte': 0x00001100, 53 | 'signatures_size_bytes': 0x3, 54 | 'signatures_page_size_bytes': 0x40, 55 | 'signatures_read_size_bytes': 1, 56 | 'signatures_write_size_bytes': 0, 57 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 58 | 'signatures_isolated_erase': False, 59 | 60 | # user_row 61 | 'user_row_address_byte': 0x00001300, 62 | 'user_row_size_bytes': 0x20, 63 | 'user_row_page_size_bytes': 0x20, 64 | 'user_row_read_size_bytes': 1, 65 | 'user_row_write_size_bytes': 1, 66 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 67 | 'user_row_isolated_erase': True, 68 | 69 | # flash 70 | 'flash_address_byte': 0x00008000, 71 | 'flash_size_bytes': 0x1000, 72 | 'flash_page_size_bytes': 0x40, 73 | 'flash_read_size_bytes': 2, 74 | 'flash_write_size_bytes': 0x40, 75 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 76 | 'flash_isolated_erase': True, 77 | 78 | # Some extra AVR specific fields 79 | 'nvmctrl_base': 0x00001000, 80 | 'syscfg_base': 0x00000F00, 81 | 'ocd_base': 0x00000F80, 82 | 'prog_clock_khz': 900, 83 | 'interface': 'UPDI', 84 | 'address_size': '16-bit', 85 | 'device_id': 0x1E922B, 86 | } 87 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny427.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny427 devices 4 | The following data would normally have been collected from device packs. 5 | But since Microchip hasn't done this, and his users were complaining, 6 | it was deduced from device packs by Spence Konde. 7 | """ 8 | 9 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 10 | 11 | DEVICE_INFO = { 12 | 'name': 'attiny427', 13 | 'architecture': 'avr8x', 14 | 15 | # eeprom 16 | 'eeprom_address_byte': 0x00001400, 17 | 'eeprom_size_bytes': 0x0080, 18 | 'eeprom_page_size_bytes': 0x20, 19 | 'eeprom_read_size_bytes': 1, 20 | 'eeprom_write_size_bytes': 1, 21 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 22 | 'eeprom_isolated_erase': True, 23 | 24 | # fuses 25 | 'fuses_address_byte': 0x00001280, 26 | 'fuses_size_bytes': 0xA, 27 | 'fuses_page_size_bytes': 1, 28 | 'fuses_read_size_bytes': 1, 29 | 'fuses_write_size_bytes': 1, 30 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 31 | 'fuses_isolated_erase': False, 32 | 33 | # internal_sram 34 | 'internal_sram_address_byte': 0x3e00, 35 | 'internal_sram_size_bytes': 0x0200, 36 | 'internal_sram_page_size_bytes': 1, 37 | 'internal_sram_read_size_bytes': 1, 38 | 'internal_sram_write_size_bytes': 1, 39 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 40 | 'internal_sram_isolated_erase': False, 41 | 42 | # lockbits 43 | 'lockbits_address_byte': 0x0000128A, 44 | 'lockbits_size_bytes': 0x1, 45 | 'lockbits_page_size_bytes': 1, 46 | 'lockbits_read_size_bytes': 1, 47 | 'lockbits_write_size_bytes': 1, 48 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 49 | 'lockbits_isolated_erase': False, 50 | 51 | # signatures 52 | 'signatures_address_byte': 0x00001100, 53 | 'signatures_size_bytes': 0x3, 54 | 'signatures_page_size_bytes': 0x40, 55 | 'signatures_read_size_bytes': 1, 56 | 'signatures_write_size_bytes': 0, 57 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 58 | 'signatures_isolated_erase': False, 59 | 60 | # user_row 61 | 'user_row_address_byte': 0x00001300, 62 | 'user_row_size_bytes': 0x20, 63 | 'user_row_page_size_bytes': 0x20, 64 | 'user_row_read_size_bytes': 1, 65 | 'user_row_write_size_bytes': 1, 66 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 67 | 'user_row_isolated_erase': True, 68 | 69 | # flash 70 | 'flash_address_byte': 0x00008000, 71 | 'flash_size_bytes': 0x1000, 72 | 'flash_page_size_bytes': 0x40, 73 | 'flash_read_size_bytes': 2, 74 | 'flash_write_size_bytes': 0x40, 75 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 76 | 'flash_isolated_erase': True, 77 | 78 | # Some extra AVR specific fields 79 | 'nvmctrl_base': 0x00001000, 80 | 'syscfg_base': 0x00000F00, 81 | 'ocd_base': 0x00000F80, 82 | 'prog_clock_khz': 900, 83 | 'interface': 'UPDI', 84 | 'address_size': '16-bit', 85 | 'device_id': 0x1E922A, 86 | } 87 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny824.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny824 devices 4 | The following data would normally have been collected from device packs. 5 | But since Microchip hasn't done this, and his users were complaining, 6 | it was deduced from device packs by Spence Konde. 7 | """ 8 | 9 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 10 | 11 | DEVICE_INFO = { 12 | 'name': 'attiny824', 13 | 'architecture': 'avr8x', 14 | 15 | # eeprom 16 | 'eeprom_address_byte': 0x00001400, 17 | 'eeprom_size_bytes': 0x0080, 18 | 'eeprom_page_size_bytes': 0x20, 19 | 'eeprom_read_size_bytes': 1, 20 | 'eeprom_write_size_bytes': 1, 21 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 22 | 'eeprom_isolated_erase': True, 23 | 24 | # fuses 25 | 'fuses_address_byte': 0x00001280, 26 | 'fuses_size_bytes': 0xA, 27 | 'fuses_page_size_bytes': 1, 28 | 'fuses_read_size_bytes': 1, 29 | 'fuses_write_size_bytes': 1, 30 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 31 | 'fuses_isolated_erase': False, 32 | 33 | # internal_sram 34 | 'internal_sram_address_byte': 0x3c00, 35 | 'internal_sram_size_bytes': 0x0400, 36 | 'internal_sram_page_size_bytes': 1, 37 | 'internal_sram_read_size_bytes': 1, 38 | 'internal_sram_write_size_bytes': 1, 39 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 40 | 'internal_sram_isolated_erase': False, 41 | 42 | # lockbits 43 | 'lockbits_address_byte': 0x0000128A, 44 | 'lockbits_size_bytes': 0x1, 45 | 'lockbits_page_size_bytes': 1, 46 | 'lockbits_read_size_bytes': 1, 47 | 'lockbits_write_size_bytes': 1, 48 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 49 | 'lockbits_isolated_erase': False, 50 | 51 | # signatures 52 | 'signatures_address_byte': 0x00001100, 53 | 'signatures_size_bytes': 0x3, 54 | 'signatures_page_size_bytes': 0x40, 55 | 'signatures_read_size_bytes': 1, 56 | 'signatures_write_size_bytes': 0, 57 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 58 | 'signatures_isolated_erase': False, 59 | 60 | # user_row 61 | 'user_row_address_byte': 0x00001300, 62 | 'user_row_size_bytes': 0x20, 63 | 'user_row_page_size_bytes': 0x20, 64 | 'user_row_read_size_bytes': 1, 65 | 'user_row_write_size_bytes': 1, 66 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 67 | 'user_row_isolated_erase': True, 68 | 69 | # flash 70 | 'flash_address_byte': 0x00008000, 71 | 'flash_size_bytes': 0x2000, 72 | 'flash_page_size_bytes': 0x40, 73 | 'flash_read_size_bytes': 2, 74 | 'flash_write_size_bytes': 0x40, 75 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 76 | 'flash_isolated_erase': True, 77 | 78 | # Some extra AVR specific fields 79 | 'nvmctrl_base': 0x00001000, 80 | 'syscfg_base': 0x00000F00, 81 | 'ocd_base': 0x00000F80, 82 | 'prog_clock_khz': 900, 83 | 'interface': 'UPDI', 84 | 'address_size': '16-bit', 85 | 'device_id': 0x1E9329, 86 | } 87 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny826.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny826 devices 4 | The following data would normally have been collected from device packs. 5 | But since Microchip hasn't done this, and his users were complaining, 6 | it was deduced from device packs by Spence Konde. 7 | """ 8 | 9 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 10 | 11 | DEVICE_INFO = { 12 | 'name': 'attiny826', 13 | 'architecture': 'avr8x', 14 | 15 | # eeprom 16 | 'eeprom_address_byte': 0x00001400, 17 | 'eeprom_size_bytes': 0x0080, 18 | 'eeprom_page_size_bytes': 0x20, 19 | 'eeprom_read_size_bytes': 1, 20 | 'eeprom_write_size_bytes': 1, 21 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 22 | 'eeprom_isolated_erase': True, 23 | 24 | # fuses 25 | 'fuses_address_byte': 0x00001280, 26 | 'fuses_size_bytes': 0xA, 27 | 'fuses_page_size_bytes': 1, 28 | 'fuses_read_size_bytes': 1, 29 | 'fuses_write_size_bytes': 1, 30 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 31 | 'fuses_isolated_erase': False, 32 | 33 | # internal_sram 34 | 'internal_sram_address_byte': 0x3c00, 35 | 'internal_sram_size_bytes': 0x0400, 36 | 'internal_sram_page_size_bytes': 1, 37 | 'internal_sram_read_size_bytes': 1, 38 | 'internal_sram_write_size_bytes': 1, 39 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 40 | 'internal_sram_isolated_erase': False, 41 | 42 | # lockbits 43 | 'lockbits_address_byte': 0x0000128A, 44 | 'lockbits_size_bytes': 0x1, 45 | 'lockbits_page_size_bytes': 1, 46 | 'lockbits_read_size_bytes': 1, 47 | 'lockbits_write_size_bytes': 1, 48 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 49 | 'lockbits_isolated_erase': False, 50 | 51 | # signatures 52 | 'signatures_address_byte': 0x00001100, 53 | 'signatures_size_bytes': 0x3, 54 | 'signatures_page_size_bytes': 0x40, 55 | 'signatures_read_size_bytes': 1, 56 | 'signatures_write_size_bytes': 0, 57 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 58 | 'signatures_isolated_erase': False, 59 | 60 | # user_row 61 | 'user_row_address_byte': 0x00001300, 62 | 'user_row_size_bytes': 0x20, 63 | 'user_row_page_size_bytes': 0x20, 64 | 'user_row_read_size_bytes': 1, 65 | 'user_row_write_size_bytes': 1, 66 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 67 | 'user_row_isolated_erase': True, 68 | 69 | # flash 70 | 'flash_address_byte': 0x00008000, 71 | 'flash_size_bytes': 0x2000, 72 | 'flash_page_size_bytes': 0x40, 73 | 'flash_read_size_bytes': 2, 74 | 'flash_write_size_bytes': 0x40, 75 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 76 | 'flash_isolated_erase': True, 77 | 78 | # Some extra AVR specific fields 79 | 'nvmctrl_base': 0x00001000, 80 | 'syscfg_base': 0x00000F00, 81 | 'ocd_base': 0x00000F80, 82 | 'prog_clock_khz': 900, 83 | 'interface': 'UPDI', 84 | 'address_size': '16-bit', 85 | 'device_id': 0x1E9328, 86 | } 87 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/deviceinfo/devices/attiny827.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Required device info for the attiny827 devices 4 | The following data would normally have been collected from device packs. 5 | But since Microchip hasn't done this, and his users were complaining, 6 | it was deduced from device packs by Spence Konde. 7 | """ 8 | 9 | from pymcuprog.deviceinfo.eraseflags import ChiperaseEffect 10 | 11 | DEVICE_INFO = { 12 | 'name': 'attiny827', 13 | 'architecture': 'avr8x', 14 | 15 | # eeprom 16 | 'eeprom_address_byte': 0x00001400, 17 | 'eeprom_size_bytes': 0x0080, 18 | 'eeprom_page_size_bytes': 0x20, 19 | 'eeprom_read_size_bytes': 1, 20 | 'eeprom_write_size_bytes': 1, 21 | 'eeprom_chiperase_effect': ChiperaseEffect.CONDITIONALLY_ERASED_AVR, 22 | 'eeprom_isolated_erase': True, 23 | 24 | # fuses 25 | 'fuses_address_byte': 0x00001280, 26 | 'fuses_size_bytes': 0xA, 27 | 'fuses_page_size_bytes': 1, 28 | 'fuses_read_size_bytes': 1, 29 | 'fuses_write_size_bytes': 1, 30 | 'fuses_chiperase_effect': ChiperaseEffect.NOT_ERASED, 31 | 'fuses_isolated_erase': False, 32 | 33 | # internal_sram 34 | 'internal_sram_address_byte': 0x3c00, 35 | 'internal_sram_size_bytes': 0x0400, 36 | 'internal_sram_page_size_bytes': 1, 37 | 'internal_sram_read_size_bytes': 1, 38 | 'internal_sram_write_size_bytes': 1, 39 | 'internal_sram_chiperase_effect': ChiperaseEffect.NOT_ERASED, 40 | 'internal_sram_isolated_erase': False, 41 | 42 | # lockbits 43 | 'lockbits_address_byte': 0x0000128A, 44 | 'lockbits_size_bytes': 0x1, 45 | 'lockbits_page_size_bytes': 1, 46 | 'lockbits_read_size_bytes': 1, 47 | 'lockbits_write_size_bytes': 1, 48 | 'lockbits_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 49 | 'lockbits_isolated_erase': False, 50 | 51 | # signatures 52 | 'signatures_address_byte': 0x00001100, 53 | 'signatures_size_bytes': 0x3, 54 | 'signatures_page_size_bytes': 0x40, 55 | 'signatures_read_size_bytes': 1, 56 | 'signatures_write_size_bytes': 0, 57 | 'signatures_chiperase_effect': ChiperaseEffect.NOT_ERASED, 58 | 'signatures_isolated_erase': False, 59 | 60 | # user_row 61 | 'user_row_address_byte': 0x00001300, 62 | 'user_row_size_bytes': 0x20, 63 | 'user_row_page_size_bytes': 0x20, 64 | 'user_row_read_size_bytes': 1, 65 | 'user_row_write_size_bytes': 1, 66 | 'user_row_chiperase_effect': ChiperaseEffect.NOT_ERASED, 67 | 'user_row_isolated_erase': True, 68 | 69 | # flash 70 | 'flash_address_byte': 0x00008000, 71 | 'flash_size_bytes': 0x2000, 72 | 'flash_page_size_bytes': 0x40, 73 | 'flash_read_size_bytes': 2, 74 | 'flash_write_size_bytes': 0x40, 75 | 'flash_chiperase_effect': ChiperaseEffect.ALWAYS_ERASED, 76 | 'flash_isolated_erase': True, 77 | 78 | # Some extra AVR specific fields 79 | 'nvmctrl_base': 0x00001000, 80 | 'syscfg_base': 0x00000F00, 81 | 'ocd_base': 0x00000F80, 82 | 'prog_clock_khz': 900, 83 | 'interface': 'UPDI', 84 | 'address_size': '16-bit', 85 | 'device_id': 0x1E9327, 86 | } 87 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/yaml/tokens.py: -------------------------------------------------------------------------------- 1 | 2 | class Token(object): 3 | def __init__(self, start_mark, end_mark): 4 | self.start_mark = start_mark 5 | self.end_mark = end_mark 6 | def __repr__(self): 7 | attributes = [key for key in self.__dict__ 8 | if not key.endswith('_mark')] 9 | attributes.sort() 10 | arguments = ', '.join(['%s=%r' % (key, getattr(self, key)) 11 | for key in attributes]) 12 | return '%s(%s)' % (self.__class__.__name__, arguments) 13 | 14 | #class BOMToken(Token): 15 | # id = '' 16 | 17 | class DirectiveToken(Token): 18 | id = '' 19 | def __init__(self, name, value, start_mark, end_mark): 20 | self.name = name 21 | self.value = value 22 | self.start_mark = start_mark 23 | self.end_mark = end_mark 24 | 25 | class DocumentStartToken(Token): 26 | id = '' 27 | 28 | class DocumentEndToken(Token): 29 | id = '' 30 | 31 | class StreamStartToken(Token): 32 | id = '' 33 | def __init__(self, start_mark=None, end_mark=None, 34 | encoding=None): 35 | self.start_mark = start_mark 36 | self.end_mark = end_mark 37 | self.encoding = encoding 38 | 39 | class StreamEndToken(Token): 40 | id = '' 41 | 42 | class BlockSequenceStartToken(Token): 43 | id = '' 44 | 45 | class BlockMappingStartToken(Token): 46 | id = '' 47 | 48 | class BlockEndToken(Token): 49 | id = '' 50 | 51 | class FlowSequenceStartToken(Token): 52 | id = '[' 53 | 54 | class FlowMappingStartToken(Token): 55 | id = '{' 56 | 57 | class FlowSequenceEndToken(Token): 58 | id = ']' 59 | 60 | class FlowMappingEndToken(Token): 61 | id = '}' 62 | 63 | class KeyToken(Token): 64 | id = '?' 65 | 66 | class ValueToken(Token): 67 | id = ':' 68 | 69 | class BlockEntryToken(Token): 70 | id = '-' 71 | 72 | class FlowEntryToken(Token): 73 | id = ',' 74 | 75 | class AliasToken(Token): 76 | id = '' 77 | def __init__(self, value, start_mark, end_mark): 78 | self.value = value 79 | self.start_mark = start_mark 80 | self.end_mark = end_mark 81 | 82 | class AnchorToken(Token): 83 | id = '' 84 | def __init__(self, value, start_mark, end_mark): 85 | self.value = value 86 | self.start_mark = start_mark 87 | self.end_mark = end_mark 88 | 89 | class TagToken(Token): 90 | id = '' 91 | def __init__(self, value, start_mark, end_mark): 92 | self.value = value 93 | self.start_mark = start_mark 94 | self.end_mark = end_mark 95 | 96 | class ScalarToken(Token): 97 | id = '' 98 | def __init__(self, value, plain, start_mark, end_mark, style=None): 99 | self.value = value 100 | self.plain = plain 101 | self.start_mark = start_mark 102 | self.end_mark = end_mark 103 | self.style = style 104 | 105 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/serial/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # This is a wrapper module for different platform implementations 4 | # 5 | # This file is part of pySerial. https://github.com/pyserial/pyserial 6 | # (C) 2001-2017 Chris Liechti 7 | # 8 | # SPDX-License-Identifier: BSD-3-Clause 9 | 10 | import sys 11 | import importlib 12 | 13 | from serial.serialutil import * 14 | #~ SerialBase, SerialException, to_bytes, iterbytes 15 | 16 | __version__ = '3.4' 17 | 18 | VERSION = __version__ 19 | 20 | # pylint: disable=wrong-import-position 21 | if sys.platform == 'cli': 22 | from serial.serialcli import Serial 23 | else: 24 | import os 25 | # chose an implementation, depending on os 26 | if os.name == 'nt': # sys.platform == 'win32': 27 | from serial.serialwin32 import Serial 28 | elif os.name == 'posix': 29 | from serial.serialposix import Serial, PosixPollSerial, VTIMESerial # noqa 30 | elif os.name == 'java': 31 | from serial.serialjava import Serial 32 | else: 33 | raise ImportError("Sorry: no implementation for your platform ('{}') available".format(os.name)) 34 | 35 | 36 | protocol_handler_packages = [ 37 | 'serial.urlhandler', 38 | ] 39 | 40 | 41 | def serial_for_url(url, *args, **kwargs): 42 | """\ 43 | Get an instance of the Serial class, depending on port/url. The port is not 44 | opened when the keyword parameter 'do_not_open' is true, by default it 45 | is. All other parameters are directly passed to the __init__ method when 46 | the port is instantiated. 47 | 48 | The list of package names that is searched for protocol handlers is kept in 49 | ``protocol_handler_packages``. 50 | 51 | e.g. we want to support a URL ``foobar://``. A module 52 | ``my_handlers.protocol_foobar`` is provided by the user. Then 53 | ``protocol_handler_packages.append("my_handlers")`` would extend the search 54 | path so that ``serial_for_url("foobar://"))`` would work. 55 | """ 56 | # check and remove extra parameter to not confuse the Serial class 57 | do_open = not kwargs.pop('do_not_open', False) 58 | # the default is to use the native implementation 59 | klass = Serial 60 | try: 61 | url_lowercase = url.lower() 62 | except AttributeError: 63 | # it's not a string, use default 64 | pass 65 | else: 66 | # if it is an URL, try to import the handler module from the list of possible packages 67 | if '://' in url_lowercase: 68 | protocol = url_lowercase.split('://', 1)[0] 69 | module_name = '.protocol_{}'.format(protocol) 70 | for package_name in protocol_handler_packages: 71 | try: 72 | importlib.import_module(package_name) 73 | handler_module = importlib.import_module(module_name, package_name) 74 | except ImportError: 75 | continue 76 | else: 77 | if hasattr(handler_module, 'serial_class_for_url'): 78 | url, klass = handler_module.serial_class_for_url(url) 79 | else: 80 | klass = handler_module.Serial 81 | break 82 | else: 83 | raise ValueError('invalid URL, protocol {!r} not known'.format(protocol)) 84 | # instantiate and open when desired 85 | instance = klass(None, *args, **kwargs) 86 | instance.port = url 87 | if do_open: 88 | instance.open() 89 | return instance 90 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/yaml/cyaml.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = ['CBaseLoader', 'CSafeLoader', 'CLoader', 3 | 'CBaseDumper', 'CSafeDumper', 'CDumper'] 4 | 5 | from _yaml import CParser, CEmitter 6 | 7 | from .constructor import * 8 | 9 | from .serializer import * 10 | from .representer import * 11 | 12 | from .resolver import * 13 | 14 | class CBaseLoader(CParser, BaseConstructor, BaseResolver): 15 | 16 | def __init__(self, stream): 17 | CParser.__init__(self, stream) 18 | BaseConstructor.__init__(self) 19 | BaseResolver.__init__(self) 20 | 21 | class CSafeLoader(CParser, SafeConstructor, Resolver): 22 | 23 | def __init__(self, stream): 24 | CParser.__init__(self, stream) 25 | SafeConstructor.__init__(self) 26 | Resolver.__init__(self) 27 | 28 | class CLoader(CParser, Constructor, Resolver): 29 | 30 | def __init__(self, stream): 31 | CParser.__init__(self, stream) 32 | Constructor.__init__(self) 33 | Resolver.__init__(self) 34 | 35 | class CBaseDumper(CEmitter, BaseRepresenter, BaseResolver): 36 | 37 | def __init__(self, stream, 38 | default_style=None, default_flow_style=None, 39 | canonical=None, indent=None, width=None, 40 | allow_unicode=None, line_break=None, 41 | encoding=None, explicit_start=None, explicit_end=None, 42 | version=None, tags=None): 43 | CEmitter.__init__(self, stream, canonical=canonical, 44 | indent=indent, width=width, encoding=encoding, 45 | allow_unicode=allow_unicode, line_break=line_break, 46 | explicit_start=explicit_start, explicit_end=explicit_end, 47 | version=version, tags=tags) 48 | Representer.__init__(self, default_style=default_style, 49 | default_flow_style=default_flow_style) 50 | Resolver.__init__(self) 51 | 52 | class CSafeDumper(CEmitter, SafeRepresenter, Resolver): 53 | 54 | def __init__(self, stream, 55 | default_style=None, default_flow_style=None, 56 | canonical=None, indent=None, width=None, 57 | allow_unicode=None, line_break=None, 58 | encoding=None, explicit_start=None, explicit_end=None, 59 | version=None, tags=None): 60 | CEmitter.__init__(self, stream, canonical=canonical, 61 | indent=indent, width=width, encoding=encoding, 62 | allow_unicode=allow_unicode, line_break=line_break, 63 | explicit_start=explicit_start, explicit_end=explicit_end, 64 | version=version, tags=tags) 65 | SafeRepresenter.__init__(self, default_style=default_style, 66 | default_flow_style=default_flow_style) 67 | Resolver.__init__(self) 68 | 69 | class CDumper(CEmitter, Serializer, Representer, Resolver): 70 | 71 | def __init__(self, stream, 72 | default_style=None, default_flow_style=None, 73 | canonical=None, indent=None, width=None, 74 | allow_unicode=None, line_break=None, 75 | encoding=None, explicit_start=None, explicit_end=None, 76 | version=None, tags=None): 77 | CEmitter.__init__(self, stream, canonical=canonical, 78 | indent=indent, width=width, encoding=encoding, 79 | allow_unicode=allow_unicode, line_break=line_break, 80 | explicit_start=explicit_start, explicit_end=explicit_end, 81 | version=version, tags=tags) 82 | Representer.__init__(self, default_style=default_style, 83 | default_flow_style=default_flow_style) 84 | Resolver.__init__(self) 85 | 86 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/serial/rs485.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # RS485 support 4 | # 5 | # This file is part of pySerial. https://github.com/pyserial/pyserial 6 | # (C) 2015 Chris Liechti 7 | # 8 | # SPDX-License-Identifier: BSD-3-Clause 9 | 10 | """\ 11 | The settings for RS485 are stored in a dedicated object that can be applied to 12 | serial ports (where supported). 13 | NOTE: Some implementations may only support a subset of the settings. 14 | """ 15 | 16 | import time 17 | import serial 18 | 19 | 20 | class RS485Settings(object): 21 | def __init__( 22 | self, 23 | rts_level_for_tx=True, 24 | rts_level_for_rx=False, 25 | loopback=False, 26 | delay_before_tx=None, 27 | delay_before_rx=None): 28 | self.rts_level_for_tx = rts_level_for_tx 29 | self.rts_level_for_rx = rts_level_for_rx 30 | self.loopback = loopback 31 | self.delay_before_tx = delay_before_tx 32 | self.delay_before_rx = delay_before_rx 33 | 34 | 35 | class RS485(serial.Serial): 36 | """\ 37 | A subclass that replaces the write method with one that toggles RTS 38 | according to the RS485 settings. 39 | 40 | NOTE: This may work unreliably on some serial ports (control signals not 41 | synchronized or delayed compared to data). Using delays may be 42 | unreliable (varying times, larger than expected) as the OS may not 43 | support very fine grained delays (no smaller than in the order of 44 | tens of milliseconds). 45 | 46 | NOTE: Some implementations support this natively. Better performance 47 | can be expected when the native version is used. 48 | 49 | NOTE: The loopback property is ignored by this implementation. The actual 50 | behavior depends on the used hardware. 51 | 52 | Usage: 53 | 54 | ser = RS485(...) 55 | ser.rs485_mode = RS485Settings(...) 56 | ser.write(b'hello') 57 | """ 58 | 59 | def __init__(self, *args, **kwargs): 60 | super(RS485, self).__init__(*args, **kwargs) 61 | self._alternate_rs485_settings = None 62 | 63 | def write(self, b): 64 | """Write to port, controlling RTS before and after transmitting.""" 65 | if self._alternate_rs485_settings is not None: 66 | # apply level for TX and optional delay 67 | self.setRTS(self._alternate_rs485_settings.rts_level_for_tx) 68 | if self._alternate_rs485_settings.delay_before_tx is not None: 69 | time.sleep(self._alternate_rs485_settings.delay_before_tx) 70 | # write and wait for data to be written 71 | super(RS485, self).write(b) 72 | super(RS485, self).flush() 73 | # optional delay and apply level for RX 74 | if self._alternate_rs485_settings.delay_before_rx is not None: 75 | time.sleep(self._alternate_rs485_settings.delay_before_rx) 76 | self.setRTS(self._alternate_rs485_settings.rts_level_for_rx) 77 | else: 78 | super(RS485, self).write(b) 79 | 80 | # redirect where the property stores the settings so that underlying Serial 81 | # instance does not see them 82 | @property 83 | def rs485_mode(self): 84 | """\ 85 | Enable RS485 mode and apply new settings, set to None to disable. 86 | See serial.rs485.RS485Settings for more info about the value. 87 | """ 88 | return self._alternate_rs485_settings 89 | 90 | @rs485_mode.setter 91 | def rs485_mode(self, rs485_settings): 92 | self._alternate_rs485_settings = rs485_settings 93 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Python MCU programmer utility 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | pymcuprog is a utility for programming various Microchip MCU devices using Microchip CMSIS-DAP based debuggers 6 | 7 | pymcuprog can be used as a library using its "backend API". For example: 8 | 9 | Setup logging - pymcuprog uses the Python logging module 10 | >>> import logging 11 | >>> logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING) 12 | 13 | Configure the session: 14 | >>> from pymcuprog.backend import SessionConfig 15 | >>> sessionconfig = SessionConfig("atmega4808") 16 | 17 | Instantiate USB transport (only 1 tool connected) 18 | >>> from pymcuprog.toolconnection import ToolUsbHidConnection 19 | >>> transport = ToolUsbHidConnection() 20 | 21 | Instantiate backend 22 | >>> from pymcuprog.backend import Backend 23 | >>> backend = Backend() 24 | 25 | Connect to tool using transport 26 | >>> backend.connect_to_tool(transport) 27 | 28 | Start the session 29 | >>> backend.start_session(sessionconfig) 30 | 31 | Read the target device_id 32 | >>> device_id = backend.read_device_id() 33 | >>> print ("Device ID is {0:06X}".format(int.from_bytes(d, byteorder="little"))) 34 | 35 | Print the pymcuprog package version: 36 | >>> from pymcuprog.version import VERSION as pymcuprog_version 37 | >>> print("pymcuprog version {}".format(pymcuprog_version)) 38 | 39 | In addition, the CLI-backend API is versioned for convenience: 40 | >>> print("pymcuprog backend API version: {}".format(backend.get_api_version())) 41 | 42 | Logging 43 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 44 | This package uses the Python logging module for publishing log messages to library users. 45 | A basic configuration can be used (see example), but for best results a more thorough configuration is 46 | recommended in order to control the verbosity of output from dependencies in the stack which also use logging. 47 | See logging.yaml which is included in the package (although only used for CLI) 48 | 49 | Dependencies 50 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 51 | pymcuprog depends on pyedbglib for its transport protocol. 52 | pyedbglib requires a USB transport library like libusb. See pyedbglib package for more information. 53 | 54 | Supported devices and tools 55 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 56 | Note: pymcuprog is primarily intended for use with PKOB nano (nEDBG) debuggers which 57 | are found on Curiosity Nano kits and other development boards. This means that it is 58 | continuously tested with a selection of AVR devices with UPDI interface as well as a 59 | selection of PIC devices. However since the protocol is compatible between all 60 | EDBG-based debuggers (pyedbglib) it is possible to use pymcuprog with a wide range of 61 | debuggers and devices, although not all device families/interfaces have been implemented. 62 | 63 | The following Atmel/Microchip debuggers are supported: 64 | * JTAGICE3 (only firmware version 3.x) 65 | * Atmel-ICE 66 | * Power Debugger 67 | * EDBG 68 | * mEDBG 69 | * PKOB nano (nEDBG) 70 | * MPLAB PICkit 4 ICD (only when in 'AVR mode') 71 | * MPLAB Snap ICD (only when in 'AVR mode') 72 | 73 | Not all functionality is provided on all boards. See device support below. 74 | 75 | The following device-types are supported: 76 | * All UPDI devices, whether mounted on kits or standalone 77 | * PIC devices mounted on Curiosity Nano kits, or similar board with PKOB nano (nEDBG) debugger 78 | * Other devices (eg ATmega328P, ATsamd21e18a) may be partially supported for experimental purposes 79 | """ 80 | import logging 81 | logging.getLogger(__name__).addHandler(logging.NullHandler()) 82 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pyedbglib/hidtransport/toolinfo.py: -------------------------------------------------------------------------------- 1 | """Gathering of all known Microchip CMSIS-DAP debuggers and default EP sizes""" 2 | 3 | from logging import getLogger 4 | 5 | # List of known useful HID/CMSIS-DAP tools 6 | # 3G tools: 7 | USB_TOOL_DEVICE_PRODUCT_ID_JTAGICE3 = 0x2140 8 | USB_TOOL_DEVICE_PRODUCT_ID_ATMELICE = 0x2141 9 | USB_TOOL_DEVICE_PRODUCT_ID_POWERDEBUGGER = 0x2144 10 | USB_TOOL_DEVICE_PRODUCT_ID_EDBG_A = 0x2111 11 | USB_TOOL_DEVICE_PRODUCT_ID_ZERO = 0x2157 12 | USB_TOOL_DEVICE_PRODUCT_ID_MASS_STORAGE = 0x2169 13 | USB_TOOL_DEVICE_PRODUCT_ID_PUBLIC_EDBG_C = 0x216A 14 | USB_TOOL_DEVICE_PRODUCT_ID_KRAKEN = 0x2170 15 | 16 | # 4G tools: 17 | USB_TOOL_DEVICE_PRODUCT_ID_MEDBG = 0x2145 18 | 19 | # 5G tools: 20 | USB_TOOL_DEVICE_PRODUCT_ID_NEDBG_HID_MSD_DGI_CDC = 0x2175 21 | USB_TOOL_DEVICE_PRODUCT_ID_PICKIT4_HID_CDC = 0x2177 22 | USB_TOOL_DEVICE_PRODUCT_ID_SNAP_HID_CDC = 0x2180 23 | 24 | # The Product String Names are used to identify the tool based on the USB 25 | # device product strings (i.e. these names are usually just a subset of the 26 | # actual product strings) 27 | TOOL_SHORTNAME_TO_USB_PRODUCT_STRING = { 28 | 'atmelice': "Atmel-ICE", 29 | 'powerdebugger': "Power Debugger", 30 | 'pickit4': "MPLAB PICkit 4", 31 | 'snap': "MPLAB Snap", 32 | 'nedbg': "nEDBG", 33 | 'jtagice3': "JTAGICE3", 34 | 'medbg': "mEDBG", 35 | 'edbg': "EDBG", 36 | } 37 | 38 | def get_default_report_size(pid): 39 | """ 40 | Retrieve default EP report size based on known PIDs 41 | 42 | :param pid: product ID 43 | :return: packet size 44 | """ 45 | logger = getLogger(__name__) 46 | hid_tools = [ 47 | # 3G 48 | {'pid': USB_TOOL_DEVICE_PRODUCT_ID_JTAGICE3, 'default_report_size': 512}, 49 | {'pid': USB_TOOL_DEVICE_PRODUCT_ID_ATMELICE, 'default_report_size': 512}, 50 | {'pid': USB_TOOL_DEVICE_PRODUCT_ID_POWERDEBUGGER, 'default_report_size': 512}, 51 | {'pid': USB_TOOL_DEVICE_PRODUCT_ID_EDBG_A, 'default_report_size': 512}, 52 | # 4G 53 | {'pid': USB_TOOL_DEVICE_PRODUCT_ID_MEDBG, 'default_report_size': 64}, 54 | # 5G 55 | {'pid': USB_TOOL_DEVICE_PRODUCT_ID_NEDBG_HID_MSD_DGI_CDC, 'default_report_size': 64}, 56 | {'pid': USB_TOOL_DEVICE_PRODUCT_ID_PICKIT4_HID_CDC, 'default_report_size': 64}, 57 | {'pid': USB_TOOL_DEVICE_PRODUCT_ID_SNAP_HID_CDC, 'default_report_size': 64}] 58 | 59 | logger.debug("Looking up report size for pid 0x{:04X}".format(pid)) 60 | for tool in hid_tools: 61 | if tool['pid'] == pid: 62 | logger.debug("Default report size is {:d}".format(tool['default_report_size'])) 63 | return tool['default_report_size'] 64 | logger.debug("PID not found! Reverting to 64b.") 65 | return 64 66 | 67 | def tool_shortname_to_product_string_name(shortname): 68 | """ 69 | Mapping for common short names of tools to product string name 70 | 71 | The intention is that this function is always run on the tool name and that the conversion 72 | only happens if the name is a known shortname. If the shortname is not known of if the name 73 | provided is already a valid Product string name then the provided shortname parameter will 74 | just be returned unchanged. So if the name already is a correct Product string name it is 75 | still safe to run this conversion funtion on it. 76 | 77 | :param shortname: shortname typically used by atbackend (powerdebugger, atmelice etc.) 78 | :return: String to look for in USB product strings to identify the tool 79 | """ 80 | logger = getLogger(__name__) 81 | 82 | if shortname is None: 83 | logger.debug("Tool shortname is None") 84 | # This is also valid as the user might have provided no tool name, but the conversion function 85 | # should still be valid 86 | return shortname 87 | 88 | shortname_lower = shortname.lower() 89 | if shortname_lower not in TOOL_SHORTNAME_TO_USB_PRODUCT_STRING: 90 | logger.debug("%s is not a known tool shortname", shortname) 91 | # ...but it could be a valid Product string name already so no reason to report an error 92 | return shortname 93 | 94 | return TOOL_SHORTNAME_TO_USB_PRODUCT_STRING[shortname_lower] 95 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/serial/aio.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Python Serial Port Extension for Win32, Linux, BSD, Jython 4 | # module for serial IO for POSIX compatible systems, like Linux 5 | # see __init__.py 6 | # 7 | # (C) 2015 Chris Liechti 8 | # 9 | # SPDX-License-Identifier: BSD-3-Clause 10 | """\ 11 | Support asyncio with serial ports. EXPERIMENTAL 12 | 13 | Posix platforms only, Python 3.4+ only. 14 | 15 | Windows event loops can not wait for serial ports with the current 16 | implementation. It should be possible to get that working though. 17 | """ 18 | import asyncio 19 | import serial 20 | import logger 21 | 22 | 23 | class SerialTransport(asyncio.Transport): 24 | def __init__(self, loop, protocol, serial_instance): 25 | self._loop = loop 26 | self._protocol = protocol 27 | self.serial = serial_instance 28 | self._closing = False 29 | self._paused = False 30 | # XXX how to support url handlers too 31 | self.serial.timeout = 0 32 | self.serial.nonblocking() 33 | loop.call_soon(protocol.connection_made, self) 34 | # only start reading when connection_made() has been called 35 | loop.call_soon(loop.add_reader, self.serial.fd, self._read_ready) 36 | 37 | def __repr__(self): 38 | return '{self.__class__.__name__}({self._loop}, {self._protocol}, {self.serial})'.format(self=self) 39 | 40 | def close(self): 41 | if self._closing: 42 | return 43 | self._closing = True 44 | self._loop.remove_reader(self.serial.fd) 45 | self.serial.close() 46 | self._loop.call_soon(self._protocol.connection_lost, None) 47 | 48 | def _read_ready(self): 49 | data = self.serial.read(1024) 50 | if data: 51 | self._protocol.data_received(data) 52 | 53 | def write(self, data): 54 | self.serial.write(data) 55 | 56 | def can_write_eof(self): 57 | return False 58 | 59 | def pause_reading(self): 60 | if self._closing: 61 | raise RuntimeError('Cannot pause_reading() when closing') 62 | if self._paused: 63 | raise RuntimeError('Already paused') 64 | self._paused = True 65 | self._loop.remove_reader(self._sock_fd) 66 | if self._loop.get_debug(): 67 | logger.debug("%r pauses reading", self) 68 | 69 | def resume_reading(self): 70 | if not self._paused: 71 | raise RuntimeError('Not paused') 72 | self._paused = False 73 | if self._closing: 74 | return 75 | self._loop.add_reader(self._sock_fd, self._read_ready) 76 | if self._loop.get_debug(): 77 | logger.debug("%r resumes reading", self) 78 | 79 | #~ def set_write_buffer_limits(self, high=None, low=None): 80 | #~ def get_write_buffer_size(self): 81 | #~ def writelines(self, list_of_data): 82 | #~ def write_eof(self): 83 | #~ def abort(self): 84 | 85 | 86 | @asyncio.coroutine 87 | def create_serial_connection(loop, protocol_factory, *args, **kwargs): 88 | ser = serial.Serial(*args, **kwargs) 89 | protocol = protocol_factory() 90 | transport = SerialTransport(loop, protocol, ser) 91 | return (transport, protocol) 92 | 93 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 94 | # test 95 | if __name__ == '__main__': 96 | class Output(asyncio.Protocol): 97 | def connection_made(self, transport): 98 | self.transport = transport 99 | print('port opened', transport) 100 | transport.serial.rts = False 101 | transport.write(b'hello world\n') 102 | 103 | def data_received(self, data): 104 | print('data received', repr(data)) 105 | self.transport.close() 106 | 107 | def connection_lost(self, exc): 108 | print('port closed') 109 | asyncio.get_event_loop().stop() 110 | 111 | loop = asyncio.get_event_loop() 112 | coro = create_serial_connection(loop, Output, '/dev/ttyUSB0', baudrate=115200) 113 | loop.run_until_complete(coro) 114 | loop.run_forever() 115 | loop.close() 116 | -------------------------------------------------------------------------------- /software/makefile: -------------------------------------------------------------------------------- 1 | # =================================================================================== 2 | # Project: PocketRadio 3 | # Author: Stefan Wagner 4 | # Year: 2022 5 | # URL: https://github.com/wagiminator 6 | # =================================================================================== 7 | # Type "make help" in the command line. 8 | # =================================================================================== 9 | 10 | # Input and Output File Names 11 | SKETCH = PocketRadio.ino 12 | TARGET = pocketradio 13 | 14 | # Microcontroller Settings 15 | DEVICE ?= attiny412 16 | CLOCK = 1000000 17 | FUSE0 = 0x00 18 | FUSE1 = 0x00 19 | FUSE2 = 0x01 20 | FUSE4 = 0x00 21 | FUSE5 = 0xC5 22 | FUSE6 = 0x04 23 | FUSE7 = 0x00 24 | FUSE8 = 0x00 25 | 26 | # Programmer Settings 27 | PROGRMR ?= serialupdi 28 | PORT ?= /dev/ttyUSB0 29 | 30 | # Toolchain 31 | CC = avr-gcc 32 | OBJCOPY = avr-objcopy 33 | OBJDUMP = avr-objdump 34 | AVRSIZE = avr-size 35 | PYPROG = python3 -u ./tools/pymcuprog/prog.py -t uart -u $(PORT) -b 230400 -d $(DEVICE) 36 | AVRDUDE = avrdude -C ./tools/avrdude/avrdude.conf -c $(PROGRMR) -P $(PORT) -p $(DEVICE) 37 | CLEAN = rm -f *.lst *.obj *.cof *.list *.map *.eep.hex *.o *.s *.d 38 | 39 | # Compiler Flags 40 | CFLAGS = -w -flto -Os -mmcu=$(DEVICE) -DF_CPU=$(CLOCK) -x c++ 41 | CFLAGS += -B include/dev/$(DEVICE) -I include 42 | 43 | # Symbolic Targets 44 | help: 45 | @echo "Use the following commands:" 46 | @echo "make all compile and build $(TARGET).elf/.bin/.hex/.asm for $(DEVICE)" 47 | @echo "make hex compile and build $(TARGET).hex for $(DEVICE)" 48 | @echo "make asm compile and disassemble to $(TARGET).asm for $(DEVICE)" 49 | @echo "make bin compile and build $(TARGET).bin for $(DEVICE)" 50 | @echo "make upload compile and upload to $(DEVICE) using $(PROGRMR)" 51 | @echo "make fuses burn fuses of $(DEVICE) using $(PROGRMR) programmer" 52 | @echo "make install compile, upload and burn fuses for $(DEVICE)" 53 | @echo "make clean remove all build files" 54 | 55 | all: buildelf buildbin buildhex buildasm removetemp size 56 | 57 | elf: buildelf removetemp size 58 | 59 | bin: buildelf buildbin removetemp size removeelf 60 | 61 | hex: buildelf buildhex removetemp size removeelf 62 | 63 | asm: buildelf buildasm removetemp size removeelf 64 | 65 | flash: install 66 | 67 | install: hex 68 | @echo "Installing $(TARGET).hex to $(DEVICE) using $(PROGRMR) ..." 69 | ifeq ($(PROGRMR),serialupdi) 70 | @$(PYPROG) --fuses 0:$(FUSE0) 1:$(FUSE1) 2:$(FUSE2) 4:$(FUSE4) 5:$(FUSE5) 6:$(FUSE6) 7:$(FUSE7) 8:$(FUSE8) -f $(TARGET).hex -a write 71 | else 72 | @$(AVRDUDE) -Ufuse0:w:$(FUSE0):m -Ufuse1:w:$(FUSE1):m -Ufuse2:w:$(FUSE2):m -Ufuse4:w:$(FUSE4):m -Ufuse5:w:$(FUSE5):m -Ufuse6:w:$(FUSE6):m -Ufuse7:w:$(FUSE7):m -Ufuse8:w:$(FUSE8):m -U flash:w:$(TARGET).hex:i 73 | endif 74 | 75 | upload: hex 76 | @echo "Uploading $(TARGET).hex to $(DEVICE) using $(PROGRMR) ..." 77 | ifeq ($(PROGRMR),serialupdi) 78 | @$(PYPROG) -f $(TARGET).hex -a write 79 | else 80 | @$(AVRDUDE) -U flash:w:$(TARGET).hex:i 81 | endif 82 | 83 | fuses: 84 | @echo "Burning fuses of $(DEVICE) ..." 85 | ifeq ($(PROGRMR),serialupdi) 86 | @$(PYPROG) --fuses 0:$(FUSE0) 1:$(FUSE1) 2:$(FUSE2) 4:$(FUSE4) 5:$(FUSE5) 6:$(FUSE6) 7:$(FUSE7) 8:$(FUSE8) -a erase 87 | else 88 | @$(AVRDUDE) -e -Ufuse0:w:$(FUSE0):m -Ufuse1:w:$(FUSE1):m -Ufuse2:w:$(FUSE2):m -Ufuse4:w:$(FUSE4):m -Ufuse5:w:$(FUSE5):m -Ufuse6:w:$(FUSE6):m -Ufuse7:w:$(FUSE7):m -Ufuse8:w:$(FUSE8):m 89 | endif 90 | 91 | clean: 92 | @echo "Cleaning all up ..." 93 | @$(CLEAN) 94 | @rm -f $(TARGET).elf $(TARGET).bin $(TARGET).hex $(TARGET).asm 95 | 96 | buildelf: 97 | @echo "Compiling $(SKETCH) for $(DEVICE) @ $(CLOCK)Hz ..." 98 | @$(CC) $(CFLAGS) $(SKETCH) -o $(TARGET).elf 99 | 100 | buildbin: 101 | @echo "Building $(TARGET).bin ..." 102 | @$(OBJCOPY) -O binary -R .eeprom $(TARGET).elf $(TARGET).bin 103 | 104 | buildhex: 105 | @echo "Building $(TARGET).hex ..." 106 | @$(OBJCOPY) -j .text -j .data -O ihex $(TARGET).elf $(TARGET).hex 107 | 108 | buildasm: 109 | @echo "Disassembling to $(TARGET).asm ..." 110 | @$(OBJDUMP) -d $(TARGET).elf > $(TARGET).asm 111 | 112 | size: 113 | @echo "------------------" 114 | @echo "FLASH: $(shell $(AVRSIZE) -d $(TARGET).elf | awk '/[0-9]/ {print $$1 + $$2}') bytes" 115 | @echo "SRAM: $(shell $(AVRSIZE) -d $(TARGET).elf | awk '/[0-9]/ {print $$2 + $$3}') bytes" 116 | @echo "------------------" 117 | 118 | removetemp: 119 | @echo "Removing temporary files ..." 120 | @$(CLEAN) 121 | 122 | removeelf: 123 | @echo "Removing $(TARGET).elf ..." 124 | @rm -f $(TARGET).elf 125 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/yaml/serializer.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = ['Serializer', 'SerializerError'] 3 | 4 | from .error import YAMLError 5 | from .events import * 6 | from .nodes import * 7 | 8 | class SerializerError(YAMLError): 9 | pass 10 | 11 | class Serializer: 12 | 13 | ANCHOR_TEMPLATE = 'id%03d' 14 | 15 | def __init__(self, encoding=None, 16 | explicit_start=None, explicit_end=None, version=None, tags=None): 17 | self.use_encoding = encoding 18 | self.use_explicit_start = explicit_start 19 | self.use_explicit_end = explicit_end 20 | self.use_version = version 21 | self.use_tags = tags 22 | self.serialized_nodes = {} 23 | self.anchors = {} 24 | self.last_anchor_id = 0 25 | self.closed = None 26 | 27 | def open(self): 28 | if self.closed is None: 29 | self.emit(StreamStartEvent(encoding=self.use_encoding)) 30 | self.closed = False 31 | elif self.closed: 32 | raise SerializerError("serializer is closed") 33 | else: 34 | raise SerializerError("serializer is already opened") 35 | 36 | def close(self): 37 | if self.closed is None: 38 | raise SerializerError("serializer is not opened") 39 | elif not self.closed: 40 | self.emit(StreamEndEvent()) 41 | self.closed = True 42 | 43 | #def __del__(self): 44 | # self.close() 45 | 46 | def serialize(self, node): 47 | if self.closed is None: 48 | raise SerializerError("serializer is not opened") 49 | elif self.closed: 50 | raise SerializerError("serializer is closed") 51 | self.emit(DocumentStartEvent(explicit=self.use_explicit_start, 52 | version=self.use_version, tags=self.use_tags)) 53 | self.anchor_node(node) 54 | self.serialize_node(node, None, None) 55 | self.emit(DocumentEndEvent(explicit=self.use_explicit_end)) 56 | self.serialized_nodes = {} 57 | self.anchors = {} 58 | self.last_anchor_id = 0 59 | 60 | def anchor_node(self, node): 61 | if node in self.anchors: 62 | if self.anchors[node] is None: 63 | self.anchors[node] = self.generate_anchor(node) 64 | else: 65 | self.anchors[node] = None 66 | if isinstance(node, SequenceNode): 67 | for item in node.value: 68 | self.anchor_node(item) 69 | elif isinstance(node, MappingNode): 70 | for key, value in node.value: 71 | self.anchor_node(key) 72 | self.anchor_node(value) 73 | 74 | def generate_anchor(self, node): 75 | self.last_anchor_id += 1 76 | return self.ANCHOR_TEMPLATE % self.last_anchor_id 77 | 78 | def serialize_node(self, node, parent, index): 79 | alias = self.anchors[node] 80 | if node in self.serialized_nodes: 81 | self.emit(AliasEvent(alias)) 82 | else: 83 | self.serialized_nodes[node] = True 84 | self.descend_resolver(parent, index) 85 | if isinstance(node, ScalarNode): 86 | detected_tag = self.resolve(ScalarNode, node.value, (True, False)) 87 | default_tag = self.resolve(ScalarNode, node.value, (False, True)) 88 | implicit = (node.tag == detected_tag), (node.tag == default_tag) 89 | self.emit(ScalarEvent(alias, node.tag, implicit, node.value, 90 | style=node.style)) 91 | elif isinstance(node, SequenceNode): 92 | implicit = (node.tag 93 | == self.resolve(SequenceNode, node.value, True)) 94 | self.emit(SequenceStartEvent(alias, node.tag, implicit, 95 | flow_style=node.flow_style)) 96 | index = 0 97 | for item in node.value: 98 | self.serialize_node(item, node, index) 99 | index += 1 100 | self.emit(SequenceEndEvent()) 101 | elif isinstance(node, MappingNode): 102 | implicit = (node.tag 103 | == self.resolve(MappingNode, node.value, True)) 104 | self.emit(MappingStartEvent(alias, node.tag, implicit, 105 | flow_style=node.flow_style)) 106 | for key, value in node.value: 107 | self.serialize_node(key, node, None) 108 | self.serialize_node(value, node, key) 109 | self.emit(MappingEndEvent()) 110 | self.ascend_resolver() 111 | 112 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pyedbglib/util/binary.py: -------------------------------------------------------------------------------- 1 | """Packing and unpacking numbers into bytearrays of 8-bit values with various endian encodings""" 2 | 3 | from numbers import Integral 4 | 5 | def _check_input_value(value, bits): 6 | """ 7 | :param value: An integer 8 | :param bits: Number of bits used to represent this integer 9 | :return: Raises an OverflowError if the value is too large 10 | """ 11 | # Be sure to support both py2 and py3 12 | if not isinstance(value, Integral): 13 | raise TypeError("The input {} is not an Integral type".format(value)) 14 | 15 | if value > (2 ** bits) - 1: 16 | raise OverflowError("Value {} is larger than the maximum value {}".format(value, (2 ** bits) - 1)) 17 | 18 | 19 | def pack_le32(value): 20 | """ 21 | :param value: input value 22 | :return: 32-bit little endian bytearray representation of the input value 23 | """ 24 | _check_input_value(value, 32) 25 | return bytearray([value & 0xFF, (value >> 8) & 0xFF, (value >> 16) & 0xFF, (value >> 24) & 0xFF]) 26 | 27 | 28 | def pack_be32(value): 29 | """ 30 | :param value: input value 31 | :return: 32-bit big endian bytearray representation of the input value 32 | """ 33 | _check_input_value(value, 32) 34 | return bytearray( 35 | [(value >> 24) & 0xFF, 36 | (value >> 16) & 0xFF, 37 | (value >> 8) & 0xFF, 38 | value & 0xFF]) 39 | 40 | 41 | def pack_le24(value): 42 | """ 43 | :param value: input value 44 | :return: 24-bit little endian bytearray representation of the input value 45 | """ 46 | _check_input_value(value, 24) 47 | return bytearray([value & 0xFF, (value >> 8) & 0xFF, (value >> 16) & 0xFF]) 48 | 49 | 50 | def pack_be24(value): 51 | """ 52 | :param value: input value 53 | :return: 24-bit big endian bytearray representation of the input value 54 | """ 55 | _check_input_value(value, 24) 56 | return bytearray( 57 | [(value >> 16) & 0xFF, 58 | (value >> 8) & 0xFF, 59 | value & 0xFF]) 60 | 61 | 62 | def pack_le16(value): 63 | """ 64 | :param value: input value 65 | :return: 16-bit little endian bytearray representation of the input value 66 | """ 67 | _check_input_value(value, 16) 68 | return bytearray([value & 0xFF, (value >> 8) & 0xFF]) 69 | 70 | 71 | def pack_be16(value): 72 | """ 73 | :param value: input value 74 | :return: 16-bit big endian bytearray representation of the input value 75 | """ 76 | _check_input_value(value, 16) 77 | return bytearray([(value >> 8) & 0xFF, value & 0xFF]) 78 | 79 | 80 | def _check_input_array(data, length): 81 | """ 82 | Used to check if a bytearray or list of 8-bit values has the correct length to convert to an integer 83 | 84 | :param data: bytearray (or list) representing a value 85 | :param length: Expected length of the list 86 | :return: Raises a ValueError if len(data) is not the same as length 87 | """ 88 | if not isinstance(data, (list, bytearray)): 89 | raise TypeError("The input {} is not a list of bytearray".format(data)) 90 | 91 | if len(data) != length: 92 | raise ValueError("Input data {} does not have length {}".format(data, length)) 93 | 94 | 95 | def unpack_le32(data): 96 | """ 97 | :param data: 32-bit little endian bytearray representation of an integer 98 | :return: integer value 99 | """ 100 | _check_input_array(data, 4) 101 | return data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24) 102 | 103 | 104 | def unpack_be32(data): 105 | """ 106 | :param data: 32-bit big endian bytearray representation of an integer 107 | :return: integer value 108 | """ 109 | _check_input_array(data, 4) 110 | return data[3] + (data[2] << 8) + (data[1] << 16) + (data[0] << 24) 111 | 112 | 113 | def unpack_le24(data): 114 | """ 115 | :param data: 24-bit little endian bytearray representation of an integer 116 | :return: integer value 117 | """ 118 | _check_input_array(data, 3) 119 | return data[0] + (data[1] << 8) + (data[2] << 16) 120 | 121 | 122 | def unpack_be24(data): 123 | """ 124 | :param data: 24-bit big endian bytearray representation of an integer 125 | :return: integer value 126 | """ 127 | _check_input_array(data, 3) 128 | return data[2] + (data[1] << 8) + (data[0] << 16) 129 | 130 | 131 | def unpack_le16(data): 132 | """ 133 | :param data: 16-bit little endian bytearray representation of an integer 134 | :return: integer value 135 | """ 136 | _check_input_array(data, 2) 137 | return data[0] + (data[1] << 8) 138 | 139 | 140 | def unpack_be16(data): 141 | """ 142 | :param data: 16-bit big endian bytearray representation of an integer 143 | :return: integer value 144 | """ 145 | _check_input_array(data, 2) 146 | return data[1] + (data[0] << 8) 147 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/pymcuprog/serialupdi/physical.py: -------------------------------------------------------------------------------- 1 | """ 2 | Serial driver for UPDI stack 3 | """ 4 | import time 5 | from logging import getLogger 6 | import serial 7 | from serial.serialutil import SerialException 8 | 9 | from . import constants 10 | 11 | 12 | class UpdiPhysical: 13 | """ 14 | PDI physical driver using a given serial port at a given baud 15 | """ 16 | 17 | def __init__(self, port, baud=115200): 18 | """ 19 | Initialise the serial port 20 | """ 21 | self.logger = getLogger(__name__) 22 | 23 | # Inter-byte delay 24 | self.ibdly = 0.0001 25 | self.port = port 26 | self.baud = baud 27 | self.ser = None 28 | 29 | self.initialise_serial(self.port, self.baud) 30 | 31 | # send an initial break as handshake 32 | self.send([constants.UPDI_BREAK]) 33 | 34 | def change_baud(self, newbaud): 35 | self.ser.baudrate = newbaud 36 | 37 | def initialise_serial(self, port, baud): 38 | """ 39 | Standard serial port initialisation 40 | :param port: serial port to use 41 | :param baud: baud rate 42 | """ 43 | self.logger.info("Opening port '%s' at '%d' baud", port, baud) 44 | try: 45 | self.ser = serial.Serial(None, baud, parity=serial.PARITY_EVEN, timeout=1, stopbits=serial.STOPBITS_TWO) 46 | self.ser.port = port 47 | self.ser.dtr = False 48 | self.ser.rts = False 49 | self.ser.open() 50 | except SerialException: 51 | self.logger.error("Unable to open serial port '%s'", port) 52 | raise 53 | 54 | def _loginfo(self, msg, data): 55 | if data and isinstance(data[0], str): 56 | i_data = [ord(x) for x in data] 57 | else: 58 | i_data = data 59 | data_str = "[" + ", ".join([hex(x) for x in i_data]) + "]" 60 | self.logger.debug("%s : %s", msg, data_str) 61 | 62 | def send_double_break(self): 63 | """ 64 | Sends a double break to reset the UPDI port 65 | 66 | BREAK is actually just a slower zero frame 67 | A double break is guaranteed to push the UPDI state 68 | machine into a known state, albeit rather brutally 69 | """ 70 | 71 | self.logger.info("Sending double break") 72 | 73 | # Re-init at a lower baud 74 | # At 300 bauds, the break character will pull the line low for 30ms 75 | # Which is slightly above the recommended 24.6ms 76 | self.ser.close() 77 | temporary_serial = serial.Serial(None, 300, parity=serial.PARITY_EVEN, timeout=1, 78 | stopbits=serial.STOPBITS_ONE) 79 | temporary_serial.port = self.port 80 | temporary_serial.dtr = False 81 | temporary_serial.rts = False 82 | temporary_serial.open() 83 | 84 | # Send two break characters, with 1 stop bit in between 85 | temporary_serial.write([constants.UPDI_BREAK]) 86 | 87 | # Wait for the double break end 88 | temporary_serial.read(1) 89 | 90 | time.sleep(0.1) 91 | 92 | # Send two break characters, with 1 stop bit in between 93 | temporary_serial.write([constants.UPDI_BREAK]) 94 | 95 | # Wait for the double break end 96 | temporary_serial.read(1) 97 | 98 | # Re-init at the real baud 99 | temporary_serial.close() 100 | self.initialise_serial(self.port, self.baud) 101 | 102 | def send(self, command): 103 | """ 104 | Sends a char array to UPDI with NO inter-byte delay 105 | Note that the byte will echo back 106 | """ 107 | self.logger.info("send %d bytes", len(command)) 108 | self._loginfo("data: ", command) 109 | 110 | self.ser.write(command) 111 | # it will echo back. 112 | echo = self.ser.read(len(command)) 113 | 114 | def receive(self, size): 115 | """ 116 | Receives a frame of a known number of chars from UPDI 117 | :param size: bytes to receive 118 | """ 119 | response = bytearray() 120 | timeout = 1 121 | 122 | # For each byte 123 | while size and timeout: 124 | 125 | # Read 126 | character = self.ser.read() 127 | 128 | # Anything in? 129 | if character: 130 | response.append(ord(character)) 131 | size -= 1 132 | else: 133 | timeout -= 1 134 | 135 | self._loginfo("receive", response) 136 | return response 137 | 138 | def sib(self): 139 | """ 140 | System information block is just a string coming back from a SIB command 141 | """ 142 | self.send([ 143 | constants.UPDI_PHY_SYNC, 144 | constants.UPDI_KEY | constants.UPDI_KEY_SIB | constants.UPDI_SIB_32BYTES]) 145 | return self.ser.readline() 146 | 147 | def __del__(self): 148 | if self.ser: 149 | self.logger.info("Closing port '%s'", self.port) 150 | self.ser.close() 151 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/yaml/composer.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = ['Composer', 'ComposerError'] 3 | 4 | from .error import MarkedYAMLError 5 | from .events import * 6 | from .nodes import * 7 | 8 | class ComposerError(MarkedYAMLError): 9 | pass 10 | 11 | class Composer: 12 | 13 | def __init__(self): 14 | self.anchors = {} 15 | 16 | def check_node(self): 17 | # Drop the STREAM-START event. 18 | if self.check_event(StreamStartEvent): 19 | self.get_event() 20 | 21 | # If there are more documents available? 22 | return not self.check_event(StreamEndEvent) 23 | 24 | def get_node(self): 25 | # Get the root node of the next document. 26 | if not self.check_event(StreamEndEvent): 27 | return self.compose_document() 28 | 29 | def get_single_node(self): 30 | # Drop the STREAM-START event. 31 | self.get_event() 32 | 33 | # Compose a document if the stream is not empty. 34 | document = None 35 | if not self.check_event(StreamEndEvent): 36 | document = self.compose_document() 37 | 38 | # Ensure that the stream contains no more documents. 39 | if not self.check_event(StreamEndEvent): 40 | event = self.get_event() 41 | raise ComposerError("expected a single document in the stream", 42 | document.start_mark, "but found another document", 43 | event.start_mark) 44 | 45 | # Drop the STREAM-END event. 46 | self.get_event() 47 | 48 | return document 49 | 50 | def compose_document(self): 51 | # Drop the DOCUMENT-START event. 52 | self.get_event() 53 | 54 | # Compose the root node. 55 | node = self.compose_node(None, None) 56 | 57 | # Drop the DOCUMENT-END event. 58 | self.get_event() 59 | 60 | self.anchors = {} 61 | return node 62 | 63 | def compose_node(self, parent, index): 64 | if self.check_event(AliasEvent): 65 | event = self.get_event() 66 | anchor = event.anchor 67 | if anchor not in self.anchors: 68 | raise ComposerError(None, None, "found undefined alias %r" 69 | % anchor, event.start_mark) 70 | return self.anchors[anchor] 71 | event = self.peek_event() 72 | anchor = event.anchor 73 | if anchor is not None: 74 | if anchor in self.anchors: 75 | raise ComposerError("found duplicate anchor %r; first occurence" 76 | % anchor, self.anchors[anchor].start_mark, 77 | "second occurence", event.start_mark) 78 | self.descend_resolver(parent, index) 79 | if self.check_event(ScalarEvent): 80 | node = self.compose_scalar_node(anchor) 81 | elif self.check_event(SequenceStartEvent): 82 | node = self.compose_sequence_node(anchor) 83 | elif self.check_event(MappingStartEvent): 84 | node = self.compose_mapping_node(anchor) 85 | self.ascend_resolver() 86 | return node 87 | 88 | def compose_scalar_node(self, anchor): 89 | event = self.get_event() 90 | tag = event.tag 91 | if tag is None or tag == '!': 92 | tag = self.resolve(ScalarNode, event.value, event.implicit) 93 | node = ScalarNode(tag, event.value, 94 | event.start_mark, event.end_mark, style=event.style) 95 | if anchor is not None: 96 | self.anchors[anchor] = node 97 | return node 98 | 99 | def compose_sequence_node(self, anchor): 100 | start_event = self.get_event() 101 | tag = start_event.tag 102 | if tag is None or tag == '!': 103 | tag = self.resolve(SequenceNode, None, start_event.implicit) 104 | node = SequenceNode(tag, [], 105 | start_event.start_mark, None, 106 | flow_style=start_event.flow_style) 107 | if anchor is not None: 108 | self.anchors[anchor] = node 109 | index = 0 110 | while not self.check_event(SequenceEndEvent): 111 | node.value.append(self.compose_node(node, index)) 112 | index += 1 113 | end_event = self.get_event() 114 | node.end_mark = end_event.end_mark 115 | return node 116 | 117 | def compose_mapping_node(self, anchor): 118 | start_event = self.get_event() 119 | tag = start_event.tag 120 | if tag is None or tag == '!': 121 | tag = self.resolve(MappingNode, None, start_event.implicit) 122 | node = MappingNode(tag, [], 123 | start_event.start_mark, None, 124 | flow_style=start_event.flow_style) 125 | if anchor is not None: 126 | self.anchors[anchor] = node 127 | while not self.check_event(MappingEndEvent): 128 | #key_event = self.peek_event() 129 | item_key = self.compose_node(node, None) 130 | #if item_key in node.value: 131 | # raise ComposerError("while composing a mapping", start_event.start_mark, 132 | # "found duplicate key", key_event.start_mark) 133 | item_value = self.compose_node(node, item_key) 134 | #node.value[item_key] = item_value 135 | node.value.append((item_key, item_value)) 136 | end_event = self.get_event() 137 | node.end_mark = end_event.end_mark 138 | return node 139 | 140 | -------------------------------------------------------------------------------- /software/tools/pymcuprog/libs/intelhex/compat.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011, Bernhard Leiner 2 | # Copyright (c) 2013-2018 Alexander Belchenko 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, 6 | # with or without modification, are permitted provided 7 | # that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain 10 | # the above copyright notice, this list of conditions 11 | # and the following disclaimer. 12 | # * Redistributions in binary form must reproduce 13 | # the above copyright notice, this list of conditions 14 | # and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # * Neither the name of the author nor the names 17 | # of its contributors may be used to endorse 18 | # or promote products derived from this software 19 | # without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 23 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 24 | # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 | # IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 27 | # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 29 | # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 30 | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 33 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | 35 | '''Compatibility functions for python 2 and 3. 36 | 37 | @author Bernhard Leiner (bleiner AT gmail com) 38 | @author Alexander Belchenko (alexander belchenko AT gmail com) 39 | ''' 40 | 41 | __docformat__ = "javadoc" 42 | 43 | 44 | import sys, array 45 | 46 | 47 | if sys.version_info[0] >= 3: 48 | # Python 3 49 | Python = 3 50 | 51 | def asbytes(s): 52 | if isinstance(s, bytes): 53 | return s 54 | return s.encode('latin1') 55 | def asstr(s): 56 | if isinstance(s, str): 57 | return s 58 | return s.decode('latin1') 59 | 60 | # for python >= 3.2 use 'tobytes', otherwise 'tostring' 61 | array_tobytes = array.array.tobytes if sys.version_info[1] >= 2 else array.array.tostring 62 | 63 | IntTypes = (int,) 64 | StrType = str 65 | UnicodeType = str 66 | 67 | range_g = range # range generator 68 | def range_l(*args): # range list 69 | return list(range(*args)) 70 | 71 | def dict_keys(dikt): # dict keys list 72 | return list(dikt.keys()) 73 | def dict_keys_g(dikt): # dict keys generator 74 | return dikt.keys() 75 | def dict_items_g(dikt): # dict items generator 76 | return dikt.items() 77 | 78 | from io import StringIO, BytesIO 79 | 80 | def get_binary_stdout(): 81 | return sys.stdout.buffer 82 | 83 | def get_binary_stdin(): 84 | return sys.stdin.buffer 85 | 86 | else: 87 | # Python 2 88 | Python = 2 89 | 90 | asbytes = str 91 | asstr = str 92 | 93 | array_tobytes = array.array.tostring 94 | 95 | IntTypes = (int, long) 96 | StrType = basestring 97 | UnicodeType = unicode 98 | 99 | #range_g = xrange # range generator 100 | def range_g(*args): 101 | # we want to use xrange here but on python 2 it does not work with long ints 102 | try: 103 | return xrange(*args) 104 | except OverflowError: 105 | start = 0 106 | stop = 0 107 | step = 1 108 | n = len(args) 109 | if n == 1: 110 | stop = args[0] 111 | elif n == 2: 112 | start, stop = args 113 | elif n == 3: 114 | start, stop, step = args 115 | else: 116 | raise TypeError('wrong number of arguments in range_g call!') 117 | if step == 0: 118 | raise ValueError('step cannot be zero') 119 | if step > 0: 120 | def up(start, stop, step): 121 | while start < stop: 122 | yield start 123 | start += step 124 | return up(start, stop, step) 125 | else: 126 | def down(start, stop, step): 127 | while start > stop: 128 | yield start 129 | start += step 130 | return down(start, stop, step) 131 | 132 | range_l = range # range list 133 | 134 | def dict_keys(dikt): # dict keys list 135 | return dikt.keys() 136 | def dict_keys_g(dikt): # dict keys generator 137 | return dikt.keys() 138 | def dict_items_g(dikt): # dict items generator 139 | return dikt.items() 140 | 141 | from cStringIO import StringIO 142 | BytesIO = StringIO 143 | 144 | import os 145 | def _force_stream_binary(stream): 146 | """Force binary mode for stream on Windows.""" 147 | if os.name == 'nt': 148 | f_fileno = getattr(stream, 'fileno', None) 149 | if f_fileno: 150 | fileno = f_fileno() 151 | if fileno >= 0: 152 | import msvcrt 153 | msvcrt.setmode(fileno, os.O_BINARY) 154 | return stream 155 | 156 | def get_binary_stdout(): 157 | return _force_stream_binary(sys.stdout) 158 | 159 | def get_binary_stdin(): 160 | return _force_stream_binary(sys.stdin) 161 | --------------------------------------------------------------------------------