zephyrproject-rtos / openocd

OpenOCD with Zephyr patches for building Zephyr SDK
Other
28 stars 45 forks source link

cfg: Set STM32F746G discovery board to use 4000 kHz on reset-start #41

Closed gromero closed 1 year ago

gromero commented 3 years ago

Hi,

Could I get reviews for the following change that affects only ST STM32F746G Discovery boards, please?

Currently board/stm32f746g-disco.cfg already uses the maximum adapter speed available for reset-init events (4000 kHz). However it doesn't set that speed for reset-start events and so the speed for that event is inherited from the included config file arget/stm32f7x.cfg, which sets that speed to just 2000 kHz.

That commit overrides the inherited speed for reset-start events setting the adapter speed to be equal to the one used for reset-init events, i.e. to its maximum speed (4000 kHz).

That change avoids the following messages to appear when fashing the board:

Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz

Like, for instance, in:

Open On-Chip Debugger 0.10.0+dev-01508-gf79c90268-dirty (2021-01-14-14:40)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
066CFF485153826687133653
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 2000 kHz
Info : STLINK V2J25M14 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.236292
Warn : Silicon bug: single stepping may enter pending exception handler!
Info : stm32f7x.cpu: hardware has 8 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f7x.cpu on 3333
Info : Listening on port 3333 for gdb connections
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* stm32f7x.cpu       hla_target little stm32f7x.cpu       running

Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08001fb0 msp: 0x200331a8
Info : device id = 0x10016449
Info : flash size = 1024 kbytes
auto erase enabled
wrote 32768 bytes from file /tmp/tvm-debug-mode-tempdirs/2021-01-15T17-48-42___qjv395d0/00000/build/runtime/zephyr/zephyr.hex in 1.377706s (23.227 KiB/s)

Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08001fb0 msp: 0x200331a8
verified 32108 bytes in 0.455013s (68.911 KiB/s)

Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz

It also increases the throughput a bit when flashing the device.

Thanks, Gustavo

gromero commented 3 years ago

@galak @erwango Erwan, before changing Zephyr to pick up board/stm32f746g-disco.cfg instead of board/stm32f7discovery.cfg (which was obsoleted by commit https://github.com/zephyrproject-rtos/openocd/commit/f79c902686f3ae500f3426dc2e552fdec80796d1), and per our discussion on Slack this week, it's necessary to fix the adapter speed in reset-start. I'll proceed to send another PR to Zephyr addressing the change we've discussed. Thanks.

gromero commented 3 years ago

Pushed a v2 fixing a nit in the comments.

galak commented 3 years ago

Have you sent this to upstream openocd?

gromero commented 3 years ago

@galak Hi. Nope, I haven't yet. Do you prefer I submit there first? I was unsure because I don't how Zephyr's openocd how / when currently it syncs with upstream openocd.

galak commented 3 years ago

@galak Hi. Nope, I haven't yet. Do you prefer I submit there first? I was unsure because I don't how Zephyr's openocd how / when currently it syncs with upstream openocd.

yes, preference is upstream first

erwango commented 3 years ago

@gromero can't this be put directly in boards/arm/stm32f746g_disco/support/openocd.cfg ?

gromero commented 3 years ago

yes, preference is upstream first

Got it. Let me work that out on openocd upstream. I'll get back here once I'm done there. Thanks.

BTW, I'm struggling to understand why commit f79c902686f3ae500f3426dc2e552fdec80796d1 is on branch zephyr-20200722 but not on master branch? Isn't zephyr-20200722 created based upon master? (note that I've based my change on zephyr-20200722 branch, not on master). Do you know why that happens?

gromero commented 3 years ago

@gromero can't this be put directly in boards/arm/stm32f746g_disco/support/openocd.cfg ?

Hi Erwan! Yep, that would work too, but I think the correct approach is to get it fixed on openocd side, upstream (as @galak requested and actually that what I was planning, I just didn't know how/when Zephyr's openocd synced with openocd upstream)

If we apply the change only to openocd.cfg it only affects Zephyr, right?

stephanosio commented 1 year ago

Closing as stale