Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make programmer usbasp libavrdude ready #1763

Merged
merged 10 commits into from
Apr 25, 2024
Merged

Conversation

stefanrueger
Copy link
Collaborator

  • Move static variables to PDATA space in usbasp.c
  • Utilise magic memory tree interface for usbasp.c
  • Implement usbasp_tpi_write_byte()

It's a draft that is supposed to also fix #1755.

@MCUdude
Copy link
Collaborator

MCUdude commented Apr 19, 2024

@stefanrueger do you have an idea what happened to the make build system? I'm not able to build anymore:

$ ./configure
checking build system type... x86_64-apple-darwin21.6.0
checking host system type... x86_64-apple-darwin21.6.0
checking target system type... x86_64-apple-darwin21.6.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... mkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking versioninfo item CMAKE_PROJECT_VERSION... 7.3
checking versioninfo item GIT_COMMIT_DATE... 20240413
checking versioninfo item GIT_COMMIT_HASH... 428ea426
checking versioninfo item GIT_TAG_HASH... e599214c
checking versioninfo derived PACKAGE_VERSION... 7.3-20240413
checking versioninfo derived AVRDUDE_FULL_VERSION... 7.3-20240413 (428ea426)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking for gawk... (cached) awk
checking for a sed that does not truncate output... /usr/bin/sed
checking for bison... bison -y
checking for flex... flex
checking for lex output file root... lex.yy
checking for lex library... none needed
checking whether yytext is a pointer... yes
checking for ar... ar
checking the archiver (ar) interface... ar
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 786432
checking how to convert x86_64-apple-darwin21.6.0 file names to x86_64-apple-darwin21.6.0 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin21.6.0 file names to toolchain format... func_convert_file_noop
checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r
checking for file... file
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin21.6.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking whether yylex_destroy is generated by flex... version Apple(flex-34) => yes
checking for WSAStartup in -lws2_32... no
checking for tputs in -ltermcap... yes
checking for tputs in -lncurses... yes
checking for readline in -lreadline... yes
checking for elf_getshdrstrndx in -lelf... yes
checking for libelf.h... no
checking for libelf/libelf.h... yes
checking for library containing gethostent... none required
checking for library containing setsockopt... none required
checking for usb_get_string_simple in -lusb... yes
checking for usb.h... yes
checking for lusb0_usb.h... no
checking for libusb_init in -lusb-1.0... yes
checking for libusb-1.0/libusb.h... yes
checking for libusb.h... no
checking for libusb_init in -lusb... no
checking for libusb.h... (cached) no
checking for library containing hid_init... -lhidapi
checking for hidapi/hidapi.h... yes
checking for sp_open in -lserialport... yes
checking for libserialport.h... yes
checking for ftdi_new in -lftdi1... yes
checking for ftdi_usb_get_strings in -lftdi... no
checking for ftdi_tcioflush... yes
checking for pthread.h... yes
checking for pthread_create in -lpthread... yes
checking for limits.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for fcntl.h... yes
checking for sys/ioctl.h... yes
checking for sys/time.h... yes
checking for termios.h... yes
checking for unistd.h... (cached) yes
checking for ddk/hidsdi.h... no
checking for an ANSI C-conforming const... yes
checking for netinet/in.h... yes
checking for memset... yes
checking for select... yes
checking for strcasecmp... yes
checking for strdup... yes
checking for strerror... yes
checking for strncasecmp... yes
checking for strtol... yes
checking for strtoul... yes
checking for gettimeofday... yes
checking for usleep... yes
checking for getaddrinfo... yes
checking for a Win32 HID library... no
checking for uint_t... no
checking for ulong_t... no
checking for serial device... unknown
checking if gcc accepts -Wno-pointer-sign ... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating doc/Makefile
config.status: creating avrdude.spec
config.status: creating Makefile
config.status: creating GNUmakefile
config.status: creating avrdude.conf.tmp
config.status: creating ac_cfg.h
config.status: ac_cfg.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands


Configuration summary:
----------------------
DO HAVE    libelf
DO HAVE    libusb
DO HAVE    libusb_1_0
DO HAVE    libftdi1
DON'T HAVE libftdi
DON'T HAVE libhid
DO HAVE    libhidapi
DO HAVE    libreadline
DO HAVE    libserialport
DO HAVE    pthread
DISABLED   doc
DISABLED   parport
DISABLED   linuxgpio
DISABLED   linuxspi

$ make
GIT_COMMIT_DATE has changed from 20240413 to 20240417
Recorded and current version information do not match.
Re-running autoreconf via bootstrap.
+ rm -rf autom4te.cache
+ LIBTOOLIZE=libtoolize
+ glibtoolize --version
+ LIBTOOLIZE=glibtoolize
+ export LIBTOOLIZE
+ autoreconf -i
configure.ac:104: error: Macro PKG_PROG_PKG_CONFIG is not available. It is usually defined in file pkg.m4 provided by package pkg-config.
configure.ac:104: the top level
autom4te: error: /usr/local/opt/m4/bin/m4 failed with exit status: 1
aclocal: error: /usr/local/Cellar/autoconf/2.72/bin/autom4te failed with exit status: 1
autoreconf: error: aclocal failed with exit status: 1
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh '/Users/hans/Downloads/avrdude-terminal/src/auto-aux/missing' aclocal-1.16 -I auto-m4 -I build-helpers
configure.ac:104: error: Macro PKG_PROG_PKG_CONFIG is not available. It is usually defined in file pkg.m4 provided by package pkg-config.
configure.ac:104: the top level
autom4te: error: /usr/local/opt/m4/bin/m4 failed with exit status: 1
aclocal-1.16: error: autom4te failed with exit status: 1
make: *** [aclocal.m4] Error 1

@MCUdude
Copy link
Collaborator

MCUdude commented Apr 19, 2024

I can confirm that 4761a70 is the issue on my computer...

@stefanrueger
Copy link
Collaborator Author

I don't have the foggiest. I use the following Makefile

all:
	cmake --build build_linux

install:
	cmake --build build_linux; sudo cmake --build build_linux --target install

new:
	sudo rm -rf build_linux
	./build.sh 
	cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo -D HAVE_LINUXGPIO=1 -D HAVE_LINUXSPI=1 -D HAVE_PARPORT=1 -B build_linux
	cmake --build build_linux

and type make new, then a series of make and make install... You might be able to adapt this to MacOS?

@stefanrueger stefanrueger added the enhancement New feature or request label Apr 19, 2024
@stefanrueger
Copy link
Collaborator Author

I can confirm that 4761a70 is the issue on my computer...

Ahh, that are changes that were intended to make a new version of libgpiod available on Linux. So that PR #1725 wasn't tested to work for MacOS. Maybe @mhei or @mcuee can help?

@mcuee
Copy link
Collaborator

mcuee commented Apr 20, 2024

@MCUdude and @stefanrueger

No issues here under my Mac Mini M1 2020 (macOS 14.4.1).

The following is the build log for git main.

