Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 500350 - dev-embedded/openocd-9999- changed libusb dependencies and other build tweaks
Summary: dev-embedded/openocd-9999- changed libusb dependencies and other build tweaks
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Embedded Team (OBSOLETE)
URL:
Whiteboard:
Keywords:
: 507686 (view as bug list)
Depends on:
Blocks: 509356
  Show dependency tree
 
Reported: 2014-02-05 10:10 UTC by Paul Fertser
Modified: 2014-05-17 09:07 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Fertser 2014-02-05 10:10:11 UTC
Hi,

OpenOCD 0.8.0 is soon to be released and the OpenOCD team would be happy to hear Gentoo maintainers suggestions about how to make their work easier and more pleasant.

Current build-related highlights for the upcoming version:

0. pkg-config made mandatory;

1. For FTDI-based adapters a new "interface driver" called "ftdi" is strongly recommended over the old "ft2232". The sole dependency for "ftdi" is libusb-1.0;

2. configure auto-detects presence of libusb-0.1 (which can be provided by libusb-compat), libusb-1.0 and hidapi (needed by the new ARM CMSIS-DAP driver) and enables all the drivers that depend on the particular library automatically;

3. ft2232-ftdi (deprecated) and other libftdi-based drivers can now be compiled and linked against libftdi1 as well as libftdi so no ebuild hacks should be necessary (but the said drivers are not auto-enabled);

4. ftd2xx proprietary library doesn't seem to be popular, all the drivers that use it can work with libftdi;

5. OCDxprefix shit was removed;

6. Support for new debugging adapters was added, namely TI ICDI, CMSIS DAP, Andes AICE, etc.

Also the main README was cleaned-up and brought up-to-date, so you might want to reread it. Currently the list of user-visible changes is being discussed at http://openocd.zylin.com/#/c/1881 .

Any feedback is appreciated, and thank you in advance.

Reproducible: Always
Comment 1 Markos Chandras (RETIRED) gentoo-dev 2014-04-28 17:41:44 UTC
Hi,

Thanks for pinging me about this bug. I think I answered most of your concerns in IRC but for reference, please attach a diff for the current 0.8.0_rc2 ebuild with the changes you propose.
Comment 2 Paul Fertser 2014-04-28 18:30:44 UTC
List of USB debug adapters and their dependencies:

Requiring libusb-1:
--enable-ftdi, --enable-stlink, --enable-ti-icdi, --enable-ulink, --enable-usb-blaster-2

Requiring either libusb-1 or libusb-0.1:
--enable-jlink, --enable-osbdm, --enable-opendous, --enable-aice

Requiring libusb-0.1:
--enable-vsllink, --enable-usbprog, --enable-rlink, --enable-armjtagew

Requiring hidapi.pc / hidapi-hidraw.pc / hidapi-libusb.pc:
--enable-cmsis-dap

Each of these options requires explicit --disable- if you want to have a reproducible build or else it will get auto-enabled based on the corresponding library's availability during the configure time.

