avrdude: Compilation on Windows/MSVC
This commit is contained in:
parent
68a570221b
commit
07817c8ee5
22 changed files with 2385 additions and 732 deletions
|
@ -1173,118 +1173,118 @@ programmer
|
|||
|
||||
# Parallel port programmers.
|
||||
|
||||
programmer
|
||||
id = "bsd";
|
||||
desc = "Brian Dean's Programmer, http://www.bsdhome.com/avrdude/";
|
||||
type = "par";
|
||||
connection_type = parallel;
|
||||
vcc = 2, 3, 4, 5;
|
||||
reset = 7;
|
||||
sck = 8;
|
||||
mosi = 9;
|
||||
miso = 10;
|
||||
;
|
||||
# programmer
|
||||
# id = "bsd";
|
||||
# desc = "Brian Dean's Programmer, http://www.bsdhome.com/avrdude/";
|
||||
# type = "par";
|
||||
# connection_type = parallel;
|
||||
# vcc = 2, 3, 4, 5;
|
||||
# reset = 7;
|
||||
# sck = 8;
|
||||
# mosi = 9;
|
||||
# miso = 10;
|
||||
# ;
|
||||
|
||||
programmer
|
||||
id = "stk200";
|
||||
desc = "STK200";
|
||||
type = "par";
|
||||
connection_type = parallel;
|
||||
buff = 4, 5;
|
||||
sck = 6;
|
||||
mosi = 7;
|
||||
reset = 9;
|
||||
miso = 10;
|
||||
;
|
||||
# programmer
|
||||
# id = "stk200";
|
||||
# desc = "STK200";
|
||||
# type = "par";
|
||||
# connection_type = parallel;
|
||||
# buff = 4, 5;
|
||||
# sck = 6;
|
||||
# mosi = 7;
|
||||
# reset = 9;
|
||||
# miso = 10;
|
||||
# ;
|
||||
|
||||
# The programming dongle used by the popular Ponyprog
|
||||
# utility. It is almost similar to the STK200 one,
|
||||
# except that there is a LED indicating that the
|
||||
# programming is currently in progress.
|
||||
|
||||
programmer parent "stk200"
|
||||
id = "pony-stk200";
|
||||
desc = "Pony Prog STK200";
|
||||
pgmled = 8;
|
||||
;
|
||||
# programmer parent "stk200"
|
||||
# id = "pony-stk200";
|
||||
# desc = "Pony Prog STK200";
|
||||
# pgmled = 8;
|
||||
# ;
|
||||
|
||||
programmer
|
||||
id = "dt006";
|
||||
desc = "Dontronics DT006";
|
||||
type = "par";
|
||||
connection_type = parallel;
|
||||
reset = 4;
|
||||
sck = 5;
|
||||
mosi = 2;
|
||||
miso = 11;
|
||||
;
|
||||
# programmer
|
||||
# id = "dt006";
|
||||
# desc = "Dontronics DT006";
|
||||
# type = "par";
|
||||
# connection_type = parallel;
|
||||
# reset = 4;
|
||||
# sck = 5;
|
||||
# mosi = 2;
|
||||
# miso = 11;
|
||||
# ;
|
||||
|
||||
programmer parent "dt006"
|
||||
id = "bascom";
|
||||
desc = "Bascom SAMPLE programming cable";
|
||||
;
|
||||
# programmer parent "dt006"
|
||||
# id = "bascom";
|
||||
# desc = "Bascom SAMPLE programming cable";
|
||||
# ;
|
||||
|
||||
programmer
|
||||
id = "alf";
|
||||
desc = "Nightshade ALF-PgmAVR, http://nightshade.homeip.net/";
|
||||
type = "par";
|
||||
connection_type = parallel;
|
||||
vcc = 2, 3, 4, 5;
|
||||
buff = 6;
|
||||
reset = 7;
|
||||
sck = 8;
|
||||
mosi = 9;
|
||||
miso = 10;
|
||||
errled = 1;
|
||||
rdyled = 14;
|
||||
pgmled = 16;
|
||||
vfyled = 17;
|
||||
;
|
||||
# programmer
|
||||
# id = "alf";
|
||||
# desc = "Nightshade ALF-PgmAVR, http://nightshade.homeip.net/";
|
||||
# type = "par";
|
||||
# connection_type = parallel;
|
||||
# vcc = 2, 3, 4, 5;
|
||||
# buff = 6;
|
||||
# reset = 7;
|
||||
# sck = 8;
|
||||
# mosi = 9;
|
||||
# miso = 10;
|
||||
# errled = 1;
|
||||
# rdyled = 14;
|
||||
# pgmled = 16;
|
||||
# vfyled = 17;
|
||||
# ;
|
||||
|
||||
programmer
|
||||
id = "sp12";
|
||||
desc = "Steve Bolt's Programmer";
|
||||
type = "par";
|
||||
connection_type = parallel;
|
||||
vcc = 4,5,6,7,8;
|
||||
reset = 3;
|
||||
sck = 2;
|
||||
mosi = 9;
|
||||
miso = 11;
|
||||
;
|
||||
# programmer
|
||||
# id = "sp12";
|
||||
# desc = "Steve Bolt's Programmer";
|
||||
# type = "par";
|
||||
# connection_type = parallel;
|
||||
# vcc = 4,5,6,7,8;
|
||||
# reset = 3;
|
||||
# sck = 2;
|
||||
# mosi = 9;
|
||||
# miso = 11;
|
||||
# ;
|
||||
|
||||
programmer
|
||||
id = "picoweb";
|
||||
desc = "Picoweb Programming Cable, http://www.picoweb.net/";
|
||||
type = "par";
|
||||
connection_type = parallel;
|
||||
reset = 2;
|
||||
sck = 3;
|
||||
mosi = 4;
|
||||
miso = 13;
|
||||
;
|
||||
# programmer
|
||||
# id = "picoweb";
|
||||
# desc = "Picoweb Programming Cable, http://www.picoweb.net/";
|
||||
# type = "par";
|
||||
# connection_type = parallel;
|
||||
# reset = 2;
|
||||
# sck = 3;
|
||||
# mosi = 4;
|
||||
# miso = 13;
|
||||
# ;
|
||||
|
||||
programmer
|
||||
id = "abcmini";
|
||||
desc = "ABCmini Board, aka Dick Smith HOTCHIP";
|
||||
type = "par";
|
||||
connection_type = parallel;
|
||||
reset = 4;
|
||||
sck = 3;
|
||||
mosi = 2;
|
||||
miso = 10;
|
||||
;
|
||||
# programmer
|
||||
# id = "abcmini";
|
||||
# desc = "ABCmini Board, aka Dick Smith HOTCHIP";
|
||||
# type = "par";
|
||||
# connection_type = parallel;
|
||||
# reset = 4;
|
||||
# sck = 3;
|
||||
# mosi = 2;
|
||||
# miso = 10;
|
||||
# ;
|
||||
|
||||
programmer
|
||||
id = "futurlec";
|
||||
desc = "Futurlec.com programming cable.";
|
||||
type = "par";
|
||||
connection_type = parallel;
|
||||
reset = 3;
|
||||
sck = 2;
|
||||
mosi = 1;
|
||||
miso = 10;
|
||||
;
|
||||
# programmer
|
||||
# id = "futurlec";
|
||||
# desc = "Futurlec.com programming cable.";
|
||||
# type = "par";
|
||||
# connection_type = parallel;
|
||||
# reset = 3;
|
||||
# sck = 2;
|
||||
# mosi = 1;
|
||||
# miso = 10;
|
||||
# ;
|
||||
|
||||
|
||||
# From the contributor of the "xil" jtag cable:
|
||||
|
@ -1294,87 +1294,87 @@ programmer
|
|||
# avrdude versions before 5.5j).
|
||||
# With this, TMS connects to RESET, TDI to MOSI, TDO to MISO and TCK
|
||||
# to SCK (plus vcc/gnd of course)
|
||||
programmer
|
||||
id = "xil";
|
||||
desc = "Xilinx JTAG cable";
|
||||
type = "par";
|
||||
connection_type = parallel;
|
||||
mosi = 2;
|
||||
sck = 3;
|
||||
reset = 4;
|
||||
buff = 5;
|
||||
miso = 13;
|
||||
vcc = 6;
|
||||
;
|
||||
# programmer
|
||||
# id = "xil";
|
||||
# desc = "Xilinx JTAG cable";
|
||||
# type = "par";
|
||||
# connection_type = parallel;
|
||||
# mosi = 2;
|
||||
# sck = 3;
|
||||
# reset = 4;
|
||||
# buff = 5;
|
||||
# miso = 13;
|
||||
# vcc = 6;
|
||||
# ;
|
||||
|
||||
|
||||
programmer
|
||||
id = "dapa";
|
||||
desc = "Direct AVR Parallel Access cable";
|
||||
type = "par";
|
||||
connection_type = parallel;
|
||||
vcc = 3;
|
||||
reset = 16;
|
||||
sck = 1;
|
||||
mosi = 2;
|
||||
miso = 11;
|
||||
;
|
||||
# programmer
|
||||
# id = "dapa";
|
||||
# desc = "Direct AVR Parallel Access cable";
|
||||
# type = "par";
|
||||
# connection_type = parallel;
|
||||
# vcc = 3;
|
||||
# reset = 16;
|
||||
# sck = 1;
|
||||
# mosi = 2;
|
||||
# miso = 11;
|
||||
# ;
|
||||
|
||||
programmer
|
||||
id = "atisp";
|
||||
desc = "AT-ISP V1.1 programming cable for AVR-SDK1 from <http://micro-research.co.th/> micro-research.co.th";
|
||||
type = "par";
|
||||
connection_type = parallel;
|
||||
reset = ~6;
|
||||
sck = ~8;
|
||||
mosi = ~7;
|
||||
miso = ~10;
|
||||
;
|
||||
# programmer
|
||||
# id = "atisp";
|
||||
# desc = "AT-ISP V1.1 programming cable for AVR-SDK1 from <http://micro-research.co.th/> micro-research.co.th";
|
||||
# type = "par";
|
||||
# connection_type = parallel;
|
||||
# reset = ~6;
|
||||
# sck = ~8;
|
||||
# mosi = ~7;
|
||||
# miso = ~10;
|
||||
# ;
|
||||
|
||||
programmer
|
||||
id = "ere-isp-avr";
|
||||
desc = "ERE ISP-AVR <http://www.ere.co.th/download/sch050713.pdf>";
|
||||
type = "par";
|
||||
connection_type = parallel;
|
||||
reset = ~4;
|
||||
sck = 3;
|
||||
mosi = 2;
|
||||
miso = 10;
|
||||
;
|
||||
# programmer
|
||||
# id = "ere-isp-avr";
|
||||
# desc = "ERE ISP-AVR <http://www.ere.co.th/download/sch050713.pdf>";
|
||||
# type = "par";
|
||||
# connection_type = parallel;
|
||||
# reset = ~4;
|
||||
# sck = 3;
|
||||
# mosi = 2;
|
||||
# miso = 10;
|
||||
# ;
|
||||
|
||||
programmer
|
||||
id = "blaster";
|
||||
desc = "Altera ByteBlaster";
|
||||
type = "par";
|
||||
connection_type = parallel;
|
||||
sck = 2;
|
||||
miso = 11;
|
||||
reset = 3;
|
||||
mosi = 8;
|
||||
buff = 14;
|
||||
;
|
||||
# programmer
|
||||
# id = "blaster";
|
||||
# desc = "Altera ByteBlaster";
|
||||
# type = "par";
|
||||
# connection_type = parallel;
|
||||
# sck = 2;
|
||||
# miso = 11;
|
||||
# reset = 3;
|
||||
# mosi = 8;
|
||||
# buff = 14;
|
||||
# ;
|
||||
|
||||
# It is almost same as pony-stk200, except vcc on pin 5 to auto
|
||||
# disconnect port (download on http://electropol.free.fr/spip/spip.php?article27)
|
||||
programmer parent "pony-stk200"
|
||||
id = "frank-stk200";
|
||||
desc = "Frank STK200";
|
||||
buff = ; # delete buff pin assignment
|
||||
vcc = 5;
|
||||
;
|
||||
# programmer parent "pony-stk200"
|
||||
# id = "frank-stk200";
|
||||
# desc = "Frank STK200";
|
||||
# buff = ; # delete buff pin assignment
|
||||
# vcc = 5;
|
||||
# ;
|
||||
|
||||
# The AT98ISP Cable is a simple parallel dongle for AT89 family.
|
||||
# http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2877
|
||||
programmer
|
||||
id = "89isp";
|
||||
desc = "Atmel at89isp cable";
|
||||
type = "par";
|
||||
connection_type = parallel;
|
||||
reset = 17;
|
||||
sck = 1;
|
||||
mosi = 2;
|
||||
miso = 10;
|
||||
;
|
||||
# programmer
|
||||
# id = "89isp";
|
||||
# desc = "Atmel at89isp cable";
|
||||
# type = "par";
|
||||
# connection_type = parallel;
|
||||
# reset = 17;
|
||||
# sck = 1;
|
||||
# mosi = 2;
|
||||
# miso = 10;
|
||||
# ;
|
||||
|
||||
|
||||
#This programmer bitbangs GPIO lines using the Linux sysfs GPIO interface
|
||||
|
|
|
@ -331,59 +331,8 @@ add_library(semver STATIC
|
|||
${LIBDIR}/semver/semver.c
|
||||
)
|
||||
|
||||
add_library(avrdude STATIC
|
||||
${LIBDIR}/avrdude/arduino.c
|
||||
${LIBDIR}/avrdude/avr.c
|
||||
# ${LIBDIR}/avrdude/avrftdi.c
|
||||
# ${LIBDIR}/avrdude/avrftdi_tpi.c
|
||||
${LIBDIR}/avrdude/avrpart.c
|
||||
${LIBDIR}/avrdude/avr910.c
|
||||
${LIBDIR}/avrdude/bitbang.c
|
||||
${LIBDIR}/avrdude/buspirate.c
|
||||
${LIBDIR}/avrdude/butterfly.c
|
||||
${LIBDIR}/avrdude/config.c
|
||||
${LIBDIR}/avrdude/config_gram.c
|
||||
${LIBDIR}/avrdude/confwin.c
|
||||
${LIBDIR}/avrdude/crc16.c
|
||||
# ${LIBDIR}/avrdude/dfu.c
|
||||
${LIBDIR}/avrdude/fileio.c
|
||||
# ${LIBDIR}/avrdude/flip1.c
|
||||
# ${LIBDIR}/avrdude/flip2.c
|
||||
# ${LIBDIR}/avrdude/ft245r.c
|
||||
# ${LIBDIR}/avrdude/jtagmkI.c
|
||||
# ${LIBDIR}/avrdude/jtagmkII.c
|
||||
# ${LIBDIR}/avrdude/jtag3.c
|
||||
${LIBDIR}/avrdude/lexer.c
|
||||
${LIBDIR}/avrdude/linuxgpio.c
|
||||
${LIBDIR}/avrdude/lists.c
|
||||
${LIBDIR}/avrdude/par.c
|
||||
${LIBDIR}/avrdude/pgm.c
|
||||
${LIBDIR}/avrdude/pgm_type.c
|
||||
${LIBDIR}/avrdude/pickit2.c
|
||||
${LIBDIR}/avrdude/pindefs.c
|
||||
${LIBDIR}/avrdude/ppi.c
|
||||
${LIBDIR}/avrdude/ppiwin.c
|
||||
${LIBDIR}/avrdude/safemode.c
|
||||
${LIBDIR}/avrdude/ser_avrdoper.c
|
||||
${LIBDIR}/avrdude/serbb_posix.c
|
||||
${LIBDIR}/avrdude/serbb_win32.c
|
||||
${LIBDIR}/avrdude/ser_posix.c
|
||||
${LIBDIR}/avrdude/ser_win32.c
|
||||
${LIBDIR}/avrdude/stk500.c
|
||||
${LIBDIR}/avrdude/stk500generic.c
|
||||
${LIBDIR}/avrdude/stk500v2.c
|
||||
${LIBDIR}/avrdude/term.c
|
||||
${LIBDIR}/avrdude/update.c
|
||||
# ${LIBDIR}/avrdude/usbasp.c
|
||||
# ${LIBDIR}/avrdude/usb_hidapi.c
|
||||
# ${LIBDIR}/avrdude/usb_libusb.c
|
||||
# ${LIBDIR}/avrdude/usbtiny.c
|
||||
${LIBDIR}/avrdude/wiring.c
|
||||
|
||||
${LIBDIR}/avrdude/main.c
|
||||
${LIBDIR}/avrdude/avrdude-slic3r.hpp
|
||||
${LIBDIR}/avrdude/avrdude-slic3r.cpp
|
||||
)
|
||||
add_subdirectory(src/avrdude)
|
||||
|
||||
# Generate the Slic3r Perl module (XS) typemap file.
|
||||
set(MyTypemap ${CMAKE_CURRENT_BINARY_DIR}/typemap)
|
||||
|
|
69
xs/src/avrdude/CMakeLists.txt
Normal file
69
xs/src/avrdude/CMakeLists.txt
Normal file
|
@ -0,0 +1,69 @@
|
|||
|
||||
|
||||
remove_definitions(-D_UNICODE -DUNICODE)
|
||||
|
||||
|
||||
set(AVRDUDE_SOURCES
|
||||
${LIBDIR}/avrdude/arduino.c
|
||||
${LIBDIR}/avrdude/avr.c
|
||||
# ${LIBDIR}/avrdude/avrftdi.c
|
||||
# ${LIBDIR}/avrdude/avrftdi_tpi.c
|
||||
${LIBDIR}/avrdude/avrpart.c
|
||||
${LIBDIR}/avrdude/avr910.c
|
||||
${LIBDIR}/avrdude/bitbang.c
|
||||
${LIBDIR}/avrdude/buspirate.c
|
||||
${LIBDIR}/avrdude/butterfly.c
|
||||
${LIBDIR}/avrdude/config.c
|
||||
${LIBDIR}/avrdude/config_gram.c
|
||||
# ${LIBDIR}/avrdude/confwin.c
|
||||
${LIBDIR}/avrdude/crc16.c
|
||||
# ${LIBDIR}/avrdude/dfu.c
|
||||
${LIBDIR}/avrdude/fileio.c
|
||||
# ${LIBDIR}/avrdude/flip1.c
|
||||
# ${LIBDIR}/avrdude/flip2.c
|
||||
# ${LIBDIR}/avrdude/ft245r.c
|
||||
# ${LIBDIR}/avrdude/jtagmkI.c
|
||||
# ${LIBDIR}/avrdude/jtagmkII.c
|
||||
# ${LIBDIR}/avrdude/jtag3.c
|
||||
${LIBDIR}/avrdude/lexer.c
|
||||
${LIBDIR}/avrdude/linuxgpio.c
|
||||
${LIBDIR}/avrdude/lists.c
|
||||
# ${LIBDIR}/avrdude/par.c
|
||||
${LIBDIR}/avrdude/pgm.c
|
||||
${LIBDIR}/avrdude/pgm_type.c
|
||||
${LIBDIR}/avrdude/pickit2.c
|
||||
${LIBDIR}/avrdude/pindefs.c
|
||||
# ${LIBDIR}/avrdude/ppi.c
|
||||
# ${LIBDIR}/avrdude/ppiwin.c
|
||||
${LIBDIR}/avrdude/safemode.c
|
||||
${LIBDIR}/avrdude/ser_avrdoper.c
|
||||
${LIBDIR}/avrdude/serbb_posix.c
|
||||
${LIBDIR}/avrdude/serbb_win32.c
|
||||
${LIBDIR}/avrdude/ser_posix.c
|
||||
${LIBDIR}/avrdude/ser_win32.c
|
||||
${LIBDIR}/avrdude/stk500.c
|
||||
${LIBDIR}/avrdude/stk500generic.c
|
||||
${LIBDIR}/avrdude/stk500v2.c
|
||||
${LIBDIR}/avrdude/term.c
|
||||
${LIBDIR}/avrdude/update.c
|
||||
# ${LIBDIR}/avrdude/usbasp.c
|
||||
# ${LIBDIR}/avrdude/usb_hidapi.c
|
||||
# ${LIBDIR}/avrdude/usb_libusb.c
|
||||
# ${LIBDIR}/avrdude/usbtiny.c
|
||||
${LIBDIR}/avrdude/wiring.c
|
||||
|
||||
${LIBDIR}/avrdude/main.c
|
||||
${LIBDIR}/avrdude/avrdude-slic3r.hpp
|
||||
${LIBDIR}/avrdude/avrdude-slic3r.cpp
|
||||
)
|
||||
if (WIN32)
|
||||
set(AVRDUDE_SOURCES ${AVRDUDE_SOURCES}
|
||||
${LIBDIR}/avrdude/windows/unistd.cpp
|
||||
${LIBDIR}/avrdude/windows/getopt.c
|
||||
)
|
||||
endif()
|
||||
add_library(avrdude STATIC ${AVRDUDE_SOURCES})
|
||||
if (WIN32)
|
||||
target_compile_definitions(avrdude PRIVATE WIN32NATIVE=1)
|
||||
target_include_directories(avrdude SYSTEM PRIVATE ${LIBDIR}/avrdude/windows) # So that sources find the getopt.h windows drop-in
|
||||
endif()
|
|
@ -17,7 +17,12 @@
|
|||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#if defined (WIN32NATIVE)
|
||||
/* #undef HAVE_GETTIMEOFDAY */
|
||||
// We have a gettimeofday() replacement in unistd.cpp (there is also one in ppiwin.c, but that file is written for Cygwin/MinGW)
|
||||
#else
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <hidapi/hidapi.h> header file. */
|
||||
/* #undef HAVE_HIDAPI_HIDAPI_H */
|
||||
|
@ -89,7 +94,7 @@
|
|||
#define HAVE_MEMSET 1
|
||||
|
||||
/* parallel port access enabled */
|
||||
#define HAVE_PARPORT 1
|
||||
// #define HAVE_PARPORT 1
|
||||
|
||||
/* Define to 1 if you have the <pthread.h> header file. */
|
||||
// #define HAVE_PTHREAD_H 1
|
||||
|
|
|
@ -25,9 +25,12 @@
|
|||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#if !defined(WIN32NATIVE)
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "avrdude.h"
|
||||
#include "libavrdude.h"
|
||||
|
||||
|
|
|
@ -32,9 +32,12 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if !defined(WIN32NATIVE)
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "avrdude.h"
|
||||
#include "libavrdude.h"
|
||||
|
||||
|
|
|
@ -16,19 +16,20 @@ static void avrdude_message_handler_ostream(const char *msg, unsigned size, void
|
|||
os << msg;
|
||||
}
|
||||
|
||||
int main(std::vector<std::string> args, std::string sys_config, std::ostream &stderr)
|
||||
int main(std::vector<std::string> args, std::string sys_config, std::ostream &os)
|
||||
{
|
||||
std::vector<char *> c_args {{ const_cast<char*>(PACKAGE_NAME) }};
|
||||
for (const auto &arg : args) {
|
||||
c_args.push_back(const_cast<char*>(arg.data()));
|
||||
}
|
||||
|
||||
::avrdude_message_handler_set(avrdude_message_handler_ostream, reinterpret_cast<void*>(&stderr));
|
||||
::avrdude_message_handler_set(avrdude_message_handler_ostream, reinterpret_cast<void*>(&os));
|
||||
const auto res = ::avrdude_main(static_cast<int>(c_args.size()), c_args.data(), sys_config.c_str());
|
||||
::avrdude_message_handler_set(nullptr, nullptr);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Slic3r {
|
||||
|
||||
namespace AvrDude {
|
||||
int main(std::vector<std::string> args, std::string sys_config, std::ostream &stderr);
|
||||
int main(std::vector<std::string> args, std::string sys_config, std::ostream &os);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,25 +43,31 @@ int avrdude_main(int argc, char * argv [], const char *sys_config);
|
|||
|
||||
#if defined(WIN32NATIVE)
|
||||
|
||||
#include "ac_cfg.h"
|
||||
// #include "ac_cfg.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#ifdef UNICODE
|
||||
#error "UNICODE should not be defined for avrdude bits on Windows"
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_USLEEP)
|
||||
int usleep(unsigned int us);
|
||||
#endif
|
||||
// #ifdef __cplusplus
|
||||
// extern "C" {
|
||||
// #endif
|
||||
|
||||
#if !defined(HAVE_GETTIMEOFDAY)
|
||||
struct timezone;
|
||||
int gettimeofday(struct timeval *tv, struct timezone *tz);
|
||||
#endif /* HAVE_GETTIMEOFDAY */
|
||||
// #if !defined(HAVE_USLEEP)
|
||||
// int usleep(unsigned int us);
|
||||
// #endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
// #if !defined(HAVE_GETTIMEOFDAY)
|
||||
// struct timezone;
|
||||
// int gettimeofday(struct timeval *tv, struct timezone *tz);
|
||||
// #endif /* HAVE_GETTIMEOFDAY */
|
||||
|
||||
// #ifdef __cplusplus
|
||||
// }
|
||||
// #endif
|
||||
#endif /* defined(WIN32NATIVE) */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,6 +41,11 @@ typedef unsigned long pinmask_t;
|
|||
#endif
|
||||
|
||||
|
||||
#if defined(WIN32NATIVE)
|
||||
#define PATH_MAX 1024 // Tad arbitrary, but should be ok for avrdude's pruposes
|
||||
#endif
|
||||
|
||||
|
||||
/* formerly lists.h */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
|
|
|
@ -42,8 +42,10 @@
|
|||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#if !defined(WIN32NATIVE)
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "avrdude.h"
|
||||
#include "libavrdude.h"
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
// #include "jtagmkII.h"
|
||||
// #include "jtag3.h"
|
||||
#include "linuxgpio.h"
|
||||
#include "par.h"
|
||||
// #include "par.h"
|
||||
#include "pickit2.h"
|
||||
#include "ppi.h"
|
||||
#include "serbb.h"
|
||||
|
@ -80,7 +80,7 @@ const PROGRAMMER_TYPE programmers_types[] = {
|
|||
// {"jtagice3_dw", jtag3_dw_initpgm, jtag3_dw_desc},
|
||||
// {"jtagice3_isp", stk500v2_jtag3_initpgm, stk500v2_jtag3_desc},
|
||||
{"linuxgpio", linuxgpio_initpgm, linuxgpio_desc},
|
||||
{"par", par_initpgm, par_desc},
|
||||
// {"par", par_initpgm, par_desc},
|
||||
{"pickit2", pickit2_initpgm, pickit2_desc},
|
||||
{"serbb", serbb_initpgm, serbb_desc},
|
||||
{"stk500", stk500_initpgm, stk500_desc},
|
||||
|
|
|
@ -152,7 +152,7 @@ static int winnt_pp_open(void)
|
|||
}
|
||||
else if(ver_info.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||
{
|
||||
HANDLE h = CreateFile(DRIVERNAME,
|
||||
HANDLE h = CreateFileA(DRIVERNAME,
|
||||
GENERIC_READ,
|
||||
0,
|
||||
NULL,
|
||||
|
|
|
@ -254,7 +254,7 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
|
|||
port = newname;
|
||||
}
|
||||
|
||||
hComPort = CreateFile(port, GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
||||
hComPort = CreateFileA(port, GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
if (hComPort == INVALID_HANDLE_VALUE) {
|
||||
|
|
|
@ -262,7 +262,7 @@ static int serbb_open(PROGRAMMER *pgm, char *port)
|
|||
if (bitbang_check_prerequisites(pgm) < 0)
|
||||
return -1;
|
||||
|
||||
hComPort = CreateFile(port, GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
||||
hComPort = CreateFileA(port, GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
if (hComPort == INVALID_HANDLE_VALUE) {
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "avrdude.h"
|
||||
#include "libavrdude.h"
|
||||
|
@ -759,7 +760,7 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
unsigned int page_size,
|
||||
unsigned int addr, unsigned int n_bytes)
|
||||
{
|
||||
unsigned char buf[page_size + 16];
|
||||
unsigned char *buf = alloca(page_size + 16);
|
||||
int memtype;
|
||||
int a_div;
|
||||
int block_size;
|
||||
|
|
File diff suppressed because it is too large
Load diff
1258
xs/src/avrdude/windows/getopt.c
Normal file
1258
xs/src/avrdude/windows/getopt.c
Normal file
File diff suppressed because it is too large
Load diff
188
xs/src/avrdude/windows/getopt.h
Normal file
188
xs/src/avrdude/windows/getopt.h
Normal file
|
@ -0,0 +1,188 @@
|
|||
|
||||
/* getopt.h */
|
||||
/* Declarations for getopt.
|
||||
Copyright (C) 1989-1994, 1996-1999, 2001 Free Software
|
||||
Foundation, Inc. This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute
|
||||
it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software
|
||||
Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will
|
||||
be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with the GNU C Library; if not, write
|
||||
to the Free Software Foundation, Inc., 59 Temple Place,
|
||||
Suite 330, Boston, MA 02111-1307 USA. */
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
|
||||
#ifndef __need_getopt
|
||||
# define _GETOPT_H 1
|
||||
#endif
|
||||
|
||||
/* If __GNU_LIBRARY__ is not already defined, either we are being used
|
||||
standalone, or this is the first header included in the source file.
|
||||
If we are being used with glibc, we need to include <features.h>, but
|
||||
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
|
||||
not defined, include <ctype.h>, which will pull in <features.h> for us
|
||||
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
|
||||
doesn't flood the namespace with stuff the way some other headers do.) */
|
||||
#if !defined __GNU_LIBRARY__
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
extern char *optarg;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns -1, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int optopt;
|
||||
|
||||
#ifndef __need_getopt
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
||||
of `struct option' terminated by an element containing a name which is
|
||||
zero.
|
||||
|
||||
The field `has_arg' is:
|
||||
no_argument (or 0) if the option does not take an argument,
|
||||
required_argument (or 1) if the option requires an argument,
|
||||
optional_argument (or 2) if the option takes an optional argument.
|
||||
|
||||
If the field `flag' is not NULL, it points to a variable that is set
|
||||
to the value given in the field `val' when the option is found, but
|
||||
left unchanged if the option is not found.
|
||||
|
||||
To have a long-named option do something other than set an `int' to
|
||||
a compiled-in constant, such as set a value from `optarg', set the
|
||||
option's `flag' field to zero and its `val' field to a nonzero
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero `flag' field, `getopt'
|
||||
returns the contents of the `val' field. */
|
||||
|
||||
struct option
|
||||
{
|
||||
# if (defined __STDC__ && __STDC__) || defined __cplusplus
|
||||
const char *name;
|
||||
# else
|
||||
char *name;
|
||||
# endif
|
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||
|
||||
# define no_argument 0
|
||||
# define required_argument 1
|
||||
# define optional_argument 2
|
||||
#endif /* need getopt */
|
||||
|
||||
|
||||
/* Get definitions and prototypes for functions to process the
|
||||
arguments in ARGV (ARGC of them, minus the program name) for
|
||||
options given in OPTS.
|
||||
|
||||
Return the option character from OPTS just read. Return -1 when
|
||||
there are no more options. For unrecognized options, or options
|
||||
missing arguments, `optopt' is set to the option letter, and '?' is
|
||||
returned.
|
||||
|
||||
The OPTS string is a list of characters which are recognized option
|
||||
letters, optionally followed by colons, specifying that that letter
|
||||
takes an argument, to be placed in `optarg'.
|
||||
|
||||
If a letter in OPTS is followed by two colons, its argument is
|
||||
optional. This behavior is specific to the GNU `getopt'.
|
||||
|
||||
The argument `--' causes premature termination of argument
|
||||
scanning, explicitly telling `getopt' that there are no more
|
||||
options.
|
||||
|
||||
If OPTS begins with `--', then non-option arguments are treated as
|
||||
arguments to the option '\0'. This behavior is specific to the GNU
|
||||
`getopt'. */
|
||||
|
||||
#if (defined __STDC__ && __STDC__) || defined __cplusplus
|
||||
# ifdef __GNU_LIBRARY__
|
||||
/* Many other libraries have conflicting prototypes for getopt, with
|
||||
differences in the consts, in stdlib.h. To avoid compilation
|
||||
errors, only prototype getopt for the GNU C library. */
|
||||
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts);
|
||||
# else /* not __GNU_LIBRARY__ */
|
||||
extern int getopt ();
|
||||
# endif /* __GNU_LIBRARY__ */
|
||||
|
||||
# ifndef __need_getopt
|
||||
extern int getopt_long (int ___argc, char *const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind);
|
||||
extern int getopt_long_only (int ___argc, char *const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind);
|
||||
|
||||
/* Internal only. Users should not call this directly. */
|
||||
extern int _getopt_internal (int ___argc, char *const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only);
|
||||
# endif
|
||||
#else /* not __STDC__ */
|
||||
extern int getopt ();
|
||||
# ifndef __need_getopt
|
||||
extern int getopt_long ();
|
||||
extern int getopt_long_only ();
|
||||
|
||||
extern int _getopt_internal ();
|
||||
# endif
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make sure we later can get all the definitions and declarations. */
|
||||
#undef __need_getopt
|
||||
|
||||
#endif /* getopt.h */
|
44
xs/src/avrdude/windows/unistd.cpp
Normal file
44
xs/src/avrdude/windows/unistd.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include "unistd.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
int usleep(unsigned usec)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(usec));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// SO: https://stackoverflow.com/questions/10905892/equivalent-of-gettimeday-for-windows
|
||||
int gettimeofday(struct timeval *tp, struct timezone *tzp)
|
||||
{
|
||||
// Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's
|
||||
// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
|
||||
// until 00:00:00 January 1, 1970
|
||||
static const std::uint64_t EPOCH = ((std::uint64_t) 116444736000000000ULL);
|
||||
|
||||
SYSTEMTIME system_time;
|
||||
FILETIME file_time;
|
||||
std::uint64_t time;
|
||||
|
||||
GetSystemTime(&system_time);
|
||||
SystemTimeToFileTime(&system_time, &file_time);
|
||||
time = ((std::uint64_t)file_time.dwLowDateTime);
|
||||
time += ((std::uint64_t)file_time.dwHighDateTime) << 32;
|
||||
|
||||
tp->tv_sec = (long)((time - EPOCH) / 10000000L);
|
||||
tp->tv_usec = (long)(system_time.wMilliseconds * 1000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
85
xs/src/avrdude/windows/unistd.h
Normal file
85
xs/src/avrdude/windows/unistd.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
#ifndef SLIC3R_AVRDUDE_UNISTD_H
|
||||
#define SLIC3R_AVRDUDE_UNISTD_H 1
|
||||
|
||||
/* This is intended as a drop-in replacement for unistd.h on Windows.
|
||||
* Please add functionality as neeeded.
|
||||
* https://stackoverflow.com/a/826027/1202830
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <io.h>
|
||||
#include <getopt.h> /* getopt at: https://gist.github.com/ashelly/7776712 */
|
||||
#include <process.h> /* for getpid() and the exec..() family */
|
||||
#include <direct.h> /* for _getcwd() and _chdir() */
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h> /* both for stat() */
|
||||
|
||||
#ifndef __cplusplus
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
#define __func__ __FUNCTION__
|
||||
|
||||
#define srandom srand
|
||||
#define random rand
|
||||
|
||||
/* Values for the second argument to access.
|
||||
These may be OR'd together. */
|
||||
#define R_OK 4 /* Test for read permission. */
|
||||
#define W_OK 2 /* Test for write permission. */
|
||||
//#define X_OK 1 /* execute permission - unsupported in windows*/
|
||||
#define F_OK 0 /* Test for existence. */
|
||||
|
||||
#define access _access
|
||||
#define dup2 _dup2
|
||||
#define execve _execve
|
||||
#define ftruncate _chsize
|
||||
#define unlink _unlink
|
||||
#define fileno _fileno
|
||||
#define getcwd _getcwd
|
||||
#define chdir _chdir
|
||||
#define isatty _isatty
|
||||
#define lseek _lseek
|
||||
#define snprintf _snprintf
|
||||
#define strncasecmp _strnicmp
|
||||
#define strcasecmp _stricmp
|
||||
#define stat _stat
|
||||
/* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */
|
||||
|
||||
#ifdef _WIN64
|
||||
#define ssize_t __int64
|
||||
#else
|
||||
#define ssize_t long
|
||||
#endif
|
||||
|
||||
#define STDIN_FILENO 0
|
||||
#define STDOUT_FILENO 1
|
||||
#define STDERR_FILENO 2
|
||||
|
||||
#ifndef __cplusplus
|
||||
/* should be in some equivalent to <sys/types.h> */
|
||||
typedef __int8 int8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#endif
|
||||
|
||||
|
||||
int usleep(unsigned usec);
|
||||
int gettimeofday(struct timeval *tp, struct timezone *tzp);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* unistd.h */
|
|
@ -255,7 +255,26 @@ void set_preset_bundle(PresetBundle *preset_bundle)
|
|||
{
|
||||
g_PresetBundle = preset_bundle;
|
||||
|
||||
AvrDude::main({{ "-h" }}, "/tmp/", std::cerr); // XXX: tmp
|
||||
auto res = AvrDude::main({{
|
||||
// "-h",
|
||||
"-v",
|
||||
"-p",
|
||||
"atmega2560",
|
||||
"-c",
|
||||
"wiring",
|
||||
"-P",
|
||||
"COM1",
|
||||
"-b115200",
|
||||
"-D",
|
||||
"-U",
|
||||
"flash:w:c:\\local\\prusa3d_fw-3.2.0-RC2.534-1_75mm_MK3-EINSy10a-E3Dv6full.hex:i",
|
||||
}},
|
||||
"c:\\local\\Slic3r\\resources\\avrdude\\avrdude.conf", std::cerr
|
||||
); // XXX: tmp
|
||||
|
||||
std::cerr << "AvrDude::main: " << res << std::endl;
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void set_preset_updater(PresetUpdater *updater)
|
||||
|
|
Loading…
Reference in a new issue