Commit Graph

3548 Commits

Author SHA1 Message Date
Joerg Wunsch
73c8a7854b Populate many more methods of struct programmer_t
For optional methods, place checks that prevent dereferencing NULL
pointers, resulting in a SWIG exception instead.

For methods that return values in pointers, provide "argout" typemaps.
2024-03-20 13:52:48 +01:00
Joerg Wunsch
a02994dd12 Always populate setup and teardown methods of struct programmer_t
Many programmer implementations require "cookies" to store internal
data. It helps to be able to always call setup and teardown methods.
2024-03-20 13:46:26 +01:00
Joerg Wunsch
0e7a76f837 Fix typo: False -> false
This is C code, not Python. ;-)
2024-03-20 10:07:33 +01:00
Joerg Wunsch
1de634ffa1 Make the reporting functions a bit more robust
Sometimes, non-ASCII characters might appear in message strings,
causing a UTF-8 decoding error. Catch it, so the remainder can
proceed.
2024-03-19 23:13:15 +01:00
Joerg Wunsch
cbfaa9f718 Add an argout typemap for read_sib
This allows to convert the read_sib result into a Python
bytes() object.
2024-03-19 23:08:17 +01:00
Joerg Wunsch
fa78ea3a34 Set the progress and message callbacks by default
Also bump verbosity to 2 as a starting point - this is
development right now.
2024-03-19 23:07:23 +01:00
Joerg Wunsch
5fd5cffdda Use correct index into tuple in message_type() 2024-03-19 23:06:47 +01:00
Joerg Wunsch
984eb922b2 Remove MSVC build for arm64 by now
It attempts to link against the wrong (x86) Python libs.
2024-03-18 22:09:27 +01:00
Joerg Wunsch
858c3f696c Add an update_progress implementation
This allows for Python code providing a callback function that
is used to indicate progress.

Also fix a few minor things in message callback (reference
counting of Python objects).
2024-03-18 20:57:17 +01:00
Joerg Wunsch
296883cf1a Initialize progress reporting in avr_{read,write}_mem
Progress reporting needs to be initialized by passing it a "header"
string, in order to re-adjust internal static variables.
avr_{read,write}_mem did not do this, so they only reported progress
upon the very first invocation.
2024-03-18 20:55:19 +01:00
Joerg Wunsch
68d44ea1e6 Implement Python callback for avrdude_message2()
Doing so requires quite a bit of C preprocessing, since a va_list from
C cannot be passed to a Python function directly.

Also, using stdout or stderr is not necessarily going to be the
correct target for a Python program, so instead, convert the FILE*
arguments to names to pass them to Python.

By now, the '\v' feature of the message system (conditional newline)
is ignored here.
2024-03-18 17:45:55 +01:00
Joerg Wunsch
5782c182c1 Update swigtest.py
Reflect current status: helper to start and stop a programmer in the
correct sequence. Read signature memory space, and compare signature
against config file definition.
2024-03-15 22:52:59 +01:00
Joerg Wunsch
1e3dc29d81 Add more docstrings, clean-up warnings 2024-03-15 21:12:10 +01:00
Joerg Wunsch
a3475a6629 Implement the heart of struct programmer_t
This also implements the main methods that need to be accessible
from outside, as kind-of an OO approach to struct programmer_t.
2024-03-15 17:57:56 +01:00
Joerg Wunsch
c9cee81281 Add a typemap to represent the AVRPART signature as Python bytes. 2024-03-15 17:27:17 +01:00
Joerg Wunsch
920b964af9 Add AVRMEM* buffer handling methods
m->buf is not directly accessible from within Python. Add two methods
that allow to place and retrieve data there, as Python bytes() objects.
2024-03-15 14:35:07 +01:00
Joerg Wunsch
356693dab4 Add device variants to example printout 2024-03-13 13:56:40 +01:00
Joerg Wunsch
1968a11754 Combine the various cast_* functions with ldata()
All these typecast helpers are supposed to operate on LNODEID elements,
in order to convert them to the desired target type. As such, it makes
sense to include the ldata() LNODEID access itself.

