dist/tools/openocd: use reset halt command for board using stlink#8976
dist/tools/openocd: use reset halt command for board using stlink#8976aabadie wants to merge 3 commits intoRIOT-OS:masterfrom
Conversation
cladmi
left a comment
There was a problem hiding this comment.
A good idea to refactor this, but still a bit messy and not sure all changes are valid. See details inline.
|
|
||
| export DEBUG_ADAPTER ?= stlink | ||
| export STLINK_VERSION ?= 2 | ||
| export OPENOCD_CONFIG := $(RIOTBOARD)/$(BOARD)/dist/openocd.cfg |
There was a problem hiding this comment.
I do not like that you need here to set it to the default openocd value.
I would prefer it handled in the stlink-adapter, see below.
| export OPENOCD_DBG_START_CMD = -c 'reset halt' | ||
|
|
||
| # select OpenOCD configuration depending on CPU type | ||
| ifeq (,$(OPENOCD_CONFIG)) |
There was a problem hiding this comment.
Follow up to setting to the default value in boards:
You could add another check if $(RIOTBOARD)/$(BOARD)/dist/openocd.cfg does not exist before using the st configuration.
| @@ -1,3 +1,3 @@ | |||
| source [find target/stm32l0.cfg] | |||
| reset_config srst_only | |||
| reset_config srst_only connect_assert_srst | |||
There was a problem hiding this comment.
Why do you change the reset_config configurations in a "boards/common/stm32-link: add common place for stlink" commit ?
If it it necessary, it should be another properly justified commit.
| # this board has an on-board ST-link adapter | ||
| export DEBUG_ADAPTER ?= stlink | ||
|
|
||
| # call a 'reset halt' command before starting the debugger |
There was a problem hiding this comment.
Please do not call this commit "revert" as it is not reverting the change, only using the now common definition.
| @@ -1,3 +0,0 @@ | |||
| source [find target/stm32l0.cfg] | |||
|
|
|||
| reset_config trst_and_srst srst_nogate connect_assert_srst | |||
There was a problem hiding this comment.
This reset configuration is different from the common one in st/configs/stm32l0.cfg
I think this file should be kept.
There was a problem hiding this comment.
I think this file should be kept
It could but it makes no difference if using the common one (with the connect_assert_srst). I checked on other L0 based boards (nucleo-l053/nucleo-l073) and the openocd configuration file provided by this PR works for all of them.
| @@ -1 +0,0 @@ | |||
| source [find target/stm32f7x.cfg] | |||
There was a problem hiding this comment.
It does not match the st/configs/stm32f7.cfg configuration.
| endif | ||
|
|
||
| # this board uses openocd | ||
| # include openocd |
There was a problem hiding this comment.
Previous comment before was better than repeating what the next line does.
|
Oh absolutely right. Should I re-do them there then ? |
Not needed, both PRs are linked. But I'll apply the requested changes in #8475 |
a1f0103 to
5d85034
Compare
|
I think you can now rebase again. |
5d85034 to
b9a33ff
Compare
|
@cladmi, rebased and comments addressed. |
cladmi
left a comment
There was a problem hiding this comment.
ACK changes looks good for me.
I trust you that it is necessary for all stlink boards.
|
Merge now if you want, or ask if you want someone else testing. |
|
This implies that it is now not possible anymore to "attach" to a running node, right? Please wait a bit before merging, I'd like to get some opinions over lunch. |
/edit, it was for @kaspar030 not for @smlng |
|
Ping? |
'reset halt' is now set globally for all boards using st-link when debugging
b1c2d2a to
84b6ca6
Compare
|
After discussing briefly about this PR with @cladmi at the summit, it seems that the best solution is:
OPENOCD_DBG_START_CMD= make BOARD=<any stlink board> debugwill put |
|
@cladmi, what's your opinion about my latest comment ? |
|
@cladmi ? |
I agree completely with this. It is incredibly annoying to have the debug or flash commands fail because the CPU happened to be in a low power mode at the time that the tool tried to connect. This is going to become more common now that the boards are getting more low power support fixes and applications will begin using low power modes to a greater extent.
It would be useful to have a command which tries to attach to the running system, and if that fails fall back to a connect under reset configuration, but someone would need to implement this as a shell script since OpenOCD needs a restart after a failed init AFAIK. I have experimented with various combinations of |
@gebart, I'm happy we are on the same line about this. I'm +1 for merging #10479 since it does the same thing but globally. What would be great is to add some documentation somewhere about how to attach a crashed/running application without resetting it all. I'm thinking of this kind of thing: |
|
Sorry I missed the ping, I agree that having reliable flash is better. I think #10479 only takes care on the debug-server though, am I right ? |
Not really. In the current state, #10479 applies '-c reset halt' by default to all debug sessions using OpenOCD, see here. |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Contribution description
Based on
#8856and#8475, this PR uses thereset haltcommand of openocd for all board using an stlink adapter.It might not be the best solution and has side effects: after starting the debug session the program is always halted in the entry point (for ARM) otherwise it can be at any position which might be something expected (but doesn't work after).
Issues/PRs references
Fixes #8975, based on
#8856and#8475