Skip to content

SDK Openocd stm32f4discovery.cfg is incorrect for new versions of the STM32F407G-DISC1 #7144

@scott-eddy

Description

@scott-eddy

The new versions of the STM32F4 discovery boards, STM32F407G-DISC1, have an STLINK V2A embedded on the board instead of an STLINK-V2. However the openocd script that is shipped in Zephyr-SDK-0.9.2 specifies using the stlink v2:

# This is an STM32F4 discovery board with a single STM32F407VGT6 chip.
# http://www.st.com/internet/evalboard/product/252419.jsp

source [find interface/stlink-v2.cfg]

transport select hla_swd

# increase working area to 64KB
set WORKAREASIZE 0x10000

source [find target/stm32f4x.cfg]

reset_config srst_only

Using this config causes the hello_world sample to fail when executing the flash target:

zephyr/samples/hello_world/build$ ninja flash
[1/74] Generating always_rebuild
Building for board stm32f4_disco
[1/2] Flashing stm32f4_disco
/opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/openocd -s /opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/share/openocd/scripts -f /home/eddy/OpenSource/zephyr/boards/arm/stm32f4_disco/support/openocd.cfg -c init -c targets -c 'reset halt' -c 'flash write_image erase /home/eddy/OpenSource/zephyr/samples/hello_world/build/zephyr/zephyr.bin 0x8000000' -c 'reset halt' -c 'verify_image /home/eddy/OpenSource/zephyr/samples/hello_world/build/zephyr/zephyr.bin 0x8000000' -c 'reset run' -c shutdown
Open On-Chip Debugger 0.10.0-g7852ae77-dirty (2017-10-15-17:20)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Error: open failed
in procedure 'init' 
in procedure 'ocd_bouncer'

Error running /opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/openocd -s /opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/share/openocd/scripts -f /home/eddy/OpenSource/zephyr/boards/arm/stm32f4_disco/support/openocd.cfg -c init -c targets -c 'reset halt' -c 'flash write_image erase /home/eddy/OpenSource/zephyr/samples/hello_world/build/zephyr/zephyr.bin 0x8000000' -c 'reset halt' -c 'verify_image /home/eddy/OpenSource/zephyr/samples/hello_world/build/zephyr/zephyr.bin 0x8000000' -c 'reset run' -c shutdown
Traceback (most recent call last):
  File "/home/eddy/OpenSource/zephyr/scripts/support/zephyr_flash_debug.py", line 110, in <module>
    main()
  File "/home/eddy/OpenSource/zephyr/scripts/support/zephyr_flash_debug.py", line 96, in main
    handlers[args.top_command](args)
  File "/home/eddy/OpenSource/zephyr/scripts/support/zephyr_flash_debug.py", line 34, in runner_handler
    runner.run(args.command)
  File "/home/eddy/OpenSource/zephyr/scripts/support/runner/core.py", line 394, in run
    self.do_run(command, **kwargs)
  File "/home/eddy/OpenSource/zephyr/scripts/support/runner/openocd.py", line 90, in do_run
    self.do_flash(**kwargs)
  File "/home/eddy/OpenSource/zephyr/scripts/support/runner/openocd.py", line 122, in do_flash
    self.check_call(cmd)
  File "/home/eddy/OpenSource/zephyr/scripts/support/runner/core.py", line 435, in check_call
    subprocess.check_call(cmd)
  File "/usr/lib/python3.6/subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/openocd', '-s', '/opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/share/openocd/scripts', '-f', '/home/eddy/OpenSource/zephyr/boards/arm/stm32f4_disco/support/openocd.cfg', '-c', 'init', '-c', 'targets', '-c', 'reset halt', '-c', 'flash write_image erase /home/eddy/OpenSource/zephyr/samples/hello_world/build/zephyr/zephyr.bin 0x8000000', '-c', 'reset halt', '-c', 'verify_image /home/eddy/OpenSource/zephyr/samples/hello_world/build/zephyr/zephyr.bin 0x8000000', '-c', 'reset run', '-c', 'shutdown']' returned non-zero exit status 1.
FAILED: zephyr/cmake/flash/CMakeFiles/flash 
cd /home/eddy/OpenSource/zephyr/samples/hello_world/build && /usr/bin/cmake -E env /usr/bin/python3 /home/eddy/OpenSource/zephyr/scripts/support/zephyr_flash_debug.py --verbose openocd flash --board-dir=/home/eddy/OpenSource/zephyr/boards/arm/stm32f4_disco --kernel-elf=/home/eddy/OpenSource/zephyr/samples/hello_world/build/zephyr/zephyr.elf --kernel-hex=/home/eddy/OpenSource/zephyr/samples/hello_world/build/zephyr/zephyr.hex --kernel-bin=/home/eddy/OpenSource/zephyr/samples/hello_world/build/zephyr/zephyr.bin --gdb=/opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-zephyr-eabi/arm-zephyr-eabi-gdb --openocd=/opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/openocd --openocd-search=/opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/share/openocd/scripts --cmd-load="flash write_image erase /home/eddy/OpenSource/zephyr/samples/hello_world/build/zephyr/zephyr.bin 0x8000000" --cmd-verify="verify_image /home/eddy/OpenSource/zephyr/samples/hello_world/build/zephyr/zephyr.bin 0x8000000"
ninja: build stopped: subcommand failed.

Updating the stm32f4discovery.cfg file to use v2-1 fixes the probelm:

# This is an STM32F4 discovery board with a single STM32F407VGT6 chip.
# http://www.st.com/internet/evalboard/product/252419.jsp

source [find interface/stlink-v2-1.cfg]

transport select hla_swd

# increase working area to 64KB
set WORKAREASIZE 0x10000

source [find target/stm32f4x.cfg]

reset_config srst_only

Causing the ninja flash to succeed:

[1/74] Generating always_rebuild
Building for board stm32f4_disco
[1/2] Flashing stm32f4_disco
/opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/openocd -s /opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/share/openocd/scripts -f /home/eddy/OpenSource/zephyr/boards/arm/stm32f4_disco/support/openocd.cfg -c init -c targets -c 'reset halt' -c 'flash write_image erase /home/eddy/OpenSource/zephyr/samples/hello_world/build/zephyr/zephyr.bin 0x8000000' -c 'reset halt' -c 'verify_image /home/eddy/OpenSource/zephyr/samples/hello_world/build/zephyr/zephyr.bin 0x8000000' -c 'reset run' -c shutdown
Open On-Chip Debugger 0.10.0-g7852ae77-dirty (2017-10-15-17:20)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v25 API v2 SWIM v14 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 2.907062
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* stm32f4x.cpu       hla_target little stm32f4x.cpu       running
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000c30 msp: 0x20000780
auto erase enabled
Info : device id = 0x10076413
Info : flash size = 1024kbytes
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x20000046 msp: 0x20000780
wrote 16384 bytes from file /home/eddy/OpenSource/zephyr/samples/hello_world/build/zephyr/zephyr.bin in 2.127447s (7.521 KiB/s)
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000c30 msp: 0x20000780
verified 11904 bytes in 0.170699s (68.102 KiB/s)
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
shutdown command invoked

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions