From 3bdf138721bd4a08ed743312e11a95aa8a2ee892 Mon Sep 17 00:00:00 2001 From: Marius Greuel Date: Thu, 5 May 2022 20:45:47 +0200 Subject: [PATCH 01/14] Fix micronucleus bootloader to check for unresponsive USB devices --- src/micronucleus.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/micronucleus.c b/src/micronucleus.c index b3c25341..b8d9d7ee 100644 --- a/src/micronucleus.c +++ b/src/micronucleus.c @@ -744,6 +744,19 @@ static int micronucleus_open(PROGRAMMER* pgm, char* port) { avrdude_message(MSG_INFO, "%s: ERROR: Failed to open USB device: %s\n", progname, usb_strerror()); } + else + { + // Send a dummy request to check for a unresponsive USB device. + int result = micronucleus_get_bootloader_info(pdata); + if (result < 0) + { + avrdude_message(MSG_NOTICE, "%s: WARNING: Failed to probe device (error %d), skipping...\n", + progname, result); + + usb_close(pdata->usb_handle); + pdata->usb_handle = NULL; + } + } } } } From c64f2030a175341ee8943757d12dcf91f5af829c Mon Sep 17 00:00:00 2001 From: Marius Greuel Date: Thu, 5 May 2022 21:42:27 +0200 Subject: [PATCH 02/14] Improve micronucleus bootloader user experience for unresponsive USB devices --- src/micronucleus.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/src/micronucleus.c b/src/micronucleus.c index b8d9d7ee..28dac2cb 100644 --- a/src/micronucleus.c +++ b/src/micronucleus.c @@ -139,6 +139,22 @@ static int micronucleus_check_connection(pdata_t* pdata) } } +static bool micronucleus_is_device_responsive(pdata_t* pdata, struct usb_device* device) +{ + pdata->usb_handle = usb_open(device); + if (pdata->usb_handle == NULL) + { + return false; + } + + int result = micronucleus_check_connection(pdata); + + usb_close(pdata->usb_handle); + pdata->usb_handle = NULL; + + return result >= 0; +} + static int micronucleus_reconnect(pdata_t* pdata) { struct usb_device* device = usb_device(pdata->usb_handle); @@ -696,6 +712,7 @@ static int micronucleus_open(PROGRAMMER* pgm, char* port) usb_init(); bool show_retry_message = true; + bool show_unresponsive_device_message = true; time_t start_time = time(NULL); for (;;) @@ -717,6 +734,19 @@ static int micronucleus_open(PROGRAMMER* pgm, char* port) pdata->major_version = (uint8_t)(device->descriptor.bcdDevice >> 8); pdata->minor_version = (uint8_t)(device->descriptor.bcdDevice >> 0); + if (!micronucleus_is_device_responsive(pdata, device)) + { + if (show_unresponsive_device_message) + { + avrdude_message(MSG_INFO, "%s: WARNING: Unresponsive Micronucleus device detected, please reconnect....\n", + progname); + + show_unresponsive_device_message = false; + } + + continue; + } + avrdude_message(MSG_NOTICE, "%s: Found device with Micronucleus V%d.%d, bus:device: %s:%s\n", progname, pdata->major_version, pdata->minor_version, @@ -744,19 +774,6 @@ static int micronucleus_open(PROGRAMMER* pgm, char* port) { avrdude_message(MSG_INFO, "%s: ERROR: Failed to open USB device: %s\n", progname, usb_strerror()); } - else - { - // Send a dummy request to check for a unresponsive USB device. - int result = micronucleus_get_bootloader_info(pdata); - if (result < 0) - { - avrdude_message(MSG_NOTICE, "%s: WARNING: Failed to probe device (error %d), skipping...\n", - progname, result); - - usb_close(pdata->usb_handle); - pdata->usb_handle = NULL; - } - } } } } From 01a9e42d7d43bb4329740f9d72b1c3591e342726 Mon Sep 17 00:00:00 2001 From: Marius Greuel Date: Thu, 5 May 2022 22:08:46 +0200 Subject: [PATCH 03/14] Fix typo in micronucleus message --- src/micronucleus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/micronucleus.c b/src/micronucleus.c index 28dac2cb..c3dd007d 100644 --- a/src/micronucleus.c +++ b/src/micronucleus.c @@ -738,7 +738,7 @@ static int micronucleus_open(PROGRAMMER* pgm, char* port) { if (show_unresponsive_device_message) { - avrdude_message(MSG_INFO, "%s: WARNING: Unresponsive Micronucleus device detected, please reconnect....\n", + avrdude_message(MSG_INFO, "%s: WARNING: Unresponsive Micronucleus device detected, please reconnect...\n", progname); show_unresponsive_device_message = false; From 75bfbf7bef53a54a6824626913253d0b4bebc9e8 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 9 May 2022 02:02:42 +0200 Subject: [PATCH 04/14] fix M1 homebrew path --- build.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index baea4516..4fceb6e3 100755 --- a/build.sh +++ b/build.sh @@ -50,7 +50,13 @@ case "${ostype}" in then build_flags="${build_flags} -D CMAKE_C_FLAGS=-I/opt/local/include -D CMAKE_EXE_LINKER_FLAGS=-L/opt/local/lib" else - build_flags="${build_flags} -D CMAKE_C_FLAGS=-I/usr/local/include -D CMAKE_EXE_LINKER_FLAGS=-L/usr/local/Cellar" + # Apple M1 (may be new version of homebrew also) + if [ -d /opt/homebrew ] + then + build_flags="${build_flags} -D CMAKE_C_FLAGS=-I/usr/homebrew/include -D CMAKE_EXE_LINKER_FLAGS=-L/usr/homebrew/Cellar" + else + build_flags="${build_flags} -D CMAKE_C_FLAGS=-I/usr/local/include -D CMAKE_EXE_LINKER_FLAGS=-L/usr/local/Cellar" + fi fi ;; From a23055d6481f268f1782a55303cc5427072bbe1e Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 9 May 2022 14:51:16 +0200 Subject: [PATCH 05/14] fix typo --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 4fceb6e3..0b664807 100755 --- a/build.sh +++ b/build.sh @@ -53,7 +53,7 @@ case "${ostype}" in # Apple M1 (may be new version of homebrew also) if [ -d /opt/homebrew ] then - build_flags="${build_flags} -D CMAKE_C_FLAGS=-I/usr/homebrew/include -D CMAKE_EXE_LINKER_FLAGS=-L/usr/homebrew/Cellar" + build_flags="${build_flags} -D CMAKE_C_FLAGS=-I/opt/homebrew/include -D CMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/Cellar" else build_flags="${build_flags} -D CMAKE_C_FLAGS=-I/usr/local/include -D CMAKE_EXE_LINKER_FLAGS=-L/usr/local/Cellar" fi From 8b61c9dd8f0c0e99bd89389c4f19f186beeef3ef Mon Sep 17 00:00:00 2001 From: Marius Greuel Date: Wed, 11 May 2022 20:56:05 +0200 Subject: [PATCH 06/14] CMake: Move MSVC compatibility shim into library --- src/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a8e0262b..7d6771f3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,7 +51,7 @@ include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) add_compile_definitions(CONFIG_DIR=\"${CONFIG_DIR}\") if(WIN32) - set(EXTRA_WINDOWS_SOURCES "${PROJECT_BINARY_DIR}/src/windows.rc") + set(EXTRA_WINDOWS_RESOURCES "${PROJECT_BINARY_DIR}/src/windows.rc") set(EXTRA_WINDOWS_LIBRARIES setupapi ws2_32) endif() @@ -216,6 +216,7 @@ add_library(libavrdude xbee.c ${FLEX_Parser_OUTPUTS} ${BISON_Parser_OUTPUTS} + "${EXTRA_WINDOWS_SOURCES}" ) set_target_properties(libavrdude PROPERTIES @@ -253,7 +254,7 @@ add_executable(avrdude term.h whereami.c whereami.h - "${EXTRA_WINDOWS_SOURCES}" + "${EXTRA_WINDOWS_RESOURCES}" ) target_link_libraries(avrdude PUBLIC libavrdude) From 053c2dcdd3cb24e0778bd54073c7456a66056a68 Mon Sep 17 00:00:00 2001 From: Marius Greuel Date: Wed, 11 May 2022 20:57:14 +0200 Subject: [PATCH 07/14] CMake: Include GCC specific options also for MSYS2 --- src/CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d6771f3..7577e113 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,11 +55,6 @@ if(WIN32) set(EXTRA_WINDOWS_LIBRARIES setupapi ws2_32) endif() -if(NOT WIN32) - set(LIB_MATH m) - add_compile_options(-Wall) # -Wextra -endif() - if(MSVC) add_compile_definitions(_CRT_SECURE_NO_WARNINGS=1) add_compile_definitions(_CRT_NONSTDC_NO_WARNINGS=1) @@ -79,6 +74,9 @@ if(MSVC) set(EXTRA_WINDOWS_INCLUDES ${EXTRA_WINDOWS_INCLUDES} "msvc" ) +else() + set(LIB_MATH m) + add_compile_options(-Wall) # -Wextra endif() # ===================================== From 0ea4b08b2f895ed89dcc0f0557acf9de0bd0dcd3 Mon Sep 17 00:00:00 2001 From: Marius Greuel Date: Wed, 11 May 2022 21:02:03 +0200 Subject: [PATCH 08/14] CMake: If installed, use static version of libreadline for MSYS2 --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95c89d2b..cf3623e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,7 @@ if(WIN32) set(PREFERRED_LIBHIDAPI libhidapi.a libhidapi-libusb.a libhidapi-hidraw.a hidapi hidapi-libusb hidapi-hidraw) set(PREFERRED_LIBFTDI libftdi.a ftdi) set(PREFERRED_LIBFTDI1 libftdi1.a ftdi1) + set(PREFERRED_LIBREADLINE libreadline.a) else() set(PREFERRED_LIBELF elf) set(PREFERRED_LIBUSB usb) @@ -125,6 +126,7 @@ else() set(PREFERRED_LIBHIDAPI hidapi hidapi-libusb hidapi-hidraw) set(PREFERRED_LIBFTDI ftdi) set(PREFERRED_LIBFTDI1 ftdi1) + set(PREFERRED_LIBREADLINE readline) endif() # ------------------------------------- @@ -212,7 +214,7 @@ endif() # ------------------------------------- # Find libreadline -find_library(HAVE_LIBREADLINE NAMES readline) +find_library(HAVE_LIBREADLINE NAMES ${PREFERRED_LIBREADLINE}) if(HAVE_LIBREADLINE) set(LIB_LIBREADLINE ${HAVE_LIBREADLINE}) endif() From 65bb41f8e9bd500d2afe2462a7ff7f93b3c277b7 Mon Sep 17 00:00:00 2001 From: Marius Greuel Date: Wed, 11 May 2022 21:08:05 +0200 Subject: [PATCH 09/14] CMake: Add build option to select static or shared libraries --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf3623e9..19897c72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,13 @@ option(USE_LIBUSBWIN32 "Prefer libusb-win32 over libusb" OFF) option(DEBUG_CMAKE "Enable debugging output for this CMake project" OFF) option(BUILD_SHARED_LIBS "Build shared libraries" OFF) +if(WIN32) + # Prefer static libraries over DLLs on Windows + option(USE_STATIC_LIBS "Use static libraries" ON) +else() + option(USE_STATIC_LIBS "Use static libraries" OFF) +endif() + include(CheckIncludeFile) include(CheckSymbolExists) include(FetchContent) @@ -110,8 +117,7 @@ endif() # Detect installed libraries # ===================================== -# Prefer static libraries over DLLs on Windows -if(WIN32) +if(USE_STATIC_LIBS) set(PREFERRED_LIBELF libelf.a elf) set(PREFERRED_LIBUSB libusb.a usb) set(PREFERRED_LIBUSB_1_0 libusb-1.0.a usb-1.0) From 3b0d7e5d5d325362d4ca1f4ebc7271c653a89766 Mon Sep 17 00:00:00 2001 From: Ebben Aries Date: Sat, 21 May 2022 14:25:27 -0600 Subject: [PATCH 10/14] Fix src/CMakeLists.txt to honor CMAKE_INSTALL_LIBDIR --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a8e0262b..d4472481 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -264,8 +264,8 @@ target_link_libraries(avrdude PUBLIC libavrdude) install(TARGETS avrdude DESTINATION bin) install(TARGETS libavrdude - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION include COMPONENT dev ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/avrdude.conf" TYPE SYSCONF) From feaa1c6a6b0a0cf234dbd9e86e5b0d13d745c09a Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Mon, 30 May 2022 07:01:22 +0200 Subject: [PATCH 11/14] PR 950 done --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index ca827290..1a0c4824 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,7 @@ Changes since version 7.0: * Pull requests: - Fix .Dd macro in manpage #949 + - fix M1 homebrew path #950 * Internals: From cb114233ef68625332df5fff876467f57648cd9d Mon Sep 17 00:00:00 2001 From: Marius Greuel Date: Fri, 10 Jun 2022 20:38:54 +0200 Subject: [PATCH 12/14] Mention PR #945, #962, #972 --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS b/NEWS index 1a0c4824..4638746a 100644 --- a/NEWS +++ b/NEWS @@ -15,10 +15,15 @@ Changes since version 7.0: * Issues fixed: + - Fix micronucleus bootloader to check for unresponsive USB + devices #945 + - Fix src/CMakeLists.txt to honor CMAKE_INSTALL_LIBDIR #972 + * Pull requests: - Fix .Dd macro in manpage #949 - fix M1 homebrew path #950 + - CMake Enhancements #962 * Internals: From 3b0a2abc20e88101a194b953ab31cd8ab89d27dd Mon Sep 17 00:00:00 2001 From: MCUdude Date: Sun, 19 Jun 2022 10:53:07 +0200 Subject: [PATCH 13/14] Reduce programmer description string length to less than 80 characters. #941 related --- src/avrdude.conf.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 362b6167..ba7f4f8e 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -947,9 +947,10 @@ programmer ; # commercial version of USBtiny, using a separate VID/PID +# https://github.com/IowaScaledEngineering/ckt-avrprogrammer programmer id = "iseavrprog"; - desc = "USBtiny-based USB programmer, https://github.com/IowaScaledEngineering/ckt-avrprogrammer"; + desc = "USBtiny-based programmer, https://iascaled.com"; type = "usbtiny"; connection_type = usb; usbvid = 0x1209; From 1aa59aaa98e6a79bb4a321be80c5113184dd2668 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Sun, 19 Jun 2022 19:56:56 +0200 Subject: [PATCH 14/14] PR #1000 is done now --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 4638746a..888796ca 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,8 @@ Changes since version 7.0: - Fix .Dd macro in manpage #949 - fix M1 homebrew path #950 - CMake Enhancements #962 + - Reduce programmer desc string length in avrdude.conf + to < 80 characters #1000 * Internals: