-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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 vs code launch.json auto generation in waf configure #28839
base: master
Are you sure you want to change the base?
add vs code launch.json auto generation in waf configure #28839
Conversation
6d4d3b6
to
1cf121c
Compare
wscript
Outdated
openocd_target = 'stm32g4x.cfg' | ||
|
||
with open(openocd_cfg_path, 'w+') as f: | ||
f.write("source [find interface/stlink-v2.cfg]\n") |
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 don't think this is right - pointing to the stlink-v2
config.
The most of the stlink*.cfg
files point to the more common stlink.cfg
- eg: https://github.com/openocd-org/openocd/blob/master/tcl/interface/stlink-v2.cfg
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.
You are right, thanks for the hint, shoule be stlink.cfg, updated
1cf121c
to
709ece0
Compare
wscript
Outdated
"args": [ | ||
"-S", | ||
"--model", | ||
"+", |
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 don't know that this is a valid model for all vehicle types/targets
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.
Should accept a extra params to overwirite this, now it's more like a template, the default params I get from the output of sim_vehicle.py
wscript
Outdated
mcu_type = cfg.env.get_flat('APJ_BOARD_TYPE') | ||
openocd_target = '' | ||
if mcu_type.startswith("STM32H7"): | ||
openocd_target = 'stm32h7x.cfg' |
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.
https://github.com/ArduPilot/ardupilot/blob/master/Tools/debug/openocd-h7.cfg
The ardupilot supplied openocd H7 config file points to dual bank.
Not sure if we should also point this to stm32h7x_dual_bank.cfg.
When I've debugged on hardware, I have used the ardupilot config file to talk to the H7.
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.
should include the dualbank, I am trying to find the dual bank condition in waf env
709ece0
to
b5c4f2a
Compare
the above error should coming from using lldb in WSL(linux), code updated, use gdb instead outside macos |
b5c4f2a
to
a52c375
Compare
4f3f9a7
to
d217a06
Compare
2024.12.16 update
what's the benefit of using --vs-launch instead of copy template launch.json from document?
|
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.
Overall, I like the idea, but I think we need to find a way to make it generate on build instead of on configure. That way, we don't need a launch configuration for every vehicle binary, just one for the last one configured/built. The --vs-launch
option should just create/overwrite one launch configuration named "vs-launch" with whatever the last build was. I poked around trying to see if I could get that to work, but I've run out of time, and I don't know waf well enough yet.
I also don't think we should automatically delete the launch.json on a parse error. Throw an error and quit. Make the user fix it or delete it themselves. Since launch.json is gitignored, if we delete it, you'll likely be losing something that isn't backed up anywhere.
@@ -0,0 +1,209 @@ | |||
import os | |||
import json |
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.
Need to use something that supports comments. Something like this: https://github.com/Kijewski/pyjson5
Otherwise, you will pretty much always get a parse failure and will delete the user's existing launch.json.
} | ||
|
||
if launch_profile.get('sitl'): | ||
merge_dicts(launch_configuration, launch_profile.get('sitl')) |
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.
merge_dicts(launch_configuration, launch_profile.get('sitl')) | |
launch_configuration |= launch_profile.get('sitl') |
Don't need to implement a dictionary merger. This is supported in 3.9+ https://peps.python.org/pep-0584/
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.
thanks
my first try is putting it in the waf build, then I thought about not to slow down the build process, I will update it raise a error instead of delete a launch.json with syntax error |
auto generate vscode launch.json for setup stm32 gdb or SITL lldb debug session in VSCODE
waf configure arg "--vs-launch", only active --debug
example command
./waf configure --board Pixhawk4 --debug --vs-launch
STM32 debug need https://github.com/Marus/cortex-debug and STLINK
./waf configure --board sitl --debug --vs-launch