From 92cdcc2e795acdbbf9b2bdcb6e3d4b9f1357dbc7 Mon Sep 17 00:00:00 2001 From: Jason Ngo Date: Tue, 10 Jan 2023 17:41:15 -0500 Subject: [PATCH] Some build automation changes --- .cargo/config.toml | 2 +- .gitignore | 1 + .vscode/launch.json | 58 +++++++++++++++++++++++++++++++++++++++++++++ .vscode/tasks.json | 44 +++++++++++++++++++++++++++++----- Cargo.toml | 2 +- openocd.gdb | 23 ++++++++++++++++++ 6 files changed, 122 insertions(+), 8 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 openocd.gdb diff --git a/.cargo/config.toml b/.cargo/config.toml index 8146f1b..c2965d6 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,5 +1,5 @@ [target.'cfg(all(target_arch = "arm", target_os = "none"))'] -runner = "gdb-multiarch -q -x openocd.gdb" +runner = "probe-run --chip RP2040" rustflags = [ "-C", "linker=flip-link", "-C", "link-arg=--nmagic", diff --git a/.gitignore b/.gitignore index 143e42d..bbf24d1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ Cargo.lock target/ *.log +*.svd # editor files .vscode/* diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..b3fed9d --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,58 @@ +{ + "version": "0.2.0", + "inputs": [ + { + "type": "pickString", + "id": "exampleName", + "description": "Which example would you like to run?", + "options": [ + "graphics", + "music" + ], + "default": "music" + }, + { + "type": "pickString", + "id": "configuration", + "description": "Choose a configuration", + "default": "debug", + "options": [ + "debug", + "release", + ] + } + ], + "configurations": [ + { + "cwd": "${workspaceFolder}", + "executable": "${workspaceFolder}/target/thumbv6m-none-eabi/debug/examples/${input:exampleName}", + "name": "Pico Debug", + "request": "launch", + "type": "cortex-debug", + "gdbPath": "gdb-multiarch", + "gdbTarget": "localhost:3333", + "servertype": "openocd", + "configFiles": [ + "interface/picoprobe.cfg", + "interface/cmsis-dap.cfg", + "target/rp2040.cfg" + ], + "searchDir": [], + "runToEntryPoint": "main", + "showDevDebugOutput": "none", + "svdFile": "rp2040.svd", + "svdPath": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd", + "preLaunchTask": "Build Debug", + "preLaunchCommands": [ + "monitor init", + "monitor reset init", + "monitor halt" + ], + "postRestartCommands": [ + "break main", + "continue" + ] + } + + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index ef371ea..4015539 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -15,12 +15,12 @@ "type": "promptString", "id": "thumbyLocation", "description": "What drive is your Thumby mounted to (e.g. D:/)?", - "default": "E:/" - } + "default": "D:/" + }, ], "tasks": [ { - "label": "Build Debug", + "label": "1Debug", "type": "shell", "command": "cargo", "args": [ @@ -39,6 +39,26 @@ }, "problemMatcher": "$rustc" }, + { + "label": "Run Debug", + "type": "shell", + "command": "cargo", + "args": [ + "run", + "--example", + "${input:exampleName}", + "--target", + "thumbv6m-none-eabi" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "reveal": "always" + }, + "problemMatcher": "$rustc" + }, { "label": "Build Release", "type": "shell", @@ -61,7 +81,19 @@ "problemMatcher": "$rustc" }, { - "label": "elf2uf2 Example", + "label": "elf2uf2 Example (Debug)", + "type": "shell", + "command": "elf2uf2-rs", + "args": [ + "${workspaceFolder}/target/thumbv6m-none-eabi/debug/examples/${input:exampleName}" + ], + "problemMatcher": [ + "$rustc" + ], + "dependsOn": "Build Debug" + }, + { + "label": "elf2uf2 Example (Release)", "type": "shell", "command": "elf2uf2-rs", "args": [ @@ -83,7 +115,7 @@ "problemMatcher": [ "$rustc" ], - "dependsOn": "elf2uf2 Example" - } + "dependsOn": "elf2uf2 Example (Release)" + }, ] } \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index c968e0b..616cd7f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ keywords = ["thumby", "tiny-circuits", "rp2040", "embedded"] license = "Apache-2.0" name = "thumby" repository = "https://github.com/jngo102/thumby-rs" -version = "0.0.1" +version = "0.0.2" [badges] circle-ci = { repository = "jngo102/thumby-rs", branch = "main" } diff --git a/openocd.gdb b/openocd.gdb new file mode 100644 index 0000000..5b62db8 --- /dev/null +++ b/openocd.gdb @@ -0,0 +1,23 @@ +# connect to OpenOCD on TCP port 3333 +target extended-remote :3333 + +# print demangled function/variable symbols +set print asm-demangle on + +# set backtrace limit to not have infinite backtrace loops +set backtrace limit 32 + +# detect unhandled exceptions, hard faults and panics +break DefaultHandler +break HardFault + +# *try* stopping at the user entry point (it might be gone due to inlining) +break main + +monitor arm semihosting enable + +# load the application binary onto the Pico's flash +load + +# start the process but immediately halt the processor +stepi \ No newline at end of file