当前位置:   article > 正文

mac下使用vscode搭建stm32开发环境_mac vscode stm32 hello

mac vscode stm32 hello

1. 使用stm32Cube 生成makefile的工程

2. 安装arm-gcc编译器,Jlink等

3. 创建tasks.json文件

  1. {
  2. "version": "2.0.0",
  3. "tasks": [
  4. {
  5. "label": "Build", // 任务名
  6. "type": "shell", // 任务执行的是shell命令
  7. "command": "make", // 任务命令
  8. "problemMatcher": "$gcc", // GCC捕获错误
  9. },
  10. {
  11. "label": "Build Clean", // 任务名
  12. "type": "shell", // 任务执行的是shell命令
  13. "command": "make clean", // 任务命令
  14. "problemMatcher": "$gcc", // GCC捕获错误
  15. },
  16. {
  17. "label": "Program", //下载代码
  18. "type": "shell",
  19. "command": "JLinkExe -device stm32f103vb -autoconnect 1 -if SWD -speed 4000 -CommandFile CommandFile.jlink",
  20. "dependsOn": "Build", // 依赖"Build"命令先运行
  21. "problemMatcher": [],
  22. "group": { // 设置为默认"build"组命令,⇧⌘B 按键快速编译烧录
  23. "kind": "build",
  24. "isDefault": true
  25. }
  26. },
  27. {
  28. "label": "Disassembly",
  29. "type": "shell",
  30. "command": "arm-none-eabi-objdump -ldS OBJ/STM32_REG_TEST1.elf > STM32_REG_TEST1.asm",
  31. "problemMatcher": [],
  32. },
  33. {
  34. "label": "GDBServer",
  35. "type": "shell",
  36. "command": "JLinkGDBServer -select USB -device STM32F103RC -endian little -if SWD -speed 4000 -noir -noLocalhostOnly",
  37. "problemMatcher": [],
  38. },
  39. {
  40. "label": "Connect to JLink",
  41. "type": "shell",
  42. "command": "JLinkExe -device stm32f103vb -autoconnect 1 -if SWD -speed 4000",
  43. "dependsOn": "make",
  44. "problemMatcher": [],
  45. },
  46. {
  47. "label": "JLink RTT log",
  48. "type": "shell",
  49. "command": "JLinkRTTClient",
  50. "problemMatcher": [],
  51. }
  52. ]
  53. }

4. 创建launch.json文件

  1. {
  2. "version": "0.2.0",
  3. "configurations": [
  4. {
  5. "name": "DGB debug",
  6. "type": "cppdbg",
  7. "request": "launch",
  8. "targetArchitecture": "arm",
  9. "program": "${fileDirname}/${fileBasenameNoExtension}",
  10. "args": [],
  11. "stopAtEntry": false,
  12. "cwd": "${workspaceFolder}", // 工作路径
  13. "environment": [],
  14. "externalConsole": false,
  15. //"preLaunchTask": "Program", // 前置任务
  16. //"postDebugTask": "...", // 后置任务
  17. "MIMode": "gdb",
  18. "miDebuggerPath": "/Users/peixu/toolchain/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gdb", // GDB command路径
  19. "launchCompleteCommand": "None",
  20. "miDebuggerServerAddress": "localhost:2331", // GDBSerevr IP:Port
  21. "customLaunchSetupCommands": [
  22. {
  23. "text": "file /Users/peixu/Documents/Embedded/Project/21_cleaner_x/cleaner_x/sdk/source/mcu/vscode_envirment_bootloader_test/bootloader_vscode_makefile/build/bootloader_vscode_makefile.elf",
  24. "description": "Load symbol file",
  25. "ignoreFailures": false
  26. },
  27. {
  28. "text": "target remote :2331",
  29. "description": "Connet to GDB server",
  30. "ignoreFailures": false
  31. },
  32. {
  33. "text": "break main",
  34. "description": "Set breakpoints at main",
  35. "ignoreFailures": false
  36. },
  37. {
  38. "text": "monitor reset",
  39. "description": "Reset the target",
  40. "ignoreFailures": false
  41. },
  42. ]
  43. }
  44. ]
  45. }

5. 创建jlink文件

  1. % vim CommandFile.jlink
  2. h
  3. loadbin build/bootloader_vscode_makefile.bin 0x8000000
  4. r
  5. g
  6. qc
  7. % JLinkExe -device stm32f103rc -autoconnect 1 -if SWD -speed 4000 -CommandFile CommandFile.jlink

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/喵喵爱编程/article/detail/984461
推荐阅读
相关标签
  

闽ICP备14008679号