Merge remote-tracking branch 'upstream/main'

This commit is contained in:
Joerg Wunsch 2021-12-28 15:00:53 +01:00
commit a625db23e0
6 changed files with 44 additions and 18 deletions

View File

@ -48,15 +48,19 @@ set(AVRDUDE_EXTERNAL_PATH "${PROJECT_SOURCE_DIR}/external")
find_package(FLEX) find_package(FLEX)
if(FLEX_FOUND) if(FLEX_FOUND)
FLEX_TARGET(Parser lexer.l "${PROJECT_BINARY_DIR}/lexer.c") FLEX_TARGET(Parser lexer.l "${PROJECT_BINARY_DIR}/lexer.c")
if (FLEX_VERSION VERSION_GREATER_EQUAL 2.5.9)
set(HAVE_YYLEX_DESTROY 1)
endif()
else() else()
message(SEND_ERROR "This CMake project requires flex, which is not installed on your system." ) message(SEND_ERROR "This CMake project requires 'flex', which is not installed on your system." )
endif() endif()
find_package(BISON) find_package(BISON)
if(BISON_FOUND) if(BISON_FOUND)
BISON_TARGET(Parser config_gram.y "${PROJECT_BINARY_DIR}/config_gram.c" DEFINES_FILE "${PROJECT_BINARY_DIR}/config_gram.h") BISON_TARGET(Parser config_gram.y "${PROJECT_BINARY_DIR}/config_gram.c" DEFINES_FILE "${PROJECT_BINARY_DIR}/config_gram.h")
else() else()
message(SEND_ERROR "This CMake project requires bison, which is not installed on your system." ) message(SEND_ERROR "This CMake project requires 'bison', which is not installed on your system." )
endif() endif()
# ===================================== # =====================================
@ -121,6 +125,11 @@ if(HAVE_LIBUSB_1_0)
set(LIB_LIBUSB_1_0 ${HAVE_LIBUSB_1_0}) set(LIB_LIBUSB_1_0 ${HAVE_LIBUSB_1_0})
endif() endif()
# FreeBSD's library 'libusb' supports both the libusb-0.1 and libusb-1.0 API.
if (HAVE_LIBUSB AND CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(HAVE_LIBUSB_1_0 ${HAVE_LIBUSB})
endif()
find_library(HAVE_LIBUSB_WIN32 NAMES libusb0.a usb0) find_library(HAVE_LIBUSB_WIN32 NAMES libusb0.a usb0)
if(HAVE_LIBUSB OR HAVE_LIBUSB_1_0 OR HAVE_LIBUSB_WIN32) if(HAVE_LIBUSB OR HAVE_LIBUSB_1_0 OR HAVE_LIBUSB_WIN32)
@ -182,6 +191,8 @@ endif()
# Setup target specific options # Setup target specific options
# ===================================== # =====================================
add_compile_definitions(CONFIG_DIR=\"${CONFIG_DIR}\")
if(WIN32) if(WIN32)
set(HAVE_LIBWS2_32 1) set(HAVE_LIBWS2_32 1)
set(EXTRA_WINDOWS_SOURCES "${PROJECT_BINARY_DIR}/windows.rc") set(EXTRA_WINDOWS_SOURCES "${PROJECT_BINARY_DIR}/windows.rc")
@ -318,8 +329,22 @@ message(STATUS "----------------------")
# Configure files # Configure files
# ===================================== # =====================================
macro(configure_option option)
if(${${option}})
string(REGEX REPLACE "(.*)@${option}_BEGIN@(.*)@${option}_END@(.*)" "\\1\\2\\3" conf_file "${conf_file}")
else()
string(REGEX REPLACE "(.*)@${option}_BEGIN@(.*)@${option}_END@(.*)" "\\1\\3" conf_file "${conf_file}")
endif()
endmacro()
file(READ avrdude.conf.in conf_file)
configure_option(HAVE_PARPORT)
configure_option(HAVE_LINUXGPIO)
configure_option(HAVE_LINUXSPI)
file(WRITE "${PROJECT_BINARY_DIR}/avrdude.conf.in" "${conf_file}")
configure_file(cmake_config.h.in ac_cfg.h) configure_file(cmake_config.h.in ac_cfg.h)
configure_file(avrdude.conf.in avrdude.conf) configure_file("${PROJECT_BINARY_DIR}/avrdude.conf.in" avrdude.conf)
configure_file(avrdude.spec.in avrdude.spec) configure_file(avrdude.spec.in avrdude.spec)
if(WIN32) if(WIN32)
configure_file(windows.rc.in windows.rc) configure_file(windows.rc.in windows.rc)

View File

@ -331,7 +331,7 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype,
/* supports "paged load" thru post-increment */ /* supports "paged load" thru post-increment */
if ((p->flags & AVRPART_HAS_TPI) && mem->page_size > 1 && if ((p->flags & AVRPART_HAS_TPI) && mem->page_size > 1 &&
pgm->cmd_tpi != NULL) { mem->size % mem->page_size == 0 && pgm->cmd_tpi != NULL) {
while (avr_tpi_poll_nvmbsy(pgm)); while (avr_tpi_poll_nvmbsy(pgm));
@ -361,7 +361,8 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype,
return avr_mem_hiaddr(mem); return avr_mem_hiaddr(mem);
} }
if (pgm->paged_load != NULL && mem->page_size > 1) { if (pgm->paged_load != NULL && mem->page_size > 1 &&
mem->size % mem->page_size == 0) {
/* /*
* the programmer supports a paged mode read * the programmer supports a paged mode read
*/ */

View File

@ -71,7 +71,7 @@ enum { FTDI_SCK = 0, FTDI_MOSI, FTDI_MISO, FTDI_RESET };
static int write_flush(avrftdi_t *); static int write_flush(avrftdi_t *);
/* /*
* returns a human-readable name for a pin number. the name should match with * returns a human-readable name for a pin number. The name should match with
* the pin names used in FTDI datasheets. * the pin names used in FTDI datasheets.
*/ */
static char* static char*
@ -125,7 +125,7 @@ ftdi_pin_name(avrftdi_t* pdata, struct pindef_t pin)
} }
/* /*
* output function, to save if(vebose>level)-constructs. also prefixes output * output function, to save if(vebose>level)-constructs. Also prefixes output
* with "avrftdi function-name(line-number):" to identify were messages came * with "avrftdi function-name(line-number):" to identify were messages came
* from. * from.
* This function is the backend of the log_*-macros, but it can be used * This function is the backend of the log_*-macros, but it can be used
@ -163,9 +163,9 @@ void avrftdi_log(int level, const char * func, int line,
} }
/* /*
* helper function to print a binary buffer *buf of size len. begin and end of * helper function to print a binary buffer *buf of size len. Begin and end of
* the dump are enclosed in the string contained in *desc. offset denotes the * the dump are enclosed in the string contained in *desc. Offset denotes the
* number of bytes which are printed on the first line (may be 0). after that * number of bytes which are printed on the first line (may be 0). After that
* width bytes are printed on each line * width bytes are printed on each line
*/ */
static void buf_dump(const unsigned char *buf, int len, char *desc, static void buf_dump(const unsigned char *buf, int len, char *desc,
@ -531,7 +531,7 @@ static int avrftdi_check_pins_bb(PROGRAMMER * pgm, bool output)
/* value for 8/12/16 bit wide interface */ /* value for 8/12/16 bit wide interface */
int valid_mask = ((1 << pdata->pin_limit) - 1); int valid_mask = ((1 << pdata->pin_limit) - 1);
log_debug("Using valid mask bibanging: 0x%08x\n", valid_mask); log_debug("Using valid mask bitbanging: 0x%08x\n", valid_mask);
static struct pindef_t valid_pins; static struct pindef_t valid_pins;
valid_pins.mask[0] = valid_mask; valid_pins.mask[0] = valid_mask;
valid_pins.inverse[0] = valid_mask ; valid_pins.inverse[0] = valid_mask ;
@ -556,7 +556,7 @@ static int avrftdi_check_pins_mpsse(PROGRAMMER * pgm, bool output)
avrftdi_t* pdata = to_pdata(pgm); avrftdi_t* pdata = to_pdata(pgm);
/* SCK/MOSI/MISO are fixed and not invertable?*/ /* SCK/MOSI/MISO are fixed and not invertible?*/
/* TODO: inverted SCK/MISO/MOSI */ /* TODO: inverted SCK/MISO/MOSI */
static const struct pindef_t valid_pins_SCK = {{0x01},{0x00}} ; static const struct pindef_t valid_pins_SCK = {{0x01},{0x00}} ;
static const struct pindef_t valid_pins_MOSI = {{0x02},{0x00}} ; static const struct pindef_t valid_pins_MOSI = {{0x02},{0x00}} ;
@ -705,7 +705,7 @@ static int avrftdi_open(PROGRAMMER * pgm, char *port)
if(err) { if(err) {
log_err("Error %d occurred: %s\n", err, ftdi_get_error_string(pdata->ftdic)); log_err("Error %d occurred: %s\n", err, ftdi_get_error_string(pdata->ftdic));
//stupid hack, because avrdude calls pgm->close() even when pgm->open() fails //stupid hack, because avrdude calls pgm->close() even when pgm->open() fails
//and usb_dev is intialized to the last usb device from probing //and usb_dev is initialized to the last usb device from probing
pdata->ftdic->usb_dev = NULL; pdata->ftdic->usb_dev = NULL;
return err; return err;
} else { } else {
@ -831,7 +831,7 @@ static int avrftdi_initialize(PROGRAMMER * pgm, AVRPART * p)
/*setting rst back to 0 */ /*setting rst back to 0 */
set_pin(pgm, PIN_AVR_RESET, OFF); set_pin(pgm, PIN_AVR_RESET, OFF);
/*wait at least 20ms bevor issuing spi commands to avr */ /*wait at least 20ms before issuing spi commands to avr */
usleep(20 * 1000); usleep(20 * 1000);
} }
@ -840,7 +840,7 @@ static int avrftdi_initialize(PROGRAMMER * pgm, AVRPART * p)
static void avrftdi_display(PROGRAMMER * pgm, const char *p) static void avrftdi_display(PROGRAMMER * pgm, const char *p)
{ {
// print the full pin definitiions as in ft245r ? // print the full pin definitions as in ft245r ?
return; return;
} }
@ -1045,7 +1045,7 @@ static int avrftdi_flash_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
bufptr += 4; bufptr += 4;
} }
/* find a poll byte. we cannot poll a value of 0xff, so look /* find a poll byte. We cannot poll a value of 0xff, so look
* for a value != 0xff * for a value != 0xff
*/ */
for(poll_index = addr+len-1; poll_index > addr-1; poll_index--) for(poll_index = addr+len-1; poll_index > addr-1; poll_index--)

View File

@ -22,8 +22,6 @@
#define VERSION "@PROJECT_VERSION@" #define VERSION "@PROJECT_VERSION@"
#define CONFIG_DIR "${CONFIG_DIR}"
/* Options */ /* Options */
/* Linux sysfs GPIO support enabled */ /* Linux sysfs GPIO support enabled */

View File

@ -430,6 +430,7 @@ int jtag3_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
if (serial_send(&pgm->fd, buf, len + 4) != 0) { if (serial_send(&pgm->fd, buf, len + 4) != 0) {
avrdude_message(MSG_INFO, "%s: jtag3_send(): failed to send command to serial port\n", avrdude_message(MSG_INFO, "%s: jtag3_send(): failed to send command to serial port\n",
progname); progname);
free(buf);
return -1; return -1;
} }

View File

@ -214,6 +214,7 @@ static int jtagmkI_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
if (serial_send(&pgm->fd, buf, len + 2) != 0) { if (serial_send(&pgm->fd, buf, len + 2) != 0) {
avrdude_message(MSG_INFO, "%s: jtagmkI_send(): failed to send command to serial port\n", avrdude_message(MSG_INFO, "%s: jtagmkI_send(): failed to send command to serial port\n",
progname); progname);
free(buf);
return -1; return -1;
} }