cancel
Showing results for 
Search instead for 
Did you mean: 

Openocd flashing elf in STM32L4

Mohamad Nazmul Alam
Associate II
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
4 REPLIES 4
Rob.Riggs
Senior III
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?

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,

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?

Posted on June 30, 2017 at 06:27

Hi Rob,

Thanks for your suggestion.

Unfortunately it didn't work. I am also new to openocd and tried to follow same flashing instruction used for F4 device. I get the following error while running gdb load instruction

openocd window :

Unable to match requested speed 500 kHz, using 480 kHz

Unable to match requested speed 500 kHz, using 480 kHz

adapter speed: 480 kHz

timed out while waiting for target halted

TARGET: stm32l4x.cpu - Not halted

in procedure 'reset'

in procedure 'ocd_bouncer'

Target not halted

failed erasing sectors 0 to 4

flash_erase returned -304

gdb window:

(gdb) load /home/fadedreamz/hello-world.elf

Error erasing flash with vFlashErase packet

Just a thought, is there any official tool for STLink in linux?

Thanks again.