Subject: bug#43852: closed (Re: [bug#43852] [PATCH v2] gnu: Add riscv-openocd.)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 22 Oct 2020 14:50:01 +0000

Your bug report

#43852: [PATCH] gnu: Add riscv-openocd.

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
43852: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=43852
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: [bug#43852] [PATCH v2] gnu: Add riscv-openocd.
From: Ludovic Courtès <[email-masked]>
To: Malte Frank Gerdes <[email-masked]>
Cc: Ricardo Wurmus <[email-masked]>, Danny Milosavljevic <[email-masked]>, Andreas Enge <[email-masked]>, [email-masked], Mathieu Othacehe <[email-masked]>
Date: Thu, 22 Oct 2020 16:49:34 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

Malte Frank Gerdes <[email-masked]> skribis:

>>>From 5be71d32e9694fadea411a267e36333697510bb1 Mon Sep 17 00:00:00 2001
> From: Malte Frank Gerdes <[email-masked]>
> Date: Sat, 10 Oct 2020 15:24:46 +0200
> Subject: [PATCH 1/2] gnu: libjaylink: Update to 0.2.0
>
> * gnu/packages/embedded.scm (libjaylink): Update to 0.2.0
> [origin]: Substitute upstream repository location.

[...]

>>>From de5299f976f54ef431e856ca15b045408495491b Mon Sep 17 00:00:00 2001
> From: Malte Frank Gerdes <[email-masked]>
> Date: Sat, 10 Oct 2020 15:31:14 +0200
> Subject: [PATCH 2/2] gnu: openocd: Update to
>  9a877a83a1c8b1f105cdc0de46c5cbc4d9e8799e.
>
> * gnu/packages/embedded.scm (openocd): Update to 9a877a83a1c8b1f105cdc0de46c5cbc4d9e8799e.
> [version]: Substitute release with current master.
> [source]: Remove openocd-nrf52.patch
> [arguments]: Replace bootstrap build phase.
>
> * gnu/local.mk: Remove openocd-nrf52.patch.
> * gnu/packages/patches/openocd-nrf52.patch: Remove file.

I believe this addresses the concerns Andreas raised, so I’ve applied
them now.

(I’ve Cc’d Ricardo, Danny, and Mathieu, who also work in this area, just
so they notice.)

Thanks!

Ludo’.

Subject: [PATCH] gnu: Add riscv-openocd.
From: Malte Frank Gerdes <[email-masked]>
To: [email-masked]
Date: Wed, 07 Oct 2020 22:02:09 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

this adds OpenOCD with RISC-V support to Guix.

There is a problem though: riscv-openocd bundles libjaylink, which is
also available as a package. The available package cannot be used
because it is too old and riscv-openocd has riscv-specific additions
made to it. So the question is: does this justify using the bundled
library or should I do something? (if yes, what?)

I have successfully used the package to communicate via JTAG with a
Sipeed Nano and a JLink V8.

I built this package successfully on: x86_64-linux, aarch64-linux

Malte

>From ccbb612dcf87e2e628febfee74f893726b6ca309 Mon Sep 17 00:00:00 2001
From: Malte Frank Gerdes <[email-masked]>
Date: Wed, 7 Oct 2020 20:27:51 +0200
Subject: [PATCH] gnu: Add riscv-openocd.

* gnu/packages/embedded.scm (riscv-openocd): New variable.
* gnu/packages/patches/riscv-openocd-reproducibility.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register patch.
---
 gnu/local.mk                                  |  2 +
 gnu/packages/embedded.scm                     | 80 +++++++++++++++++++
 .../riscv-openocd-reproducibility.patch       | 57 +++++++++++++
 3 files changed, 139 insertions(+)
 create mode 100644 gnu/packages/patches/riscv-openocd-reproducibility.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index f3b5b17e84..4fa460d4a1 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -37,6 +37,7 @@
 # Copyright © 2020 Brice Waegeneire <[email-masked]>
 # Copyright © 2020 Tanguy Le Carrour <[email-masked]>
 # Copyright © 2020 Martin Becze <[email-masked]>
+# Copyright © 2020 Malte Frank Gerdes <[email-masked]>
 #
 # This file is part of GNU Guix.
 #
@@ -1407,6 +1408,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/pango-skip-libthai-test.patch		\
   %D%/packages/patches/pciutils-hurd-configure.patch		\
   %D%/packages/patches/ppsspp-disable-upgrade-and-gold.patch		\
+  %D%/packages/patches/riscv-openocd-reproducibility.patch		\
   %D%/packages/patches/samba-fix-fcntl-hint-detection.patch		\
   %D%/packages/patches/sdl-pango-api_additions.patch		\
   %D%/packages/patches/sdl-pango-blit_overflow.patch		\
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index f9f0e04238..89fdf81349 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2018, 2019 Clément Lassieur <[email-masked]>
 ;;; Copyright © 2020 Marius Bakke <[email-masked]>
 ;;; Copyright © 2020 Björn Höfling <[email-masked]>
+;;; Copyright © 2020 Malte Frank Gerdes <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -38,6 +39,7 @@
   #:use-module (gnu packages)
   #:use-module (gnu packages autotools)
   #:use-module ((gnu packages base) #:prefix base:)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages cross-base)
   #:use-module (gnu packages dejagnu)
@@ -54,6 +56,7 @@
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages swig)
   #:use-module (gnu packages texinfo)
