zoukankan      html  css  js  c++  java
  • windows下STM32开发环境的搭建

    一、概述

    1、说明

      笔者已经写了一篇Linux下STM32开发环境的搭建 ,这两篇文章的最区别在于开发环境所处的系统平台不一样,而其实这个区别对于开发环境的搭建其实影响不大,制作局部上的操作上发生了改变。鉴于此,本文没有必要对windows下搭建STM32开发环境的详细过程进行阐述,读者可以结合Linux下STM32开发环境的搭建和本文进行windows下STM32开发环境的搭建。

    2、开发环境描述

    硬件开发板:野火STM32开发板

    Cortex-M3型号:STM32F103VET6

    下载器与调试接口:Jlink + JTAG

    操作系统:windows XP

    集成开发环境平台:eclipse IDE for C/C++ developers

    交叉编译链:arm-none-eabi-gcc

    调试服务器:JLink GDB Server

    二、搭建步骤

    1、安装eclipse IDE for C/C++ developers

      安装之后,Eclipse还不能正常运行,因为Eclipse要运行在Java虚拟机上,所以还需要安装JDK或者JRE,以创建Java虚拟机,给Eclipse的运行提供一个环境。

    2、安装JDK

      参考安装JDK,安装JDK成功之后,重新启动Eclipse就可以看到能够成功运行了。

    3、安装交叉编译链arm-none-eabi-gcc

    • 双击安装,注意在安装的最后选择不要把安装路径添加到环境变量中(否则将会把安装路径添加到用户的环境变量PATH中,当将来安装其他版本的工具链时,有可能发生名字冲突)

    • 测试安装是否成功

      参考:Toolchain install

    4、安装编译工具(make & rm)

      make 和 rm 是Linux和OS X下的工具,windows上没有这样的工具,但是使用交叉编译链时需要调用Makefile脚本,其中使用了这些工具。所以,在windows上还需要安装这样的工具。

    • 添加此编译工具的目录到Eclipse的环境变量中,Eclipse的环境变量都在选项Window->Preference中

    The echo command

    The archive also contains an executable for the echo command. It is not mandatory for the build to succeed, but it is recommended to have it in the build path, to avoid an annoying CDT bug, that triggers an error during the first build of a new project, claiming that ‘Program “gcc” not found in PATH’.

    参考:Build tools (make & rm) on Windows

    5、安装JLink软件

      JLink软件包含:GDB Server、JLink驱动等等工具

    注意:JLinkGDBServer.exe、JLinkGDBServerCL.exe其实是相同的工具,都是GDB调试服务器。区别在于前者是图形界面,而后者是命令行界面。在windows上使用的话,推荐使用命令行模式的工具。

    6、安装GNU ARM Eclipse插件包

      此插件包包含了6个插件,能实现不同的功能。其中第一个插件是为了使Eclipse支持交叉编译,最后的两个是硬件调试的支持。

      参考:Plug-ins install

    7、新建一个LED_Test工程并配置、编译

      参考1:Linux下STM32开发环境的搭建

      参考2:STM32开源开发环境的搭建

      另外,倘若交叉编译工具链找不到的话,可以看看下边的选项是否配置正确

      倘若想要生成反汇编、Map文件等,可以在Build Steps中添加命令

    三、使用GDB Hardware Debugging进行硬件调试

    1、安装GDB调试插件--C/C++ GDB HardWare Debugging

    • Eclipse-->Help-->Install new software-->ADD

    名字:CDT Juno

    地址:http://download.eclipse.org/tools/cdt/releases/juno

    • 选中插件C/C++ GDB HardWare Debugging

    • 一路Next,完成安装

    2、设置Eclipse调试环境并启动调试

      参考:Linux下STM32开发环境的搭建

    四、使用GDB SEGGER J-Link Debugging调试

    1、GDB SEGGER J-Link Debugging优于GDB Hardware Debugging

    • transparent integration of the GDB server, automatically started/stopped for each debug session
    • advanced graphical user interface to configure most GDB client and GDB server SEGGER specific options
    • transparent integration of the semihosting and Serial Wire Viewer (SWV) window as a standard Eclipse console
    • a functional restart button, to reset the target and restart the debugging session, without having to rewrite the executable image
    • direct use of project toolchain definition (prefix, suffix, path) to simplify configuration of the GDB client
    • macro based J-Link folder path definition, for simplified management of the GDB server location when upgrades to new SEGGER versions are released
    • support for SWO registers configuration to match a given system clock frequency

                        参考:The J-Link hardware debugging Eclipse plug-in

    2、安装GDB SEGGER J-Link Debugging插件

      在我们安装GNU ARM Eclipse插件包的时候,已经将这个插件安装了

    3、配置Eclipse调试环境并启动调试

    1> 将Jlink软件的安装目录添加到Eclipse的环境变量中,此环境变量再接下来的配置中会用到

    2> 设置Debug Configurations

    3> 启动调试

    本章参考:The J-Link hardware debugging Eclipse plug-in

    五、直接使用arm-none-eabi-gdb进行调试

    1、创建系统环境变量HOME

      变量的值为当前登陆用户目录,例如管理员目录:C:Documents and SettingsAdministrator

    2、在用户目录中创建.gdbinit文件

      在winows上创建以“.”开头的文件方法是在Windowx下创建以点开头的.hatccess文件。该文件的内容为:

    set auto-load safe-path /

    3、在工程的Debug目录中创建.gdbinit文件

    target remote :2331
    set mem inaccessible-by-default off
    monitor speed auto
    monitor endian little
    monitor reset
    monitor flash device = STM32F103ZE
    monitor flash breakpoints = 1
    monitor flash download = 1
    load
    monitor reg sp = (0x08000000)
    monitor reg pc = (0x08000004)
    break ResetHandler
    break main
    continue

    4、启动JlinkGDBServerCL

      进入Jlink软件的安装目录,启动JlinkGDBServerCL

    5、启动调试

      打开命令终端(win徽标+R-->cmd),进入工程的Debug目录,输入调试命令

      调试结果如下:

      此时JlinkGDBServerCL的情况如下:

  • 相关阅读:
    ajax同步和异步
    vue组件
    type of的返回值有哪些
    git配置
    vue 获取时间戳对象转换为日期格式
    JavaScript运行机制
    单页面开发首屏加载慢,白屏如何解决
    单页面和多页面开发的优缺点
    【安全测试】sql注入
    【Python学习一】使用Python+selenium实现第一个自动化测试脚本
  • 原文地址:https://www.cnblogs.com/amanlikethis/p/3816790.html
Copyright © 2011-2022 走看看