Develop and debug STM32 under Linux

Source: Internet
Author: User

Because of the recent need to do some STM32 development, and most of my other development on Linux, often in Windows and Linux switching feeling more inconvenient, so I studied the Linux under the development of STM32 tools, by the way to do the next record.

The development tools used

Software platform:

Eclipse Luna

Download: HTTPS://ECLIPSE.ORG/DOWNLOADS/PACKAGES/RELEASE/LUNA/SR2

For installing the system Workbench for STM32 plug-in, it is recommended that you download the Eclipse IDE for C + + developers version.

System Workbench for STM32 (Eclipse plugin)

Download: http://www.openstm32.org/Installing+System+Workbench+for+STM32+from+Eclipse?structure=Documentation

Choose it because the plug-in will be installed after the STM32 development environment has been configured, easy to use, and stm32cubemx directly can be used to generate the project for it. This plug-in is better compatible with Eclipse Luna, has a problem with Eclipse Mars compatibility, and is not tested by other eclipse versions.

Stm32cubemx

Download: Http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/PF259242?sc=microxplorer

This is the official St company developed to initialize the STM32 peripheral driver software. The software is currently only available in Windows, but because it is in Java, it can run properly under Linux. However, because it is for the Windows environment, the resulting project needs to make some changes to normal use under Linux, this is left to the next.

In addition, although the STM32CUBEMX has an Eclipse plugin, the plugin can only run under Windows

Debugger:

St-link V2

This is the officially supported debugger for System Workbench. The price is also relatively cheap (pirated is very cheap, genuine is not expensive).

Development Board:

Stm32f407zet6

It should be supported by the development boards of most STM32 chips.

Operating system:

Ubuntu 12.04 64-bit

Software Installation

The installation of System Workbench for STM32 is not the same as the normal Eclipse plug-in installation. It is worth noting that Eclipse Luna needs openjdk 7 operating environment, I use Ubuntu 12.04, the system comes with OPENJDK 6, need to install, and then change the Eclipse startup parameters ( If you have not modified the system's default Java Runtime Environment, add the following in the Eclipse.ini file in the Eclipse installation directory:

-vm/usr/lib/jvm/java-1.7.0-openjdk-amd64/bin

If you are Ubuntu 14.04 and above, there is no need to add this one.

The following is mainly about the installation of STM32CUBEMX. First download the STM32CUBEMX (at the bottom of the link given above), after the decompression should be able to obtain an EXE file, but this file does not need to install wine to run. If the default Java version of the system is OPENJDK 6, run the following statement:

sudo /usr/lib/jvm/java-1.7. 0-openjdk-amd64/bin/java-jar/path/to/your/setupstm32cubemx.exe

If it is openjdk 7 and above, run directly:

sudo java-jar/path/to/your/setupstm32cubemx.exe

The following article will/usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/omitted, if the default is OpenJDK 6, please manually add this absolute path. Also, replace the/path/to/your/with the path to your actual file.

Then it will come out an installation interface, select the installation path, and then install.

After installation, there should be a STM32CubeMX.exe file in the installation directory. Run:

Java-jar/path/to/your/stm32cubemx.exe

Then choose Help->install New Libraries, install the required support library, etc., and you can use it for development. In Updater settings you can choose the download path to support the library.

Development Settings Stm32cubemx

Create a new project, choose your own chip type, and configure the appropriate pins, clocks, and peripherals.

In Project settings, select Toolchain/ide as Sw4stm32. Then use STM32CUBEMX to generate the code. Copy the generated code into the eclipse's workspace.

Please refer to other materials for specific use of STM32CUBEMX.

System Workbench for STM32

Next, we open Eclipse, which installs the System workbench. Select File->import->existing Projects into Workspace, select the path where your code is located, and be careful not to tick copy Projects into Workspace.

Next, make some configuration of the project.

Select the current project, select Projects->properities, select C + + build->settings in the list on the left, open this setup interface may take some time, please wait patiently.

Under the tool SETTINGS->MCU GCC Complier->symboles, the

__WEAK=__ATTRIBUTE__ ((weak)) changed to ' __weak=__attribute__ ((weak)) ' __packed=__attribute__ ((__packed__)) to ' __ packed=__attribute__ ((__packed__)) '

In other words, add the two parameters to the single quotation mark

Under the tool SETTINGS->MCU GCC Complier->includes, the

INC changed to.. /.. /.. /incdrivers/stm32f4xx_hal_driver/inc changed to. /.. /.. /drivers/stm32f4xx_hal_driver/incdrivers/stm32f4xx_hal_driver/inc/legacy changed to. /.. /.. /drivers/stm32f4xx_hal_driver/inc/legacydrivers/cmsis/include changed to. /.. /.. /drivers/cmsis/includedrivers/cmsis/device/st/stm32f4xx/include changed to. /.. /.. /drivers/cmsis/device/st/stm32f4xx/include

That is, the path is preceded by: /.. /.. /, in addition, if there is a backslash "\" in the path, it should be replaced with a forward slash "/".

Under the tool SETTINGS->MCU GCC linker->general, the

.. \stm32f407zetx_flash.ld changed to. /stm32f407zetx_flash.ld

Replace the backslash with a forward slash.

Then the space in the artifact name under build artifact is removed.

Through the above settings, it should be possible to compile the pass.

At this point, in the Project Management pane, right-clicking on the Applications folder and selecting Index->freshen all Files, you can eliminate the error prompt.

Then continue, under Projects->properities settings, select Run/debug Settings, select New->ac6 STM32 debugging

A dialog box will pop up that defines the new board, selecting your debugging tools and interfaces, and the name of the Development Board. A debug profile is automatically generated when you click OK. A new dialog box will then pop up.

In the popup dialog box, on the Debugger tab, select the Use Local Script, and then select the CFG file that was generated by the dialog box that just popped up, select OK (this step is usually not done and is already configured by default).

You can then start debugging normally by selecting the Run->debug as->ac6 STM32/C + + application.

Develop and debug STM32 under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.