From 4ce144d67f83a830c349feddd4e5b68611a4148c Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 9 Oct 2018 18:00:12 +0200 Subject: [PATCH] Add openocd with patch for STM32L4+ --- openocd/default/Add-STM32L4-Plus-Dev-ID.patch | 45 ++++++++ openocd/default/PKGBUILD | 44 ++++++++ openocd/git/Add-STM32L4-Plus-Dev-ID.patch | 45 ++++++++ openocd/git/PKGBUILD | 104 ++++++++++++++++++ 4 files changed, 238 insertions(+) create mode 100644 openocd/default/Add-STM32L4-Plus-Dev-ID.patch create mode 100644 openocd/default/PKGBUILD create mode 100644 openocd/git/Add-STM32L4-Plus-Dev-ID.patch create mode 100644 openocd/git/PKGBUILD diff --git a/openocd/default/Add-STM32L4-Plus-Dev-ID.patch b/openocd/default/Add-STM32L4-Plus-Dev-ID.patch new file mode 100644 index 00000000..e45b0e14 --- /dev/null +++ b/openocd/default/Add-STM32L4-Plus-Dev-ID.patch @@ -0,0 +1,45 @@ +From 829e7d9eaca3f47f32b184e3479c066e05f8554b Mon Sep 17 00:00:00 2001 +From: Elrond +Date: Mon, 5 Mar 2018 13:20:28 +0100 +Subject: [PATCH] Add STM32L4+ flash/dev_id + +According to RM0432 chapter 51.6.1 the DBGMCU_IDCODE is +0x470. + +Tested on NUCLEO-STM32L4R5ZI with a similiar change to +openocd 0.10.0-4 in Debian. + +Signed-off-by: Elrond +Change-Id: I9b57013ef23fa963abfecddb728e4a6fadd1f8a1 +--- + src/flash/nor/stm32l4x.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/src/flash/nor/stm32l4x.c b/src/flash/nor/stm32l4x.c +index 6a1fa07..dcb7a92 100644 +--- a/src/flash/nor/stm32l4x.c ++++ b/src/flash/nor/stm32l4x.c +@@ -618,6 +618,9 @@ static int stm32l4_probe(struct flash_bank *bank) + + /* set max flash size depending on family */ + switch (device_id & 0xfff) { ++ case 0x470: ++ max_flash_size_in_kb = 2048; ++ break; + case 0x461: + case 0x415: + max_flash_size_in_kb = 1024; +@@ -743,6 +746,10 @@ static int get_stm32l4_info(struct flash_bank *bank, char *buf, int buf_size) + device_str = "STM32L43x/44x"; + break; + ++ case 0x470: ++ device_str = "STM32L4Rxxx/4Sxxx"; ++ break; ++ + default: + snprintf(buf, buf_size, "Cannot identify target as a STM32L4\n"); + return ERROR_FAIL; +-- +1.9.1 + diff --git a/openocd/default/PKGBUILD b/openocd/default/PKGBUILD new file mode 100644 index 00000000..390b1558 --- /dev/null +++ b/openocd/default/PKGBUILD @@ -0,0 +1,44 @@ +# $Id: PKGBUILD 266875 2017-11-15 14:29:11Z foutrelis $ +# Maintainer: Sergej Pupykin +# Contributor: Bartłomiej Piotrowski +# Contributor: Matthias Bauch +# Contributor: Laszlo Papp +# Contributor: Samuel Tardieu + +pkgname=openocd +pkgver=0.10.0 +epoch=1 +pkgrel=2 +pkgdesc='Debugging, in-system programming and boundary-scan testing for embedded target devices' +arch=('x86_64') +url='http://openocd.org/' +license=('GPL') +depends=('libftdi' 'libftdi-compat' 'libusb' 'libusb-compat' 'hidapi') +options=(!strip) +_features=(amtjtagaccel armjtagew buspirate ftdi gw16012 jlink oocd_trace + opendous osbdm parport presto_libftdi remote-bitbang rlink stlink ti-icdi ulink usbprog vsllink + aice cmsis-dap dummy jtag_vpi openjtag_ftdi usb-blaster-2 usb_blaster_libftdi) +source=("https://downloads.sourceforge.net/sourceforge/$pkgname/$pkgname-${pkgver/_/-}.tar.bz2" + 'Add-STM32L4-Plus-Dev-ID.patch') +sha256sums=('7312e7d680752ac088b8b8f2b5ba3ff0d30e0a78139531847be4b75c101316ae' + 'a3c4e15d8ee6fa63f668b363a96652db923c7da84fc9ffcf39448e2983da2994') + +prepare() { + cd $pkgname-${pkgver/_/-} + sed -i 's|ftdi_new();|(void*)12345;|g' configure{,.ac} + patch -p1 -i '../Add-STM32L4-Plus-Dev-ID.patch' # doesn't apply yet +} + +build() { + cd $pkgname-${pkgver/_/-} + libtoolize + autoreconf + ./configure --prefix=/usr ${_features[@]/#/--enable-} --disable-werror + make +} + +package() { + cd $pkgname-${pkgver/_/-} + make DESTDIR="$pkgdir" install + (cd "$pkgdir"/usr/share/openocd/scripts/target && mv 1986*.cfg 1986be1t.cfg) +} diff --git a/openocd/git/Add-STM32L4-Plus-Dev-ID.patch b/openocd/git/Add-STM32L4-Plus-Dev-ID.patch new file mode 100644 index 00000000..e45b0e14 --- /dev/null +++ b/openocd/git/Add-STM32L4-Plus-Dev-ID.patch @@ -0,0 +1,45 @@ +From 829e7d9eaca3f47f32b184e3479c066e05f8554b Mon Sep 17 00:00:00 2001 +From: Elrond +Date: Mon, 5 Mar 2018 13:20:28 +0100 +Subject: [PATCH] Add STM32L4+ flash/dev_id + +According to RM0432 chapter 51.6.1 the DBGMCU_IDCODE is +0x470. + +Tested on NUCLEO-STM32L4R5ZI with a similiar change to +openocd 0.10.0-4 in Debian. + +Signed-off-by: Elrond +Change-Id: I9b57013ef23fa963abfecddb728e4a6fadd1f8a1 +--- + src/flash/nor/stm32l4x.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/src/flash/nor/stm32l4x.c b/src/flash/nor/stm32l4x.c +index 6a1fa07..dcb7a92 100644 +--- a/src/flash/nor/stm32l4x.c ++++ b/src/flash/nor/stm32l4x.c +@@ -618,6 +618,9 @@ static int stm32l4_probe(struct flash_bank *bank) + + /* set max flash size depending on family */ + switch (device_id & 0xfff) { ++ case 0x470: ++ max_flash_size_in_kb = 2048; ++ break; + case 0x461: + case 0x415: + max_flash_size_in_kb = 1024; +@@ -743,6 +746,10 @@ static int get_stm32l4_info(struct flash_bank *bank, char *buf, int buf_size) + device_str = "STM32L43x/44x"; + break; + ++ case 0x470: ++ device_str = "STM32L4Rxxx/4Sxxx"; ++ break; ++ + default: + snprintf(buf, buf_size, "Cannot identify target as a STM32L4\n"); + return ERROR_FAIL; +-- +1.9.1 + diff --git a/openocd/git/PKGBUILD b/openocd/git/PKGBUILD new file mode 100644 index 00000000..01ea55d3 --- /dev/null +++ b/openocd/git/PKGBUILD @@ -0,0 +1,104 @@ +# ex: ts=2 sts=2 sw=2 et +# Maintainer: yhfudev +# Contributor: veox +# Contributor: Nick Østergaard +# Contributor: Bartłomiej Piotrowski +# Contributor: Matthias Bauch +# Contributor: Laszlo Papp +# Contributor: Samuel Tardieu + +_pkgbase=openocd +pkgname=openocd-git +pkgver=0.10.0.r523.g2a3b709aa +pkgrel=1 +pkgdesc="Debugging, in-system programming and boundary-scan testing for embedded target devices (git version)" +arch=('i686' 'x86_64' 'arm') +url="http://openocd.org" +license=('GPL') +depends=('libftdi' 'libftdi-compat' 'libusb' 'libusb-compat' 'hidapi' ) +makedepends=('git' 'automake>=1.11' 'autoconf' 'libtool' 'tcl') +options=(!strip) +provides=('openocd') +conflicts=('openocd') + +source=( + "${pkgname}::git+http://repo.or.cz/openocd.git" + 'Add-STM32L4-Plus-Dev-ID.patch' +) +# "git+http://repo.or.cz/r/git2cl.git" +# "git+http://repo.or.cz/r/jimtcl.git" +# "git+http://repo.or.cz/r/libjaylink.git" +sha256sums=('SKIP' + 'a3c4e15d8ee6fa63f668b363a96652db923c7da84fc9ffcf39448e2983da2994') + +# Specify desired features and device support here. A list can be +# obtained by running ./configure in the source directory. +_features=( + aice + amtjtagaccel + armjtagew + at91rm9200 + bcm2835gpio + buspirate + cmsis-dap + dummy + ep93xx + ftdi + gw16012 + ioutil + jlink + jtag_vpi + legacy-ft2232_libftdi + oocd_trace + opendous + openjtag_ftdi + osbdm + parport + presto_libftdi + remote-bitbang + rlink + stlink + sysfsgpio + ti-icdi + ulink + usb-blaster-2 + usb_blaster_libftdi + usbprog + vsllink + #parport-giveio + #zy1000 + #zy1000-master + ) + +pkgver() { + cd "${srcdir}/${pkgname}" + git describe --tags --long | sed -E 's/^v//;s/([^-]*-g)/r\1/;s/-/./g' +} + +prepare() { + cd "$srcdir/${pkgname}" + + patch -p1 -i '../Add-STM32L4-Plus-Dev-ID.patch' +} + +build() { + cd "$srcdir/${pkgname}" + + ./bootstrap + ./configure --prefix=/usr \ + --enable-maintainer-mode \ + --disable-werror \ + ${_features[@]/#/--enable-} + + #make clean + make +} + +package() { + cd "$srcdir/${pkgname}" + make "DESTDIR=${pkgdir}" install + rm -rf ${srcdir}/$pkgname-build + rm -rf "$pkgdir/usr/share/info/dir" + mkdir -p "$pkgdir/usr/lib/udev/rules.d" + mv "$pkgdir/usr/share/$_pkgbase/contrib/60-openocd.rules" "$pkgdir/usr/lib/udev/rules.d" +}