Stm32 linux stlink linux

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Open source STM32 MCU programming toolset

License

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Open source version of the STMicroelectronics STLINK Tools

Recent new features and bugfixes can be found in the Changelog of this software project.

The stlink library and tools are licensed under the BSD-3 License.

stlink is an open source toolset to program and debug STM32 devices and boards manufactured by STMicroelectronics. It supports several so called STLINK programmer boards (and clones thereof) which use a microcontroller chip to translate commands from USB to JTAG/SWD. There are four generations available on the market which are all supported by this toolset:

  • STLINK/V1[obsolete as of 21-11-2019, continued support by this toolset]
    • transport layer: SCSI passthru commands over USB
    • stand-alone programmer
    • on-board on STM32VL Discovery boards
    • transport layer: raw USB commands
    • stand-alone programmer
    • on-board on STM32L Discovery and STM32 Nucleo boards
    • transport layer: raw USB commands
    • on-board on some STM32 Nucleo boards
    • transport layer: raw USB commands
    • stand-alone programmer (STLINK-V3SET, STLINK-V3MINI, STLINK-V3MODS)
    • on-board on some STM32 Nucleo boards (STLINK-V3E)

    On the user level there is no difference in handling or operation between these different revisions.

    The STlink toolset includes:

    • st-info — a programmer and chip information tool
    • st-flash — a flash manipulation tool
    • st-trace — a logging tool to record information on execution
    • st-util — a GDB server (supported in Visual Studio Code / VSCodium via the Cortex-Debug plugin)
    • stlink-lib — a communication library
    • stlink-gui — a GUI-Interface [optional]

    Supported operating systems and hardware combinations

    Currently known working MCU targets are listed in supported_devices.md.

    A list of supported operating can be found in version_support.md.

    Our tutorial may help you along with some advanced tasks and additional info.

    As of Release v1.6.1 stand-alone Windows binaries are made available (again) on the release page of the project. Please ensure to select the correct version for your system (i686 or x86_64). The archive file can be unzipped to any desired location as it does not contain any hardcoded paths. However we suggest to move the unzipped application folder to C:\Program Files\ on 32-bit systems and to C:\Program Files (x86)\ on 64-bit systems (the toolset is 32-bit).

    Alternatively one may compile and install from source as described in our compiling manual.

    Linux / Unix:

    We recommend to install stlink-tools from the package repository of the used distribution:

    Note: As packages distributed via the Debian and Ubuntu repositories differ from our self-maintained deb-package, we recommend to use the latter instead (see link below). It provides the opportunity to handle and fix user-reported package issues directly within the project and is not redundant to any limitations deriving from external maintenance guidelines.

    • Debian Linux: (Link)
    • Ubuntu Linux: (Link)
    • Arch Linux: (Link)
    • Alpine Linux: (Link)
    • Fedora: (Link)
    • FreeBSD: Users can install from freshports
    • MacOS: Support for macOS will end with v1.8.0. Please use v1.7.0 (current master branch) and the related documentation instead.

    Installation from source (advanced users)

    When there is no executable available for your platform or you need the latest (possible unstable) version you need to compile the toolset yourself. This procedure is explained in the compiling manual.

    Contributing and versioning

    • The semantic versioning scheme is used. Read more at semver.org
    • Before creating a pull request, please ALWAYS open a new issue for the discussion of the intended new features. Bugfixes don’t require a discussion via a ticket-issue. However they should always be described in a few words as soon as they appear to help others as well.
    • Contributors and/or maintainers may submit comments or request changes to patch-proposals and/or pull-requests.
    • ATTENTION: NEVER EVER use the ‘#’ character to count-up single points within a listing as ‘#’ is exclusively reserved for referencing GitHub issues and pull-requests. Otherwise you accidentally introduce false cross references within the project.
    • Please start new forks from the develop branch, as pull requests will go into this branch as well.

    I hope it’s not to out of topic, but I’ve been so frustrated with AVR related things on OpenBSD, the fact that stlink built out of the box without needing to touch anything was so relieving. Literally made my whole weekend better! I take it’s thanks to @Crest and also to the stlink-org team (@Nightwalker-87 and @xor-gate it seems) to have made a software that’s not unfriendly to the «fringe» OSes. Thank you — nbonfils, 11.12.2021

    About

    Open source STM32 MCU programming toolset

    Источник

    STM32: How to start in Linux

    When developing software for STM32 microcontrollers, I usually include the following steps.

    1. Generation of basic project on STM32CubeMX
    2. Writing code in any comfortable text editor (I use Sublime Text)
    3. Compilation of code with use arm-none-eabi-gcc
    4. Firmware of microcontroller with use st-link

    The whole process of installation and start-up are described below.

    Stack

    STM32CubeMX

    I prefer to work with STM32CubeMX. It allows you to quickly generate a project with the setting of the periphery and clock frequency of the microcontroller, as well as the ability to connect such cool things as FreeRTOS or lwIP.

    Installation procedure

    sudo ./SetupSTM32CubeMX-4.25.1.linux
    STM32CUBEMX_HOME=~/.prog/STM32CubeMX export PATH=$STM32CUBEMX_HOME:$PATH 

    cubemx

    After configuring the peripherals and clock frequencies, need to generate a project. Also need to configure of the generation of the project. I set the generation Makefile and put a tick to generate *.c and *.h files for each peripheral.

    You may have to wait for the required libraries to be downloaded.

    To firmware and debug the program on the microcontroller, you will need st-link. It can be cloned from repository and assemble it yourself. I recommend installing from the repository of your distribution — it’s faster.

    Also will need a compiler and debugger to build:

    They can also be taken from the repository.

    After successful project generation, you will see a bunch of files and folders, that need to be compiled.

    sublime

    The first, need say Makefile is where your compiler is.

    ####################################### # binaries ####################################### BINPATH = /bin PREFIX = arm-none-eabi-

    After all this, need to build a project.

    And fill firmware into the microcontroller using st-link.

    You can use the graphical version of STlink-GUI.

    STlinkGUI

    I prefer do it from console.

    1 2 3 4 5 6 7 8 9 10 11 12 13 14
    $ st-flash write ./build/how-run.bin 0x08000000 st-flash 1.5.0 2018-05-26T17:00:50 INFO common.c: Loading device parameters. 2018-05-26T17:00:50 INFO common.c: Device connected is: F76xxx device, id 0x10016451 2018-05-26T17:00:50 INFO common.c: SRAM size: 0x80000 bytes (512 KiB), Flash: 0x200000 bytes (2048 KiB) in pages of 2048 bytes 2018-05-26T17:00:50 INFO common.c: Attempting to write 4004 (0xfa4) bytes to stm32 address: 134217728 (0x8000000) Flash page at addr: 0x08000000 erased 2018-05-26T17:00:50 INFO common.c: Finished erasing 1 pages of 32768 (0x8000) bytes 2018-05-26T17:00:50 INFO common.c: Starting Flash write for F2/F4/L4 2018-05-26T17:00:50 INFO flash_loader.c: Successfully loaded flash loader in sram enabling 32-bit flash writes size: 4004 2018-05-26T17:00:50 INFO common.c: Starting verification of write complete 2018-05-26T17:00:50 INFO common.c: Flash written and verified! jolly good!

    Obstacles, that may stand between you and STM32

    Make error

    When you try to build a project, you will see the following error:

    make-eror

    If you open Makefile, in block sources you will see repeated lines.

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
    ###################################### # source ###################################### # C sources C_SOURCES = \ /Src/system_stm32f7xx.c \ Src/main.c \ Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cortex.c \ Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_gpio.c \ Src/main.c \ Src/stm32f7xx_it.c \ Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma_ex.c \ Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr_ex.c \ Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim.c \ Src/gpio.c \ Src/stm32f7xx_hal_msp.c \ Src/stm32f7xx_it.c \ Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma.c \ Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c.c \ Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim_ex.c \ Src/gpio.c \ Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash.c \ Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c_ex.c \ Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc.c \ Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.c \ Src/stm32f7xx_hal_msp.c \ Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr.c \ Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc_ex.c \ Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash_ex.c

    In my case is following lines:

    Src/main.c \ Src/gpio.c \ Src/stm32f7xx_it.c \ Src/stm32f7xx_hal_msp.c \ 

    This lines need delete and project should be compiling. This is bug of code generation in STM32CubeMX. We wrote to the developers of STM32CubeMX about this bug. It remains to wait until they fix and release an update.

    No libraries

    You may encounter the following error during build.

    make-eror

    Compiler say what he cannot find library stdint.h. For fix it error need install

    It can also be taken from the repository.

    Источник

    stlinkv2

    Микроконтроллеры stm32 прошиваются разными способами, например, через COM порт, или по USB, используя режим dfu. Также прошивку можно заливить по интерфейсу SWD.

    Для подключения к SWD используется или отдельное устройство st-link, или st-link, входящий в отладочные платы семейства discovery.

    Программирование микроконтроллеров stm32 при помощи stlink

    Для того чтобы залить прошивку на микроконтроллер stm32 из под linux потребуется утилита st-flash. Готовых пакетов с этой утилитой нет, поэтому её надо собирать из исходников.

    Скачиваем исходники st-link:

    git clone git://github.com/texane/stlink.git

    Добавляем правило для udev, чтобы к st-link был доступ не только у root’a:

    sudo cp 49-stlinkv1.rules 49-stlinkv2.rules /etc/udev/rules.d sudo udevadm control --reload-rules
    st-flash write firmware.bin 0x08000000

    Отладка программы для stm32 при помощи st-link

    Используя st-link можно не только заливать прошивку но и отлаживать её. Для этого запускаем gdb сервер st-util.

    Затем запускаем arm-none-eabi-gdb и в нем выполняем команды.

    Подключаемся к gdb серверу:

    target remote localhost:4242

    Загруженный файл заливаем в микроконтроллер:

    Устанавливаем breakpoint на функцию main:

    Запускаем выполнение программы:

    Поле того, как отладчик остановится на функции main, можно выполнять пошаговую отладку:

    В арсенале отладчика gdb есть ещё куча полезных команд. А если связать gdb c eclipse, то получиться довольно удобная среда с графическим интерфейсом.

    Источник

    Читайте также:  Linux удаление временных файлов
Оцените статью
Adblock
detector