mcuee@mcuees-Mac-mini src % CFLAGS="-I/opt/homebrew/include" LDFLAGS="-L/opt/homebrew/lib" ./configure --prefix=/Users/mcuee/bin
checking build system type... aarch64-apple-darwin23.4.0
checking host system type... aarch64-apple-darwin23.4.0
checking target system type... aarch64-apple-darwin23.4.0
checking for a BSD-compatible install... /opt/homebrew/bin/ginstall -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /opt/homebrew/bin/gmkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking versioninfo item CMAKE_PROJECT_VERSION... 7.3
checking versioninfo item GIT_COMMIT_DATE... 20240417
checking versioninfo item GIT_COMMIT_HASH... 8fe729f0
checking versioninfo item GIT_TAG_HASH... e599214c
checking versioninfo derived PACKAGE_VERSION... 7.3-20240417
checking versioninfo derived AVRDUDE_FULL_VERSION... 7.3-20240417 (8fe729f0)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking for gawk... (cached) gawk
checking for a sed that does not truncate output... /opt/homebrew/bin/gsed
checking for bison... bison -y
checking for flex... flex
checking for lex output file root... lex.yy
checking for lex library... none needed
checking whether yytext is a pointer... yes
checking for ar... ar
checking the archiver (ar) interface... ar
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /opt/homebrew/bin/gsed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 786432
checking how to convert aarch64-apple-darwin23.4.0 file names to aarch64-apple-darwin23.4.0 format... func_convert_file_noop
checking how to convert aarch64-apple-darwin23.4.0 file names to toolchain format... func_convert_file_noop
checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r
checking for file... file
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... ld: warning: -single_module is obsolete
no
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin23.4.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking pkg-config is at least version 0.23... yes
checking whether yylex_destroy is generated by flex... version Apple(flex-34) => yes
checking for WSAStartup in -lws2_32... no
checking for tputs in -ltermcap... yes
checking for tputs in -lncurses... yes
checking for readline in -lreadline... yes
checking for elf_getshdrstrndx in -lelf... yes
checking for libelf.h... no
checking for libelf/libelf.h... yes
checking for library containing gethostent... none required
checking for library containing setsockopt... none required
checking for usb_get_string_simple in -lusb... yes
checking for usb.h... yes
checking for lusb0_usb.h... no
checking for libusb_init in -lusb-1.0... yes
checking for libusb-1.0/libusb.h... yes
checking for libusb.h... no
checking for libusb_init in -lusb... no
checking for libusb.h... (cached) no
checking for library containing hid_init... -lhidapi
checking for hidapi/hidapi.h... yes
checking for sp_open in -lserialport... yes
checking for libserialport.h... yes
checking for ftdi_new in -lftdi1... yes
checking for ftdi_usb_get_strings in -lftdi... no
checking for ftdi_tcioflush... yes
checking for pthread.h... yes
checking for pthread_create in -lpthread... yes
checking for limits.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for fcntl.h... yes
checking for sys/ioctl.h... yes
checking for sys/time.h... yes
checking for termios.h... yes
checking for unistd.h... (cached) yes
checking for ddk/hidsdi.h... no
checking for an ANSI C-conforming const... yes
checking for netinet/in.h... yes
checking for memset... yes
checking for select... yes
checking for strcasecmp... yes
checking for strdup... yes
checking for strerror... yes
checking for strncasecmp... yes
checking for strtol... yes
checking for strtoul... yes
checking for gettimeofday... yes
checking for usleep... yes
checking for getaddrinfo... yes
checking for a Win32 HID library... no
checking for uint_t... no
checking for ulong_t... no
checking for serial device... unknown
checking if gcc accepts -Wno-pointer-sign ... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating doc/Makefile
config.status: creating avrdude.spec
config.status: creating Makefile
config.status: creating GNUmakefile
config.status: creating avrdude.conf.tmp
config.status: creating ac_cfg.h
config.status: executing depfiles commands
config.status: executing libtool commands


Configuration summary:
----------------------
DO HAVE    libelf
DO HAVE    libusb
DO HAVE    libusb_1_0
DO HAVE    libftdi1
DON'T HAVE libftdi
DON'T HAVE libhid
DO HAVE    libhidapi
DO HAVE    libreadline
DO HAVE    libserialport
DO HAVE    pthread
DISABLED   doc
DISABLED   parport
DISABLED   linuxgpio
DISABLED   linuxspi
mcuee@mcuees-Mac-mini src % make
/Library/Developer/CommandLineTools/usr/bin/make  all-recursive
Making all in .
  CC       avrdude-main.o
  CC       avrdude-whereami.o
  CC       avrdude-developer_opts.o
  CC       libavrdude_a-config_gram.o
  CC       libavrdude_a-lexer.o
