MUS177-267 OpenOCD (update)

Installing OpenOCD

I have edited this document to put preferred methods of installation on the top. Also note that openocd 0.10 is required to program STM32F7 family chips.

macOS – Preferred method – homebrew

  • install Xcode and Xcode command line tools
  • install homebrew using  this command in the Terminal:
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • install openocd using this in the Terminal:
    brew install --HEAD openocd
  • run openocd -f board/stm32f4discovery.cfg from the Terminal

Windows – Preferred method – Freddie Chopin

  • Download from http://www.freddiechopin.info/en/download/category/4-openocd
  • You will need a .7z unpacker to open the archive.
  • Place in your STMToolchain folder (not strictly necessary)
  • run openocd with options -f “board\stm32f4discovery.cfg” from Eclipse. You can do this from the Command Line, but you will need to set the MSDOS search path.

Common Bug – If you are “bounced” by openocd and have an STM32F4Discovery board

  • You probably have version MB997E of the board
  • Edit the file board/stm32f4discovery.cfg (in the openocd scripts folder) with Eclipse. If on macOS, you will have to first type Command-Shift-G in the file open box and enter /usr/local/share/openocd/scripts
  • Change the line that reads
    source [find interface/stlink-v2.cfg]

    to

    source [find interface/stlink-v2-1.cfg]
  • Save the file and try openocd again

Common Bug – If you are “bounced” by openocd and you are running Windows

Testing – Check Telnet Connection to OpenOCD

You will be able to connect to openocd with “telnet localhost 4444”. Windows users may need to enable the Telnet Client

Other methods to install OpenOCD (not all will work on all hosts)

 Windows & macOS (precompiled OpenOCD – latest for STM32F7)

  • Download from https://github.com/gnu-mcu-eclipse/openocd/releases
  • To run from command line – add bin directory to search path. macOS example – edit .bashrc:
     export PATH=$PATH:/Applications/GNU\ MCU\ Eclipse/OpenOCD/0.10.0-3-20170826-1813-dev/bin
  • Windows example – edit Control Panel:System:Advanced:Environment:Path. Append to end of path text:
    ;C:\Program Files\GNU MCU Eclipse\OpenOCD\0.10.0-3-20170826-1813-dev/bin
  • Run from Terminal (macOS) or Command Prompt (Windows)
    Windows

    openocd -s "C:\Program Files\GNU MCU Eclipse\OpenOCD\0.10.0-3-20170826-1813-dev\scripts" -f "board\stm32f4discovery.cfg"

    macOS

    openocd -s /Applications/GNU\ MCU\ Eclipse/OpenOCD/0.10.0-3-20170826-1813-dev/scripts -f stm32f4discovery.cfg

Windows(MSYS2 precompiled method)

  • Install MSYS2 from www.msys2.org
  • Install OpenOCD binary for 64: pacman S mingww64x86_64openocdgit
  • -or- for 32 bit: pacman S mingww64i686openocdgit
  • Restart MSYS2
  • Enter openocd -s “/mingw64/share/openocd/scripts” -f “board/stm32f4discovery.cfg”
  • You can now connect via “telnet localhost 4444” from another MSYS2 window
  • Connection from Eclipse uses port 3333 rather than 4444