vscode: initial development configuration (#1520)
* vscode: initial development configuration; fbt: `vscode_dist` target for deploying vscode config * vscode: fixed fbt blackmagic command Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
		
							parent
							
								
									51f5641c5e
								
							
						
					
					
						commit
						6499597586
					
				
							
								
								
									
										4
									
								
								.vscode/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								.vscode/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
			
		||||
./c_cpp_properties.json
 | 
			
		||||
./launch.json
 | 
			
		||||
./settings.json
 | 
			
		||||
./tasks.json
 | 
			
		||||
							
								
								
									
										32
									
								
								.vscode/example/c_cpp_properties.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								.vscode/example/c_cpp_properties.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,32 @@
 | 
			
		||||
{
 | 
			
		||||
    "configurations": [
 | 
			
		||||
        {
 | 
			
		||||
            "name": "Win32",
 | 
			
		||||
            "compilerPath": "${workspaceFolder}/toolchain/i686-windows/bin/arm-none-eabi-gcc.exe",
 | 
			
		||||
            "intelliSenseMode": "gcc-arm",
 | 
			
		||||
            "compileCommands": "${workspaceFolder}/build/latest/compile_commands.json",
 | 
			
		||||
            "configurationProvider": "ms-vscode.cpptools",
 | 
			
		||||
            "cStandard": "gnu17",
 | 
			
		||||
            "cppStandard": "c++17"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "Linux",
 | 
			
		||||
            "compilerPath": "${workspaceFolder}/toolchain/x86_64-linux/bin/arm-none-eabi-gcc",
 | 
			
		||||
            "intelliSenseMode": "gcc-arm",
 | 
			
		||||
            "compileCommands": "${workspaceFolder}/build/latest/compile_commands.json",
 | 
			
		||||
            "configurationProvider": "ms-vscode.cpptools",
 | 
			
		||||
            "cStandard": "gnu17",
 | 
			
		||||
            "cppStandard": "c++17"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "Mac",
 | 
			
		||||
            "compilerPath": "${workspaceFolder}/toolchain/x86_64-darwin/bin/arm-none-eabi-gcc",
 | 
			
		||||
            "intelliSenseMode": "gcc-arm",
 | 
			
		||||
            "compileCommands": "${workspaceFolder}/build/latest/compile_commands.json",
 | 
			
		||||
            "configurationProvider": "ms-vscode.cpptools",
 | 
			
		||||
            "cStandard": "gnu17",
 | 
			
		||||
            "cppStandard": "c++17"
 | 
			
		||||
        }
 | 
			
		||||
    ],
 | 
			
		||||
    "version": 4
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										87
									
								
								.vscode/example/launch.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										87
									
								
								.vscode/example/launch.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,87 @@
 | 
			
		||||
{
 | 
			
		||||
    // Use IntelliSense to learn about possible attributes.
 | 
			
		||||
    // Hover to view descriptions of existing attributes.
 | 
			
		||||
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
 | 
			
		||||
    "version": "0.2.0",
 | 
			
		||||
    "inputs": [
 | 
			
		||||
        {
 | 
			
		||||
            "id": "BLACKMAGIC",
 | 
			
		||||
            "type": "command",
 | 
			
		||||
            "command": "shellCommand.execute",
 | 
			
		||||
            "args": {
 | 
			
		||||
                "command": "./fbt get_blackmagic",
 | 
			
		||||
                "description": "Get Blackmagic device",
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    ],
 | 
			
		||||
    "configurations": [
 | 
			
		||||
        {
 | 
			
		||||
            "name": "Attach FW (ST-Link)",
 | 
			
		||||
            "cwd": "${workspaceFolder}",
 | 
			
		||||
            "executable": "./build/latest/firmware.elf",
 | 
			
		||||
            "request": "attach",
 | 
			
		||||
            "type": "cortex-debug",
 | 
			
		||||
            "servertype": "openocd",
 | 
			
		||||
            "device": "stlink",
 | 
			
		||||
            "svdFile": "./debug/STM32WB55_CM4.svd",
 | 
			
		||||
            "rtos": "FreeRTOS",
 | 
			
		||||
            "configFiles": [
 | 
			
		||||
                "interface/stlink.cfg",
 | 
			
		||||
                "./debug/stm32wbx.cfg",
 | 
			
		||||
            ],
 | 
			
		||||
            "postAttachCommands": [
 | 
			
		||||
                // "attach 1",
 | 
			
		||||
                "compare-sections",
 | 
			
		||||
            ]
 | 
			
		||||
            // "showDevDebugOutput": "raw",
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "Attach FW (blackmagic)",
 | 
			
		||||
            "cwd": "${workspaceFolder}",
 | 
			
		||||
            "executable": "./build/latest/firmware.elf",
 | 
			
		||||
            "request": "attach",
 | 
			
		||||
            "type": "cortex-debug",
 | 
			
		||||
            "servertype": "external",
 | 
			
		||||
            "gdbTarget": "${input:BLACKMAGIC}",
 | 
			
		||||
            "svdFile": "./debug/STM32WB55_CM4.svd",
 | 
			
		||||
            "rtos": "FreeRTOS",
 | 
			
		||||
            "postAttachCommands": [
 | 
			
		||||
                "monitor swdp_scan",
 | 
			
		||||
                "attach 1",
 | 
			
		||||
                "set confirm off",
 | 
			
		||||
                "set mem inaccessible-by-default off",
 | 
			
		||||
                "compare-sections",
 | 
			
		||||
            ]
 | 
			
		||||
            // "showDevDebugOutput": "raw",
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "Attach FW (JLink)",
 | 
			
		||||
            "cwd": "${workspaceFolder}",
 | 
			
		||||
            "executable": "./build/latest/firmware.elf",
 | 
			
		||||
            "request": "attach",
 | 
			
		||||
            "type": "cortex-debug",
 | 
			
		||||
            "servertype": "jlink",
 | 
			
		||||
            "interface": "swd",
 | 
			
		||||
            "device": "STM32WB55RG",
 | 
			
		||||
            "svdFile": "./debug/STM32WB55_CM4.svd",
 | 
			
		||||
            "rtos": "FreeRTOS",
 | 
			
		||||
            // "showDevDebugOutput": "raw",
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "fbt debug",
 | 
			
		||||
            "type": "python",
 | 
			
		||||
            "request": "launch",
 | 
			
		||||
            "program": "./lib/scons/scripts/scons.py",
 | 
			
		||||
            "args": [
 | 
			
		||||
                "sdk"
 | 
			
		||||
            ]
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "python debug",
 | 
			
		||||
            "type": "python",
 | 
			
		||||
            "request": "launch",
 | 
			
		||||
            "program": "${file}",
 | 
			
		||||
            "args": []
 | 
			
		||||
        }
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										22
									
								
								.vscode/example/settings.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								.vscode/example/settings.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
			
		||||
{
 | 
			
		||||
    "C_Cpp.default.cStandard": "gnu17",
 | 
			
		||||
    "C_Cpp.default.cppStandard": "c++17",
 | 
			
		||||
    "python.formatting.provider": "black",
 | 
			
		||||
    "workbench.tree.indent": 12,
 | 
			
		||||
    "cortex-debug.enableTelemetry": false,
 | 
			
		||||
    "cortex-debug.variableUseNaturalFormat": true,
 | 
			
		||||
    "cortex-debug.showRTOS": true,
 | 
			
		||||
    "cortex-debug.armToolchainPath.windows": "${workspaceFolder}/toolchain/i686-windows/bin",
 | 
			
		||||
    "cortex-debug.armToolchainPath.linux": "${workspaceFolder}/toolchain/x86_64-linux/bin",
 | 
			
		||||
    "cortex-debug.armToolchainPath.osx": "${workspaceFolder}/toolchain/x86_64-darwin/bin",
 | 
			
		||||
    "cortex-debug.openocdPath.windows": "${workspaceFolder}/toolchain/i686-windows/openocd/bin/openocd.exe",
 | 
			
		||||
    "cortex-debug.openocdPath.linux": "${workspaceFolder}/toolchain/x86_64-linux/openocd/bin/openocd",
 | 
			
		||||
    "cortex-debug.openocdPath.osx": "${workspaceFolder}/toolchain/x86_64-darwin/openocd/bin/openocd",
 | 
			
		||||
    "editor.formatOnSave": true,
 | 
			
		||||
    "files.associations": {
 | 
			
		||||
        "*.scons": "python",
 | 
			
		||||
        "SConscript": "python",
 | 
			
		||||
        "SConstruct": "python",
 | 
			
		||||
        "*.fam": "python",
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										103
									
								
								.vscode/example/tasks.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								.vscode/example/tasks.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,103 @@
 | 
			
		||||
{
 | 
			
		||||
    // See https://go.microsoft.com/fwlink/?LinkId=733558
 | 
			
		||||
    // for the documentation about the tasks.json format
 | 
			
		||||
    "version": "2.0.0",
 | 
			
		||||
    "tasks": [
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Release] Build",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt COMPACT=1 DEBUG=0"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Debug] Build",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Release] Flash (ST-Link)",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt COMPACT=1 DEBUG=0 FORCE=1 flash"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Debug] Flash (ST-Link)",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt FORCE=1 flash"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Release] Flash (blackmagic)",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt COMPACT=1 DEBUG=0 FORCE=1 flash_blackmagic"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Debug] Flash (blackmagic)",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt FORCE=1 flash_blackmagic"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Release] Flash (JLink)",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt COMPACT=1 DEBUG=0 FORCE=1 jflash"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Debug] Flash (JLink)",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt FORCE=1 jflash"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Release] Build update bundle",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt update_package COMPACT=1 DEBUG=0"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Debug] Build update bundle",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt update_package"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Release] Build updater",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt updater_all COMPACT=1 DEBUG=0"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Debug] Build updater",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt updater_all"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Debug] Flash (USB, w/o resources)",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt FORCE=1 flash_usb"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Release] Flash (USB, w/o resources)",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt COMPACT=1 DEBUG=0 FORCE=1 flash_usb"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Debug:unit_tests] Flash (USB)",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt FIRMWARE_APP_SET=unit_tests FORCE=1 flash_usb"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "label": "[Release] Flash (USB, with resources)",
 | 
			
		||||
            "group": "build",
 | 
			
		||||
            "type": "shell",
 | 
			
		||||
            "command": "./fbt COMPACT=1 DEBUG=0 FORCE=1 flash_usb_full"
 | 
			
		||||
        },
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										15
									
								
								.vscode/extensions.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								.vscode/extensions.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
{
 | 
			
		||||
	// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
 | 
			
		||||
	// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
 | 
			
		||||
	// List of extensions which should be recommended for users of this workspace.
 | 
			
		||||
	"recommendations": [
 | 
			
		||||
		"ms-python.black-formatter",
 | 
			
		||||
		"ms-vscode.cpptools",
 | 
			
		||||
		"amiralizadeh9480.cpp-helper",
 | 
			
		||||
		"marus25.cortex-debug",
 | 
			
		||||
		"zxh404.vscode-proto3",
 | 
			
		||||
		"augustocdias.tasks-shell-input"
 | 
			
		||||
	],
 | 
			
		||||
	// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
 | 
			
		||||
	"unwantedRecommendations": []
 | 
			
		||||
}
 | 
			
		||||
@ -274,8 +274,13 @@ distenv.PhonyTarget("cli", "${PYTHON3} scripts/serial_cli.py")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Find blackmagic probe
 | 
			
		||||
 | 
			
		||||
distenv.PhonyTarget(
 | 
			
		||||
    "get_blackmagic",
 | 
			
		||||
    "@echo $( ${BLACKMAGIC_ADDR} $)",
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# Prepare vscode environment
 | 
			
		||||
vscode_dist = distenv.Install("#.vscode", distenv.Glob("#.vscode/example/*"))
 | 
			
		||||
distenv.Precious(vscode_dist)
 | 
			
		||||
distenv.NoClean(vscode_dist)
 | 
			
		||||
distenv.Alias("vscode_dist", vscode_dist)
 | 
			
		||||
 | 
			
		||||
@ -24,6 +24,19 @@ To build with FBT, call it specifying configuration options & targets to build.
 | 
			
		||||
 | 
			
		||||
To run cleanup (think of `make clean`) for specified targets, add `-c` option.
 | 
			
		||||
 | 
			
		||||
## VSCode integration
 | 
			
		||||
 | 
			
		||||
`fbt` includes basic development environment configuration for VSCode. To deploy it, run `./fbt vscode_dist`. That will copy initial environment configuration to `.vscode` folder. After that, you can use that configuration by starting VSCode and choosing firmware root folder in "File > Open Folder" menu.
 | 
			
		||||
 | 
			
		||||
 * On first start, you'll be prompted to install recommended plug-ins. Please install them for best development experience. _You can find a list of them in `.vscode/extensions.json`._
 | 
			
		||||
 * Basic build tasks are invoked in Ctrl+Shift+B menu.
 | 
			
		||||
 * Debugging requires a supported probe. That includes:
 | 
			
		||||
    * Wi-Fi devboard with stock firmware (blackmagic),
 | 
			
		||||
    * ST-Link and compatible devices,
 | 
			
		||||
    * J-Link for flashing and debugging (in VSCode only). _Note that J-Link tools are not included with our toolchain and you have to [download](https://www.segger.com/downloads/jlink/) them yourself and put on your system's PATH._
 | 
			
		||||
 * Without a supported probe, you can install firmware on Flipper using USB installation method.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## FBT targets
 | 
			
		||||
 | 
			
		||||
FBT keeps track of internal dependencies, so you only need to build the highest-level target you need, and FBT will make sure everything they depend on is up-to-date.
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user