Add stub for windows dfu version.

This commit is contained in:
Serge Vakulenko 2018-09-06 12:10:01 -07:00
parent 3486e57383
commit aa28209336
9 changed files with 78 additions and 2076 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.o
*.hd
dmrconfig
dmrconfig.exe

View File

@ -5,7 +5,7 @@ GITCOUNT = $(shell git rev-list HEAD --count)
CFLAGS = -g -O -Wall -Werror -DVERSION='"$(VERSION).$(GITCOUNT)"'
LDFLAGS = -g
OBJS = main.o util.o radio.o dfu.o uv380.o md380.o
OBJS = main.o util.o radio.o dfu-libusb.o uv380.o md380.o
LIBS = -lusb-1.0
# Mac OS X
@ -28,7 +28,7 @@ dmrconfig.linux: dmrconfig
strip $@
###
dfu.o: dfu.c util.h
dfu-libusb.o: dfu-libusb.c util.h
main.o: main.c radio.h util.h
md380.o: md380.c radio.h util.h
radio.o: radio.c radio.h util.h

View File

@ -5,8 +5,8 @@ GITCOUNT = $(shell git rev-list HEAD --count)
CFLAGS = -g -O -Wall -Werror -DVERSION='"$(VERSION).$(GITCOUNT)"' -Ilibusb-win32
LDFLAGS = -g -s
OBJS = main.o util.o radio.o dfu.o uv380.o md380.o
LIBS = -Llibusb-win32 -lusb-1.0
OBJS = main.o util.o radio.o dfu-windows.o uv380.o md380.o
LIBS =
# Compiling Windows binary from Linux
ifeq (/usr/bin/i586-mingw32msvc-gcc,$(wildcard /usr/bin/i586-mingw32msvc-gcc))
@ -15,9 +15,6 @@ endif
ifeq (/usr/bin/i686-w64-mingw32-gcc,$(wildcard /usr/bin/i686-w64-mingw32-gcc))
CC = i686-w64-mingw32-gcc
endif
ifeq (/usr/bin/i686-w64-mingw32-gcc-win32,$(wildcard /usr/bin/i686-w64-mingw32-gcc-win32))
CC = i686-w64-mingw32-gcc-win32
endif
all: dmrconfig.exe
@ -31,7 +28,7 @@ install: dmrconfig
install -c -s dmrconfig /usr/local/bin/dmrconfig
###
dfu.o: dfu.c util.h
dfu-windows.o: dfu-windows.c util.h
main.o: main.c radio.h util.h
md380.o: md380.c radio.h util.h
radio.o: radio.c radio.h util.h

View File

63
dfu-windows.c Normal file
View File