Add docstrings for them as well, also for the entire module.
2024-03-13 12:53:30 +01:00
Joerg Wunsch
d34324ceed Add a -v option to build.sh
This allows for a verbose build, where the commands being called
are displayed.
2024-03-12 20:54:21 +01:00
Joerg Wunsch
f9b959343e Replace hand-crafted dicts for AVRMEM and AVRPART by SWIG structs
This requires a bit of Python helpers for pretty-printing, but
otherwise simplifies many things later on.
2024-03-12 18:12:28 +01:00
Joerg Wunsch
fd8704d982 Implement avrdude_message2() from main.c
This is eventually to be replaced by a Python callback.
Right now, use what main.c is using.
2024-03-10 22:55:50 +01:00
Joerg Wunsch
65bf6393da Declare avrdude_message*() in library header file
While these functions are *not* implemented by the library itself,
they are supposed to be provided by whatever application is using the
library. As such, they need to be declared in the public library
header file, including the various constants for msglvl and msgmode.
2024-03-10 22:50:24 +01:00
mcuee
e986f167db Add PYTHON_LIBRARY to swig_libavrdude linking 2024-03-09 20:55:25 +08:00
Joerg Wunsch
e063bf16db Make path to os.add_dll_directory() absolute 2024-03-09 08:15:38 +01:00
Joerg Wunsch
3f5c32b6d4 Fix include directories for SWIG build 2024-03-08 16:16:35 +01:00
Joerg Wunsch
8c4f3b0632 Tweak Windows DLL search paths 2024-03-08 16:10:46 +01:00
mcuee
cfe608a63f Update build.yml to use CMAKE_VERBOSE_MAKEFILE to debug Windows build
This is to debug Windows MSVC and MSYS2 build.
Previous change already use the same option to debug macOS build.
2024-03-08 17:23:07 +08:00
Joerg Wunsch
9be5164b5b Add prog_modes to AVRPART* wrapper
Can be then passed to ad.avr_prog_modes_str() to decode nicely.
2024-03-08 08:58:29 +01:00
Joerg Wunsch
e10730ef40 Add some heuristics to find out the Windows build directory
Adding the build directory to the module search path eases development
by now.
2024-03-08 08:39:07 +01:00
Joerg Wunsch
3f944559b6 Add PM_* names, and signature search functions 2024-03-07 22:49:13 +01:00
Joerg Wunsch
334b8c5899 Protect AVRMEM* and AVRPART* typemaps agains NULL pointers
Some library functions might return AVRMEM* and AVRPART* as
NULL pointers. Prevent them from being dereferenced, and
return a Python None object instead.
2024-03-07 22:49:13 +01:00
Joerg Wunsch
377d3f353c Turn PM_* #defines into an enum
This helps the SWIG wrapper to define them as well.
2024-03-07 22:49:13 +01:00
mcuee
9567f96f1b Update build.yml to revert previous change 2024-03-06 23:15:07 +08:00
mcuee
02d3e16b0e One more try to debug macOS build for SWIG 2024-03-06 23:11:11 +08:00
mcuee
9f6badaf18 Update build.yml to debug macOS Homebrew CI issue 2024-03-06 21:28:25 +08:00
mcuee
a98d2155e7 Update build.yml to add Python/Swig for MSYS2 build 2024-03-06 20:22:09 +08:00
mcuee
d48c944df2 Update build.yml to use Homebrew python 2024-03-06 20:13:01 +08:00
Joerg Wunsch
d4fe955808 Merge remote-tracking branch 'upstream/main' into swig_libavrdude 2024-03-03 21:59:32 +01:00
Joerg Wunsch
4f455c6043 First tiny little steps towards a SWIG "hello world"
Config file handling and basic list handling is there.
2024-03-03 21:37:08 +01:00
stefanrueger
34366a6b9d Update test-avrdude help message 2024-02-29 20:26:57 +13:00
stefanrueger
27eb695c21 Update NEWS 2024-02-29 11:46:58 +13:00
Stefan Rueger
076e2e90cd Merge pull request #1709 from stefanrueger/benchmark
Add benchmark option `-b` for `test-avrdude`
2024-02-29 11:41:38 +13:00
Stefan Rueger
e5304a4d59 Merge pull request #1707 from ndim/fix-cmake-builds-related-to-ac_cfg.h
Fix cmake build errors related to ac_cfg.h
2024-02-29 11:41:17 +13:00
stefanrueger
71a9cb47b3 Keep case of part in test-avrdude -b -p "-p part ..." 2024-02-28 23:27:38 +13:00
stefanrueger
e35714b1ce Change 1-byte file upload for emulated chip erase 2024-02-28 22:14:28 +13:00
stefanrueger
64c5d1da0b Remove avrbench and generate 4-number benchmark table with legend 2024-02-28 22:07:18 +13:00
stefanrueger
61ed3dd18f Mention avrbench legend in test-avrdude -b summary 2024-02-27 23:14:31 +13:00
stefanrueger
82c001bab4 Drop chip erase and checking test for test-avrdude -b 2024-02-27 23:10:01 +13:00
stefanrueger
efd6bab19c Widen chip erase tests to also capture -c urclock emulation 2024-02-27 22:51:36 +13:00
stefanrueger
cd41d2b4e2 Change /dev/null to temp file to be Windows compatible 2024-02-27 15:00:22 +13:00