lexer.c:2434:38: warning: comparison of integers of different signs: 'yy_size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
        if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
  CC       libavrdude_a-arduino.o
  CC       libavrdude_a-avr.o
  CC       libavrdude_a-avr910.o
  CC       libavrdude_a-avrcache.o
  CC       libavrdude_a-avrftdi.o
  CC       libavrdude_a-avrftdi_tpi.o
  CC       libavrdude_a-avrintel.o
  CC       libavrdude_a-avrpart.o
  CC       libavrdude_a-bitbang.o
  CC       libavrdude_a-buspirate.o
  CC       libavrdude_a-butterfly.o
  CC       libavrdude_a-ch341a.o
  CC       libavrdude_a-config.o
  CC       libavrdude_a-confwin.o
  CC       libavrdude_a-dfu.o
  CC       libavrdude_a-dryrun.o
  CC       libavrdude_a-fileio.o
  CC       libavrdude_a-flip1.o
  CC       libavrdude_a-flip2.o
  CC       libavrdude_a-ft245r.o
  CC       libavrdude_a-jtagmkI.o
  CC       libavrdude_a-jtagmkII.o
  CC       libavrdude_a-jtag3.o
  CC       libavrdude_a-leds.o
  CC       libavrdude_a-linuxgpio.o
  CC       libavrdude_a-linuxspi.o
  CC       libavrdude_a-lists.o
  CC       libavrdude_a-micronucleus.o
  CC       libavrdude_a-par.o
  CC       libavrdude_a-pgm.o
  CC       libavrdude_a-pgm_type.o
  CC       libavrdude_a-pickit2.o
  CC       libavrdude_a-pindefs.o
  CC       libavrdude_a-ppi.o
  CC       libavrdude_a-ppiwin.o
  CC       libavrdude_a-serbb_posix.o
  CC       libavrdude_a-serbb_win32.o
  CC       libavrdude_a-ser_avrdoper.o
  CC       libavrdude_a-ser_posix.o
  CC       libavrdude_a-ser_win32.o
  CC       libavrdude_a-serialadapter.o
  CC       libavrdude_a-stk500.o
  CC       libavrdude_a-stk500v2.o
  CC       libavrdude_a-stk500generic.o
  CC       libavrdude_a-strutil.o
  CC       libavrdude_a-teensy.o
  CC       libavrdude_a-term.o
  CC       libavrdude_a-usbasp.o
  CC       libavrdude_a-serialupdi.o
  CC       libavrdude_a-updi_link.o
  CC       libavrdude_a-updi_state.o
  CC       libavrdude_a-updi_readwrite.o
  CC       libavrdude_a-updi_nvm.o
  CC       libavrdude_a-updi_nvm_v0.o
  CC       libavrdude_a-updi_nvm_v2.o
  CC       libavrdude_a-updi_nvm_v3.o
  CC       libavrdude_a-updi_nvm_v4.o
  CC       libavrdude_a-updi_nvm_v5.o
  CC       libavrdude_a-urclock.o
  CC       libavrdude_a-usb_hidapi.o
  CC       libavrdude_a-usb_libusb.o
  CC       libavrdude_a-usbtiny.o
  CC       libavrdude_a-update.o
  CC       libavrdude_a-wiring.o
  CC       libavrdude_a-xbee.o
  AR       libavrdude.a
  CCLD     avrdude
ld: warning: search path 'CoreFoundation' not found
  CC       libavrdude_la-config_gram.lo
  CC       libavrdude_la-lexer.lo
lexer.c:2434:38: warning: comparison of integers of different signs: 'yy_size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
        if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
  CC       libavrdude_la-arduino.lo
  CC       libavrdude_la-avr.lo
  CC       libavrdude_la-avr910.lo
  CC       libavrdude_la-avrcache.lo
  CC       libavrdude_la-avrftdi.lo
  CC       libavrdude_la-avrftdi_tpi.lo
  CC       libavrdude_la-avrintel.lo
  CC       libavrdude_la-avrpart.lo
  CC       libavrdude_la-bitbang.lo
  CC       libavrdude_la-buspirate.lo
  CC       libavrdude_la-butterfly.lo
  CC       libavrdude_la-ch341a.lo
  CC       libavrdude_la-config.lo
  CC       libavrdude_la-confwin.lo
  CC       libavrdude_la-dfu.lo
  CC       libavrdude_la-dryrun.lo
  CC       libavrdude_la-fileio.lo
  CC       libavrdude_la-flip1.lo
  CC       libavrdude_la-flip2.lo
  CC       libavrdude_la-ft245r.lo
  CC       libavrdude_la-jtagmkI.lo
  CC       libavrdude_la-jtagmkII.lo
  CC       libavrdude_la-jtag3.lo
  CC       libavrdude_la-leds.lo
  CC       libavrdude_la-linuxgpio.lo
  CC       libavrdude_la-linuxspi.lo
  CC       libavrdude_la-lists.lo
  CC       libavrdude_la-micronucleus.lo
  CC       libavrdude_la-par.lo
  CC       libavrdude_la-pgm.lo
  CC       libavrdude_la-pgm_type.lo
  CC       libavrdude_la-pickit2.lo
  CC       libavrdude_la-pindefs.lo
  CC       libavrdude_la-ppi.lo
  CC       libavrdude_la-ppiwin.lo
  CC       libavrdude_la-serbb_posix.lo
  CC       libavrdude_la-serbb_win32.lo
  CC       libavrdude_la-ser_avrdoper.lo
  CC       libavrdude_la-ser_posix.lo
  CC       libavrdude_la-ser_win32.lo
  CC       libavrdude_la-serialadapter.lo
  CC       libavrdude_la-stk500.lo
  CC       libavrdude_la-stk500v2.lo
  CC       libavrdude_la-stk500generic.lo
  CC       libavrdude_la-strutil.lo
  CC       libavrdude_la-teensy.lo
  CC       libavrdude_la-term.lo
  CC       libavrdude_la-usbasp.lo
  CC       libavrdude_la-serialupdi.lo
  CC       libavrdude_la-updi_link.lo
  CC       libavrdude_la-updi_state.lo
  CC       libavrdude_la-updi_readwrite.lo
  CC       libavrdude_la-updi_nvm.lo
  CC       libavrdude_la-updi_nvm_v0.lo
  CC       libavrdude_la-updi_nvm_v2.lo
  CC       libavrdude_la-updi_nvm_v3.lo
  CC       libavrdude_la-updi_nvm_v4.lo
  CC       libavrdude_la-updi_nvm_v5.lo
  CC       libavrdude_la-urclock.lo
  CC       libavrdude_la-usb_hidapi.lo
  CC       libavrdude_la-usb_libusb.lo
  CC       libavrdude_la-usbtiny.lo
  CC       libavrdude_la-update.lo
  CC       libavrdude_la-wiring.lo
  CC       libavrdude_la-xbee.lo
  CCLD     libavrdude.la

@mcuee
Copy link
Collaborator

mcuee commented Apr 20, 2024

@MCUdude

Please install pkg-config to see if the issue goes away.
pkgconf is another alternative but I use pkg-config since that is what I use under Linux. Take note you can only install one of the two packages.

mcuee@mcuees-Mac-mini src % brew info pkg-config
==> pkg-config: stable 0.29.2 (bottled)
Manage compile and link flags for libraries
https://freedesktop.org/wiki/Software/pkg-config/
Conflicts with:
  pkgconf (because both install `pkg.m4` file)
Installed
/opt/homebrew/Cellar/pkg-config/0.29.2_3 (11 files, 676.9KB) *
  Poured from bottle on 2021-03-26 at 18:55:59
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/p/pkg-config.rb
License: GPL-2.0-or-later
==> Analytics
install: 48,780 (30 days), 145,038 (90 days), 594,000 (365 days)
install-on-request: 13,488 (30 days), 44,146 (90 days), 178,505 (365 days)
build-error: 413 (30 days)

mcuee@mcuees-Mac-mini src % brew info pkgconf
==> pkgconf: stable 2.1.1 (bottled), HEAD
Package compiler and linker metadata toolkit
https://github.com/pkgconf/pkgconf
Conflicts with:
  pkg-config (because both install `pkg.m4` file)
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/p/pkgconf.rb
License: ISC
==> Options
--HEAD
	Install HEAD version
