STM32F0Discovery Under Linux Tutorial Part 1 – Setting up the GCC ARM Toolchain, OpenOCD and stlink

This is the first part of a 2-part tutorial on setting up  and using a free and fully functional development environment with the STM32F0Discovery board on a Linux PC . The official ARM (GNU Tools for ARM Embedded Processors) GCC toolchain and the openOCD and Texane’s stlink debugger / programmer utilities will be used within a command line based environment.  Two example projects will be utilized; one that’s based on the STM32F0′s standard peripheral library and one that isn’t.

Why the ARM Cortex-M0 & why the STM32F0 Family Specifically?

The ARM Cortex-M0 is a 32-bit core that strikes an excellent balance between performance,  power usage and price. It may not be as sophisticated and powerful as its older siblings the ARM Cortex-M3 & M4, but its simplicity, ease of use, lower cost and reduced power consumption easily makes up for that. The ARM Cortex-M0 core was designed to compete with other 8-bit/16-bit microcontroller cores and it succeeds in this goal on all major fronts; performance,low power, price and time to market.

The STM32F0 Microcontroller family has a very generous dose of hardware peripherals generous memory options and now more packaging options that include 20-SSOP(0.65mm) and 32-LQFP (0.8mm), both of which are easier to hand solder than the classic 0.5mm QFP and QFN packages that are the norm for 32-bit microcontrollers. The STM32F0 Microcontroller family also has what has got to be the lowest cost development board with Debugger; the STM32F0 Discovery board. This board costs $8-$10, includes headers that are breadboard-able as well as a ST-LINK V2 debugger that can be used with other SMT32Fx based boards as well in addition to the target STM32F0 microcontroller. In addition it also has two switches and two LEDs.

The major disadvantage of this board is that there’s no cost free, cross platform, ready to go integrated development environment(IDE) solution for it. I originally wrote a series of tutorials for setting up a custom IDE for this board under MS Windows. There’s also the Coocox IDE which now supports the STM32F0 parts. Its free & easy to use, but unfortunately is only available on MS Windows.

Downloading & Installing the Toolchain & Firmware Package

Here are the things that you will need to download:

The toolchain linked above (GNU Tools for ARM Embedded Processors) is actively developed by ARM engineers and is used in many Commercial IDEs. It is free, complete, has no limitations and is regularly updated. Be sure to download the Linux version from the Toolchain Website.

We will also download the STM32FoDiscovery Firmware Package. This package not only contains the standard peripheral libraries but also other important files such as linker files, startup files and the system files that are necessary to get the STM32F0 Microcontroller running.

Finally it is imperative that we download and view all datasheets and reference manuals related to the STM32F0 Microcontroller. Documentation is your friend.

  • If a 64-bit Linux OS is being used, install 32-bit libraries. In Ubuntu based Distros, type:
    sudo apt-get install ia32-libs

    In Debian based distros first enable the 32-bit package repos:

    dpkg --add-architecture i386

    and then update:

    apt-get update

    Both commands must be run as root. Feel free to use “sudo” if it is already installed on your machine. Once the 32-bit repos are added, run:

    apt-get install ia32-libs

    as root.

  • The First step is to create a directory in your home folder. I’ll call it “EmbeddedArm”. From the terminal type:
    mkdir ~/EmbeddedArm
  • Download the compressed Toolchain and extract it into the “EmbeddedArm” directory. Make sure you download the Linux version of the toolchain (it should end with the .tar.bz2 extension). Extraction can be achieved easily with the GUI based archive manager available on your distro. From the command line, navigate to the directory containing the compressed toolchain and extract it with the following command :
    tar -xvjf gcc-arm-none-eabi-X_X-xxxxxx-xxxxxxxx-linux.tar.bz2 -C ~/EmbeddedArm/

    The uppercase X ‘s should denote the version of the Compiler/toolchain while the lowercase x’s should denote the release date. Since the toolchain is regularly updated, expect the version and release date of the toolchain to change regularly.

  • The next step will be to add the toolchain’s “bin” directory to the “PATH” environment variable. This will allow us to access the toolchain through the terminal from any directory on our Linux PC. To do this we will open the “.bashrc” file located in our home folder using the nano editor:
    nano ~/.bashrc

    and adding the following at the end of the .bashrc file:

    export PATH=$PATH:$HOME/EmbeddedArm/gcc-arm-none-eabi-4_7-2013q2/bin

    When  done, exit the nano editor with Ctrl-X and when prompted to save the file choose yes. Once back on the command line type:

    source ~/.bashrc

    This should cause the change to be reflected immediately in the current terminal window. Alternatively we could close the terminal and re-open a new one.

  • At this point the toolchain should be installed and accessible for any directory via the command line / terminal. To test the toolchain type:
arm-none-eabi-gcc -v

The version information of the toolchain should be printed out (Figure 1) indicating that the installation was successful.

Figure 1. ARM Toolchain successfully installed

  • Now extract the STM32FoDiscovery Firmware Package (.zip file) and extract it into the “EmbeddedArm”  directory  with either the GUI archive manager or with the zip command from the command line. To install the zip utility type:
    sudo apt-get install zip unzip

    Once installed, type:

    unzip -d ~/EmbeddedArm/

Downloading and Installing Texane’s Stlink Utilities

Things that you will need to download:

  • First install the tools dependencies:
    sudo apt-get install git libusb-1.0.0-dev pkg-config autotools-dev
  • Navigate into the “EmbeddedArm” directory:
    cd ~/EmbeddedArm

    and clone the Texane’s stlink directory with this command:

    git clone git://
  • Type the following commands:
    • cd stlink

       to navigate into the stlink directory and then:

    • /
    • ./configure
    • make

    The three commands above build the st-util and st-flash binaries in the stlink directory! the st-util binary is a GDBserver that communicates with the STLink V/2 hardware on the STM32F0Discovery board, and is used for debugging. The st-flash binary can be used to program the target STM32F0 on the dev board via the STLINK V/2 hardware.

  • At this point copy the file “49-stlinkv2.rules” from its location in the stlink directory, to the “/etc/udev/rules.d/directory :
    sudo cp ~/EmbeddedArm/stlink/49-stlinkv2.rules /etc/udev/rules.d/
  • This gives user access to the STLINK V/2 hardware (on the STM32F0 Discovery board) through the Linux OS. To immediately load the .rules file without a reboot, typeL
    sudo udevadm control --reload-rules
  • Finally add the stlink directory to the PATH variable in the ~/.bashrc file. This will allow us to use the st-util and st-flash binaries from anywhere on on our PC via the terminal. Using the nano editor, open the .bashrc file:
    nano ~/.bashrc

    and then type the following at the end of the file:

    export PATH=$PATH:$HOME/EmbeddedArm/stlink/

    Then exit the nano editor and save all changes. Once you are back in the terminal window, type:

    source ~/.bashrc

    to immediately reload the new PATH variable.

  • To test the st-util GDBserver connect the STM32F0Discovery board to your PC and  type at the command line:

    You should see output identical to that in Figure 2.

Figure 2. st-util successfully installed

Figure 2. st-util successfully installed

  • To test the st-flash programming utility simply type at the command line:
st-flash read out.bin 0x8000000 4096
  • This command reads the contents of the flash / program memory (first 4096 bytes) starting at address 0×8000000 (beginning of flash / program memory) and saves it into out.bin. You should see output identical to that in Figure 3.
Figure 3. st-flash successfully installed

Figure 3. st-flash successfully installed

  • I highly recommend that you read the documentation that comes with the stlink utility. It comes in the form of a pdf file that’s located at: “~/EmbeddedArm/stlink/doc/tutorial/tutorial.pdf”

Downloading and Installing OpenOCD

Things that you will need to download:

In this section of the tutorial,  OpenOCD will be downloaded, extracted, built and installed.  OpenOCD is a gdbserver application with built-in support for the debugger included in the STM32FoDiscovery; the ST-LINK V/2…..OpenOCD like Texane’s stlink, can be used to download code to the STM32F0Discovery as well as to perform hardware debugging. OpenOCD is distributed as source, so we will have to download it, extract it, build it and install it.

  • To start,  download the latest openOCD release. Once downloaded extract the openOCD compressed source file (.tar.bz2) to the EmbeddedArm folder using a GUI archive manager or from the command line with the following command:
    tar -xvjf openocd-x.x.x.tar.bz2 -C ~/EmbeddedArm/

    Again the lowercase x’s denote the version number of OpenOCD. Before building OpenOCD we need to install some dependencies as instructed on this site. The following command should install all dependencies:

    sudo apt-get install git zlib1g-dev libtool flex bison libgmp3-dev libmpfr-dev libncurses5-dev libmpc-dev autoconf texinfo build-essential libftdi-dev libusb-1.0.0-dev


  • Navigate into the OpenOCD source folder:
    cd ~/EmbeddedArm/openocd-x.x.x

    and type the following commands in order:

    • ./configure --enable-maintainer-mode --enable-stlink  --prefix=$HOME/EmbeddedArm/openocd-bin
    • make
    • make install

    The first command configures the openOCD build to include support for the ST-LINK V/2 debugger/programmer and specifies the directory “$HOME/EmbeddedArm/openocd-bin” that will contain the openOCD binaries. The second command builds openOCD and the third command installs it by putting all binary files in the directory specified by the first command. If this directory is located outside of the home folder tree, it must have root privileges i.e.

sudo make install
  • If you have already installed Texane’s stlink as instructed in the previous section, make sure that the “49-stlinkv2.rules” is in the “/etc/udev/rules.d” directory as instructed above. If you have NOT installed the stlink utility. or for some reason refuse to do so, create the following file with nano:
    sudo nano  /etc/udev/rules.d/stlinkv2.rules
  • Now add the following text to it:
    ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE="0666"

    Exit nano and save the file. This file is required to give the non root user access to the ST-LINK V/2 hardware on the STM32F0Discovery. Now reload the udev rules:

    sudo udevadm control --reload-rules
  • Finally open .bashrc file in the home directory again with nano and add at the bottom of the file:
    export PATH=$PATH:$HOME/EmbeddedArm/openocd-bin/bin

    Close the file and save changes. then type:

    source ~/.bashrc

    in the terminal window to reload the new updated PATH variable. This will allow us to access the openOCD binary from any directory on our computer via the terminal.

Figure 4. OpenOCD successfully installed

Figure 4. OpenOCD successfully installed

  • Connect the STM32Discovery to your computer and run the following command:
    openocd -s ~/EmbeddedArm/openocd-bin/share/openocd/scripts/ -f board/stm32f0discovery.cfg


    openocd -s ~/EmbeddedArm/openocd-bin/share/openocd/scripts/ -f interface/stlink-v2.cfg -f target/stm32f0x_stlink.cfg

    The -s flag sets the search directory that openOCD should search in to locate the appropriate configuration files. The -f flag specifies a particular file within that directory. The first command simply specifies the configuration file for the evaluation board whereas the second specifies the configuration file for the programming interface (“stlink-v2.cfg”) and the target (“stm32f0x_stlink.cfg”). With either command, the OpenOCD gdbserver should successfully be activated as shown in Figures 4 & 5.

Figure 5. OpenOCD successfully installed

Figure 5. OpenOCD successfully installed

OpenOCD vs Texane’s Stlink

Texane’s stlink tools are dedicated to the ST-Link hardware and work very well for programming and debugging with the ST-Link & ST-Link V/2. I like them because they are is easier to type out, the commands are shorter and can be easily integrated into a makefile.

OpenOCD is a much more encompassing utility that works with a multitude of Programming/ Debugging hardware and supports a huge list of target microcontroller/ microcontroller architectures. I personally find it a little harder to use, but it can do pretty much everything that Texane’s stlink tools do.

At this point the “EmbeddedARM” should have 5 folders:

  • gcc-arm-none-eabi-4_7-2013q2”  – The ARM toolchain folder
  • openocd-0.7.0” – The openOCD source folder
  • openocd-bin” – The openOCD binary folder
  • “stlink”             -  Texane’s stlink utility
  • “STM32F0-Discovery_FW_V1.0.0″ – The STM32F0 Discovery standard peripheral library & CMSIS library

In the next tutorial we will take a look at using a minimalist integrated development environment from the command line.

This entry was posted in Free STM32F0 Development Environment. Bookmark the permalink.

