Trying to use a Raspberry Pi 4’s native UART (physical pins 8 and 10 on the GPIO header) to program an ATtiny402, using the pymcuprog library:
aaron@Aaron-Bench:~ $ sudo pip install pymcuprog
[sudo] password for aaron:
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pymcuprog
Downloading pymcuprog-3.17.3.45-py3-none-any.whl (224 kB)
|████████████████████████████████| 224 kB 968 kB/s
Collecting IntelHex
Downloading https://www.piwheels.org/simple/intelhex/intelhex-2.3.0-py2.py3-none-any.whl (50 kB)
|████████████████████████████████| 50 kB 175 kB/s
Collecting appdirs
Downloading https://www.piwheels.org/simple/appdirs/appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Collecting PyYAML
Downloading PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (731 kB)
|████████████████████████████████| 731 kB 1.1 MB/s
Collecting pyedbglib>=2.24
Downloading pyedbglib-2.24.2.18-py3-none-any.whl (70 kB)
|████████████████████████████████| 70 kB 810 kB/s
Requirement already satisfied: pyserial in /usr/lib/python3/dist-packages (from pymcuprog) (3.5b0)
Collecting hidapi
Downloading hidapi-0.14.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (925 kB)
|████████████████████████████████| 925 kB 23 kB/s
Collecting pyserial
Downloading https://www.piwheels.org/simple/pyserial/pyserial-3.5-py2.py3-none-any.whl (90 kB)
|████████████████████████████████| 90 kB 286 kB/s
Collecting cython
Downloading Cython-3.0.10-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.5 MB)
|████████████████████████████████| 3.5 MB 1.4 MB/s
Requirement already satisfied: setuptools>=19.0 in /usr/lib/python3/dist-packages (from hidapi->pyedbglib>=2.24->pymcuprog) (52.0.0)
Installing collected packages: pyserial, hidapi, cython, PyYAML, pyedbglib, IntelHex, appdirs, pymcuprog
Attempting uninstall: pyserial
Found existing installation: pyserial 3.5b0
Not uninstalling pyserial at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'pyserial'. No files were found to uninstall.
Successfully installed IntelHex-2.3.0 PyYAML-6.0.1 appdirs-1.4.4 cython-3.0.10 hidapi-0.14.0 pyedbglib-2.24.2.18 pymcuprog-3.17.3.45 pyserial-3.5
aaron@Aaron-Bench:~ $ pymcuprog ping -d attiny402 -t uart -u /dev/ttyS0
Connecting to SerialUPDI
pymcuprog.pymcuprog - ERROR - Operation failed with error: (22, 'Invalid argument')
aaron@Aaron-Bench:~ $
Just to check and see if it’s even trying, I put a logic analyzer on the wire and tried again. It saw nothing. But CuteCom does work:
Okay, so the port works, and the 1k “contention resistor” works as an echo, as seen in CuteCom.
Back to pymcuprog, intentionally keeping the port open in CuteCom as another test:
aaron@Aaron-Bench:~ $ pymcuprog ping -d attiny402 -t uart -u /dev/ttyS0
Connecting to SerialUPDI
pymcuprog.serialupdi.physical - ERROR - Unable to open serial port '/dev/ttyS0'
pymcuprog.pymcuprog - ERROR - Operation failed with SerialException: [Errno 16] could not open port /dev/ttyS0: [Errno 16] Device or resource busy: '/dev/ttyS0'
aaron@Aaron-Bench:~ $
So at least I got the port right. The “Invalid argument” can’t be that.
Closed the port in CuteCom, re-armed the logic analyzer, and tried pymcuprog again. Same error as the first time, and the analyzer again saw nothing.
With such a terrible error message, I’m out of ideas. Anyone know what’s going on?