==> Analytics
install: 117 (30 days), 400 (90 days), 1,611 (365 days)
install-on-request: 107 (30 days), 351 (90 days), 1,464 (365 days)
build-error: 0 (30 days)

@mcuee
Copy link
Collaborator

mcuee commented Apr 20, 2024

and type make new, then a series of make and make install... You might be able to adapt this to MacOS?

@stefanrueger

The step of build.sh is probably not necessary in your Makefile. But similar idea should work under macOS. Just make install needs to be careful -- you need to set up the correct prefix as /usr/local may not be desired for macOS Homebrew. It will break my system for example as I have /opt/homebrew for native ARM64 Homebrew and /usr/local for x64 Homebrew.

I do not install PRs to the system -- I only install git main to the system from time to time.
https://github.com/avrdudes/avrdude/wiki/Building-AVRDUDE-for-macOS#installation-of-git-main-for-homebrew

For PRs, I either test in the build_darwin directory or more often I copy them to another directory like avrdude_bin.

@MCUdude
With the improvement in autotools build I think it is okay for you to continue using the autotools build system. If you want to use CMake, you can just use build.sh for PR build.

rm -rf build_darwin
./build.sh

I do not recommend you to use the installation step even though it may work for you (x64 Homebrew). It will conflict with homebrew's installation.

mhei added a commit to mhei/avrdude that referenced this pull request Apr 20, 2024
At the moment, pkg-config is a build requirement only for detecting
and using libgpiod on Linux.
So we can also move the pkg-config detection logic into the
conditional block, so that is not required on other Unix-like
platforms.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
@mhei
Copy link
Contributor

mhei commented Apr 20, 2024

@MCUdude : could you give mhei@3d18fe5 a try on your system? This moves the pkg-config build requirement into a conditional block which is then only required when linuxgpio is enabled. I guess this is not the case on MacOS.
For Linux system, I think we should document the pkg-config on the Wiki page, so that users who build avrdude themself do not stumble over this issue.

@mcuee
Copy link
Collaborator

mcuee commented Apr 20, 2024

@MCUdude : could you give mhei@3d18fe5 a try on your system? This moves the pkg-config build requirement into a conditional block which is then only required when linuxgpio is enabled. I guess this is not the case on MacOS. For Linux system, I think we should document the pkg-config on the Wiki page, so that users who build avrdude themself do not stumble over this issue.

I have updated the wiki to reocmmend the installation of pkg-config (Linux and macOS) or pkgconf (FreeBSD and Cygwin/MSYS2). I see that as one of the essential package for anyone building avrdude and its dependancies from source codes. For example, libusb-compat-0.1 will require pkg-config.

Still I think your fix is still good to have for now.

@mcuee
Copy link
Collaborator

mcuee commented Apr 21, 2024

@stefanrueger

I cannot test Issue #1755 but at least a sanity check is okay using ATmega128A. Tested under macOS (Mac Mini M1 2020).

mcuee@mcuees-Mac-mini tools % ./test-avrdude -e ../build_darwin/src/avrdude -p "-c usbasp -p atmega128a"
Testing ../build_darwin/src/avrdude version 7.3-20240419 (fd0838b3)
Prepare "-c usbasp -p atmega128a" and press 'enter' or 'space' to continue. Press any other key to skip
✅   0.217 s: fuse access: clear, set and read eesave fuse bit
✅   0.249 s: fuse access: set eesave fusebit to delete EEPROM on chip erase
✅   0.519 s: chip erase
✅   8.846 s: flash -U write/verify holes_rjmp_loops_131072B.hex
✅   3.325 s: flash -T write/verify holes_rjmp_loops_131072B.hex
✅   0.422 s: eeprom check whether programmer can flip 0s to 1s
✅  10.871 s: eeprom -U write/verify holes_pack_my_box_4096B.hex
✅  21.679 s: eeprom -T write/verify holes_{the_five_boxing_wizards,pack_my_box}_4096B.hex
✅   3.558 s: chip erase and spot check flash is actually erased
✅   0.449 s: spot check eeprom is erased, too

