hosted: Allow to build without libusb, libftdi and hidapi with HOSTED_BMP_ONLY=1

This commit is contained in:
Uwe Bonnes 2020-12-05 16:52:35 +01:00
parent 32db38ecf2
commit 0870b778c0
4 changed files with 73 additions and 12 deletions

View File

@ -2,6 +2,14 @@ SYS = $(shell $(CC) -dumpmachine)
CFLAGS += -DENABLE_DEBUG -DPLATFORM_HAS_DEBUG
CFLAGS +=-I ./target -I./platforms/pc
# Define HOSTED_BMP_ONLY to '1' in order to build the hosted blackmagic
# executable with support for native BMP probes only. This makes
# linking against the libftdi and libusb libraries unnecessary. This can
# be useful to minimize external dependencies, and make building on
# windows systems easier.
HOSTED_BMP_ONLY ?= 0
CFLAGS += -DHOSTED_BMP_ONLY=$(HOSTED_BMP_ONLY)
ifneq (, $(findstring linux, $(SYS)))
SRC += serial_unix.c
ifeq ($(ASAN), 1)
@ -24,27 +32,32 @@ LDFLAGS += -framework CoreFoundation
CFLAGS += -Ihidapi/hidapi
endif
ifneq ($(HOSTED_BMP_ONLY), 1)
LDFLAGS += -lusb-1.0
CFLAGS += $(shell pkg-config --cflags libftdi1)
LDFLAGS += $(shell pkg-config --libs libftdi1)
CFLAGS += -Wno-missing-field-initializers
endif
ifneq (, $(findstring mingw, $(SYS)))
SRC += cmsis_dap.c dap.c hid.c
ifneq ($(HOSTED_BMP_ONLY), 1)
CFLAGS += -DCMSIS_DAP
else
ifeq ($(shell pkg-config --exists hidapi-libusb && echo 0), 0)
SRC += cmsis_dap.c dap.c
ifneq (, $(findstring mingw, $(SYS)))
SRC += hid.c
else
CFLAGS += $(shell pkg-config --cflags hidapi-libusb)
LDFLAGS += $(shell pkg-config --libs hidapi-libusb)
CFLAGS += -DCMSIS_DAP
SRC += cmsis_dap.c dap.c
endif
endif
VPATH += platforms/pc
SRC += timing.c cl_utils.c utils.c
SRC += stlinkv2.c bmp_libusb.c
SRC += bmp_remote.c remote_swdptap.c remote_jtagtap.c
ifneq ($(HOSTED_BMP_ONLY), 1)
SRC += bmp_libusb.c stlinkv2.c
SRC += ftdi_bmp.c libftdi_swdptap.c libftdi_jtagtap.c
SRC += jlink.c jlink_adiv5_swdp.c jlink_jtagtap.c
else
SRC += bmp_serial.c
endif
PC_HOSTED = 1

View File

@ -22,6 +22,7 @@
#include "libusb-1.0/libusb.h"
#include "cl_utils.h"
#include "ftdi_bmp.h"
#include "version.h"
#define VENDOR_ID_STLINK 0x0483
#define PRODUCT_ID_STLINK_MASK 0xffe0
@ -35,6 +36,17 @@
#define VENDOR_ID_SEGGER 0x1366
void bmp_ident(bmp_info_t *info)
{
DEBUG_INFO("BMP hosted %s\n for ST-Link V2/3, CMSIS_DAP, JLINK and "
"LIBFTDI/MPSSE\n", FIRMWARE_VERSION);
if (info && info->vid && info->pid)
DEBUG_INFO("Using %04x:%04x %s %s\n %s\n", info->vid, info->pid,
info->serial,
info->manufacturer,
info->product);
}
void libusb_exit_function(bmp_info_t *info)
{
if (!info->usb_link)

View File

@ -0,0 +1,40 @@
/*
* This file is part of the Black Magic Debug project.
*
* Copyright (C) 2020 Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* Find all known serial connected debuggers */
#include "general.h"
#include <stdint.h>
#include "platform.h"
#include "bmp_hosted.h"
#include "version.h"
void bmp_ident(bmp_info_t *info)
{
(void) info;
DEBUG_INFO("BMP hosted %s\n", FIRMWARE_VERSION);
}
void libusb_exit_function(bmp_info_t *info) {(void)info;};
int find_debuggers(BMP_CL_OPTIONS_t *cl_opts, bmp_info_t *info)
{
(void)cl_opts;
(void)info;
return -1;
};

View File

@ -85,11 +85,7 @@ void platform_init(int argc, char **argv)
} else if (find_debuggers(&cl_opts, &info)) {
exit(-1);
}
DEBUG_INFO("BMP hosted %s\n for ST-Link V2/3, CMSIS_DAP, JLINK and "
"LIBFTDI/MPSSE\n", FIRMWARE_VERSION);
DEBUG_INFO("Using %04x:%04x %s %s\n %s\n", info.vid, info.pid, info.serial,
info.manufacturer,
info.product);
bmp_ident(&info);
switch (info.bmp_type) {
case BMP_TYPE_BMP:
if (serial_open(&cl_opts, info.serial))