Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
VERSION_MAIN = 1
VERSION_SUB = 8
include version.mk

CC = gcc
OBJS = main.o hex.o
Expand All @@ -16,15 +15,15 @@ ifeq ($(shell uname -s),Darwin)
else
# Rules for Linux, etc.
OBJS += usb-libusb.o
CFLAGS = -O3
CFLAGS = -O3
LDFLAGS = -lusb
SYSTEM = linux
endif

CFLAGS += -DVERSION_MAIN=$(VERSION_MAIN) -DVERSION_SUB=$(VERSION_SUB)
#CFLAGS += -DDEBUG

all:
all:
@echo
@echo Please make 'mphidflash32' or 'mphidflash64' for 32 or 64 bit version
@echo
Expand All @@ -39,7 +38,7 @@ mphidflash64: LDFLAGS += -m64
mphidflash64: EXEC = mphidflash-$(VERSION_MAIN).$(VERSION_SUB)-$(SYSTEM)-64
mphidflash64: mphidflash

mphidflash32: CFLAGS += -m32
mphidflash32: CFLAGS += -m32
mphidflash32: LDFLAGS += -m32
mphidflash32: EXEC = mphidflash-$(VERSION_MAIN).$(VERSION_SUB)-$(SYSTEM)-32
mphidflash32: mphidflash
Expand All @@ -50,7 +49,7 @@ mphidflash: $(OBJS)

install:
@echo
@echo Please make 'install32 or install64' to install 32 or 64 bit target
@echo Please make 'install32' or 'install64' to install 32 or 64 bit target
@echo

# Must install as root; e.g. 'sudo make install'
Expand Down Expand Up @@ -82,3 +81,21 @@ src-zipfile:
rm -f $(DISTPATH)/mphidflash-$(VERSION_MAIN).$(VERSION_SUB)-src.zip
zip $(DISTPATH)/mphidflash-$(VERSION_MAIN).$(VERSION_SUB)-src.zip README.txt CHANGELOG COPYING Makefile* *.c *.h


cross: windows

win: windows

windows:
make -f Makefile.win

win32: mingw32

mingw32:
make -f Makefile.win mphidflash32

win64: mingw64

mingw64:
make -f Makefile.win mphidflash64

25 changes: 18 additions & 7 deletions Makefile.win
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
VERSION_MAIN = 1
VERSION_SUB = 8
include version.mk
SYSTEM = win

# determine the compiler in reach - it might be a cross-compiler
CC32 := $(shell basename `which i586-mingw32msvc-gcc i686-w64-mingw32-gcc | head -n 1`)
CC64 := $(shell basename `which x86_64-mingw32msvc-gcc x86_64-w64-mingw32-gcc | head -n 1`)
CC = $(CC32)

CC = i586-mingw32msvc-gcc
EXECS = mphidflash.exe
EXECPATH = binaries
OBJS = main.o hex.o usb-windows.o
CFLAGS = -DWIN -DVERSION_MAIN=$(VERSION_MAIN) -DVERSION_SUB=$(VERSION_SUB)
LDFLAGS = -lhid -lsetupapi
LDFLAGS = -lhid -lsetupapi

all: $(EXECS)

Expand All @@ -14,14 +19,20 @@ all: $(EXECS)
.c.o:
$(CC) $(CFLAGS) -c $*.c

# todo: add 64 bit target (low priority as 32 bit works on all platforms)
mphidflash64: CC = $(CC64)
mphidflash64: CFLAGS += -m64
mphidflash64: LDFLAGS += -m64
mphidflash64: EXEC = mphidflash-$(VERSION_MAIN).$(VERSION_SUB)-$(SYSTEM)-64.exe
mphidflash64: mphidflash.exe

mphidflash32: CFLAGS += -m32
mphidflash32: CC = $(CC32)
mphidflash32: CFLAGS += -m32
mphidflash32: LDFLAGS += -m32
mphidflash32: EXEC = mphidflash-$(VERSION_MAIN).$(VERSION_SUB)-$(SYSTEM)-32.exe
mphidflash32: mphidflash.exe

mphidflash.exe: $(OBJS)
$(CC) $(OBJS) $(LDFLAGS) -o binaries/mphidflash-$(VERSION_MAIN).$(VERSION_SUB)-win-32.exe
$(CC) $(OBJS) $(LDFLAGS) -o $(EXECPATH)/$(EXEC)

