Update README.
[fw/stlink] / README
1 HOWTO
2 =====
3
4 To run the gdb server, do (you do not need sudo if you have set up
5 permissions correctly):
6 $ make -C build && sudo ./build/st-util 1234 /dev/sg1
7
8 Then, in gdb:
9 (gdb) target remote :1234
10
11 Have fun!
12
13 Running programs from SRAM
14 ==========================
15
16 You can run your firmware directly from SRAM if you want to. Just link
17 it at 0x20000000 and do
18 (gdb) load firmware.elf
19
20 It will be loaded, and pc will be adjusted to point to start of the
21 code, if it is linked correctly (i.e. ELF has correct entry point).
22
23 Writing to flash
24 ================
25
26 The GDB stub ships with a correct memory map, including the flash area.
27 If you would link your executable to 0x08000000 and then do
28 (gdb) load firmware.elf
29 then it would be written to the memory.
30
31 FAQ
32 ===
33
34 Q: My breakpoints do not work at all or only work once.
35
36 A: Optimizations can cause severe instruction reordering. For example,
37 if you are doing something like `REG = 0x100;' in a loop, the code may
38 be split into two parts: loading 0x100 into some intermediate register
39 and moving that value to REG. When you set up a breakpoint, GDB will
40 hook to the first instruction, which may be called only once if there are
41 enough unused registers. In my experience, -O3 causes that frequently.
42
43 Q: At some point I use GDB command `next', and it hangs.
44
45 A: Sometimes when you will try to use GDB `next' command to skip a loop,
46 it will use a rather inefficient single-stepping way of doing that.
47 Set up a breakpoint manually in that case and do `continue'.