@mcuee
Copy link
Collaborator

mcuee commented Apr 21, 2024

This PR is also good for ATmega168P.

mcuee@mcuees-Mac-mini tools % ./test-avrdude -e ../build_darwin/src/avrdude -p "-c usbasp -p atmega168p"
Testing ../build_darwin/src/avrdude version 7.3-20240419 (fd0838b3)
Prepare "-c usbasp -p atmega168p" and press 'enter' or 'space' to continue. Press any other key to skip
✅   0.223 s: fuse access: clear, set and read eesave fuse bit
✅   0.250 s: fuse access: set eesave fusebit to delete EEPROM on chip erase
✅   0.454 s: chip erase
✅   1.492 s: flash -U write/verify holes_rjmp_loops_16384B.hex
✅   0.647 s: flash -T write/verify holes_rjmp_loops_16384B.hex
✅   0.338 s: eeprom check whether programmer can flip 0s to 1s
✅   1.613 s: eeprom -U write/verify holes_pack_my_box_512B.hex
✅   3.010 s: eeprom -T write/verify holes_{the_five_boxing_wizards,pack_my_box}_512B.hex
✅   0.850 s: chip erase and spot check flash is actually erased
✅   0.290 s: spot check eeprom is erased, too

The data sheet wants a single word write, not a write block
@stefanrueger
Copy link
Collaborator Author

Brilliant tests, @mcuee. Many thanks for checking this PR and the other as well as far as your hardware is accessible.

This needs a final test for TPI programming, in particular the fuse. I have now studied the data sheet and rewritten the usbasp_tpi_write_byte() routine accordingly. Although the previously used write block of 16 bytes probably worked, the data sheet only requires writing one word. @MCUdude or @mcuee could you check usbasp with a TPI part (say, ATtiny10)?

$ tools/test-avrdude -d 0 -p"-c usbasp -p t10"

@mcuee
Copy link
Collaborator

mcuee commented Apr 21, 2024

@stefanrueger

Unfortunately I do not have the ATtiny10 or other TPI parts for testing.

@MCUdude
Copy link
Collaborator

MCUdude commented Apr 22, 2024

@mhei ssorry, but that didn't work:

