-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add debug support #4
base: main
Are you sure you want to change the base?
Conversation
Use it this way for now. |
I forgot to write. |
It is now possible to easily launch a debugger using VSCode. Right now, only openocd is supported. |
@sago35 Cherrs |
@bmentink
https://github.com/ciniml/debug-tools-builder/releases/
If you can
Next you need to build tinygo at https://github.com/tinygo-org/tinygo/tree/buildinfo
|
Many Thanks. Regarding the "building tinygo" step. I am using your custom branch that has the PWM max frequency fix, has that been applied to the @sago35 .. Also, what is the extension name that gives you the vscode picoprobe openocd interface? I only see one for MacOS and I am on Linux .... or does it work for Linux as well .. (My TinyGo extension does not have any options you can set) |
@sago35 I have picoprobe flashing and gdb talking to the board. I just need further help with setting up visualStudio. Thanks. |
Now you can use the Once created, install the extension. Subsequent steps are as shown in the video below. note: |
@sago35 Is the |
@bmentink
vsce is for VSCode. https://code.visualstudio.com/api/working-with-extensions/publishing-extension |
I don't have vsce installed, do I have to install that with npm? You say Please give clear steps on what to do with visual to get the extension .. i.e treat me like a baby :) |
Please wait a moment while I upload the vsix file. First,
Now all that remains is to run the following to create https://github.com/tinygo-org/vscode-tinygo#development
|
Perfect .. Thanks 👍 |
@bmentink |
I have the extension installed, and I have selected the openocd interface. However the settings.json file and the tasks.json files look wrong, as this is what I get when trying to run a debug session.
Am I not mean't to edit those files with the correct paths etc ..? |
@bmentink |
@sago35 I tried what you suggested, I removed .vscode, and reinstalled go and the .vsix file as you suggested. the paths still took wrong. tasks.json looks like:
The error was:
It seems to have ignored me setting the tinygo path to my custom build tinygo ... The tinygo path in my case is: For reference, my settings.json looks like:
|
Ahhh, I missed setting the target when the window containing main() is open ... very important step !!!! ...
|
When starting debug, run it while the main package is displayed in VSCode. Also, please let me know the results of the following command so I can look into it.
|
What do you mean by The out put of the above command is:
|
If by package, you mean main.go, then the above command should be .. |
At the moment, I am getting a permission error where it is compiling the .elf file:
why is there a "/" in front of the out.elf? |
I think the update: change |
Adding the rules did not help ... will investigate further.. cheers |
Can |
|
When tinygo gdb is run, openocd is also run. |
Adding |
You may try rebooting linux once. |
Ok, will try tomorrow.. Stopping for the day.. Thanks for the help..
…On Tue, 22 Mar 2022, 4:44 pm sago35, ***@***.***> wrote:
You may try rebooting linux once.
—
Reply to this email directly, view it on GitHub
<#4 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACNHVB4EUOZMN7BNXLYL773VBE6ZFANCNFSM5OKUPISQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Yay, got it working. I discovered openocd requires you to be part of the |
To complete this PR, the remaining tasks are as follows
|
No more $TMP setup, etc. Now ready for reaview. |
Great job! @sago35 Have you tried debugging into interrupt handlers, or functions called from the handler? I can only seem to debug mainline code, which is frustrating, as all my code runs off interrupts ... |
I tried this with feather-m4-can. I think we need better debugging support for tinygo, not just for interrupts. |
@aykevl By the way, the 0.3.0 tag does not seem to have been pushed. |
Pre-built binaries can be downloaded from the following links |
ping @aykevl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First review.
It looks like you are first building a binary using tinygo build
and then debugging it separately using the Cortex-M debug extension, correct?
I think there is a better way, but I haven't investigated it yet: by using tinygo gdb
directly and providing the gdb-rsp port number to the debugger. This will make it possible to debug all architectures, not just Cortex-M.
(Right now tinygo gdb
will run GDB itself, but it could be modified to simply output the openocd port number that a VS Code extension could attach to).
"tinygo.openocdInterface": { | ||
"description": "which hardware programmer to use (ex: jlink, cmsis-dap, stlink-v2, ...)", | ||
"type": "string", | ||
"default": "cmsis-dap" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be an empty string by default, for boards that have an on-board debugger. For example, the BBC micro:bit has a cmsis-dap debugger on board while many STM32 development boards have a ST-Link debugger on board. By picking a debugger here, it looks like you are overriding the default for a particular board.
let buildPkg = ''; | ||
let editor = vscode.window.activeTextEditor; | ||
if (editor) { | ||
buildPkg = editor.document.fileName; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go packages normally work in packages, not in files. I think this should use the directory of the current file, not the path of the current file.
envVars.TARGET = target; | ||
envVars.TINYGOROOT = tinygoroot; | ||
envVars.GdbPath = path.basename(gdbPath); | ||
envVars.OpenocdInterface = openocdInterface; | ||
envVars.OpenocdTarget = openocdTarget; | ||
envVars.TmpDir = os.tmpdir(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you storing all of these in .vscode/settings.json? I don't see how they are necessary for the Go extension.
@aykevl Thanks for the review.
I think that is a very good idea. |
If you didn't see it already, this will be useful: https://code.visualstudio.com/api/extension-guides/debugger-extension (I didn't read the page yet). |
This PR adds debug support to vscode-tinygo.
It works as follows.
.vscode/settings.json
.vscode/launch.json
.vscode/tasks.json
to be used from.vscode/launch.json
The following are the parts that are not done so far.
If tasks.json does not exist, adding a task will fail.fixedIf you create the file to be written later first, there will be no error.