Skip to content

Commit eda95bd

Browse files
author
buildmaster
committed
Initial
0 parents  commit eda95bd

File tree

218 files changed

+46003
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+46003
-0
lines changed

CHANGELOG.md

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Changelog
2+
3+
## [3.13] - May 2022
4+
5+
## Added
6+
- DSG-3936 Fixed AVR ISP implementation and added commands (beta)
7+
- DSG-4172 github-10 Disable ACK response signature on serialUPDI block write (speed-up)
8+
- DSG-3951 github-8 Added --erase argument to erase device before write with single execution
9+
- DSG-3972 CLI help additions
10+
- DSG-3997 Added debugwire_disable() to Avr8Protocol
11+
12+
## Fixed
13+
- DSG-3945, DSG-3938 Unable to write fuse byte 0 on Curiosity Nano ATtiny kits
14+
- DSG-4488 github-19 Return bytearray (not list) from serialUPDI read
15+
- DSG-4594 SAMD21 performance improvement (SAM-IoT provisioning)
16+
- DSG-4540 Fixed SAMD21 non-word-oriented read failure
17+
- DSG-3941 Improved feedback on verification failure
18+
- DSG-3944 Removed timeout warning for serialUPDI with a locked device
19+
- DSG-4419 Corrected AVR high voltage UPDI device data
20+
- DSG-3993 github-9 Corrected AVR signature sizes to make additional data available
21+
22+
## [3.10] - October 2021
23+
24+
### Added
25+
- DSG-2702 Add serialupdi backend for AVR EA
26+
- DSG-3633 github-3 Add missing AVR-DB devices
27+
- DSG-3635 github-4 Add missing ATtiny devices
28+
- DSG-3662 Add ascii-art for serialUPDI
29+
- DSG-3804 Add py39 metadata to package
30+
- DSG-3943 github-7 Add CLI documentation
31+
32+
### Fixed
33+
- DSG-2859 github-1 serialUPDI write user_row on locked device fails
34+
- DSG-3538 github-2 Unable to write fuses on ATmega4809 using serialUPDI
35+
- DSG-3817 SAM D21 user row programming fails
36+
- DSG-3952 Incorrect size of FUSES on Dx, Ex devices
37+
38+
## [3.9] - April 2021
39+
40+
### Added
41+
- DSG-2920 Raise exception if device ID does not match
42+
- DSG-2918 SerialUPDI: error recovery if non-ascii characters are read in SIB
43+
- DSG-2861 Valid memory types are listed if an invalid one is specified
44+
45+
### Fixed
46+
- DSG-3238 PIC16 eeprom displays incorrect address
47+
- DSG-3239 PIC16 eeprom verification does not work
48+
- DSG-2925 UPDI device revision not correctly parsed/displayed
49+
- DSG-2860 SerialUPDI: chip erase does not work on locked device
50+
- DSG-2857 SerialUPDI: crash when writing lockbits
51+
- DSG-2855 Verify action fails if hex file contains eeprom content
52+
- DSG-2854 User row excluded when reading to hex file
53+
- DSG-2850 UPDI device model fix (sram)
54+
55+
### Changed
56+
- DSG-2862 Improved exception handling
57+
- DSG-3203 Improved exception handling
58+
- DSG-3178 Cosmetic changes for publication
59+
60+
## [3.7.4] - December 2020
61+
62+
### Added
63+
- DSG-1492 Added verify function
64+
- DSG-2039 Added all UPDI devices
65+
- DSG-2279 Added error codes
66+
- DSG-1550 Flash-only erase
67+
68+
### Fixed
69+
- DSG-2470 No feedback when multiple kits are connected
70+
- DSG-2014 Error when reading using -m and -o but no -b
71+
- DSG-2738 Padding to page size when writing user row on locked device
72+
73+
### Changed
74+
- DSG-2234 Logging using logging module
75+
- DSG-2034 prevent read using -b with no -m specified
76+
- DSG-2009 prevent writing from hexfile with memory type specified
77+
- DSG-2012 prevent writing from hexfile with offset specified
78+
- DSG-2458 documentation changes
79+
- DSG-2041 documentation changes
80+
- DSG-2042 documentation changes
81+
- DSG-2043 documentation changes
82+
- DSG-2011 documentation changes
83+
84+
## [3.1.3] - June 2020
85+
- First public release to PyPi

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2021 Microchip Technology Inc. and its subsidiaries.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