$ git log --oneline | head -5
3d18fe5b Require pkg-config only when linuxgpio is enabled (refs #1763)
8fe729f0 Update NEWS
58588988 Merge pull request #1750 from stefanrueger/static-buspirate
6aece29a Merge pull request #1749 from stefanrueger/deprecated
4761a701 Merge pull request #1725 from mhei/support-for-libgpiodv2

$ ./bootstrap 
+ rm -rf autom4te.cache
+ LIBTOOLIZE=libtoolize
+ glibtoolize --version
+ LIBTOOLIZE=glibtoolize
+ export LIBTOOLIZE
+ autoreconf -i
configure.ac:518: error: Macro PKG_PROG_PKG_CONFIG is not available. It is usually defined in file pkg.m4 provided by package pkg-config.
configure.ac:518: the top level
autom4te: error: /usr/local/opt/m4/bin/m4 failed with exit status: 1
aclocal: error: /usr/local/Cellar/autoconf/2.72/bin/autom4te failed with exit status: 1
autoreconf: error: aclocal failed with exit status: 1

But thanks for the tip @mcuee! brew install pkg-config did the trick!

@MCUdude
Copy link
Collaborator

MCUdude commented Apr 22, 2024

But I can confirm that this PR resolves #1755. Now I'm able to write to the fuse memory, something I couldn't do before. However, I was stupid enough to write config wdton=0, which turns on the watchdog timer. And now I'm in this endless bootloop, and I can't figure out how to recover the chip. Even a 12V pulse on the reset pin doesn't help!

@stefanrueger
Copy link
Collaborator Author

stefanrueger commented Apr 22, 2024

Oh no! What about -U fuse:w:0xff:m assuming that's a ATtiny10 (or -T "factory reset")?

@MCUdude
Copy link
Collaborator

MCUdude commented Apr 22, 2024

The on-board LED is constantly flashing, so I'm not sure what's happening.
But regardless of what I do, I can't communicate with it. I'll see if I can find a replacement chip.

@stefanrueger
Copy link
Collaborator Author

stefanrueger commented Apr 22, 2024

Maybe we need to re-think how to test a t10? This is what the test-script currently does

$ tools/test-avrdude -ld 0 -p"-c dryrun -p t10"
Testing avrdude version 7.3-20240417 (8fe729f0)
# -c dryrun -p t10
$ avrdude -qq -c dryrun -p t10 -T "config wdton=0; config wdton=1; config wdton"
$ avrdude -qq -c dryrun -p t10 -e -FAU flash:w:0xff:m
$ avrdude -qq -c dryrun -p t10 -Uflash:w:tools/test_files/holes_rjmp_loops_1024B.hex
$ avrdude -qq -c dryrun -p t10 -T "write flash tools/test_files/holes_rjmp_loops_1024B.hex:a"
$ avrdude -qq -c dryrun -p t10 -T "write flash tools/test_files/rjmp_loops_for_bootloaders_1024B.hex:a"
$ avrdude -qq -c dryrun -p t10 -e -FAU flash:w:0xff:m -U flash:v:tools/test_files/holes_flash_0xff_1024B.hex

Maybe the config ckout fuse bit is a safer option? Clock output is on PB2, whilst TPI pins are PB0/1 and Reset is PB3

@MCUdude
Copy link
Collaborator

MCUdude commented Apr 24, 2024

Sorry for being so unavailable lately. I've been busy with other things in life, but I'll try to catch up as soon as I have some spare time.

I concluded that my T10 was absolutely fubar. While trying to recover it by applying 12V to the reset pin, I acidentally applied 12V to the VCC pin instead. I didn't have a spare T10, but I did have a T9 I could use as well. And with the latest commit, this PR seems to be good to go!

$ ./avrdude -cusbasp -pattiny9 -t
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9008 (probably t9)
avrdude: processing -t interactive terminal
avrdude> c
config rstdisbl=external_reset # 1
config wdton=wdt_programmable # 1
config ckout=co_disabled # 1
config lb=no_lock # 3
avrdude> c ckout=
# conf ckout=gpio        # 0
config ckout=co_disabled # 1 (factory)
avrdude> c ckout=gpio
avrdude> q
avrdude done.  Thank you.

$ ./avrdude -cusbasp -pattiny9 -t
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9008 (probably t9)
avrdude: processing -t interactive terminal
avrdude> c
config rstdisbl=external_reset # 1
config wdton=wdt_programmable # 1
config ckout=gpio # 0
config lb=no_lock # 3
avrdude> read flash
Reading | ################################################## | 100% 0.10 s 
0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0040  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0090  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
avrdude> write flash 0 "Hello World!"
Caching | ################################################## | 100% 0.00 s 
avrdude> flush
avrdude: synching cache to device ... 
Writing | ################################################## | 100% 0.06 s 
avrdude> q
avrdude done.  Thank you.

$ ./avrdude -cusbasp -pattiny9 -t
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9008 (probably t9)
avrdude: processing -t interactive terminal
avrdude> read flash
Reading | ################################################## | 100% 0.20 s 
0000  48 65 6c 6c 6f 20 57 6f  72 6c 64 21 00 ff ff ff  |Hello World!....|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0040  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0090  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
avrdude> c
config rstdisbl=external_reset # 1
config wdton=wdt_programmable # 1
config ckout=gpio # 0
config lb=no_lock # 3

@stefanrueger
Copy link
Collaborator Author

@MCUdude Thanks for testing, and sorry for the collateral damage to the t10! Great to know. I'll merge a ton of PRs soon, including this one.

@stefanrueger stefanrueger merged commit ade6a8d into avrdudes:main Apr 25, 2024
12 checks passed
@stefanrueger stefanrueger deleted the usbasp branch April 25, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

usbasp_write_byte in TPI mode; all writes have to be done at page level
4 participants