| --flash=n[k][m] | st-flash | One can specify `--flash=128k` for example, to override the default value of 64k<br/>for the STM32F103C8T6 to assume 128k of flash being present. This option accepts<br/>decimal (128k), octal 0200k, or hex 0x80k values. Leaving the multiplier out is<br/>equally valid, e.g.: `--flash=0x20000`. The size may be followed by an optional "k"<br/>or "m" to multiply the given value by 1k (1024) or 1M respectively. | v1.4.0 |
| --freq=n[k][m] | st-flash | The frequency of the SWD/JTAG interface can be specified, to override the default<br/>1800 kHz configuration. This option solely accepts decimal values (5K or 1.8M) with<br/>the unit `Hz` being left out. Valid frequencies are: `5K, 15K, 25K, 50K, 100K,`<br/>`125K, 240K, 480K, 950K, 1200K(1.2M), 1800K(1.8M), 4000K(4M)`. | v1.6.1 |
| --opt | st-flash | Optimisation can be enabled in order to skip flashing empty (0x00 or 0xff) bytes at<br/>the end of binary file. This may cause some garbage data left after a flash operation.<br/>This option was enabled by default in earlier releases. | v1.6.1 |
| --reset | st-flash | Trigger a reset both before and after flashing. The default use the hardware reset<br/>through `NRST` pin. The software system reset is used if the hardware reset failed <br/>(`NRST` pin not connected). | v1.0.0 |
| --connect-under-reset | st-flash | Connect under reset. Option makes it possible to connect to the device before code<br/>executing. This is useful when the target contains a code that go device to sleep, <br/>disables of debug pins or other special code. | v1.6.1 |
| --version | st-info<br/>st-flash<br/>st-util | Print version information. | |
| --help | st-flash<br/>st-util | Print list of available commands. _(To be added to this table.)_ | |
When flashing a file, a checksum is calculated for the binary file, both in md5 and the sum algorithm.
The latter is also used by the official ST-Link utility tool from STMicroelectronics as described in the document: [`UM0892 - User manual - STM32 ST-LINK utility software description`](https://www.st.com/resource/en/user_manual/cd00262073-stm32-stlink-utility-software-description-stmicroelectronics.pdf).
The `stlink` toolset also provides a GUI which is an optional feature. It is only installed if a gtk3 toolset has been detected during package installation or compilation from source. It is not available for Windows. If you prefer to have an user interface on the latter system, please use the official `ST-LINK Utility` instead.
which is world writable (this is from the `MODE:="0666"` below). I have several files in my `/etc/udev/rules.d` directory. In this particular case, the `49-stlinkv2-1.rules` file contains the following:
Make sure that you have all 3 files from here: https://github.com/stlink-org/stlink/tree/master/etc/udev/rules.d in your `/etc/udev/rules.d` directory. After copying new files or editing excisting files in `/etc/udev/ruled.d` you should run the following:
to ensure that the rules actually take effect. Using the trigger command means that you shouldn't need to unplug and replug the device, but you might want to try that for good measure as well.
If the VID:PID of your device doesn't match those in any of the 3 files, then you may need to create a custom rule file to match your VID:PID.
However it appears that not all counterfeited parts cause problems during operation, but some are known to not even being able to execute a basic "blinky" example binary. Further there can be problems that may not even show up or affect you directly, but somewhen later in time (or maybe never).
This demonstrates there is no guarantee for a proper working chip with equal functionality compared to the original.
Please keep this in mind and be sceptical when facing problems with this type of boards.
Check your hardware and try to identify what you have in front of you before assuming a bug in the `stlink` toolset.
Please let us know, if you come across any further websites or tutorials that help to identify STM32 fake chips so we can list them here to help others.
Q: My breakpoints do not work at all or only work once.
A: Optimizations can cause severe instruction reordering. For example, if you are doing something like `REG = 0x100;' in a loop, the code may be split into two parts: loading 0x100 into some intermediate register and moving that value to REG. When you set up a breakpoint, GDB will hook to the first instruction, which may be called only once if there are enough unused registers. In my experience, -O3 causes that frequently.
Q: At some point I use GDB command `next', and it hangs.
A: Sometimes when you will try to use GDB `next` command to skip a loop, it will use a rather inefficient single-stepping way of doing that. Set up a breakpoint manually in that case and do `continue`.
Q: Load command does not work in GDB.
A: Some people report XML/EXPAT is not enabled by default when compiling GDB. Memory map parsing thus fail. Use --enable-expat.