实验了两个晚上,终于把Eclipse+YAGARTO+JLINK对STM32编译和调试搞定了,
现在实现了JLINK仿真功能,可以作为IAR、MDK的另一种选择了吧。下面是步骤:
1. 下载安装YAGARTO Tools和YAGARTO GNU ARM toolchain,http://www.yagarto.de/
2. 下载Eclipse和JRE环境,先安装JRE,为了提供Eclipse的运行环境,Eclipse可以运行后下载安装CDT(使Eclipse支持c,c++语言),这个要等挺长时间,请耐心等待安装CDT,我这个破笔记本大概用了1个小时。。。
3. 用Eclipse打开附件中的提供的参考工程,执行Project-Build Project,可以看到顺利编译通过,然后打开GDB Server,我用的是Segger的V4.14h,选择Little endian,Cache reads,Show log window选项。
4. 在Eclipse中选择Window-Open Perspective-Debug,然后点击那个小虫子旁边的小钮弹出一个菜单,选择Debug Configurations,然后在弹出的窗口中选择GDB Hardware Debugger后,点击New Launch configuration,选择c/c++ Application的test_rom.elf,底部选择Using Standard GDB Debugging Launcher,
选择Debugger标签,GDB Command填入arm-none-eabi-gdb,不要勾选Use remote target,然后startup标签的第一个文本框填入
# connect to the J-Link gdb server
target remote localhost:2331
# Enable flash download and flash breakpoints.
# Flash download and flash breakpoints are features of
# the J-Link software which require separate licenses
# from SEGGER.
# Select flash device
monitor flash device = STM32F103ZE
# Enable FlashDL and FlashBPs
monitor flash download = 1
monitor flash breakpoints = 1
# Clear all pendig breakpoints
monitor clrbp
# Set gdb server to little endian
monitor endian little
# Set JTAG speed to 5 kHz
monitor speed 5
# Reset the target
monitor reset
monitor sleep 100
# Set JTAG speed in khz
monitor speed auto
# Vector table placed in Flash
monitor writeu32 0xE000ED08 = 0x00000000
Run Commands中填入:
monitor reg r13 = (0x00000000)
monitor reg pc = (0x00000004)
#break ResetHandler
break SystemInit
break main
continue
请不要勾选Runtime Options中的选项。然后点击Apply,点击Debug开始调试,请确保GDB Server已经打开,并且连接正常。
基本上就这样了,这里的例程是点亮两个灯,哦,对了,我用的板子是自己做的,请根据自己的板子修改LED的管脚定义。
可以添加断点观察程序的运行情况。
这个工程里的启动文件用的是ST库gcc_ride7里的startup_stm32f10x_hd.S,因为目标MCU是F103ZET6,ldscript文件用的也是ST库里给gcc_ride7带的链接文件,稍微修改下。
比较郁闷的是Makefile文件,没有找到一个格式好的来进行修改,还请高手指点一二啊。对Makefile我只能看懂,却不会写。。。应该说工程里德这个Makefile还有小bug,你拿来用过了就知道,我先不说。。。
WorkSpace_Eclipse.rarourdev_641775GFK0CN.rar(文件大小:2.96M) (原文件名:WorkSpace_Eclipse.rar)
原文出至:http://www.amobbs.com/forum.php?mod=viewthread&tid=4755164