Skip to main content
Mohamad Nazmul Alam
Associate
June 29, 2017
Question

Openocd flashing elf in STM32L4

  • June 29, 2017
  • 1 reply
  • 2665 views
Posted on June 30, 2017 at 01:27

Hello,

I am new to STM based MCU and currently have STM32L4Discovery. I am trying to flash an elf to the device using openocd (I am using linux). And failing to do so. I am trying to investigate the issue. According to my understanding the flash address in the openocd is correct and also the FLASH_ACR and RCC_CR are correct. However the flashing is failing saying -

flash write algorithm aborted by target

error executing stm32l4 flash write algorithm

flash write failed = 000000a0

block write failed

error writing to flash at address 0x08000000 at offset 0x00000000

Any suggestion would be helpful.

Thanks in advance,

Regards,

#stm32l4-flash
This topic has been closed for replies.

1 reply

Rob.Riggs
Senior
June 30, 2017
Posted on June 30, 2017 at 02:00

I assume what you have is an 'STM32L476 Discovery kit'.  Speak up if that's not what you have.

Have you read through UM1879, especially section 7.1?

What version of openocd are you using?

What programmer are you using?

If using the built-in ST-Link programmer, are the CN3 jumpers installed?

What command-line are you using?

Mohamad Nazmul Alam
Associate
June 30, 2017
Posted on June 30, 2017 at 03:46

Hi Rob,

Thanks for the reply.

It is STM32L475VG Discovery IoT Kit.

I am not sure what user manual you meant, I tried to check datasheet and the reference manual for openocd related stuff (the memory location it is trying to flash, the register location etc etc). But not sure where programming instructions are pointed out.

openocd version:

Open On-Chip Debugger 0.10.0+dev-00161-g1725abc (2017-06-28-21:51)

Programmer used:

Builtin STLink, I am not sure what you meant by CN3 jumper, in my board I have JP1 set to 5V_ST_LINK.

Commands used:

sudo openocd -f /usr/local/share/openocd/scripts/board/stm32l4discovery.cfg

flash write_image /home/fadedreamz/hello-world.elf [failed]

program /home/fadedreamz/hello-world.elf [failed]

Thanks again and regards,

Rob.Riggs
Senior
June 30, 2017
Posted on June 30, 2017 at 04:58

Hi

Alam.Mohammad_Nazmul

OK. That's a different L4 Discovery board; one I wasn't aware of.

I typically use GDB to load images for me via openocd. My knowledge of openocd commands is minimal. However,those commands do not match any I recall seeing.

http://openocd.org/doc/html/General-Commands.html

These days I just have Eclipse do it all for me.

Try this. Open two terminal windows. In the first, run openocd as you have above.

In the other window, start anARM gdb session:

$ arm-none-eabi-gdb

...

(gdb) target remote localhost:3333

You should see some activity in the openocd window.

(gdb) load

/home/fadedreamz/hello-world.elf

Loading section .isr_vector, size 0x194 lma 0x8000000

Loading section .text, size 0x17398 lma 0x80001a0

Loading section .rodata, size 0x4abc lma 0x8017538

...

(gdb)

Does that work for you?