On Sat, Jan 17, 2015 at 09:14:08PM +0300, Paul Fertser wrote:
> Attached to this mail is an OpenWrt Makefile that will (hopefully)
> allow you to build OpenOCD for any OpenWrt target. I will propose it
> upstream once it gets a bit more testing and Jens's fix is committed.

New version of the patches, now with support for HIDAPI so CMSIS-DAP
adapters work too (runtime-tested).

-- 
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:[email protected]
>From e21eb573a0a2db561b3e629586ed6770e293d670 Mon Sep 17 00:00:00 2001
From: Paul Fertser <[email protected]>
Date: Sun, 18 Jan 2015 02:20:29 +0300
Subject: [PATCH 1/2] libs: add HIDAPI, a library to access HID devices

Signed-off-by: Paul Fertser <[email protected]>
---
 libs/hidapi/Makefile                            | 74 +++++++++++++++++++++++++
 libs/hidapi/patches/010-add-iconv-linkage.patch | 22 ++++++++
 2 files changed, 96 insertions(+)
 create mode 100644 libs/hidapi/Makefile
 create mode 100644 libs/hidapi/patches/010-add-iconv-linkage.patch

diff --git a/libs/hidapi/Makefile b/libs/hidapi/Makefile
new file mode 100644
index 0000000..7b1165e
--- /dev/null
+++ b/libs/hidapi/Makefile
@@ -0,0 +1,74 @@
+#
+# Copyright (C) 2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=hidapi
+PKG_VERSION:=0.8.0-rc1
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://github.com/signal11/hidapi.git
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=hidapi-0.8.0-rc1
+PKG_MAINTAINER:=Paul Fertser <[email protected]>
+
+PKG_LICENSE:=BSD
+PKG_LICENSE_FILES:=LICENSE-bsd.txt
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/nls.mk
+
+define Package/hidapi
+  SECTION:=libs
+  CATEGORY:=Libraries
+  DEPENDS:=+libusb-1.0 +libiconv +librt
+  TITLE:=Library to talk to HID devices
+  URL:=http://www.signal11.us/oss/hidapi/
+endef
+
+define Package/hidapi/description
+HIDAPI is a multi-platform library which allows an application to interface
+with USB and Bluetooth HID-Class devices on Windows, Linux, FreeBSD, and Mac
+OS X.  HIDAPI can be either built as a shared library (.so or .dll) or
+can be embedded directly into a target application by adding a single source
+file (per platform) and a single header.
+endef
+
+define Build/Configure
+endef
+
+MAKE_PATH=libusb
+MAKE_FLAGS+=-f Makefile.linux
+TARGET_CFLAGS+=-fPIC
+
+define Build/Compile
+	$(call Build/Compile/Default, libhidapi-libusb.so)
+	sed    's^@prefix@^/usr^; \
+		s^@exec_prefix@^/usr^; \
+		s^@libdir@^/usr/lib^; \
+		s^@includedir@^/usr/include^' \
+		< $(PKG_BUILD_DIR)/pc/hidapi-libusb.pc.in \
+		> $(PKG_BUILD_DIR)/pc/hidapi-libusb.pc
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include/hidapi
+	$(CP) $(PKG_BUILD_DIR)/hidapi/hidapi.h $(1)/usr/include/hidapi/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_BUILD_DIR)/libusb/libhidapi-libusb.so $(1)/usr/lib/libhidapi-libusb.so.0
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig/
+	$(CP) $(PKG_BUILD_DIR)/pc/hidapi-libusb.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/hidapi/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_BUILD_DIR)/libusb/libhidapi-libusb.so $(1)/usr/lib/libhidapi-libusb.so.0
+endef
+
+$(eval $(call BuildPackage,hidapi))
diff --git a/libs/hidapi/patches/010-add-iconv-linkage.patch b/libs/hidapi/patches/010-add-iconv-linkage.patch
new file mode 100644
index 0000000..d942d50
--- /dev/null
+++ b/libs/hidapi/patches/010-add-iconv-linkage.patch
@@ -0,0 +1,22 @@
+Index: hidapi-0.8.0-rc1/libusb/Makefile.linux
+===================================================================
+--- hidapi-0.8.0-rc1.orig/libusb/Makefile.linux
++++ hidapi-0.8.0-rc1/libusb/Makefile.linux
+@@ -22,7 +22,7 @@ COBJS_LIBUSB = hid.o
+ COBJS = $(COBJS_LIBUSB)
+ CPPOBJS   = ../hidtest/hidtest.o
+ OBJS      = $(COBJS) $(CPPOBJS)
+-LIBS_USB  = `pkg-config libusb-1.0 --libs` -lrt -lpthread
++LIBS_USB  = `pkg-config libusb-1.0 --libs` -lrt -lpthread -liconv
+ LIBS      = $(LIBS_USB)
+ INCLUDES ?= -I../hidapi `pkg-config libusb-1.0 --cflags`
+ 
+@@ -33,7 +33,7 @@ hidtest-libusb: $(COBJS_LIBUSB) $(CPPOBJ
+ 
+ # Shared Libs
+ libhidapi-libusb.so: $(COBJS_LIBUSB)
+-	$(CC) $(LDFLAGS) $(LIBS_USB) -shared -fpic -Wl,-soname,[email protected] $^ -o $@
++	$(CC) $(LDFLAGS) $^ $(LIBS_USB) -shared -fpic -Wl,-soname,[email protected] -o $@
+ 
+ # Objects
+ $(COBJS): %.o: %.c
-- 
1.8.3.2

>From 00fbef49b875761bb2c69034f5335d8e5878bd69 Mon Sep 17 00:00:00 2001
From: Paul Fertser <[email protected]>
Date: Sun, 18 Jan 2015 02:20:57 +0300
Subject: [PATCH 2/2] utils: add OpenOCD, a tool to work with hardware debug

Signed-off-by: Paul Fertser <[email protected]>
---
 utils/openocd/Makefile | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 utils/openocd/Makefile

diff --git a/utils/openocd/Makefile b/utils/openocd/Makefile
new file mode 100644
index 0000000..c8caf54
--- /dev/null
+++ b/utils/openocd/Makefile
@@ -0,0 +1,78 @@
+#
+# Copyright (C) 2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=openocd
+PKG_VERSION:=0.9.0-dev
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://git.code.sf.net/p/openocd/code
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=HEAD
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+
+PKG_MAINTAINER:=Paul Fertser <[email protected]>
+
+PKG_LICENSE:=GPL-2.0
+PKG_LICENSE_FILES:=COPYING
+
+PKG_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+PKG_FIXUP:=autoreconf
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/openocd
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=OpenOCD Utility
+  URL:=http://openocd.sf.net/
+  DEPENDS:=+libusb-1.0 +libftdi +hidapi
+endef
+
+define Package/openocd/description
+OpenOCD provides on-chip programming and debugging support with a
+layered architecture of JTAG interface and TAP support including:
+
+- (X)SVF playback to faciliate automated boundary scan and FPGA/CPLD
+  programming;
+- debug target support (e.g. ARM, MIPS): single-stepping,
+  breakpoints/watchpoints, gprof profiling, etc;
+- flash chip drivers (e.g. CFI, NAND, internal flash);
+- embedded TCL interpreter for easy scripting.
+
+Several network interfaces are available for interacting with OpenOCD:
+telnet, TCL, and GDB. The GDB server enables OpenOCD to function as a
+"remote target" for source-level debugging of embedded systems using
+the GNU GDB program (and the others who talk GDB protocol, e.g. IDA
+Pro).
+endef
+
+CONFIGURE_ARGS += \
+	--prefix="/usr" \
+	--disable-werror \
+	--enable-dummy \
+	--enable-sysfsgpio \
+	--enable-usb_blaster_libftdi \
+        --enable-openjtag_ftdi \
+        --enable-presto_libftdi
+
+define Build/Compile
+        +$(MAKE_VARS) \
+        $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(MAKE_PATH)
+endef
+
+define Package/openocd/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(INSTALL_DIR) $(1)/usr/share/openocd
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openocd $(1)/usr/bin/
+	$(CP) $(PKG_INSTALL_DIR)/usr/share/openocd/scripts $(1)/usr/share/openocd
+endef
+
+$(eval $(call BuildPackage,openocd))
-- 
1.8.3.2

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to