MANIFEST.in

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include pymcuprog/logging.yaml
2+
include images/microchip.png
3+
# These files are read in setup.py so they must be included in the source zip for pip to be able to install the zip
4+
# Note however that since the files are not a part of the package (not inside the pymcuprog sub folder)
5+
# they won't be included in the python wheel.
6+
include pypi.md
7+
include requirements.txt

README.md

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
[![MCHP](images/microchip.png)](https://www.microchip.com)
2+
3+
# pymcuprog - Python MCU programmer
4+
pymcuprog is a Python utility for programming various Microchip MCU devices using Microchip CMSIS-DAP based debuggers
5+
6+
Install using pip from [pypi](https://pypi.org/project/pymcuprog):
7+
```bash
8+
pip install pymcuprog
9+
```
10+
11+
Browse source code on [github](https://github.com/microchip-pic-avr-tools/pymcuprog)
12+
13+
Read API documentation on [github](https://microchip-pic-avr-tools.github.io/pymcuprog)
14+
15+
Read the changelog on [github](https://github.com/microchip-pic-avr-tools/pymcuprog/blob/main/CHANGELOG.md)
16+
17+
## Usage
18+
pymcuprog can be used as a command-line interface or a library
19+
20+
### CLI help
21+
For more help with using pymcuprog CLI see [help](./help.md)
22+
23+
### CLI examples
24+
When installed using pip, pymcuprog CLI is located in the Python scripts folder.
25+
26+
Test connectivity by reading the device ID using Curiosity Nano:
27+
```bash
28+
pymcuprog ping
29+
```
30+
31+
Erase memories then write contents of an Intel(R) hex file to flash using Curiosity Nano (pymcuprog does NOT automatically erase before writing):
32+
```bash
33+
pymcuprog erase
34+
pymcuprog write -f app.hex
35+
```
36+
37+
Erase memories and write an Intel hex file (using the --erase switch):
38+
```bash
39+
pymcuprog write -f app.hex --erase
40+
```
41+
42+
Erase memories, write an Intel hex file and verify the content:
43+
```bash
44+
pymcuprog write -f app.hex --erase --verify
45+
```
46+
47+
48+
### Serial port UPDI (pyupdi)
49+
The AVR UPDI interface implements a UART protocol, which means that it can be used by simply connecting TX and RX pins of a serial port together with the UPDI pin; with a series resistor (eg: 1k) between TX and UPDI to handle contention. (This configuration is also known as "pyupdi".) Be sure to connect a common ground, and use a TTL serial adapter running at the same voltage as the AVR device.
50+
51+
<pre>
52+
Vcc Vcc
53+
+-+ +-+
54+
| |
55+
+---------------------+ | | +--------------------+
56+
| Serial port +-+ +-+ AVR device |
57+
| | +----------+ | |
58+
| TX +------+ 1k +---------+ UPDI |
59+
| | +----------+ | | |
60+
| | | | |
61+
| RX +----------------------+ | |
62+
| | | |
63+
| +--+ +--+ |
64+
+---------------------+ | | +--------------------+
65+
+-+ +-+
66+
GND GND
67+
</pre>
68+
69+
pymcuprog includes this implementation as an alternative to USB/EDBG-based tools. To connect via a serial port, use the "uart" tool type with the UART switch in addition.
70+
71+
Example: checks connectivity by reading the device identity
72+
```bash
73+
pymcuprog ping -d avr128da48 -t uart -u com35
74+
```
75+
76+
For more examples see [pymcuprog on pypi.org](https://pypi.org/project/pymcuprog/)
77+
78+
### Library usage example
79+
pymcuprog can be used as a library using its backend API. For example:
80+
```python
81+
"""
82+
Example usage of pymcuprog as a library to read the device ID
83+
"""
84+
# pymcuprog uses the Python logging module
85+
import logging
86+
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)
87+
88+
# Configure the session
89+
from pymcuprog.backend import SessionConfig
90+
sessionconfig = SessionConfig("atmega4808")
91+
92+
# Instantiate USB transport (only 1 tool connected)
93+
from pymcuprog.toolconnection import ToolUsbHidConnection
94+
transport = ToolUsbHidConnection()
95+
96+
# Instantiate backend
97+
from pymcuprog.backend import Backend
98+
backend = Backend()
99+
100+
# Connect to tool using transport
101+
backend.connect_to_tool(transport)
102+
103+
# Start the session
104+
backend.start_session(sessionconfig)
105+
106+
# Read the target device_id
107+
device_id = backend.read_device_id()
108+
print ("Device ID is {0:06X}".format(int.from_bytes(device_id, byteorder="little")))
109+
```
110+
111+
## Supported devices and tools
112+
pymcuprog is primarily intended for use with PKOB nano (nEDBG) debuggers which are found on Curiosity Nano kits and other development boards. This means that it is continuously tested with a selection of AVR devices with UPDI interface as well as a selection of PIC devices. However since the protocol is compatible between all EDBG-based debuggers (pyedbglib) it is possible to use pymcuprog with a wide range of debuggers and devices, although not all device families/interfaces have been implemented.
113+
114+
### Debuggers / Tools
115+
pymcuprog supports:
116+
* PKOB nano (nEDBG) - on-board debugger on Curiosity Nano
117+
* MPLAB PICkit 4 In-Circuit Debugger (when in 'AVR mode')
118+
* MPLAB Snap In-Circuit Debugger (when in 'AVR mode')
119+
* Atmel-ICE
120+
* Power Debugger
121+
* EDBG - on-board debugger on Xplained Pro/Ultra
122+
* mEDBG - on-board debugger on Xplained Mini/Nano
123+
* JTAGICE3 (firmware version 3.0 or newer)
124+
125+
Although not all functionality is provided on all debuggers/boards. See device support section below.
126+
127+
### Devices
128+
pymcuprog supports:
129+
* All UPDI devices, whether mounted on kits or standalone
130+
* PIC devices mounted on Curiosity Nano kits, or similar board with PKOB nano (nEDBG) debugger
131+
132+
Other devices (eg ATmega328P, ATsamd21e18a) may be partially supported for experimental purposes
133+
134+
## Notes for Linux® systems
135+
This package uses pyedbglib and other libraries for USB transport and some udev rules are required. For details see the pyedbglib package: https://pypi.org/project/pyedbglib

doc/Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

doc/make.bat

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

doc/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# No requirements - all are mocked.

doc/source/_static/.keep

Whitespace-only changes.

doc/source/_templates/module.rst_t

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{%- if show_headings %}
2+
{{- basename | e | heading }}
3+
4+
{% endif -%}
5+
.. automodule:: {{ qualname }}
6+
{%- for option in automodule_options %}
7+
:{{ option }}:
8+
{%- endfor %}
9+

doc/source/_templates/package.rst_t

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{%- macro automodule(modname, options) -%}
2+
.. automodule:: {{ modname }}
3+
{%- for option in options %}
4+
:{{ option }}:
5+
{%- endfor %}
6+
{%- endmacro %}
7+
8+
{%- macro toctree(docnames) -%}
9+
.. toctree::
10+
:maxdepth: {{ maxdepth }}
11+
{% for docname in docnames %}
12+
{{ docname }}
13+
{%- endfor %}
14+
{%- endmacro %}
15+
16+
{%- if is_namespace %}
17+
{{- [pkgname, "namespace"] | join(" ") | e | heading }}
18+
{% else %}
19+
{{- pkgname | e | heading }}
20+
{% endif %}
21+
22+
{%- if modulefirst and not is_namespace %}
23+
{{ automodule(pkgname, automodule_options) }}
24+
{% endif %}
25+
26+
{%- if subpackages %}
27+
28+
{{ toctree(subpackages) }}
29+
{% endif %}
30+
31+
{%- if submodules %}
32+
{% if separatemodules %}
33+
{{ toctree(submodules) }}
34+
{%- else %}
35+
{%- for submodule in submodules %}
36+
{% if show_headings %}
37+
{{- submodule | e | heading(2) }}
38+
{% endif %}
39+
{{ automodule(submodule, automodule_options) }}
40+
{% endfor %}
41+
{%- endif %}
42+
{% endif %}
43+
44+
{%- if not modulefirst and not is_namespace %}
45+
46+
{{ automodule(pkgname, automodule_options) }}
47+
{% endif %}

doc/source/_templates/toc.rst_t

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{ header | heading }}
2+
3+
.. toctree::
4+
:maxdepth: {{ maxdepth }}
5+
{% for docname in docnames %}
6+
{{ docname }}
7+
{%- endfor %}
8+

0 commit comments

Comments
 (0)