Skip to content

Commit a9411a8

Browse files
author
buildmaster
committed
Initial
0 parents  commit a9411a8

File tree

224 files changed

+44587
-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.

224 files changed

+44587
-0
lines changed

CHANGELOG.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Changelog
2+
3+
## [3.10] - October 2021
4+
5+
### Known issue
6+
- DSG-3945 Unable to write fuse byte 0 on Curiosity Nano ATtiny kits
7+
8+
### Added
9+
- DSG-2702 Add serialupdi backend for AVR EA
10+
- DSG-3633 github-3 Add missing AVR-DB devices
11+
- DSG-3635 github-4 Add missing ATtiny devices
12+
- DSG-3662 Add ascii-art for serialUPDI
13+
- DSG-3804 Add py39 metadata to package
14+
- DSG-3943 github-7 Add CLI documentation
15+
16+
### Fixed
17+
- DSG-2859 github-1 serialUPDI write user_row on locked device fails
18+
- DSG-3538 github-2 Unable to write fuses on ATmega4809 using serialUPDI
19+
- DSG-3817 SAM D21 user row programming fails
20+
- DSG-3952 Incorrect size of FUSES on Dx, Ex devices
21+
22+
## [3.9] - April 2021
23+
24+
### Added
25+
- DSG-2920 Raise exception if device ID does not match
26+
- DSG-2918 SerialUPDI: error recovery if non-ascii characters are read in SIB
27+
- DSG-2861 Valid memory types are listed if an invalid one is specified
28+
29+
### Fixed
30+
- DSG-3238 PIC16 eeprom displays incorrect address
31+
- DSG-3239 PIC16 eeprom verification does not work
32+
- DSG-2925 UPDI device revision not correctly parsed/displayed
33+
- DSG-2860 SerialUPDI: chip erase does not work on locked device
34+
- DSG-2857 SerialUPDI: crash when writing lockbits
35+
- DSG-2855 Verify action fails if hex file contains eeprom content
36+
- DSG-2854 User row excluded when reading to hex file
37+
- DSG-2850 UPDI device model fix (sram)
38+
39+
### Changed
40+
- DSG-2862 Improved exception handling
41+
- DSG-3203 Improved exception handling
42+
- DSG-3178 Cosmetic changes for publication
43+
44+
## [3.7.4] - December 2020
45+
46+
### Added
47+
- DSG-1492 Added verify function
48+
- DSG-2039 Added all UPDI devices
49+
- DSG-2279 Added error codes
50+
- DSG-1550 Flash-only erase
51+
52+
### Fixed
53+
- DSG-2470 No feedback when multiple kits are connected
54+
- DSG-2014 Error when reading using -m and -o but no -b
55+
- DSG-2738 Padding to page size when writing user row on locked device
56+
57+
### Changed
58+
- DSG-2234 Logging using logging module
59+
- DSG-2034 prevent read using -b with no -m specified
60+
- DSG-2009 prevent writing from hexfile with memory type specified
61+
- DSG-2012 prevent writing from hexfile with offset specified
62+
- DSG-2458 documentation changes
63+
- DSG-2041 documentation changes
64+
- DSG-2042 documentation changes
65+
- DSG-2043 documentation changes
66+
- DSG-2011 documentation changes
67+
68+
## [3.1.3] - June 2020
69+
- First public release to PyPi

LICENSE.txt

Lines changed: 21 additions & 0 deletions
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

Lines changed: 7 additions & 0 deletions
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

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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+
## Usage
16+
pymcuprog can be used as a command-line interface or a library
17+
18+
### CLI help
19+
For more help with using pymcuprog CLI see [help](./help.md)
20+
21+
### CLI examples
22+
When installed using pip, pymcuprog CLI is located in the Python scripts folder.
23+
24+
Example 1: test connectivity by reading the device ID using Curiosity Nano:
25+
```bash
26+
pymcuprog ping
27+
```
28+
29+
Example 2: write contents of a hexfile to flash using Curiosity Nano:
30+
```bash
31+
pymcuprog write -f app.hex
32+
```
33+
34+
### Serial port UPDI (pyupdi)
35+
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.
36+
37+
<pre>
38+
Vcc Vcc
39+
+-+ +-+
40+
| |
41+
+---------------------+ | | +--------------------+
42+
| Serial port +-+ +-+ AVR device |
43+
| | +----------+ | |
44+
| TX +------+ 1k +---------+ UPDI |
45+
| | +----------+ | | |
46+
| | | | |
47+
| RX +----------------------+ | |
48+
| | | |
49+
| +--+ +--+ |
50+
+---------------------+ | | +--------------------+
51+
+-+ +-+
52+
GND GND
53+
</pre>
54+
55+
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.
56+
57+
Example: checks connectivity by reading the device identity
58+
```bash
59+
pymcuprog ping -d avr128da48 -t uart -u com35
60+
```
61+
62+
For more examples see [pymcuprog on pypi.org](https://pypi.org/project/pymcuprog/)
63+
64+
### Library usage example
65+
pymcuprog can be used as a library using its backend API. For example:
66+
```python
67+
"""
68+
Example usage of pymcuprog as a library to read the device ID
69+
"""
70+
# pymcuprog uses the Python logging module
71+
import logging
72+
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)
73+
74+
# Configure the session
75+
from pymcuprog.backend import SessionConfig
76+
sessionconfig = SessionConfig("atmega4808")
77+
78+
# Instantiate USB transport (only 1 tool connected)
79+
from pymcuprog.toolconnection import ToolUsbHidConnection
80+
transport = ToolUsbHidConnection()
81+
82+
# Instantiate backend
83+
from pymcuprog.backend import Backend
84+
backend = Backend()
85+
86+
# Connect to tool using transport
87+
backend.connect_to_tool(transport)
88+
89+
# Start the session
90+
backend.start_session(sessionconfig)
91+
92+
# Read the target device_id
93+
device_id = backend.read_device_id()
94+
print ("Device ID is {0:06X}".format(int.from_bytes(device_id, byteorder="little")))
95+
```
96+
97+
## Supported devices and tools
98+
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.
99+
100+
### Debuggers / Tools
101+
pymcuprog supports:
102+
* PKOB nano (nEDBG) - on-board debugger on Curiosity Nano
103+
* MPLAB PICkit 4 In-Circuit Debugger (when in 'AVR mode')
104+
* MPLAB Snap In-Circuit Debugger (when in 'AVR mode')
105+
* Atmel-ICE
106+
* Power Debugger
107+
* EDBG - on-board debugger on Xplained Pro/Ultra
108+
* mEDBG - on-board debugger on Xplained Mini/Nano
109+
* JTAGICE3 (firmware version 3.0 or newer)
110+
111+
Although not all functionality is provided on all debuggers/boards. See device support section below.
112+
113+
### Devices
114+
pymcuprog supports:
115+
* All UPDI devices, whether mounted on kits or standalone
116+
* PIC devices mounted on Curiosity Nano kits, or similar board with PKOB nano (nEDBG) debugger
117+
118+
Other devices (eg ATmega328P, ATsamd21e18a) may be partially supported for experimental purposes
119+
120+
## Notes for Linux® systems
121+
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

Lines changed: 20 additions & 0 deletions
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

Lines changed: 35 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 9 additions & 0 deletions
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+
Lines changed: 47 additions & 0 deletions
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 %}

0 commit comments

Comments
 (0)