31 Responses to STM32F0Discovery Under Linux Tutorial Part 1 – Setting up the GCC ARM Toolchain, OpenOCD and stlink

  1. Anwej Alam says:

    Thank you so much for this great tutorial…..
    I am really appreciating your effort. But I have stacked at this point.
    can you tell the what is wrong going on?

    anwej@ubuntu:~/EmbeddedArm/openocd-0.7.0$ ./configure –enable-maintainer-mode –enable-stlink –prefix=$HOME/EmbeddedArm/openocd-bin
    configure: WARNING: you should use –build, –host, –target
    configure: WARNING: invalid host type: –enable-maintainer-mode
    configure: WARNING: you should use –build, –host, –target
    configure: WARNING: invalid host type: –enable-stlink
    configure: error: invalid variable name: `–prefix’

    Thank in Advance

    • halherta says:

      Anwej..make sure that there are two dashes before enable i.e. ./configure --enable-maintainer-mode --enable-stlink --prefix=$HOME/EmbeddedArm/openocd-bin. I’m going to make sure that all commands are embedded as code to make them more copy & paste friendly.

  2. korena says:

    very helpful and detailed. Thank you.

  3. Pingback: Andreas' Blog » Blog Archive » OpenJTAG v3.1 from

  4. OLS says:

    I’m having troubles with setting up the toolchain properly under Opensuse 12.2.
    I’ve tried under Linux Mint and everything seems to be alright.
    After installing toolchain, execution of make under both listed projects has similar result:

    porszak@linux-oqbv:~/EmbeddedArm/workspace/iotogglem0> make
    arm-none-eabi-gcc -x assembler-with-cpp -mcpu=cortex-m0 -g -gdwarf-2 -mthumb -Wa,-amhls=startup/startup_stm32f0xx.lst -o startup/startup_stm32f0xx.o startup/startup_stm32f0xx.s
    /home/porszak/EmbeddedArm/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv6-m/libg.a(lib_a-exit.o): In function `exit':
    exit.c:(.text.exit+0x18): undefined reference to `_exit'
    /home/porszak/EmbeddedArm/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv6-m/crt0.o: In function `start':
    (.text+0x4e): undefined reference to `main'
    /tmp/ccuAK10I.o:(.text+0x0): undefined reference to `_sidata'
    /tmp/ccuAK10I.o:(.text+0x4): undefined reference to `_sdata'
    /tmp/ccuAK10I.o:(.text+0xc): undefined reference to `_sbss'
    /tmp/ccuAK10I.o:(.text+0x10): undefined reference to `_ebss'
    /tmp/ccuAK10I.o: In function `LoopFillZerobss':
    /home/porszak/EmbeddedArm/workspace/iotogglem0/startup/startup_stm32f0xx.s:102: undefined reference to `SystemInit'
    /home/porszak/EmbeddedArm/workspace/iotogglem0/startup/startup_stm32f0xx.s:104: undefined reference to `main'
    /home/porszak/EmbeddedArm/workspace/iotogglem0/startup/startup_stm32f0xx.s:78: undefined reference to `_sidata'
    /home/porszak/EmbeddedArm/workspace/iotogglem0/startup/startup_stm32f0xx.s:84: undefined reference to `_sdata'
    /home/porszak/EmbeddedArm/workspace/iotogglem0/startup/startup_stm32f0xx.s:89: undefined reference to `_sbss'
    /home/porszak/EmbeddedArm/workspace/iotogglem0/startup/startup_stm32f0xx.s:98: undefined reference to `_ebss'
    /tmp/ccuAK10I.o:(.isr_vector+0x0): undefined reference to `_stack_start'
    collect2: error: ld returned 1 exit status
    make: *** [startup/startup_stm32f0xx.o] Błąd 1

    porszak@linux-oqbv:~/EmbeddedArm/workspace/iotogglem0_wspl> make
    arm-none-eabi-gcc -x assembler-with-cpp -mcpu=cortex-m0 -g -gdwarf-2 -mthumb -Wa,-amhls=startup/startup_stm32f0xx.lst -o startup/startup_stm32f0xx.o startup/startup_stm32f0xx.s
    /home/porszak/EmbeddedArm/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv6-m/libg.a(lib_a-exit.o): In function `exit':
    exit.c:(.text.exit+0x18): undefined reference to `_exit'
    /home/porszak/EmbeddedArm/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv6-m/crt0.o: In function `start':
    (.text+0x4e): undefined reference to `main'
    /tmp/ccilAbOx.o:(.text+0x0): undefined reference to `_sidata'
    /tmp/ccilAbOx.o:(.text+0x4): undefined reference to `_sdata'
    /tmp/ccilAbOx.o:(.text+0xc): undefined reference to `_sbss'
    /tmp/ccilAbOx.o:(.text+0x10): undefined reference to `_ebss'
    /tmp/ccilAbOx.o: In function `LoopFillZerobss':
    /home/porszak/EmbeddedArm/workspace/iotogglem0_wspl/startup/startup_stm32f0xx.s:102: undefined reference to `SystemInit'
    /home/porszak/EmbeddedArm/workspace/iotogglem0_wspl/startup/startup_stm32f0xx.s:104: undefined reference to `main'
    /home/porszak/EmbeddedArm/workspace/iotogglem0_wspl/startup/startup_stm32f0xx.s:78: undefined reference to `_sidata'
    /home/porszak/EmbeddedArm/workspace/iotogglem0_wspl/startup/startup_stm32f0xx.s:84: undefined reference to `_sdata'
    /home/porszak/EmbeddedArm/workspace/iotogglem0_wspl/startup/startup_stm32f0xx.s:89: undefined reference to `_sbss'
    /home/porszak/EmbeddedArm/workspace/iotogglem0_wspl/startup/startup_stm32f0xx.s:98: undefined reference to `_ebss'
    /tmp/ccilAbOx.o:(.isr_vector+0x0): undefined reference to `_stack_start'
    collect2: error: ld returned 1 exit status
    make: *** [startup/startup_stm32f0xx.o] Błąd 1

    Does anyone has an idea what’s causing those troubles?

    • OLS says:

      I’ve found what was causing those errors and it wasn’t toolchain like i thought. Makefiles went insane on my opensuse because of the missing dots before the extensions of files. For example there was an %c instead of %.c and %o instead of %.o. I’ve changed those and everything began to work. I suggest to apply those fix to the makefiles. Maybe someone else would like to run them on other linux distribution that does not like the lack of dots.

    • Denis Brion says:

      Another explanation would be with make (if version >=3.82, it is too strict and makefiles should be rewritten).
      I tried to downgrade make for Mageia4 and cygwin (symptoms with make >=3.82 were the same as reported) and … it worked, at least with iotogglem0_spl ; did not test any deeper this week-

      Following lines were used
      525 mkdir workdir
      526 cd workdir
      527 git clone git://
      528 cd iotogglem0_wspl/
      529 make
      530 cd ..
      531 tar xf /cygdrive/d/make-3.81.tar.bz2 #make-3.81 is a directory in workdir
      532 cd make-3.81/
      533 ./configure && make # do not install, nor clean -quick and dirty fix
      534 ls # to be sure executable is here
      535 cd ../iotogglem0_wspl/
      536 ../make-3.81/make
      537 history # for hertaville ‘s blog…
      line 529 led to the same symptoms
      line 537 led to the following result , under cygwin:

      size iotogglem0_wspl.elf
      text data bss dec hex filename
      2584 36 8 2628 a44 iotogglem0_wspl.elf

      which is almost consistent (I had installed arm-gcc… 4.8, this blog uses 4.7 ) with this blog…

  5. Elaine Finlay says:

    Thank you very much for your tutorial…”STM32F0Discovery Under Linux Tutorial Part 1 – Setting up the GCC ARM Toolchain, OpenOCD and stlink”.
    It was very helpful.
    I was wondering if you knew of any tutorials that describe the Eclipse setup to use these tools? I am new to using the ARM processors and would like to use the Eclipse IDE for my programming environment.

  6. ozgur bas says:

    Does any one succeeded with gcc-arm-none-eabi on fedora?

    Please help me to run “the toolchain from” on fedora. First, I get an error like “arm-none-eabi-gcc: error trying to exec ‘cc1′: execvp: No such file or directory”. After adding PATH exact location of cc1, error has became

    =================== /*********************** ^ cc1: error: unrecognized command line option ‘-mlittle-endian’ cc1: error: unrecognized command line option ‘-mthumb’ cc1: warning: ‘-mcpu=’ is deprecated; use ‘-mtune=’ or ‘-march=’ instead [enabled by default] cc1: error: unrecognized command line option ‘-mthumb-interwork’ cc1: error: unrecognized command line option ‘-mfloat-abi=hard’ cc1: error: unrecognized command line option ‘-mfpu=fpv4-sp-d16’ src/stm32f4xx_it.c:1:0: error: bad value (cortex-m4) for -mtune= switch
    please help!!!

    • Denis Brion says:

      I did , at least with the building phase on FC19: I just had to downgrade make to 3-81 (one can download all and every versions of GNUmake from -the programming/debugging will betested later-.
      It should be simpler with Fedora than with other distros: openocd is already build with –enable-stlink (in the spec one can extract from the sources repository). stlink could be built without any trouble, following hertaville instructions…

      I tested using ** only** examples of code given by Hertaville -it is safe to begin with already tested examples- for stm32f0 -not f4 as you seem to do-
      This worked, with tiny adaptation for:gpiotogglep{1-4} , iotogglem0 (as far as now) ;
      the tiny modifications in the Makefile consist, if necessay in changing bakslashes into “/” -linux files, not windows ones) and del into $5RM), RM deing defined as
      RM = rm # linux’s ‘del’ at the top of the Makefile

      • Denis Brion says:

        I should have written $(RM) instead of $5RM)….

      • halherta says:

        Denis, I was able to compile the code on a F20 64 bits OS without major trouble. Just needed to replace %c,%s,%o with %.c, %.s & %.o in the makefile and adjust some file permissions for the files in the directory. Also make sure that the file permissions of the toolchain directory with all binaries and files are reasonable.

  7. Denis Brion says:

    Thanks for the file permissions tip…. (as I git clone on fat usb sticks under w7, it is somehing I usually forget and it might save me trouble with iotogglem0 _wspl .

    Else, (locally) downgrading make does not “make” necessary to replace %c … (at least for Mageia4 -as old as FC20- , cygwin and Fedora19…); I never knew whether make ‘s new conventions were better than old ones…

    The main issue I had was for examples you give _later_ (“understanding GPIO” and interrupts) : they obviously were meant for Windows, therefore I had to transform “del” into RM and give the right slashes….

    What is beautiful in your makefies is that they give a *.lst, with generated assembly; however, how can one read generated assembly (I can read simple one, like 6800, 808{0,5} or avr-s, but arms are complicated…)?

  8. Tommy C. Lee says:

    After I did your steps of installing ARM tool chain. I encountered a “arm-none-eabi-gcc command not found” problem. My solution to it is using the following command before the editing of my ~/.bashrc file and the running the “source ~/.bashrc” command. My host system is 32-bit Ubuntu-13.10. The problem is resolved. But I am not sure it is the right solution:

    sudo mv gcc-arm-none-eabi-4_8-2014q1 /opt/arm

    • halherta says:

      Tommy, run “ls -ld” on the /opt/arm/gcc-arm-none-eabi-4_8-2014q1….Who is the owner/group of this folder? This is likely a permissions problem of somesort

      • Tommy C. Lee says:

        My /opt/arm folder has no gcc-arm-none-eabi-4_8-2014q1 folder. It has four folders listed as below:

        tclee@tclee-Latitude-E6400:~$ ls -lrt /opt/arm/
        total 16
        drwxr-xr-x 4 tclee tclee 4096 Mar 4 10:14 share
        drwxr-xr-x 6 tclee tclee 4096 Mar 4 10:31 arm-none-eabi
        drwxr-xr-x 3 tclee tclee 4096 Mar 4 10:32 lib
        drwxr-xr-x 2 tclee tclee 4096 Mar 4 10:32 bin

  9. Bénetière B. says:

    Good evening, thank you for this tutorial.
    I have just a littel problem, st-util, st-info and st-flash,
    are unable to communicate with the board.
    When I type st-util in the terminal, I obtain this result :

    2014-06-15T18:15:02 INFO src/stlink-usb.c: -- exit_dfu_mode
    libusb_handle_events() timeout
    [!] send_recv
    [!] send_recv
    2014-06-15T18:15:05 INFO src/stlink-common.c: Loading device parameters....
    [!] send_recv
    [!] send_recv
    [!] send_recv
    2014-06-15T18:15:05 WARN src/stlink-common.c: unknown chip id! 0
    [!] send_recv
    [!] send_recv
    Chip ID is 00000000, Core ID is 00000000.
    [!] send_recv
    bind: Address already in use
    [!] send_recv
    [!] send_recv
    [!] send_only
    Erreur de segmentation (core dumped) (Erreur de segmentation = Segmentation fault)

    I check the dev directory, when I connect the bord a folder « stlinkv2_2 -> bus/usb/003/015 » is created.

    I try to remove and re-build but the problem persists.

    If you have an idea on what the problem is ? Thank

    • halherta says:

      Unfortunately I don’t know what is going on there…..what is your setup ? i.e which board are you using? st-util for some reason seems to be unable to read the CHIP ID /Core ID……this isn’t good… thing that I’d try is to rebuild the utility again and retry…..And if it continues to fail, there’s always openOCD

      • Bénètiere B. says:

        I’m on Ubuntu 14.04 , I using STM32F0308-Disco with st-link/V2.
        I’m novice on Linux what is the utility ?
        What is i.e. I uderstand in this context but what is the meaning ?

  10. Tommy Lee says:

    I got this issue occasionally. My solution is to run the “sudo init 6″ command with all the connections to the board: the USB/ST-LINK cable; the power cable if the board needs one. The cause, I believe, is on the host system that the libusb framework lost connection to the ST-LINK on the board.

  11. Tommy Lee says:

    My host is 64-bit Ubuntu-13.10. It has arm-none-eabi.gcc and st-link packages installed. I have been using this development system for about four months with no problem. My target includes stm32f0discover, stm32f4discovery and a proprietary stm43f4 board.

    Utility means the tools you use for the development work.

  12. Benetiere says:

    OpenOCD does not work too…

    benoit@benoit-ThinkPad-Twist:~$ openocd -s ../../usr/share/openocd/scripts/ -f interface/stlink-v2.cfg -f board/stm32f0discovery.cfg
    Open On-Chip Debugger 0.7.0 (2013-10-22-08:31)
    Licensed under GNU GPL v2
    For bug reports, read
    Warn : Interface already configured, ignoring
    Error: already specified hl_layout stlink
    srst_only separate srst_nogate srst_open_drain connect_deassert_srst
    Info : This adapter doesn't support configurable speed
    Info : STLINK v15 JTAG v63 API v2 SWIM v63 VID 0x0483 PID 0x3748
    Error: init mode failed
    in procedure 'transport'
    in procedure 'init'

    I rebuild utility (libusb-1.0-0-dev), I install two times openOCD via term and via apt-get but the problem persists.

    If you have an idea

  13. Tommy Lee says:

    I am not using OpenOCD. The reason is that arm-none-eabi-gdb+st-util meets my debugging needs. Remember, OpenOCD does the debugging based upon its configuration. OpenOCD is not designed for the ST-LINKv2 only.

  14. Benetiere says:

    Finaly I declaring forfeit, I use XP + IAR, i’m not realy enjoyed, maybe one day a try again. If I continue to try to solve the problem, I become crazy.
    Thank you Halherta & Tommy Lee for your responses.

  15. Benetiere says:

    I have questions,
    ia32-libs is necessary to compile and use st-util without problem ? Because ia32-libs has removed from ubuntu 13.
    Another question, in terminal when I type ./configure all line are yes except this one :
    checking for usb_path2devnum in -lusbpath… no

    Do you think, the problem come from here ?

  16. Tommy Lee says:

    Yes, ia32-libs is not installed in the Ubuntu-13.10 system. it never comes as an issue tome.
    If you type ./configure? openocd I cannot help since i am not using it.

    • Benetiere says:

      I use ./configure before compiling st-util.
      If I understand you use ubuntu 13.10, st-util work on this distribution maybe the problem from here ?
      Do you install other pacage to use the programs ? (other that : libusb-1.0.0-dev, pkg-config, autotools-dev)

  17. Tommy Lee says:

    You need to run the following command to install the stlink relevant packages before you run the stlink ./configure script:

    apt-get install build-essential git flex bison libgmp3-dev libmpfr-dev libncurses5-dev libmpc-dev autoconf texinfo libtool libftdi-dev libusb-1.0-0-dev zlib1g zlib1g-dev python-yaml

    If your “dpkg –get-selections|egrep ” shows the installation of , you probably do not bother to install it again.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>