Install ST-LINK V2 in MAC OS X for development under STM32
- From the sandbox
- Tutorial
Recently I came across a wonderful article on how to assemble all the development tools in a linux environment for stm32 controllers and I decided to return to the task that I was already trying to solve, namely to make everything work the same on Mac OS X (In my case, the version 10.9.1 Mavericks), since working in CooCox (and it is based on Eclipse) in the virtual machine is already pretty tired. In this article, I will describe a step-by-step algorithm on how to make everything work in OS X.

So, you want to develop on STM32 in Mac OS X, you have ST-LINK V2 separately or on a breadboard, then welcome to cat.
In general, with the exception of Microchip, with their cross-platform MPLAB X for developing for Pic (at least I know only it), none of the manufacturers really care about developers on platforms other than Windows, which creates a certain entry threshold and scares off a lot of developers, unless of course you are a user of Arduino Development Tools.
Why can’t you just take and use the whole algorithm that futurelink describedin OS X and be happy? Because apple cares about us, and therefore they cut out from the system all the components that are required to install and build packages from repositories. The package manager itself is also missing, the main paradigm is that everything needs to be set via the AppStore or, in extreme cases, the program should be downloaded at your own risk and from “not installed sources” =). However, not everything is as bad as it may seem, all these fatal flaws can be successfully eliminated, and at the same time you can get acquainted with a powerful tool that will help us in this - the package manager .
Usually, at this moment everyone writes that you need to install Xcode from the AppStore, and then install the Command Line Tools (which we need) and this method can also be used, however, if you are not going to develop anything in Xcode (or you may feel sorry place on ssd), then you can put Command Line Tools separately. All commands that will be highlighted next need to be executed in the terminal.
Just type in terminal:
A view window immediately falls out in Maverick:

Click Install and get all the necessary utilities without Xcode itself.
Download and install images manually:
Image for Mountain Lion
Image for Mavericks
After all these operations, utilities such as make, gcc, git and others will be installed on the system.
Fortunately, the global open source community did not leave Mac users in trouble and rolled out several solutions in this regard.
At the moment there are two worthy projects that can be used for these purposes Macports and Brew . If you have any of these managers, then you don’t need to put anything else, but if you are thinking about what to put, then personally I recommend Brew.
Brew installation is simple and straightforward, copy the line to the terminal and follow the instructions
All! Now you have the opportunity to install packages from repositories!
For example, you can put yourself Midnight Commander:
Or wget (I recommend installing it, it will be needed later):
If you have already installed Brew, then I recommend that you update it with the command:
And then run:
But we will not be distracted from our main task, namely to make our programmer friends with the system.
Now we can install all the packages we need, the benefit of doing this is very simple:
After installing these packages, we have everything you need to build a Texane project .
I will be guided by the fact that we will create a folder in our home directory and call it Embed Tools, but you can do it in any convenient folder.
We connect our board and run the command:
If all is well, then an answer of the form should be returned:
To maintain compatibility and the original tutorial , I will make the same links, but again, you can do it in places convenient for you, you can even not make any links, and in the eclipse itself refer directly to the installation path of the utilities.
With a high degree of probability, there will not be an opt directory in your system, which means you need to create it, and at the same time the bin directory in it:
Now create a link to st-util in the / opt / bin / directory:
Download GCC ARM TOOLCHAIN 4.8 , unpack and put everything into our Embed Tools folder. I downloaded the latest major release to date, namely 4.8-2013-q4-major and my folder, respectively, is called gcc-arm-none-eabi-4_8-2013q4. You can download several different releases and, in general, different toolchains and copy them all into our Embed Tools, and then change the link to them in the opt directory, as the futurelink suggests (it’s very convenient, by the way, you don’t have to change the link every time in projects if replaced toolchain).
Create a link to the toolchain in the / opt / arm-toolchain directory:
And for those who previously installed wget, you can use this command:
She downloads the tool chain, unpacks it into the Embed Tools folder and creates a link in / opt / arm-toolchain to it.
At the current stage, most users can proceed to the Development Environment section in the original tutorial . But perhaps not everyone is so familiar with the eclipse that they are able to decipher the phrase about installing plugins. “For both, there are update sites, plugins are installed in the standard way for the clip from the menu.” , so I decided to describe them in more detail.
In Eclipse go to Help-> Install New Software
Click Add and enter
Name: Gnu Arm Eclipse PlugIn
Location: http://gnuarmeclipse.sourceforge.net/updates
In the list of plugins of the repository, we select 2 marked with checkboxes:

Since I don’t have J-Link, I didn’t install an experimental plug-in, but maybe someone will try it.
Click Add and enter
Name: Zylin Embedded CDT
Location: http://opensource.zylin.com/zylincdt
In this case, the checkbox option is the only one, so mark it.
During the installation of plugins, a security warning will be issued, to which we answer in the affirmative.

Now you just have to create your C or C ++ project, and configure it as described in the tutorial .
That's all, I hope everything worked out for you. I wish you successful development.

So, you want to develop on STM32 in Mac OS X, you have ST-LINK V2 separately or on a breadboard, then welcome to cat.
In general, with the exception of Microchip, with their cross-platform MPLAB X for developing for Pic (at least I know only it), none of the manufacturers really care about developers on platforms other than Windows, which creates a certain entry threshold and scares off a lot of developers, unless of course you are a user of Arduino Development Tools.
Why can’t you just take and use the whole algorithm that futurelink describedin OS X and be happy? Because apple cares about us, and therefore they cut out from the system all the components that are required to install and build packages from repositories. The package manager itself is also missing, the main paradigm is that everything needs to be set via the AppStore or, in extreme cases, the program should be downloaded at your own risk and from “not installed sources” =). However, not everything is as bad as it may seem, all these fatal flaws can be successfully eliminated, and at the same time you can get acquainted with a powerful tool that will help us in this - the package manager .
Training
Usually, at this moment everyone writes that you need to install Xcode from the AppStore, and then install the Command Line Tools (which we need) and this method can also be used, however, if you are not going to develop anything in Xcode (or you may feel sorry place on ssd), then you can put Command Line Tools separately. All commands that will be highlighted next need to be executed in the terminal.
Method 1:
Just type in terminal:
make
A view window immediately falls out in Maverick:

Click Install and get all the necessary utilities without Xcode itself.
Method 2:
Download and install images manually:
Image for Mountain Lion
Image for Mavericks
After all these operations, utilities such as make, gcc, git and others will be installed on the system.
Install Package Manager
Fortunately, the global open source community did not leave Mac users in trouble and rolled out several solutions in this regard.
At the moment there are two worthy projects that can be used for these purposes Macports and Brew . If you have any of these managers, then you don’t need to put anything else, but if you are thinking about what to put, then personally I recommend Brew.
Brew installation is simple and straightforward, copy the line to the terminal and follow the instructions
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
All! Now you have the opportunity to install packages from repositories!
For example, you can put yourself Midnight Commander:
brew install mc
Or wget (I recommend installing it, it will be needed later):
brew install wget
If you have already installed Brew, then I recommend that you update it with the command:
brew update
And then run:
brew doctor
But we will not be distracted from our main task, namely to make our programmer friends with the system.
Install ST-LINK V2
Now we can install all the packages we need, the benefit of doing this is very simple:
brew install autoconf automake pkg-config libusb libusb-compat
After installing these packages, we have everything you need to build a Texane project .
I will be guided by the fact that we will create a folder in our home directory and call it Embed Tools, but you can do it in any convenient folder.
cd ~
mkdir "Embed Tools" && cd "Embed Tools"
git clone https://github.com/texane/stlink.git && cd stlink/
./autogen.sh
./configure
make
We connect our board and run the command:
./st-util
If all is well, then an answer of the form should be returned:
2014-02-08T19:46:24 INFO src/stlink-usb.c: -- exit_dfu_mode
2014-02-08T19:46:24 INFO src/stlink-common.c: Loading device parameters....
2014-02-08T19:46:24 INFO src/stlink-common.c: Device connected is: F4 device, id 0x10016413
2014-02-08T19:46:24 INFO src/stlink-common.c: SRAM size: 0x30000 bytes (192 KiB), Flash: 0x100000 bytes (1024 KiB) in pages of 16384 bytes
Chip ID is 00000413, Core ID is 2ba01477.
Target voltage is 2876 mV.
Listening at *:4242...
To maintain compatibility and the original tutorial , I will make the same links, but again, you can do it in places convenient for you, you can even not make any links, and in the eclipse itself refer directly to the installation path of the utilities.
With a high degree of probability, there will not be an opt directory in your system, which means you need to create it, and at the same time the bin directory in it:
cd /
sudo mkdir opt && cd opt
sudo mkdir bin
Now create a link to st-util in the / opt / bin / directory:
sudo ln -s ~/Embed\ Tools/stlink/st-util /opt/bin/st-util
Install ARM Toolchain
Download GCC ARM TOOLCHAIN 4.8 , unpack and put everything into our Embed Tools folder. I downloaded the latest major release to date, namely 4.8-2013-q4-major and my folder, respectively, is called gcc-arm-none-eabi-4_8-2013q4. You can download several different releases and, in general, different toolchains and copy them all into our Embed Tools, and then change the link to them in the opt directory, as the futurelink suggests (it’s very convenient, by the way, you don’t have to change the link every time in projects if replaced toolchain).
Create a link to the toolchain in the / opt / arm-toolchain directory:
sudo ln -s ~/Embed\ Tools/gcc-arm-none-eabi-4_8-2013q4/bin /opt/arm-toolchain
And for those who previously installed wget, you can use this command:
cd ~/Downloads/ && wget https://launchpad.net/gcc-arm-embedded/4.8/4.8-2013-q4-major/+download/gcc-arm-none-eabi-4_8-2013q4-20131218-mac.tar.bz2 && tar -xvvjf gcc-arm-none-eabi-4_8-2013q4-20131218-mac.tar.bz2 -C ~/Embed\ Tools/ && sudo ln -s ~/Embed\ Tools/gcc-arm-none-eabi-4_8-2013q4/bin /opt/arm-toolchain
She downloads the tool chain, unpacks it into the Embed Tools folder and creates a link in / opt / arm-toolchain to it.
Conclusion
At the current stage, most users can proceed to the Development Environment section in the original tutorial . But perhaps not everyone is so familiar with the eclipse that they are able to decipher the phrase about installing plugins. “For both, there are update sites, plugins are installed in the standard way for the clip from the menu.” , so I decided to describe them in more detail.
GNU Arm Eclipse
In Eclipse go to Help-> Install New Software
Click Add and enter
Name: Gnu Arm Eclipse PlugIn
Location: http://gnuarmeclipse.sourceforge.net/updates
Add Gnu Arm Eclipse repository window

In the list of plugins of the repository, we select 2 marked with checkboxes:

Since I don’t have J-Link, I didn’t install an experimental plug-in, but maybe someone will try it.
Zylin Embedded CDT
Click Add and enter
Name: Zylin Embedded CDT
Location: http://opensource.zylin.com/zylincdt
Zylin repository window

In this case, the checkbox option is the only one, so mark it.
During the installation of plugins, a security warning will be issued, to which we answer in the affirmative.

Now you just have to create your C or C ++ project, and configure it as described in the tutorial .
That's all, I hope everything worked out for you. I wish you successful development.