Skip to content

Fix for debugging when trying to load to ram. #87423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions boards/nxp/mimxrt1170_evk/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

if(CONFIG_SOC_MIMXRT1176_CM7 OR CONFIG_SECOND_CORE_MCUX)
board_runner_args(pyocd "--target=mimxrt1170_cm7")
board_runner_args(jlink "--device=MIMXRT1176xxxA_M7" "--reset-after-load")
# ITCM is not defined in RT1170's LinkServer device file
board_runner_args(linkserver "--override=/device/memory/-=\{\"location\":\"0x00000000\",\
\"size\":\"0x00040000\",\"type\":\"RAM\"\}")
board_runner_args(jlink "--device=MIMXRT1176xxxA_M7")

if(${BOARD_REVISION} STREQUAL "A")
board_runner_args(linkserver "--device=MIMXRT1176xxxxx:MIMXRT1170-EVK")
Expand Down
2 changes: 1 addition & 1 deletion scripts/west_commands/run_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def do_run_common_image(command, user_args, user_runner_args, used_cmds,
# the board has enabled this functionality, check if the board should be
# reset or not. If this is not specified in the board/soc file, leave it up to
# the runner's default configuration to decide if a reset should occur.
if runner_cls.capabilities().reset and '--no-reset' not in final_argv:
if runner_cls.capabilities().reset and '--no-reset' not in final_argv and len(board_image_count):
if board_image_count is not None:
reset = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nordicjm your PR #69748 made the initial change here with respect to board_image_count and the forced addition of reset. What we found is that the test here for not None is always true because board_image_count is instantiated but doesn't have any elements in it... so not None. This results in the runner always adding a reset to the gdb commands. I suspect, from your comment block above, that this wasn't your intention.

We didn't notice this change because in the normal debug situation, you wouldn't care if the gdb did reset, load, reset if the image was being put in flash. But if you are targeting an image to a RAM space, the reset, load, reset causes the bootrom to load the flash image preventing you from debugging the image you created for RAM loading/debugging.

In parallel to this PR being added, I just saw this other PR [#87138] (@VynDragon) that just merged to force the larger logic to NOT ignore the no-reset runner option. We could have done the same thing now that I see this but I'm still questioning the logic of "if board_image_count not None" when combined with the comment block about multiple images.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

board_image_count is init in the common function, it should not not ever be none. As for why I put the none check in, I do not remember

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so in this particular case, the len(board_image_count) was 0 and we needed to have this check to keep the rest of your logic from doing another reset.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nordicjm Do you have any more comments on this PR?

Copy link
Collaborator

@nordicjm nordicjm Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change here doesn't make sense, it should never have a len of 0 so you need to look into what is causing that, this change is not acceptable though without some in depth analysis showing there is a bug and given this code is in use and works fine on multiple boards by multiple vendors... I'm not seeing it


Expand Down
5 changes: 4 additions & 1 deletion scripts/west_commands/runners/linkserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ def do_run(self, command, **kwargs):
['-ex', f'target remote {self.gdb_host}:{self.gdb_port}'])

if command == 'debug':
gdb_cmd += [ '-ex', 'load', '-ex', 'monitor reset']
# If the flash node points to ram, linkserver treats
# the ram as inaccessible and does not flash.
gdb_cmd += ['-ex', 'set mem inaccessible-by-default off']
gdb_cmd += ['-ex', 'monitor reset', '-ex', 'load']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the order of load, reset being reversed to reset, load?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going to reset, we would want it to be before a load.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I do see a typo I will fix in the next push if I don't get further comments

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going to reset, we would want it to be before a load.

Yes, I see that is what you are doing, you are restating what it is that I said that am observing, my question was why. You should explain in the commit message also why you are reversing this order. I don't know why.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the commit message, let me know if that helps!


if command == 'attach':
linkserver_cmd += ['--attach']
Expand Down
Loading