嵌入式


vscode嵌入式开发

<h3>参考</h3> <p><a href="http://openocd.org/doc/pdf/openocd.pdf">http://openocd.org/doc/pdf/openocd.pdf</a></p> <p><a href="https://zhuanlan.zhihu.com/p/41517198">https://zhuanlan.zhihu.com/p/41517198</a></p> <p><a href="http://www.wujique.com/2018/03/15/可替代jlink的stm32轻量级调试器-cmsis-dap/">http://www.wujique.com/2018/03/15/可替代jlink的stm32轻量级调试器-cmsis-dap/</a></p> <p><a href="https://mcuoneclipse.com/2015/03/22/openocdcmsis-dap-debugging-with-eclipse-and-without-an-ide/">https://mcuoneclipse.com/2015/03/22/openocdcmsis-dap-debugging-with-eclipse-and-without-an-ide/</a></p> <h3>工具下载</h3> <p><a href="http://gnutoolchains.com/arm-eabi/openocd/">http://gnutoolchains.com/arm-eabi/openocd/</a></p> <p><a href="https://www.cnblogs.com/shangdawei/p/4751111.html">https://www.cnblogs.com/shangdawei/p/4751111.html</a></p> <h3>安装</h3> <h4>macos</h4> <p><a href="https://www.jianshu.com/p/ed7203324ac6">https://www.jianshu.com/p/ed7203324ac6</a></p> <ul> <li><code>brew cask install gcc-arm-embedded</code></li> <li><code>brew install openocd</code></li> <li><code>brew install stlink</code></li> </ul> <h4>windows</h4> <p><a href="https://zhuanlan.zhihu.com/p/61519415">https://zhuanlan.zhihu.com/p/61519415</a></p> <p>brew install homebrew/cask-drivers/segger-jlink</p> <h4>openocd配置文件</h4> <ul> <li>openocd.cfg</li> </ul> <pre><code> set FLASH_SIZE 0x20000 # 选择jlink source [find interface/cmsis-dap.cfg] # swd transport select swd # 选择目标芯片 source [find target/stm32f1x.cfg]</code></pre> <p>stm32f4</p> <pre><code># Configuration for EFM32 boards with on-board SEGGER J-Link # # Tested with Tiny, Giant and Zero Gecko Starter Kit. # source [find interface/stlink-v2.cfg] transport select hla_swd adapter_khz 1000 source [find target/stm32f4x.cfg]</code></pre> <h3>vscode环境配置</h3> <ul> <li>配置task 按F1后选择configure task,修改tasks.json内容</li> </ul> <pre><code>{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "type": "shell", "label": "build", "command": "mbed.exe", "args": [ "compile", "--source", "../mbed-os", "--source", "." ], "group": { "kind": "build", "isDefault": true } }, { "type": "shell", "label": "openocd", "command": "openocd" } ] }</code></pre> <p><strong><code>c_cpp_properties.json</code></strong></p> <pre><code>{ "configurations": [ { "includePath": [ "../mbed-os" ], "cStandard": "c99", "cppStandard": "c++11" } ], "version": 4 }</code></pre> <ul> <li>配置调试</li> </ul> <pre><code>{ // 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", "configurations": [ { "name": "(gdb) 启动", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/BUILD/NUCLEO_F103RB/GCC_ARM/mbed-os.elf", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "miDebuggerPath": "C:\\Program Files (x86)\\GNU Tools ARM Embedded\\8 2018-q4-major\\bin\\arm-none-eabi-gdb.exe", "setupCommands": [ { "description": "选择调试文件(.elf)到gdb", "text": "file D:/projects/blink-test/BUILD/NUCLEO_F103RB/GCC_ARM/mbed-os.elf", //此处不能使用${workspaceFolder},因为windows下分隔符是'\\',gdb识别不出来 "ignoreFailures": false }, { "description": "连接GDB Server", "text": "target remote localhost:3333", "ignoreFailures": false }, { "description": "Reset MCU", "text": "monitor reset", "ignoreFailures": false }, { "description": "Halt", "text": "monitor halt", "ignoreFailures": false }, { "description":"下载代码到MCU", "text": "load" , "ignoreFailures": false } ], "preLaunchTask": "build", } ] }</code></pre>

页面列表

ITEM_HTML