diff --git a/.gitignore b/.gitignore index 3cec5cf..6467923 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ -.vscode/ -/Build* -/Temp* \ No newline at end of file +/Build/ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..21d32fe --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,181 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "executable": "Build/app.elf", + "name": "J-Link PY32F002Ax5", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "jlink", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f002axx.svd", + "device": "PY32F002Ax5", + "type": "cortex-debug", + }, + { + "executable": "Build/app.elf", + "name": "J-Link PY32F002Bx5", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "jlink", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f002xx.svd", + "device": "PY32F002Bx5", + "type": "cortex-debug", + }, + { + "executable": "Build/app.elf", + "name": "J-Link PY32F003x4", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "jlink", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f003xx.svd", + "device": "PY32F003x4", + "type": "cortex-debug", + }, + { + "executable": "Build/app.elf", + "name": "J-Link PY32F003x6", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "jlink", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f003xx.svd", + "device": "PY32F003x6", + "type": "cortex-debug", + }, + { + "executable": "Build/app.elf", + "name": "J-Link PY32F003x8", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "jlink", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f003xx.svd", + "device": "PY32F003x8", + "type": "cortex-debug", + }, + { + "executable": "Build/app.elf", + "name": "J-Link PY32F030x6", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "jlink", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f030xx.svd", + "device": "PY32F030x6", + "type": "cortex-debug", + }, + { + "executable": "Build/app.elf", + "name": "J-Link PY32F030x8", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "jlink", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f030xx.svd", + "device": "PY32F030x8", + "type": "cortex-debug", + }, + { + "executable": "Build/app.elf", + "name": "J-Link PY32F072xB", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "jlink", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f072xx.svd", + "device": "PY32F072xB", + "type": "cortex-debug", + }, + { + "executable": "Build/app.elf", + "name": "pyOCD PY32F002Ax5", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "pyocd", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f002axx.svd", + "targetId": "py32f002ax5", + "type": "cortex-debug", + }, + { + "executable": "Build/app.elf", + "name": "pyOCD PY32F002Bx5", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "pyocd", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f002xx.svd", + "targetId": "py32f002bx5", + "type": "cortex-debug", + }, + { + "executable": "Build/app.elf", + "name": "pyOCD PY32F003x4", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "pyocd", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f003xx.svd", + "targetId": "py32f003x4", + "type": "cortex-debug", + }, + { + "executable": "Build/app.elf", + "name": "pyOCD PY32F003x6", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "pyocd", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f003xx.svd", + "targetId": "py32f003x6", + "type": "cortex-debug", + }, + { + "executable": "Build/app.elf", + "name": "pyOCD PY32F003x8", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "pyocd", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f003xx.svd", + "targetId": "py32f003x8", + "type": "cortex-debug", + }, + { + "executable": "Build/app.elf", + "name": "pyOCD PY32F030x6", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "pyocd", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f030xx.svd", + "targetId": "py32f030x6", + "type": "cortex-debug", + }, + { + "executable": "Build/app.elf", + "name": "pyOCD PY32F030x8", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "pyocd", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f030xx.svd", + "targetId": "py32f030x8", + "type": "cortex-debug", + }, + { + "executable": "Build/app.elf", + "name": "pyOCD PY32F072xB", + "preLaunchTask": "build", + "request": "launch", + "runToEntryPoint": "main", + "servertype": "pyocd", + "svdPath": "${workspaceFolder}/Misc/SVD/py32f072xx.svd", + "targetId": "py32f072xb", + "type": "cortex-debug", + }, + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..63dfca9 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,14 @@ +{ + "C_Cpp.default.compileCommands": "${workspaceFolder}/Build/compile_commands.json", + "clangd.arguments": [ + "--compile-commands-dir=Build", + "--query-driver=/usr/bin/arm-none-eabi-*", + ], + "cmake.ignoreCMakeListsMissing": true, + "cortex-debug.gdbPath": "gdb-multiarch", + "cortex-debug.objdumpPath": "arm-none-eabi-objdump", + "debug.onTaskErrors": "abort", + "files.associations": { + "*.h": "c" + }, +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..92efba0 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,21 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "command": "bear --append --output Build/compile_commands.json -- make", + "detail": "Build default Makefile target", + "label": "build", + "problemMatcher": "$gcc", + "type": "shell", + }, + { + "command": "mkdir -p Build && test -f Build/compile_commands.json || echo [] > Build/compile_commands.json", + "detail": "Create Build directory and empty compilation database", + "label": "init", + "runOptions": { + "runOn": "folderOpen" + }, + "type": "shell", + }, + ] +} diff --git a/README.md b/README.md index 637a1f4..77fc907 100644 --- a/README.md +++ b/README.md @@ -41,8 +41,8 @@ Frequency up to 72 MHz, 128 Kbytes of Flash memory, 16 Kbytes of SRAM, with more # File Structure ``` +├── .vscode # Visual Studio Code tasks and launch settings ├── Build # Build results -├── Docs # Datesheets and User Manuals ├── Examples │   ├── PY32F002B # PY32F002B examples │   │   ├── HAL # HAL library examples @@ -68,7 +68,6 @@ Frequency up to 72 MHz, 128 Kbytes of Flash memory, 16 Kbytes of SRAM, with more │   ├── PY32F0xx_HAL_Driver # PY32F002A/003/030 HAL library │   ├── PY32F0xx_LL_BSP # PY32F002A/003/030 LL BSP │   └── PY32F0xx_LL_Driver # PY32F002A/003/030 LL library -| ├── Makefile # Make config ├── Misc │   ├── Flash @@ -95,7 +94,11 @@ Frequency up to 72 MHz, 128 Kbytes of Flash memory, 16 Kbytes of SRAM, with more ## 1. Install GNU Arm Embedded Toolchain -Download the toolchain from [Arm GNU Toolchain Downloads](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) according to your pc architecture, extract the files +If possible, use your distribution's package manager to install the toolchain. +The `Makefile` and VS Code settings expect the compiler to be located in `/usr/bin`. + +If your distribution does not provide the toolchain, download it from [Arm GNU Toolchain Downloads](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) according to your architecture, then extract the files. +You will then need to adjust the path in the `Makefile` (and possibly the VS Code settings). ```bash sudo mkdir -p /opt/gcc-arm/ @@ -218,44 +221,11 @@ make flash # Debugging In VSCode -Install Cortex Debug extension, add a new configuration in launch.json, e.g. -``` -{ - "armToolchainPath": "/opt/gcc-arm/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi/bin/", - "toolchainPrefix": "arm-none-eabi", - "name": "Cortex Debug", - "cwd": "${workspaceFolder}", - "executable": "${workspaceFolder}/Build/app.elf", - "request": "launch", // can be launch or attach - "type": "cortex-debug", - "runToEntryPoint": "Reset_Handler", // "main" or other function name. runToMain is deprecated - "servertype": "jlink", // jlink, openocd, pyocd, pe and stutil - "device": "PY32F030X8", - "interface": "swd", - "preLaunchTask": "build", // Set this to run a task from tasks.json before starting a debug session - // "preLaunchCommands": ["Build all"], // Uncomment this if not using preLaunchTask - "svdFile": "${workspaceFolder}/Misc/SVD/py32f030xx.svd", // svd for this part number - "showDevDebugOutput": "vscode", // parsed, raw, vscode:vscode log and raw - "swoConfig": - { - "enabled": true, - "cpuFrequency": 8000000, // Target CPU frequency in Hz - "swoFrequency": 4000000, - "source": "probe", // either be “probe” to get directly from the debug probe, - // or a serial port device to use a serial port external to the debug probe. - "decoders": - [ - { - "label": "ITM port 0 output", - "type": "console", - "port": 0, - "showOnStartup": true, - "encoding": "ascii" - } - ] - } -} -``` +Install the Cortex-Debug extension (`marus25.cortex-debug`). + +In "Run and Debug", select the appropriate launch configuration for your debugger and device. +Note that the `Makefile` determines the target chip for building. + If Cortex Debug cannot find JLinkGDBServerCLExe, add the following line to settings.json ``` "cortex-debug.JLinkGDBServerPath": "/opt/SEGGER/JLink/JLinkGDBServerCLExe",