Some people might additionally want --enable-legacy-ft2232_libftdi (old deprecated driver for ftdi-based adapters, depends on libftdi), --enable-presto_libftdi, --enable-openjtag_ftdi (depends on libftdi), , --enable-sysfsgpio (bitbanging jtag (and swd in future) on any machine that exposes gpios through sysfs interface, --enable-bcm2835gpio (useful on raspberrypi as it works way faster than sysfsgpio), neither of the latter two drivers break compilation on i386 so can be enabled unconditionally. ioutil and minidriver are useless currently, they were needed for standalone (eCos) hardware implementations. --enable-jtag_vpi (virtual interface over TCP) is useful for the guys working on OpenRISC (or1k).

HTH, TIA
Comment 3 Markos Chandras (RETIRED) gentoo-dev 2014-05-02 19:25:42 UTC
*** Bug 507686 has been marked as a duplicate of this bug. ***
Comment 4 Markos Chandras (RETIRED) gentoo-dev 2014-05-02 19:29:08 UTC
Please review the following changes in the ebuild

--- openocd-0.8.0_rc2.ebuild	26 Apr 2014 11:26:17 -0000	1.1
+++ openocd-0.8.0_rc2.ebuild	2 May 2014 19:28:35 -0000
@@ -4,7 +4,7 @@
 
 EAPI="5"
 
-inherit eutils multilib flag-o-matic toolchain-funcs
+inherit eutils multilib flag-o-matic toolchain-funcs udev
 
 # One ebuild to rule them all
 if [[ ${PV} == "9999" ]] ; then
@@ -24,12 +24,13 @@
 
 LICENSE="GPL-2"
 SLOT="0"
-IUSE="blaster dummy ftdi minidriver parport presto segger +usb verbose-io"
+IUSE="blaster cmsis-dap dummy ftdi parport segger +usb verbose-io"
 RESTRICT="strip" # includes non-native binaries
 
 # Pull both libusb:0 and libusb:1 because some device need the former
-# others need the later etc.
+# others need the later etc. ftdi controls libftdi adapters
 DEPEND=">=dev-lang/jimtcl-0.73
+	cmsis-dap? ( dev-libs/hidapi )
 	usb? (
 		virtual/libusb:0
 		virtual/libusb:1
@@ -38,30 +39,8 @@
 
 RDEPEND="${DEPEND}"
 
-REQUIRED_USE="blaster? ( ftdi ) presto? ( ftdi )"
-
 src_prepare() {
 	epatch_user
-
-	if [[ ${PV} == "9999" ]] ; then
-		sed -i -e "/@include version.texi/d" doc/${PN}.texi || die
-		AT_NO_RECURSIVE=yes eautoreconf
-	fi
-
-	# Disable craptastic build settings.
-	sed -i \
-		-e 's:if test "[$]OCDxprefix" != "[$]ac_default_prefix":if false:' \
-		configure || die
-
-	if use ftdi ; then
-		local pc="libftdi$(has_version '=dev-embedded/libftdi-1*' && echo 1)"
-		# Use libftdi-1 paths #460916
-		local libs=$($(tc-getPKG_CONFIG) --libs ${pc})
-		sed -i \
-			-e "s:-lftdi -lusb:${libs}:" \
-			configure src/Makefile.in || die
-		append-cppflags $($(tc-getPKG_CONFIG) --cflags ${pc})
-	fi
 }
 
 src_configure() {
@@ -77,12 +56,15 @@
 		--enable-gw16012
 		--enable-oocd_trace
 		--enable-arm-jtag-ew
+		--enable-sysfsgpio
+		--enable-bcm2835gpio
 	)
 
 	# Adapters requiring usb/libusb-1.X support
 	if use usb; then
 		myconf+=(
 			--enable-aice
+			--enable-ftdi
 			--enable-ti-icdi
 			--enable-ulink
 			--enable-osbdm
@@ -99,19 +81,25 @@
 	else
 		myconf+=(
 			--disable-aice
-			--disable-stlink
+			--disable-ftdi
 			--disable-ti-icdi
 			--disable-ulink
 			--disable-osbdm
 			--disable-opendous
+			--disable-usbprog
+			--disable-jlink
+			--disable-rlink
+			--disable-stlink
+			--disable-vsllink
+			--disable-arm-jtag-ew
 		)
 	fi
 
 	if use blaster; then
-		myconf+=(
-			--enable-usb_blaster_libftdi
-			--enable-usb-blaster-2
-		)
+		if use ftdi; then
+			myconf+=( --enable_usb_flast_libftdi )
+		fi
+		myconf+=( --enable-usb-blaster-2 )
 	else
 		myconf+=(
 			--disable-usb_blaster_libftdi
@@ -119,14 +107,23 @@
 		)
 	fi
 
+	if use ftdi; then
+		myconf+=(
+			--enable-openjtag_ftdi
+			--enable-presto_libftdi
+		)
+	else
+		myconf+=(
+			--disable-openjtag_ftdi
+			--disable-presto_libftdi
+		)
+	fi
+
 	econf \
 		$(use_enable dummy) \
-		$(use_enable ftdi) \
-		$(use_enable minidriver minidriver-dummy) \
+		$(use_enable cmsis-dap) \
 		$(use_enable parport) \
 		$(use_enable parport parport_ppdev) \
-		$(use_enable parport parport_giveio) \
-		$(use_enable presto presto_libftdi) \
 		$(use_enable segger jlink) \
 		$(use_enable verbose-io verbose-jtag-io) \
 		"${myconf[@]}"
@@ -135,4 +132,5 @@
 src_install() {
 	default
 	env -uRESTRICT prepstrip "${ED}"/usr/bin "${ED}"/usr/$(get_libdir)
+	udev_dorules ${D}/usr/share/${PN}/contrib/*.rules
 }
Comment 5 Paul Fertser 2014-05-03 08:11:54 UTC
Markos, thank you for your work!

Here's my list of notes regarding the patch, some of them might be considered nitpicking, I hope that doesn't harm.

1. If you plan on using same ebuild for git version and 0.8.0, you
need to keep eautoreconf there (or probably call ./bootstrap); the
upstream git version well remain compatible (apart from the jimtcl
version bump patch which will be merged soon);

2. Almost all of the code is GPLv2+, not GPLv2; see
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-embedded/openocd/openocd-0.8.0_rc2.ebuild;

3. I guess you need to either specify a <dev-lang/jimtcl-0.74
dependency or to add a patch (http://openocd.zylin.com/2121) to be
conditionally applied when jimtcl version is 0.74 or higher;

4. It also depends on pkg-config now;

5. segger use flag is not needed, as jlink driver should be enabled
along with all the other libusb drivers, no need to treat it
separately;

6. I do not see why ioutil might be needed at all;

7. The comment about libusb-1.X is now inaccurate, some of those
adapters require libusb-0.1;

8. I do not see any necessity to have a separate "blaster" flag, I'd
just build usb-blaster-2 when "usb" is enabled and
--enable-usb_blaster_libftdi (you have a typo there btw) whenever
"ftdi" is enabled;

9. Many people are running OpenOCD on ARM successfully, it should be
no less stable there than on x86; PowerPC BE hosts are less tested but
should work too (with the most popular targets), as well as MIPS;

10. 0.8.0 final was released;

11. Option name for ARM-JTAG-EW is --enable-armjtagew.
Comment 6 Markos Chandras (RETIRED) gentoo-dev 2014-05-03 12:40:16 UTC
(In reply to Paul Fertser from comment #5)
> Markos, thank you for your work!
> 
> Here's my list of notes regarding the patch, some of them might be
> considered nitpicking, I hope that doesn't harm.
> 
> 1. If you plan on using same ebuild for git version and 0.8.0, you
> need to keep eautoreconf there (or probably call ./bootstrap); the
> upstream git version well remain compatible (apart from the jimtcl
> version bump patch which will be merged soon);

Ok

> 
> 2. Almost all of the code is GPLv2+, not GPLv2; see
> http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-embedded/openocd/
> openocd-0.8.0_rc2.ebuild;
Ok
> 
> 3. I guess you need to either specify a <dev-lang/jimtcl-0.74
> dependency or to add a patch (http://openocd.zylin.com/2121) to be
> conditionally applied when jimtcl version is 0.74 or higher;
We have no new jimtcl-0.75 in the tree so I will change that once we have that ebuild available. Restricting the version is not nice because it will cause headaches during updates.

> 
> 4. It also depends on pkg-config now;
Ok
> 
> 5. segger use flag is not needed, as jlink driver should be enabled
> along with all the other libusb drivers, no need to treat it
> separately;
Ok

> 
> 6. I do not see why ioutil might be needed at all;
Ok

> 
> 7. The comment about libusb-1.X is now inaccurate, some of those
> adapters require libusb-0.1;
Ok

> 
> 8. I do not see any necessity to have a separate "blaster" flag, I'd
> just build usb-blaster-2 when "usb" is enabled and
> --enable-usb_blaster_libftdi (you have a typo there btw) whenever
> "ftdi" is enabled;
> 
blaster is there for historic reasons. I guess it does not make sense anymore

> 9. Many people are running OpenOCD on ARM successfully, it should be
> no less stable there than on x86; PowerPC BE hosts are less tested but
> should work too (with the most popular targets), as well as MIPS;

Keywording for other architectures is a separate thing and it needs to be handled in a separate bug by the architecture teams themselves

> 
> 10. 0.8.0 final was released;
Yep, i'd rather have a fixed ebuild before pushing 0.8.0 to the tree. So I will work with _rc2 for now.

> 
> 11. Option name for ARM-JTAG-EW is --enable-armjtagew.

Ok

Thanks for the review
Comment 7 Markos Chandras (RETIRED) gentoo-dev 2014-05-03 22:20:04 UTC
+  03 May 2014; Markos Chandras <hwoarang@gentoo.org> metadata.xml,
+  openocd-0.8.0_rc2.ebuild, openocd-9999.ebuild:
+  Massive ebuild improvements and clean up thanks to Paul Fertser
+  <fercerpav@gmail.com> on bug #500350. No need for revbump as this will be
+  removed soon in favor of final 0.8.0
+


Please test the new ebuild and report back with any problems you may find. Thank you very much for your feedback and your improvements in openocd. Re-open this bug if you need to discuss further improvements before the final 0.8.0 release.
Comment 8 Paul Fertser 2014-05-04 05:38:22 UTC
Looks good to me (testing worked as expected) sans two minor things:

1. DEPEND="${REPEND} <-- typo

2. sed -i -e "/@include version.texi/d" doc/${PN}.texi || die <-- obsolete kludge, no longer useful with the current git version.

Is there any way I can get automatically notified every time a bug is filed against openocd in Gentoo?
Comment 9 Markos Chandras (RETIRED) gentoo-dev 2014-05-04 10:43:00 UTC
+  04 May 2014; Markos Chandras <hwoarang@gentoo.org> metadata.xml,
+  openocd-0.8.0_rc2.ebuild, openocd-9999.ebuild:
+  Fix typo. Remove sed for version.texi. Add Paul Fertser <fercerpav@gmail.com>
+  to metadata.xml so he is CC'd on bugs
+
Comment 10 Paul Fertser 2014-05-16 17:35:58 UTC
I'm sorry to nag but it's still not 100% correct, +ftdi build is broken because --enable_usb_blaster_libftdi should be --enable-usb_blaster_libftdi.
Comment 11 Markos Chandras (RETIRED) gentoo-dev 2014-05-16 18:52:55 UTC
(In reply to Paul Fertser from comment #10)
> I'm sorry to nag but it's still not 100% correct, +ftdi build is broken
> because --enable_usb_blaster_libftdi should be --enable-usb_blaster_libftdi.

I presume this also affects 0.8.0
Comment 12 Paul Fertser 2014-05-16 19:06:30 UTC
Obviously, yes, as they're almost identical.
Comment 13 Markos Chandras (RETIRED) gentoo-dev 2014-05-17 09:07:57 UTC
+  17 May 2014; Markos Chandras <hwoarang@gentoo.org> openocd-0.8.0.ebuild,
+  openocd-9999.ebuild:
+  Fix typo for --enable-usb_blaster_libftdi thanks to Paul Fertser
+  <fercerpav@gmail.com>
+