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 1 commit 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")
Copy link
Member

Choose a reason for hiding this comment

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

don't we want to reset after load for the more expected use case of actually booting with the ROM? or is this just what is now the default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This should be the default, this seems to be the default for the other boards as well which is one step that prevented them from running into this issue.

# ITCM is not defined in RT1170's LinkServer device file
board_runner_args(linkserver "--override=/device/memory/-=\{\"location\":\"0x00000000\",\
\"size\":\"0x00040000\",\"type\":\"RAM\"\}")
Comment on lines -10 to -12
Copy link
Member

Choose a reason for hiding this comment

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

the comment here makes me think once again that the device memory map linkserver issue is not a zephyr problem

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This code is actually wrong, and Linkserver has the correct mapping for this address space. Specifically, we gave the wrong size when this line was created but again no longer needed since Linkserver has the correct address mapping.

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):
Copy link
Member

Choose a reason for hiding this comment

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

the comment should be updated about what is this doing, I don't understand

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is not something that should be addressed in this PR. The intention of the comment makes sense, the implementation uses a default set of conditions for multiple images if none are passed in as parameters, the only update I made is it doesn't properly check or test rather this code runs if there's only one image so I added the check. I have nothing to do with the implementation so maybe my assumption of the comment is wrong as well thus I cannot make the change.

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.


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, linserver 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']
Comment on lines +153 to +156
Copy link
Member

Choose a reason for hiding this comment

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

isn't this a problem with linkserver and not this zephyr runner?


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