+  #:use-module (gnu packages version-control)
   #:use-module (gnu packages xorg)
   #:use-module (srfi srfi-1))
 
@@ -580,6 +583,83 @@ language.")
 with a layered architecture of JTAG interface and TAP support.")
     (license license:gpl2+)))
 
+(define-public riscv-openocd
+  (let ((commit "675259382bacade0d4cc44d1944be2aa6a893adc")
+        (revision "0"))
+    (package
+      (name "riscv-openocd")
+      (version (string-append "0.10.0-" revision "."
+                              (string-take commit 7)))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                     (url "https://github.com/riscv/riscv-openocd")
+                     (commit commit)))
+                (sha256
+                 (base32
+                  "083xyx2dq2f9yfkjpl8gm0icn96im1kip479y85nxl0z9ih7fxbf"))
+                (patches
+                 (search-patches "riscv-openocd-reproducibility.patch"))))
+      (build-system gnu-build-system)
+      (native-inputs
+       `(("autoconf" ,autoconf)
+         ("automake" ,automake)
+         ("which" ,base:which)
+         ("libtool" ,libtool)
+         ("pkg-config" ,pkg-config)
+         ("bash-minimal" ,bash-minimal)
+         ("texinfo" ,texinfo)))
+      (inputs
+       `(("hidapi" ,hidapi)
+         ("jimtcl" ,jimtcl)
+         ("libftdi" ,libftdi)
+         ("libusb-compat" ,libusb-compat)))
+      (arguments
+       '(#:configure-flags
+         (append (list "--disable-werror"
+                       "--enable-sysfsgpio"
+                       "--disable-internal-jimtcl")
+                 (map (lambda (programmer)
+                        (string-append "--enable-" programmer))
+                      '("amtjtagaccel" "armjtagew" "buspirate" "ftdi"
+                        "gw16012" "jlink" "opendous" "osbdm"
+                        "parport" "aice" "cmsis-dap" "dummy" "jtag_vpi"
+                        "remote-bitbang" "rlink" "stlink" "ti-icdi" "ulink"
+                        "usbprog" "vsllink" "usb-blaster-2" "usb_blaster"
+                        "presto" "openjtag")))
+         #:phases
+         (modify-phases %standard-phases
+           (replace 'bootstrap
+             (lambda _
+               (chmod "src/jtag/drivers/libjaylink/autogen.sh" #o644)
+               (invoke "sh" "bootstrap" "nosubmodule")))
+           (add-after 'bootstrap 'bootstrap-jaylink
+             ;; we are using the bundled libjaylink here, because the original
+             ;; repo (https://git.zapb.de/libjaylink.git) is now behind a login
+             ;; and cannot be cloned anymore. This package has custom additions
+             ;; to libjaylink.
+             (lambda _
+               (with-directory-excursion "src/jtag/drivers/libjaylink"
+                 (patch-shebang "autogen.sh")
+                 (invoke "sh"  "autogen.sh"))))
+           (add-before 'configure 'change-udev-group
+             (lambda _
+               (substitute* "contrib/60-openocd.rules"
+                 (("plugdev") "dialout"))
+               #t))
+           (add-after 'install 'install-udev-rules
+             (lambda* (#:key outputs #:allow-other-keys)
+               (install-file "contrib/60-openocd.rules"
+                             (string-append
+                              (assoc-ref outputs "out")
+                              "/lib/udev/rules.d/"))
+               #t)))))
+      (home-page "http://openocd.org")
+      (synopsis "On-Chip Debugger with RISC-V Support.")
+      (description "OpenOCD provides on-chip programming and debugging support
+with a layered architecture of JTAG interface and TAP support.")
+      (license license:gpl2+))))
+
 ;; The commits for all propeller tools are the stable versions published at
 ;; https://github.com/propellerinc/propgcc in the release_1_0.  According to
 ;; personal correspondence with the developers in July 2017, more recent
diff --git a/gnu/packages/patches/riscv-openocd-reproducibility.patch b/gnu/packages/patches/riscv-openocd-reproducibility.patch
new file mode 100644
index 0000000000..3f7227e7a3
--- /dev/null
+++ b/gnu/packages/patches/riscv-openocd-reproducibility.patch
@@ -0,0 +1,57 @@
+diff --git a/Makefile.am b/Makefile.am
+index fcfd554c2..55088fef8 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -94,9 +94,7 @@ TCL_FILES = find $(srcdir)/$(TCL_PATH) -name '*.cfg' -o -name '*.tcl' -o -name '
+ 		sed -e 's,^$(srcdir)/$(TCL_PATH),,'
+
+ dist-hook:
+-	if test -d $(srcdir)/.git -a \( ! -e $(distdir)/ChangeLog -o -w $(distdir)/ChangeLog \) ; then \
+-		git --git-dir $(srcdir)/.git log | $(srcdir)/tools/git2cl/git2cl > $(distdir)/ChangeLog ; \
+-	fi
++
+ 	for i in $$($(TCL_FILES)); do \
+ 		j="$(distdir)/$(TCL_PATH)/$$i" && \
+ 		mkdir -p "$$(dirname $$j)" && \
+@@ -122,7 +120,7 @@ distclean-local:
+ # instead we have a hook that enforces this in each workspace. To make sure
+ # that users actually use those hooks, we point git at them here.
+ all-local:
+-	cd $(srcdir) && git config core.hooksPath ./git-hooks
++	echo "no git"
+
+ DISTCLEANFILES = doxygen.log
+
+diff --git a/doc/Makefile.am b/doc/Makefile.am
+index 67592038d..3a2e86049 100644
+--- a/doc/Makefile.am
++++ b/doc/Makefile.am
+@@ -4,8 +4,3 @@ info_TEXINFOS += %D%/openocd.texi
+ dist_man_MANS += %D%/openocd.1
+
+ EXTRA_DIST += %D%/manual
+-
+-MAINTAINERCLEANFILES += \
+-	%D%/mdate-sh \
+-	%D%/stamp-vti \
+-	%D%/version.texi
+diff --git a/src/Makefile.am b/src/Makefile.am
+index 07981aa67..98e0c98c1 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -22,14 +22,9 @@ endif
+
+ # banner output includes RELSTR appended to $VERSION from the configure script
+ # guess-rev.sh returns either a repository version ID or "-snapshot"
+-if RELEASE
+ %C%_libopenocd_la_CPPFLAGS += -DRELSTR=\"\"
+ %C%_libopenocd_la_CPPFLAGS += -DGITVERSION=\"\"
+-else
+-%C%_libopenocd_la_CPPFLAGS += -DRELSTR=\"`$(top_srcdir)/guess-rev.sh $(top_srcdir)`\"
+-%C%_libopenocd_la_CPPFLAGS += -DGITVERSION=\"`cd $(top_srcdir) && git describe`\"
+-%C%_libopenocd_la_CPPFLAGS += -DPKGBLDDATE=\"`date +%F-%R`\"
+-endif
++
+
+ # add default CPPFLAGS
+ %C%_libopenocd_la_CPPFLAGS += $(AM_CPPFLAGS) $(CPPFLAGS)
-- 
2.28.0