clean:
rm -f $(EXECS) *.o core
Expand Down
51 changes: 28 additions & 23 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ the PIC32 HID Bootloader uses the same default USB Product Id as the supported
HID Bootloader. If used in error either 'mphidflash' or the development board
may freeze or indicate an error.

The 'mphidflash' project is hosted at https://github.com/ApertureLabsLtd/mphidflash
The 'mphidflash' project is hosted at https://github.com/AdamLaurie/mphidflash
(migrated from http://code.google.com/p/mphidflash/)

Building and Installing
Expand All @@ -28,24 +28,24 @@ For Linux, you'll need the 'libhid' development library (and associated
dependencies) installed, which can be handled by most package managers or
from the command line:

sudo apt-get install libhid-dev
sudo apt-get install libhid-dev

Assuming you're reading this as the README.txt alongside the source code,
to compile mphidflash for a 32 or 64 bit system, in the Terminal window type:

make mphidflash32
make mphidflash32

or

make mphidflash64
make mphidflash64

Then install with the command:

sudo make install32
sudo make install32

or

sudo make install64
sudo make install64

This will copy the appropriate executable to /usr/local/bin/mphidflash so you
don't need to specify a complete path to the program each time.
Expand All @@ -60,19 +60,19 @@ the command line interface.
Assuming you're reading this as the README.txt alongside the source code,
to compile mphidflash for a 32 or 64 bit system, in the Terminal window type:

make mphidflash32
make mphidflash32

or

make mphidflash64
make mphidflash64

Then install with the command:

sudo make install32
sudo make install32

or

sudo make install64
sudo make install64

This will copy the appropriate executable to /usr/local/bin/mphidflash so you
don't need to specify a complete path to the program each time.
Expand All @@ -85,14 +85,18 @@ cross compiling on Linux, you'll need the 'mingw32' toolchain (and associated
dependencies) installed, which can be handled by most package mangager or
from the command line:

sudo apt-get install mingw32
sudo apt-get install mingw32

Assuming you're reading this as the README.txt alongside the source code,
to compile mphidflash, in the Terminal window type:

make -f Makefile.win
make win32

This will create a .exe in the binaries sub-directory, which can be called
or

make win64

This will create an .exe in the binaries sub-directory, which can be called
from the Windows commmand line - e.g. 'mphidflash-1.6-win-32.exe'. You should
copy this file somewhere on your executable path and rename it to 'mphidflash.exe'.

Expand All @@ -104,22 +108,23 @@ in usb_windows.c that need to be edited to match your DDK install location.
Usage
=====
To upload a new program to your PIC, it must be connected to your computer and
set into bootloader mode. mphidflash can then be used with the following
set into bootloader mode. mphidflash can then be used with the following
options:

-help Display help screen (alternately: -?)
-write <file> Upload given file to PIC
-reset Reset PIC
-noverify Skip verification step
-erase Erase PIC memory
-sign Sign flash
-vendor <hex> Use given USB vendor id instead of default id
-product <hex> Use given USB product id instead of default id
-help Display help screen (alternately: -?)
-write <file> Upload given file to PIC
-reset Reset PIC
-noverify Skip verification step
-erase Erase PIC memory (implicit if -w)
-unlock Unlock config mem before erase/write
-sign Sign flash (for later versions of boot loader)
-vendor <hex> Use given USB vendor id instead of default id 04d8
-product <hex> Use given USB product id instead of default id 003c

Example: To upload the program test.hex to the PIC and to reset the PIC thereafter
the following command line can be used:

mphidflash -write test.hex -reset
mphidflash -write test.hex -reset

Tips
====
Expand Down
Binary file added binaries/mphidflash-1.8-linux-32
Binary file not shown.
Binary file added binaries/mphidflash-1.8-linux-64
Binary file not shown.
Binary file added binaries/mphidflash-1.8-win-32.exe
Binary file not shown.
Binary file added binaries/mphidflash-1.8-win-64.exe
Binary file not shown.
Binary file added binaries/mphidflash-1.9-linux-32
Binary file not shown.
Binary file added binaries/mphidflash-1.9-linux-64
Binary file not shown.
Binary file added binaries/mphidflash-1.9-win-32.exe
Binary file not shown.
Binary file added binaries/mphidflash-1.9-win-64.exe
Binary file not shown.
16 changes: 16 additions & 0 deletions build_all_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

make clean
make mphidflash32

make clean
make mphidflash64

make clean
make win32

make clean
make win64

make clean

Loading