texane/stlink — Issue #12: STM32F4 writing to flash does not work
Author: bikeNomad
Created: 2011-10-20 01:30:29+00:00
State: open

I'm seeing the same flash write problems described earlier.

I can debug in SRAM fine.

I updated to "master 56c4ba7 [merge] patches from uwe".
Re-built library, gdbserver, and flash tool (after fixing code in flash tool).
Ran the gdbserver as:

```
ned@linux-asus:~/src/stlink$ gdbserver/st-util usb /dev/stm32l_stlink2

```

Then ran arm-none-eabi-gdb on the blink_flash example:

```
ned@linux-asus:~/src/stlink/example/blink_flash$ arm-none-eabi-gdb blink.elf
GNU gdb (Sourcery G++ Lite 2010.09-51) 7.2.50.20100908-cvs
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-none-eabi".
Reading symbols from /home/ned/src/stlink/example/blink_flash/blink.elf...(no debugging symbols found)...done.
(gdb) tar ext :4242
Remote debugging using :4242
0x0800422c in ?? ()
(gdb) load
Loading section .isr_vector, size 0x10c lma 0x8000000
Loading section .text, size 0x9c lma 0x800010c
```

And then it never came back to me.

The output from the gdbserver debug was this:

```
stlink current mode: mass
*** looking up stlink version
st vid = 0x0483 (expect 0x0483)
stlink pid = 0x3748
stlink version = 0x2
jtag version = 0xe
swim version = 0x0
notice: the firmware doesn't support a swim interface
stlink current mode: mass
stlink current mode: mass

*** stlink_enter_swd_mode ***

*** stlink_read_mem32 ***
data_len = 4 0x4
11 64 00 20

*** stlink_core_id ***
data_len = 4 0x4
77 14 a0 2b

core_id = 0x2ba01477
Fixing wrong chip_id for STM32F4 Rev A errata
Chip ID is 00000413, Core ID is 2ba01477.
Device connected: F4 device
Device parameters: SRAM: 0x20000 bytes, Flash: up to 0x100000 bytes in pages of 0x20000 bytes

*** stlink_read_mem32 ***
data_len = 4 0x4
22 00 2d 00

Flash size is 34 KiB.

*** stlink_force_debug_mode ***

*** stlink_reset ***

*** stlink_write_mem32 ***
KARL - should read back as 0x03, not 60 02 00 00

*** stlink_read_mem32 ***
data_len = 4 0x4
61 02 00 00

*** stlink_write_mem32 ***

*** stlink_write_mem32 ***

*** stlink_write_mem32 ***

*** stlink_write_mem32 ***

*** stlink_write_mem32 ***

*** stlink_write_mem32 ***

*** stlink_read_mem32 ***
data_len = 4 0x4
01 00 00 00

*** stlink_write_mem32 ***

*** stlink_write_mem32 ***

*** stlink_write_mem32 ***

*** stlink_write_mem32 ***

*** stlink_write_mem32 ***
Listening at *:4242...
GDB connected.

*** stlink_read_all_regs ***
data_len = 84 0x54
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 0c 00 20 ff ff ff ff 2c 42 00 08 00 00 00 01 80 0c 00 20 00 00 00 00 00 00 00 00 00 00 00 00

xpsr = 0x01000000
main_sp = 0x20000c80
process_sp = 0x00000000
rw = 0x00000000
rw2 = 0x00000000

*** stlink_read_mem32 ***
data_len = 4 0x4
04 48 01 68

*** stlink_reset ***

*** stlink_read_mem32 ***
data_len = 4 0x4
00 00 00 00

*** stlink_read_mem32 ***
data_len = 4 0x4
00 00 00 00

*** stlink_write_mem32 ***

*** stlink_write_mem32 ***

*** stlink_write_mem32 ***

*** stlink_read_mem32 ***
data_len = 4 0x4
00 00 00 00

*** stlink_read_mem32 ***
data_len = 4 0x4
00 00 00 00

*** stlink_write_mem32 ***

*** stlink_write_mem32 ***

*** stlink_write_mem8 ***

*** stlink_write_reg
data_len = 2 0x2
80 00

*** stlink_write_reg
data_len = 2 0x2
80 00

*** stlink_write_reg
data_len = 2 0x2
80 00

*** stlink_write_reg
data_len = 2 0x2
80 00

*** stlink_write_reg
data_len = 2 0x2
80 00

*** stlink_read_mem32 ***
data_len = 4 0x4
00 00 00 00

*** stlink_write_mem32 ***

*** stlink_run ***

*** stlink_status ***
data_len = 4 0x4
80 00 00 00

core status: running

*** stlink_status ***
data_len = 4 0x4
80 00 00 00

core status: running
```

The stlink_status messages repeated ad infinitum until I killed the server.