# Can't connect to STML4 Discovery

**URL:** <https://community.sparkfun.com/t/cant-connect-to-stml4-discovery/34448>\
**Category:** MicroMod\
**Tags:** arm-lpc\
**Created:** [May 26, 2017, 9:47pm UTC](https://community.sparkfun.com/t/cant-connect-to-stml4-discovery/34448 "2017-05-26T21:47:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![newly-embedded](https://avatars.discourse-cdn.com/v4/letter/n/c0e974/32.png) [@newly-embedded](https://community.sparkfun.com/u/newly-embedded)\
**Post date:** [May 26, 2017, 9:47pm UTC](https://community.sparkfun.com/t/cant-connect-to-stml4-discovery/34448/1 "2017-05-26T21:47:43Z")

</div>

New user here. Much searching/reading/experimenting.

Have ST “STML4 Discovery kit for STM32L476 MCU” board and Linux system. Can connect to board over USB using [https://github.com/texane/stlink](https://github.com/texane/stlink) code but having GDB problems and not sure if working correctly. Would like to try OpenOCD.

Have built [https://sourceforge.net/projects/openoc … cd/0.10.0/](https://sourceforge.net/projects/openocd/files/openocd/0.10.0/) but can’t connect using those .cfg files. Closest was:

```auto
$ openocd \
> -s /usr/local/share/openocd/scripts \
> -f board/stm32ldiscovery.cfg
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 300 kHz
adapter_nsrst_delay: 100
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 300 kHz, using 240 kHz
Info : Unable to match requested speed 300 kHz, using 240 kHz
Info : clock speed 240 kHz
Error: open failed
in procedure 'init' 
in procedure 'ocd_bouncer'

```

Found [https://github.com/arduino/OpenOCD/blob … covery.cfg](https://github.com/arduino/OpenOCD/blob/master/tcl/board/stm32l4discovery.cfg) which has:

```auto
$ diff scripts/board/stm32ldiscovery.cfg site/scripts/board/stm32l4discovery.cfg 
1,2c1,5
< # This is an STM32L discovery board with a single STM32L152RBT6 chip.
< # http://www.st.com/internet/evalboard/product/250990.jsp
---
> # Explicitly for the STM32L476 discovery board:
> # http://www.st.com/web/en/catalog/tools/PF261635
> # but perfectly functional for any other STM32L4 board connected via
> # an stlink-v2-1 interface.
> # This is for STM32L4 boards that are connected via stlink-v2-1.
4c7
< source [find interface/stlink-v2.cfg]
---
> source [find interface/stlink-v2-1.cfg]
8,9c11
< set WORKAREASIZE 0x4000
< source [find target/stm32l1.cfg]
---
> source [find target/stm32l4x.cfg]

```

So using v2.1 and 32l4x which I suspect are closer matches to the hardware. That seems to get further, but still fails:

```auto
$ openocd \
> -s /usr/local/share/openocd/site/scripts \
> -s /usr/local/share/openocd/scripts \
> -f board/stm32l4discovery.cfg
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 500 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 500 kHz, using 480 kHz
Info : Unable to match requested speed 500 kHz, using 480 kHz
Info : clock speed 480 kHz
Info : STLINK v2 JTAG v24 API v2 SWIM v11 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.242133
Error: init mode failed (unable to connect to the target)
in procedure 'init' 
in procedure 'ocd_bouncer'

```

And suggestions – including “Buy a SparkFun board” 😉 – welcome.
