aboutsummaryrefslogtreecommitdiff
path: root/upgrade
diff options
context:
space:
mode:
Diffstat (limited to 'upgrade')
-rw-r--r--upgrade/Makefile9
-rw-r--r--upgrade/bindata.S2
-rw-r--r--upgrade/dfu.c13
-rw-r--r--upgrade/main.c12
-rw-r--r--upgrade/stm32mem.c3
-rw-r--r--upgrade/stm32mem.h6
6 files changed, 29 insertions, 16 deletions
diff --git a/upgrade/Makefile b/upgrade/Makefile
index 65d88e5..397b3e6 100644
--- a/upgrade/Makefile
+++ b/upgrade/Makefile
@@ -1,7 +1,8 @@
+OUTFILE = blackmagic_upgrade
CC = $(CROSS_COMPILE)gcc
-CFLAGS = -Wall -Wextra -std=gnu99 -O0 -g -MD
+CFLAGS = -Wall -Wextra -std=gnu99 -O0 -g -MD -mno-ms-bitfields
LDFLAGS = -lusb
OBJ = bindata.o \
@@ -9,14 +10,14 @@ OBJ = bindata.o \
stm32mem.o \
main.o
-all: bmp_upgrade
+all: $(OUTFILE)
-bmp_upgrade: $(OBJ)
+$(OUTFILE) $(OUTFILE).exe: $(OBJ)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
.PHONY: clean
clean:
- -rm -rf bmp_upgrade *.d *.o
+ -rm -rf $(OUTFILE) $(OUTFILE).exe *.d *.o
-include *.d
diff --git a/upgrade/bindata.S b/upgrade/bindata.S
index 1d94da5..585a670 100644
--- a/upgrade/bindata.S
+++ b/upgrade/bindata.S
@@ -24,5 +24,5 @@ _bindata:
.incbin "../src/blackmagic.bin"
_bindatalen:
- .word . - _bindata
+ .long (. - _bindata)
diff --git a/upgrade/dfu.c b/upgrade/dfu.c
index 2ab16ed..39d3ab4 100644
--- a/upgrade/dfu.c
+++ b/upgrade/dfu.c
@@ -18,7 +18,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <usb.h>
+#ifdef WIN32
+# include <lusb0_usb.h>
+#else
+# include <usb.h>
+#endif
#include "dfu.h"
@@ -80,12 +84,13 @@ int dfu_getstate(usb_dev_handle *dev, uint16_t iface)
int i;
uint8_t state;
do {
- i = usb_control_msg(dev,
+ i = usb_control_msg(dev,
USB_ENDPOINT_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
- DFU_GETSTATE, 0, iface, &state, 1, USB_DEFAULT_TIMEOUT);
+ DFU_GETSTATE, 0, iface, (char*)&state, 1,
+ USB_DEFAULT_TIMEOUT);
} while(i == 0);
- if(i > 0)
+ if (i > 0)
return state;
else
return i;
diff --git a/upgrade/main.c b/upgrade/main.c
index dd92a2e..38fa575 100644
--- a/upgrade/main.c
+++ b/upgrade/main.c
@@ -18,8 +18,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
-#include <usb.h>
#include <string.h>
+#ifdef WIN32
+# include <lusb0_usb.h>
+#else
+# include <usb.h>
+#endif
#include <assert.h>
@@ -70,14 +74,12 @@ struct usb_device * find_dev(void)
if (((dev->descriptor.idProduct == 0x5740) ||
(dev->descriptor.idProduct == 0x6018)) &&
- !strcmp(man, "Black Sphere Technologies") &&
- !strcmp(prod, "Black Magic Firmware Upgrade"))
+ !strcmp(man, "Black Sphere Technologies"))
return dev;
if (((dev->descriptor.idProduct == 0xDF11) ||
(dev->descriptor.idProduct == 0x6017)) &&
- !strcmp(man, "Black Sphere Technologies") &&
- !strcmp(prod, "Black Magic Probe (Upgrade)"))
+ !strcmp(man, "Black Sphere Technologies"))
return dev;
}
}
diff --git a/upgrade/stm32mem.c b/upgrade/stm32mem.c
index 4731edc..53bbb5b 100644
--- a/upgrade/stm32mem.c
+++ b/upgrade/stm32mem.c
@@ -17,13 +17,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <usb.h>
#include <string.h>
#ifdef WIN32
# include <windows.h>
+# include <lusb0_usb.h>
#else
# include <unistd.h>
+# include <usb.h>
#endif
#include "dfu.h"
diff --git a/upgrade/stm32mem.h b/upgrade/stm32mem.h
index 34cdfb1..fd99c65 100644
--- a/upgrade/stm32mem.h
+++ b/upgrade/stm32mem.h
@@ -20,7 +20,11 @@
#ifndef __STM32MEM_H
#define __STM32MEM_H
-#include <usb.h>
+#ifdef WIN32
+# include <lusb0_usb.h>
+#else
+# include <usb.h>
+#endif
int stm32_mem_erase(usb_dev_handle *dev, uint16_t iface, uint32_t addr);
int stm32_mem_write(usb_dev_handle *dev, uint16_t iface, void *data, int size);