@ -0,0 +1,63 @@
/*
* DFU routines.
*
* Copyright (C) 2018 Serge Vakulenko, KK6ABQ
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include "util.h"
const char *dfu_init(unsigned vid, unsigned pid)
{
//TODO: use STDFU.dll
fprintf(stderr, "DFU for Windows not implemented yet.\n");
exit(-1);
return 0;
}
void dfu_close()
{
//TODO
}
void dfu_erase(unsigned start, unsigned finish)
{
//TODO
}
void dfu_read_block(int bno, unsigned char *data, int nbytes)
{
//TODO
}
void dfu_write_block(int bno, unsigned char *data, int nbytes)
{
//TODO
}
void dfu_reboot()
{
//TODO
}

View File

@ -1,61 +0,0 @@
libusb 1.0 Windows binary snapshot - README
*********************************************************************
* The latest version of this snapshot can always be downloaded at: *
* https://sourceforge.net/projects/libusb/files/ *
*********************************************************************
o Visual Studio:
- Open existing or create a new project for your application
- Copy libusb.h, from the include\libusb-1.0\ directory, into your project and
make sure that the location where the file reside appears in the 'Additional
Include Directories' section (Configuration Properties -> C/C++ -> General).
- Copy the relevant .lib file from MS32\ or MS64\ and add 'libusb-1.0.lib' to
your 'Additional Dependencies' (Configuration Properties -> Linker -> Input)
Also make sure that the directory where libusb-1.0.lib resides is added to
'Additional Library Directories' (Configuration Properties -> Linker
-> General)
- If you use the static version of the libusb library, make sure that
'Runtime Library' is set to 'Multi-threaded DLL (/MD)' (Configuration
Properties -> C/C++ -> Code Generation).
NB: If your application requires /MT (Multi-threaded/libCMT), you need to
recompile a static libusb 1.0 library from source.
- Compile and run your application. If you use the DLL version of libusb-1.0,
remember that you need to have a copy of the DLL either in the runtime
directory or in system32
o WDK/DDK:
- The following is an example of a sources files that you can use to compile
a libusb 1.0 based console application. In this sample ..\libusb\ is the
directory where you would have copied libusb.h as well as the relevant
libusb-1.0.lib
TARGETNAME=your_app
TARGETTYPE=PROGRAM
USE_MSVCRT=1
UMTYPE=console
INCLUDES=..\libusb;$(DDK_INC_PATH)
TARGETLIBS=..\libusb\libusb-1.0.lib
SOURCES=your_app.c
- Note that if you plan to use libCMT instead of MSVCRT (USE_LIBCMT=1 instead
of USE_MSVCRT=1), you will need to recompile libusb to use libCMT. This can
easily be achieved, in the DDK environment, by running 'ddk_build /MT'
o MinGW/cygwin
- Copy libusb.h, from include/libusb-1.0/ to your default include directory,
and copy the MinGW32/ or MinGW64/ .a files to your default library directory.
Or, if you don't want to use the default locations, make sure that you feed
the relevant -I and -L options to the compiler.
- Add the '-lusb-1.0' linker option when compiling.
o Additional information:
- The libusb 1.0 API documentation can be accessed at:
http://api.libusb.info
- For some libusb samples (including source), please have a look in examples/
- For additional information on the libusb 1.0 Windows backend please visit:
http://windows.libusb.info
- The MinGW and MS generated DLLs are fully interchangeable, provided that you
use the import libs provided or generate one from the .def also provided.
- If you find any issue, please visit http://libusb.info/ and check the
Support section

Binary file not shown.

File diff suppressed because it is too large Load Diff

5
main.c
View File

@ -42,7 +42,7 @@ void usage()
fprintf(stderr, _("DMR Config, Version %s, %s\n"), version, copyright);
fprintf(stderr, _("Usage:\n"));
fprintf(stderr, _(" dmrconfig -r [-t]\n"));
fprintf(stderr, _(" Read codeplug from the radio and save it to a binary file 'device.img'.\n"));
fprintf(stderr, _(" Read codeplug from the radio to a file 'device.img'.\n"));
fprintf(stderr, _(" Save configuration to a text file 'device.conf'.\n"));
fprintf(stderr, _(" dmrconfig -w [-t] file.img\n"));
fprintf(stderr, _(" Write codeplug to the radio.\n"));
@ -54,11 +54,12 @@ void usage()
fprintf(stderr, _(" dmrconfig file.img\n"));
fprintf(stderr, _(" Display configuration from the codeplug image.\n"));
fprintf(stderr, _(" dmrconfig -u [-t] file.csv\n"));
fprintf(stderr, _(" Update contacts database.\n"));
fprintf(stderr, _(" Update contacts database from CSV file.\n"));
fprintf(stderr, _("Options:\n"));
fprintf(stderr, _(" -r Read codeplug from the radio.\n"));
fprintf(stderr, _(" -w Write codeplug to the radio.\n"));
fprintf(stderr, _(" -c Configure the radio from a text script.\n"));
fprintf(stderr, _(" -u Update contacts database.\n"));
fprintf(stderr, _(" -t Trace USB protocol.\n"));
exit(-1);
}