Question


I have problem trying to upload demo program into fresh stm32f4discovery board, this is what i'm doing:

  1. Connect board to computer
  2. openocd -f board/stm32f4discovery.cfg
  3. telnet localhost 4444

    Open On-Chip Debugger
    > reset init
    target state: halted
    target halted due to debug-request, current mode: Thread 
    xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
    > flash write_image demo.hex       
    device id = 0x10016413
    flash size = 8192kbytes
    flash write algorithm aborted by target
    error executing stm32x flash write algorithm
    flash memory write protected
    flash write failed = 00000010
    error writing to flash at address 0x08000000 at offset 0x00000000
    in procedure 'flash'
    

    What am I doing wrong ? I've tried flash protect, stm32f2x unlock but response is still the same: 'flash memory write protected', i've missed something ? I'm using pre-compiled demo program from st.com from package 'STM32F4-Discovery_FW_V1.1.0' from 'Project/Demonstration/Binary'.

Était-ce utile?

La solution

Flash memory must be deleted before you rewrite it.

monitor flash protect 0 0 11 off
monitor flash erase_address 0x08000000 0x40000
monitor flash write_image erase *"/path/to/hex/file.hex"* 0 ihex

Or instead of telnet and hex files, use arm-none-eabi-gdb and ELF with the following commands:

arm-none-eabi-gdb
target remote localhost:3333
monitor reset halt
file */path/to/elf/file.elf*
load
monitor reset
continue

Note that when using ELF files, you do not need to specify the address where it will be (usually 0x08000000 or 0x08008000 with bootloaders).

Also, consider using a bootloader like OpenBLT, it will help you to master the principles like VTOR, offsets, stack addresses etc.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top