forked from bennoleslie/stlink
-
Notifications
You must be signed in to change notification settings - Fork 0
stm32 discovery line linux programmer
License
BreakawayConsulting/stlink
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Introduction ============ This is a fork of https://github.com/texane/stlink . Unless you happen to have the exact same set of requirements as I do the trade-offs here are probably not going to work for you, so please just use the original. After hitting some hard to debug errors I've gone through and added extensive error checking throughout so that there are much fewer silent errors than previously. It is important to note that most of the causes of these silent errors are due to the code being debugged, rather than any fundamental problems in stlink; so please, just use the original! The rest of the changes I have made are mostly for my own taste and environment, so again, please use the original. Currently this is only tested on OS X, with the STM32F4 discovery board. There is no support for STLINKv1. Additionally, I'm only really interested in the gdbserver portion of the project so, anything else has more or less been stripped away. In terms of feature set, there are some significant improvements. Firstly the gdbserver is persistent, which means that you can exit from gdb, and then later reattach with a new instance of gdb. Secondly, it is possible to attach and detach from the running system from within gdb. HOWTO ===== First, you have to know there are several boards supported by the software. Those boards use a chip to translate from USB to JTAG commands. The chip is called stlink and there are 2 versions: . STLINKv1, present on STM32VL discovery kits, . STLINKv2, present on STM32L discovery and later kits. Only the STLINKv2 protocol is supported. Common requirements ~~~~~~~~~~~~~~~~~~~ . libusb-1.0 (You probably already have this, but you'll need the development version to compile) COMPILING ~~~~~~~~~ $ make USING THE GDBSERVER ~~~~~~~~~~~~~~~~~~~ To run the gdb server: (you do not need sudo if you have set up permissions correctly) $ make && [sudo] ./st-util There are a few options: ./st-util - usage: -h, --help Print this help -vXX, --verbose=XX specify a specific verbosity level (0..99) -v, --verbose specify generally verbose logging -p 4242, --listen_port=1234 Set the gdb server listen port. (default port: 4242) Then, in your project directory, someting like this... (remember, you need to run an _ARM_ gdb, not an x86 gdb) $ arm-none-eabi-gdb fancyblink.elf ... (gdb) tar extended-remote :4242 ... (gdb) load Loading section .text, size 0x458 lma 0x8000000 Loading section .data, size 0x8 lma 0x8000458 Start address 0x80001c1, load size 1120 Transfer rate: 1 KB/sec, 560 bytes/write. (gdb) ... (gdb) run Have fun! Resetting the chip from GDB =========================== You may reset the chip using GDB if you want. You'll need to use `target extended-remote' command like in this session: (gdb) target extended-remote localhost:4242 Remote debugging using localhost:4242 0x080007a8 in _startup () (gdb) kill Kill the program being debugged? (y or n) y (gdb) run Starting program: /home/whitequark/ST/apps/bally/firmware.elf Remember that you can shorten the commands. `tar ext :4242' is good enough for GDB. Running programs from SRAM ========================== You can run your firmware directly from SRAM if you want to. Just link it at 0x20000000 and do (gdb) load firmware.elf It will be loaded, and pc will be adjusted to point to start of the code, if it is linked correctly (i.e. ELF has correct entry point). Writing to flash ================ The GDB stub ships with a correct memory map, including the flash area. If you would link your executable to 0x08000000 and then do (gdb) load firmware.elf then it would be written to the memory. FAQ === 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'. Currently known working combinations of programmer and target ============================================================= STLink v2 (as found on the 32L and F4 Discovery boards) Known Working Targets: * STM32F407xx (STM32F4 Discovery board) Please report any and all known working combinations so I can update this!
About
stm32 discovery line linux programmer
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- C 100.0%