How to use the command st-util (with examples)

How to use the command st-util (with examples)

The command “st-util” is used to run the GDB (GNU Debugger) server for interacting with STM32 ARM Cortex microcontrollers. This command allows users to easily connect to the GDB server and write firmware to the device.

Use case 1: Running the GDB server on port 4500

Code:

st-util -p 4500

Motivation: Running the GDB server on a specific port, such as port 4500, enables communication between the GDB client (e.g. via the GNU Debugger) and the STM32 ARM Cortex microcontroller.

Explanation:

  • “st-util”: the name of the command to run the GDB server.
  • “-p 4500”: specifies the port number on which the server will run.

Example output:

st-util 1.6.1-22 (Tue Sep 22 20:40:53 2020 CEST)
2021-07-01T09:00:00 INFO common.c: Loading device parameters....
2021-07-01T09:00:00 INFO common.c: Device connected is: F4 device, id 0x10016413
…
[...]

Use case 2: Connecting to the GDB server

Code:

(gdb) target extended-remote localhost:4500

Motivation: This example demonstrates how to connect to the GDB server running on localhost with port 4500. Connecting to the server allows for debugging and interacting with the STM32 ARM Cortex microcontroller.

Explanation:

  • “(gdb)”: indicates that the following command is executed within the GDB client.
  • “target extended-remote”: command to connect to a remote target.
  • “localhost:4500”: specifies the hostname (localhost) and port number (4500) of the GDB server.

Example output:

Remote debugging using localhost:4500
[...]

Use case 3: Writing firmware to the device

Code:

(gdb) load firmware.elf

Motivation: This use case demonstrates how to write firmware to the STM32 ARM Cortex microcontroller using the GDB server and the “load” command.

Explanation:

  • “(gdb)”: indicates that the following command is executed within the GDB client.
  • “load”: command to load a binary file to the target.
  • “firmware.elf”: the name of the binary file to load to the device.

Example output:

Loading section .text, size 0x10000 lma 0x8000000
Loading section .data, size 0x2000 lma 0x8001000
Start address 0x8001000, load size 69636
Transfer rate: 14 KB/sec, 8706 bytes/write.

Conclusion:

The “st-util” command is a useful tool for running a GDB server to interact with STM32 ARM Cortex microcontrollers. With the provided examples, users can easily run the server, connect to it, and write firmware to the device. This command is essential for debugging and flashing firmware, making it an essential part of the STM32 development workflow.

Related Posts

Exploring NixOS Configurations with nixos-option (with examples)

Exploring NixOS Configurations with nixos-option (with examples)

Introduction NixOS is a Linux distribution built on the Nix package manager.

Read More
How to use the command 'py-spy' (with examples)

How to use the command 'py-spy' (with examples)

py-spy is a sampling profiler for Python programs. It allows you to analyze the execution time of your Python code by collecting samples of the program’s state at regular intervals.

Read More
How to use the command 'cs launch' (with examples)

How to use the command 'cs launch' (with examples)

This article will guide you through the various use cases of the ‘cs launch’ command, which allows you to launch an application directly from one or more Maven dependencies without the need for installation.

Read More