On one side, plugging in the STLink USB port with the host computer is demonstrated by command lsusb.
If we had ST-Link successfully installed, we can also demonstrate its existance by command st-info --probe.
On the other side, plugging in the other USB port for Nucleo-144 STM32F767ZI will be demonstrated by our test code.
2.5.2 Create and Build Project
Similar to previous section, this time, we create a Blinky C/C++ project with board configuration STM32F7xx with Chip family STM32F767xx. And we can also have the project successfully built with Release configuration with the following output:
2.5.3 Flash Built .elf onto Nucleo-144 STM32F767ZI
We first have a look at how many ST tools have been installed:
And, let's try out each ST tool one by one.
st-info
Tested in the above already, and its ONLY usage is:
st-util
Let's have a look at how can we use st-util by help.
Then, we print out the version as:
stlink-gui
Command stlink-gui will pop up a dialog automatically:
STLink Gui Initialization
Then we click on the Connect button:
STLink Gui Connecting with Board
After a while, we can see the data in tab Device Memory after the device is connected:
STLink Gui Connected
Then we click on No file and load the built .elf file F767ZI_Blinky.elf:
STLink Gui Load F767ZI_Blinky.elf
After loading F767ZI_Blinky.elf, we can see the data in tab F767ZI_Blinky.elf:
STLink Gui F767ZI_Blinky.elf Loaded
And now it's the time to flash the loaded file F767ZI_Blinky.elf down to board Nucleo-144 STM32F767ZI:
STLink Gui Flash F767ZI_Blinky.elf to Device
Flashing
STLink Gui Flashing
We also notice the situation change from within bash as follows:
After finishing flashing the data onto the device, we can even Export device memory into a particular file. Here, we can see, the data is successfully exported.
STLink Gui Flash F767ZI_Blinky.elf to Device
Finally, we can disconnect the device after flashing.
STLink Gui Disconnected
Clearly, stlink-gui is a GUI application to flash built .elf down to the device (a development board with some particular MCU).
st-flash
Unlike stlink-gui, st-flash is a command line application to flash built .bin down to the embedded device. But, we need firstly build .bin file out from .elf file. Here, we need to use the command arm-none-eabi-objcopy.
$ st-util --help
st-util - usage:
-h, --help Print this help
-V, --version Print the version
-vXX, --verbose=XX Specify a specific verbosity level (0..99)
-v, --verbose Specify generally verbose logging
-s X, --stlink_version=X
Choose what version of stlink to use, (defaults to 2)
-1, --stlinkv1 Force stlink version 1
-p 4242, --listen_port=1234
Set the gdb server listen port. (default port: 4242)
-m, --multi
Set gdb server to extended mode.
st-util will continue listening for connections after disconnect.
-n, --no-reset
Do not reset board on connection.
--semihosting
Enable semihosting support.
--serial <serial>
Use a specific serial number.
The STLINKv2 device to use can be specified in the environment
variable STLINK_DEVICE on the format <USB_BUS>:<USB_ADDR>.
$ st-util -V
st-util: invalid option -- 'V'
st-util 1.4.0-37-g065a475
2018-05-20T22:42:43 INFO common.c: Loading device parameters....
2018-05-20T22:42:43 INFO common.c: Device connected is: F76xxx device, id 0x10016451
2018-05-20T22:42:43 INFO common.c: SRAM size: 0x80000 bytes (512 KiB), Flash: 0x200000 bytes (2048 KiB) in pages of 2048 bytes
2018-05-20T22:42:43 INFO gdb-server.c: Chip ID is 00000451, Core ID is 5ba02477.
2018-05-20T22:42:43 INFO gdb-server.c: Chip clidr: 09000003, I-Cache: off, D-Cache: off
2018-05-20T22:42:43 INFO gdb-server.c: cache: LoUU: 1, LoC: 1, LoUIS: 0
2018-05-20T22:42:43 INFO gdb-server.c: cache: ctr: 8303c003, DminLine: 32 bytes, IminLine: 32 bytes
2018-05-20T22:42:43 INFO gdb-server.c: D-Cache L0: 2018-05-20T22:42:43 INFO gdb-server.c: f00fe019 LineSize: 8, ways: 4, sets: 128 (width: 12)
2018-05-20T22:42:43 INFO gdb-server.c: I-Cache L0: 2018-05-20T22:42:43 INFO gdb-server.c: f01fe009 LineSize: 8, ways: 2, sets: 256 (width: 13)
2018-05-20T22:42:43 INFO gdb-server.c: Listening at *:4242...
$ Gtk-Message: 18:40:02.578: GtkDialog mapped without a transient parent. This is discouraged.
Flash page at addr: 0x08040000 erasedEraseFlash - Sector:0x5 Size:0x40000
enabling 32-bit flash writes
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 27496
$ st-flash --help
invalid command line
stlinkv1 command line: ./st-flash [--debug] [--reset] [--format <format>] [--flash=<fsize>] {read|write} /dev/sgX <path> <addr> <size>
stlinkv1 command line: ./st-flash [--debug] /dev/sgX erase
stlinkv2 command line: ./st-flash [--debug] [--reset] [--serial <serial>] [--format <format>] [--flash=<fsize>] {read|write} <path> <addr> <size>
stlinkv2 command line: ./st-flash [--debug] [--serial <serial>] erase
stlinkv2 command line: ./st-flash [--debug] [--serial <serial>] reset
Use hex format for addr, <serial> and <size>.
fsize: Use decimal, octal or hex by prefix 0xXXX for hex, optionally followed by k=KB, or m=MB (eg. --flash=128k)
Format may be 'binary' (default) or 'ihex', although <addr> must be specified for binary format only.
./st-flash [--version]
$ st-flash write firmware.bin 0x8000000
$ st-flash read firmware.bin 0x8000000 4096
$ st-flash erase
$ st-flash erase
st-flash 1.4.0-37-g065a475
2018-05-21T02:40:59 INFO common.c: Loading device parameters....
2018-05-21T02:40:59 INFO common.c: Device connected is: F76xxx device, id 0x10016451
2018-05-21T02:40:59 INFO common.c: SRAM size: 0x80000 bytes (512 KiB), Flash: 0x200000 bytes (2048 KiB) in pages of 2048 bytes
Mass erasing..............
$ st-flash write F767ZI_Blinky.bin 0x8000000
st-flash 1.4.0-37-g065a475
2018-05-21T02:47:51 INFO common.c: Loading device parameters....
2018-05-21T02:47:51 INFO common.c: Device connected is: F76xxx device, id 0x10016451
2018-05-21T02:47:51 INFO common.c: SRAM size: 0x80000 bytes (512 KiB), Flash: 0x200000 bytes (2048 KiB) in pages of 2048 bytes
2018-05-21T02:47:51 INFO common.c: Attempting to write 9108 (0x2394) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08000000 erased
2018-05-21T02:47:51 INFO common.c: Finished erasing 1 pages of 32768 (0x8000) bytes
2018-05-21T02:47:51 INFO common.c: Starting Flash write for F2/F4/L4
2018-05-21T02:47:51 INFO flash_loader.c: Successfully loaded flash loader in sram
enabling 32-bit flash writes
size: 9108
2018-05-21T02:47:51 INFO common.c: Starting verification of write complete
2018-05-21T02:47:51 INFO common.c: Flash written and verified! jolly good!
$ st-util --semihosting
st-util 1.4.0-37-g065a475
2018-05-21T13:30:18 INFO common.c: Loading device parameters....
2018-05-21T13:30:18 INFO common.c: Device connected is: F76xxx device, id 0x10016451
2018-05-21T13:30:18 INFO common.c: SRAM size: 0x80000 bytes (512 KiB), Flash: 0x200000 bytes (2048 KiB) in pages of 2048 bytes
2018-05-21T13:30:18 INFO gdb-server.c: Chip ID is 00000451, Core ID is 5ba02477.
2018-05-21T13:30:18 INFO gdb-server.c: Chip clidr: 09000003, I-Cache: off, D-Cache: off
2018-05-21T13:30:18 INFO gdb-server.c: cache: LoUU: 1, LoC: 1, LoUIS: 0
2018-05-21T13:30:18 INFO gdb-server.c: cache: ctr: 8303c003, DminLine: 32 bytes, IminLine: 32 bytes
2018-05-21T13:30:18 INFO gdb-server.c: D-Cache L0: 2018-05-21T13:30:18 INFO gdb-server.c: f00fe019 LineSize: 8, ways: 4, sets: 128 (width: 12)
2018-05-21T13:30:18 INFO gdb-server.c: I-Cache L0: 2018-05-21T13:30:18 INFO gdb-server.c: f01fe009 LineSize: 8, ways: 2, sets: 256 (width: 13)
2018-05-21T13:30:18 INFO gdb-server.c: Listening at *:4242...
$ arm-none-eabi-gdb F767ZI_Blinky.elf
GNU gdb (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 8.0.50.20171128-git
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from F767ZI_Blinky.elf...done.
(gdb) target extended localhost:4242
Remote debugging using localhost:4242
Reset_Handler () at ../system/src/cortexm/exception_handlers.c:53
53 {
2018-05-21T13:32:42 INFO gdb-server.c: Found 8 hw breakpoint registers
2018-05-21T13:32:42 INFO gdb-server.c: GDB connected.
2018-05-21T13:48:22 INFO common.c: Attempting to write 32768 (0x8000) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08000000 erased
2018-05-21T13:48:22 INFO common.c: Finished erasing 1 pages of 32768 (0x8000) bytes
2018-05-21T13:48:22 INFO common.c: Starting Flash write for F2/F4/L4
2018-05-21T13:48:22 INFO flash_loader.c: Successfully loaded flash loader in sram
enabling 32-bit flash writes
size: 32768
2018-05-21T13:48:22 INFO common.c: Starting verification of write complete
2018-05-21T13:48:23 INFO common.c: Flash written and verified! jolly good!
(gdb) continue
Continuing.
semihosting: unsupported call 0x15
main(argc=1, argv=[""]);
Hello ARM World!
semihosting: unsupported call 0xc
semihosting: unsupported call 0x9
System clock: 192000000 Hz
Second 1
Second 2
Second 3
Second 4
Second 5
Second 6
semihosting: unsupported call 0x18