openinput-fw / openinput

Open source firmware for input devices
https://openinput.readthedocs.io
MIT License
70 stars 6 forks source link

Automatic debug setup from the build system #94

Open perigoso opened 2 years ago

perigoso commented 2 years ago

This might be a bit out of scope

Since we're working with a couple of different targets and families, with different debug setup requirements, every time I want to work on a different family I need to setup the debugging environment, either dealing with stashes, copy pasting or just writing things from scratch, this gets old quick. Maybe we could consider integrating some of this with the build system, for instance we configure a target, and the bs automatically sets up the configuration for debugging that specific target, it's just a couple json files if we're talking VSCode which is what I use to work on this. of course limiting developers to Code is not great, but doing something more flexible would maybe complicate things.

This could also just be a different tool/script altogether, or even be approached from a different angle and have an extension for Code instead.

This is just an idea I had, sorry if the explanation is a bit convoluted.

FFY00 commented 2 years ago

Can you elaborate how your debugging setup works? I think ideally we would have something built on the build system which you could then easily plug into vscode or any other development setup.

perigoso commented 2 years ago

for cortex-m devices its just a file on the .vscode config folder configuring the Cortex-Debug extension for Code, but this config varies with every device.

We could also use environment variables for this, instead of generating the file.

One thing i forgot to mention is this extension makes use of the binary generated on build, and since we're appending the version on it, it is constantly changing (E: also different targets mean different build output directories), having an environment variable or something at least for this would help out a lot

perigoso commented 2 years ago

example config file (it's from a different project so mind some differences)

.vscode/launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug",
            "cwd": "${workspaceRoot}",
            "executable": "./bin/v1.test.elf",
            "request": "launch",
            "type": "cortex-debug",
            "preLaunchTask": "Build",
            "servertype": "jlink",
            "device": "EFM32GG11B820F2048",
            "svdFile": "SiliconLabs.EFM32GG11B_DFP.5.7.0/SVD/EFM32GG11B/EFM32GG11B820F2048GQ100.svd",
            "interface": "swd",
            "swoConfig": {
                "enabled": true,
                "swoFrequency": 2000000,
                "cpuFrequency": 36000000,
                "source": "probe",
                "decoders": [
                    {
                        "port": 0,
                        "label": "Console",
                        "type": "console",
                    }
                ]
            }
        }
    ]
}

.vscode/tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build",
            "type": "shell",
            "command": "make",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },
        {
            "label": "Rebuild",
            "type": "shell",
            "command": "make clean; make"
        },
        {
            "label": "Clean",
            "type": "shell",
            "command": "make clean"
        }
    ]
}
FFY00 commented 2 years ago

Hum, I think we can just have the build system automatically generate these files.