Eclipse/OCD 中的 LPC17xx 调试问题
我会尽力做到完整和具体:
NXP LPC1756 Cortex-M3。 Eclipse Helios 使用 Codesourcery ARM 工具链和 OpenOCD 进行调试。 JTAG 是 Olimex ARM-USB-OCD。操作系统是Windows 7 64位。
我相信我现在已经解决了闪存上传方面的问题。编程后,我让脚本执行 dump_image 并且转储的图像看起来大致正确。目前我遇到了验证问题,需要解决这个问题,但在这个阶段,我的 JTAG 设置似乎正在工作,并且我正在与 '1756 成功通信。
但是,当我尝试调试时遇到了问题。首先,我的 cfg 文件,从我的目标设备 cfg 文件开始:
# NXP LPC1756 Cortex-M3 with 256kB Flash and 32kB SRAM
debug_level 2
# LPC17xx chips support both JTAG and SWD transports.
# Adapt based on what transport is active.
#source [find swj-dp.tcl]
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME lpc1756
}
if { [info exists ENDIAN] } {
set _ENDIAN $ENDIAN
} else {
set _ENDIAN little
}
if { [info exists CCLK ] } {
set _CCLK $CCLK
} else {
set _CCLK 4000
}
if { [info exists CPUTAPID ] } {
set _CPUTAPID $CPUTAPID
} else {
set _CPUTAPID 0x4ba00477
}
jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
$_TARGETNAME configure -work-area-phys 0x10000000 -work-area-size 0x8000
$_TARGETNAME configure -work-area-backup 0
#$_TARGETNAME configure -endian $_ENDIAN
#$_TARGETNAME configure -variant ARMv7
#delays on reset lines
adapter_nsrst_delay 200
jtag_ntrst_delay 200
#reset_config srst_only
#reset_config trst_and_srst srst_pulls_trst
# LPC1756 has 256kB of flash memory, managed by ROM code (including a
# boot loader which verifies the flash exception table's checksum).
# flash bank <name> lpc2000 <base> <size> 0 0 <target#> <variant> <clock> [calc checksum]
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME lpc2000 0x0 0x40000 0 0 $_TARGETNAME \
lpc1700 $_CCLK calc_checksum
# Run with *real slow* clock by default since the
# boot rom could have been playing with the PLL, so
# we have no idea what clock the target is running at.
jtag_khz 50
#$_TARGETNAME configure -event reset-init {
# Do not remap 0x0000-0x0020 to anything but the flash (i.e. select
# "User Flash Mode" where interrupt vectors are _not_ remapped,
# and reside in flash instead).
#
# See Table 612. Memory Mapping Control register (MEMMAP - 0x400F C040) bit description
# Bit Symbol Value Description Reset
# value
# 0 MAP Memory map control. 0
# 0 Boot mode. A portion of the Boot ROM is mapped to address 0.
# 1 User mode. The on-chip Flash memory is mapped to address 0.
# 31:1 - Reserved. The value read from a reserved bit is not defined. NA
#
# http://ics.nxp.com/support/documents/microcontrollers/?scope=LPC1768&type=user
#MEMMAP - set user mode
# mww 0x400FC040 0x01
#}
$_TARGETNAME configure -event reset-init {
# Force target into ARM state
#armv4_5 core_state arm
#do not remap 0x0000-0x0020 to anything but the flash
#mwb 0xE01FC040 0x01
mwb 0x400FC040 0x01
#mwb 0xE000ED08 0x00
}
现在,我的调试 cfg 文件:
#define our ports
#telnet_port 4444
#gdb_port 3333
#commands specific to the Olimex ARM-USB-OCD
interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG A"
ft2232_layout "olimex-jtag"
ft2232_vid_pid 0x15BA 0x0003
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME lpc1756
}
if { [info exists CPUTAPID ] } {
set _CPUTAPID $CPUTAPID
} else {
set _CPUTAPID 0x4ba00477
}
if { [info exists CCLK ] } {
set _CCLK $CCLK
} else {
set _CCLK 4000
}
if { [info exists ENDIAN ] } {
set _ENDIAN $ENDIAN
} else {
set _ENDIAN little
}
debug_level 3
jtag_khz 100
#delays on reset lines
adapter_nsrst_delay 200
jtag_ntrst_delay 200
#reset_config srst_only
reset_config trst_and_srst srst_pulls_trst
jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
#target cortex_m3 little 0 armv7
set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
#
$_TARGETNAME configure -work-area-phys 0x10000000 -work-area-size 0x8000
$_TARGETNAME configure -work-area-backup 0
#working_area 0 0x10000000 0x8000 nobackup
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME lpc2000 0x0 0x40000 0 0 $_TARGETNAME lpc1700 $_CCLK calc_checksum
$_TARGETNAME configure -event reset-init {
# Force target into ARM state
#armv4_5 core_state arm
#do not remap 0x0000-0x0020 to anything but the flash
mwb 0xE01FC040 0x01
mwb 0x400FC040 0x01
mwb 0xE000ED08 0x00
}
gdb_flash_program enable
init
#fast enable
jtag_khz 100
debug_level 1
在 Eclipse 中,我使用标志调用此工具:
-f arm-usb-ocd.cfg -f debug.cfg
这似乎工作正常(至少我似乎没有在控制台)。现在是我遇到问题的部分:
我在 Eclipse 中的 GDB 硬件调试下创建了一个调试配置(运行 > 调试配置...)。相关参数是:(
Main:
C/C++ Application: output\project_UT1.elf
Debugger:
C:\CodeSourcery\bin\arm-none-eabi-gdb.exe
Startup:
Reset and Delay checked (2-seconds)
Halt checked
Initialization commands:
target remote localhost:3333
monitor flash device = LPC1756
monitor flash download = 1
monitor flash breakpoints = 1
monitor endian little
monitor speed 100
monitor speed auto
monitor reset halt
monitor writeu32 0x400FC040 = 0x00000001
monitor clrbp
Load image: not checked
Load symbols: checked
Runtime options: none of Set program counter, set breakpoint or resume checked
Run commands:
monitor reg sp = 0x10001ffc
monitor reg pc = 0x00001278
continue
Using "Standard GDB Hardware Debugging Launcher"
注意:我将电脑设置为0x00001278,因为这是我的Reset_Handler的地址;我知道它应该是0x00000004,但我正在试验;当它是0x00000004时,我遇到了同样的问题......
)我尝试使用此设置进行调试,但收到一条消息,提示“GDB 硬件调试已暂停”,PC 似乎位于引导加载程序 0x1FFF0080 和我的调试器似乎不再连接。在控制台中,我看到如下内容:
.
.
.
target remote localhost:3333
0x1fff0080 in ?? ()
.
.
.
continue
Program received signal SIGINT, Interrupt.
0x1fff0080 in ?? ()
例如,在反汇编窗口中,我可以搜索并找到诸如“main”或“Reset_Handler”之类的内容,但反汇编全是“movs r0, r0”——基本上全是零。我无法单步执行(显然,暂停......)即使在0x1fff0080,它也显示“”movs r0,r0”。我似乎能够读取CPU寄存器(例如sp显示0x10001ffc,pc显示0x1fff0081,所以也许 JTAG 接口还没有死...)
我的闪存图像应该位于 0x00000000 (即当我执行 dump_image 时,设备似乎已被编程并且向量表条目看起来正确。如果是这样,我该如何执行明显成功的“dump+image”? “?
但是,即使在没有连接 JTAG 的情况下插入设备也不会产生任何操作。我看过与 LPC1768 类似的帖子,但没有找到任何适合我的东西。非常感谢任何意见或建议。
I'll try to be complete and specific:
NXP LPC1756 Cortex-M3. Eclipse Helios using Codesourcery ARM toolchain along with OpenOCD for debugging. JTAG is Olimex ARM-USB-OCD. OS is Windows 7 64-bit.
I believe I have the flash-upload side of things settled now. After programming I have the script perform a dump_image and the dumped image looks to be roughly correct. At the moment I have verification issues and need to sort that out but at this stage, it appears my JTAG setup is working and I am successfully communicating with the '1756.
However, when I try to debug I run into issues. First, my cfg files, starting with my target device cfg file:
# NXP LPC1756 Cortex-M3 with 256kB Flash and 32kB SRAM
debug_level 2
# LPC17xx chips support both JTAG and SWD transports.
# Adapt based on what transport is active.
#source [find swj-dp.tcl]
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME lpc1756
}
if { [info exists ENDIAN] } {
set _ENDIAN $ENDIAN
} else {
set _ENDIAN little
}
if { [info exists CCLK ] } {
set _CCLK $CCLK
} else {
set _CCLK 4000
}
if { [info exists CPUTAPID ] } {
set _CPUTAPID $CPUTAPID
} else {
set _CPUTAPID 0x4ba00477
}
jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
$_TARGETNAME configure -work-area-phys 0x10000000 -work-area-size 0x8000
$_TARGETNAME configure -work-area-backup 0
#$_TARGETNAME configure -endian $_ENDIAN
#$_TARGETNAME configure -variant ARMv7
#delays on reset lines
adapter_nsrst_delay 200
jtag_ntrst_delay 200
#reset_config srst_only
#reset_config trst_and_srst srst_pulls_trst
# LPC1756 has 256kB of flash memory, managed by ROM code (including a
# boot loader which verifies the flash exception table's checksum).
# flash bank <name> lpc2000 <base> <size> 0 0 <target#> <variant> <clock> [calc checksum]
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME lpc2000 0x0 0x40000 0 0 $_TARGETNAME \
lpc1700 $_CCLK calc_checksum
# Run with *real slow* clock by default since the
# boot rom could have been playing with the PLL, so
# we have no idea what clock the target is running at.
jtag_khz 50
#$_TARGETNAME configure -event reset-init {
# Do not remap 0x0000-0x0020 to anything but the flash (i.e. select
# "User Flash Mode" where interrupt vectors are _not_ remapped,
# and reside in flash instead).
#
# See Table 612. Memory Mapping Control register (MEMMAP - 0x400F C040) bit description
# Bit Symbol Value Description Reset
# value
# 0 MAP Memory map control. 0
# 0 Boot mode. A portion of the Boot ROM is mapped to address 0.
# 1 User mode. The on-chip Flash memory is mapped to address 0.
# 31:1 - Reserved. The value read from a reserved bit is not defined. NA
#
# http://ics.nxp.com/support/documents/microcontrollers/?scope=LPC1768&type=user
#MEMMAP - set user mode
# mww 0x400FC040 0x01
#}
$_TARGETNAME configure -event reset-init {
# Force target into ARM state
#armv4_5 core_state arm
#do not remap 0x0000-0x0020 to anything but the flash
#mwb 0xE01FC040 0x01
mwb 0x400FC040 0x01
#mwb 0xE000ED08 0x00
}
Now, my debug cfg file:
#define our ports
#telnet_port 4444
#gdb_port 3333
#commands specific to the Olimex ARM-USB-OCD
interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG A"
ft2232_layout "olimex-jtag"
ft2232_vid_pid 0x15BA 0x0003
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME lpc1756
}
if { [info exists CPUTAPID ] } {
set _CPUTAPID $CPUTAPID
} else {
set _CPUTAPID 0x4ba00477
}
if { [info exists CCLK ] } {
set _CCLK $CCLK
} else {
set _CCLK 4000
}
if { [info exists ENDIAN ] } {
set _ENDIAN $ENDIAN
} else {
set _ENDIAN little
}
debug_level 3
jtag_khz 100
#delays on reset lines
adapter_nsrst_delay 200
jtag_ntrst_delay 200
#reset_config srst_only
reset_config trst_and_srst srst_pulls_trst
jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
#target cortex_m3 little 0 armv7
set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
#
$_TARGETNAME configure -work-area-phys 0x10000000 -work-area-size 0x8000
$_TARGETNAME configure -work-area-backup 0
#working_area 0 0x10000000 0x8000 nobackup
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME lpc2000 0x0 0x40000 0 0 $_TARGETNAME lpc1700 $_CCLK calc_checksum
$_TARGETNAME configure -event reset-init {
# Force target into ARM state
#armv4_5 core_state arm
#do not remap 0x0000-0x0020 to anything but the flash
mwb 0xE01FC040 0x01
mwb 0x400FC040 0x01
mwb 0xE000ED08 0x00
}
gdb_flash_program enable
init
#fast enable
jtag_khz 100
debug_level 1
In Eclipse, I invoke this tool with the flags:
-f arm-usb-ocd.cfg -f debug.cfg
This appears to work fine (at least I don't seem to get any errors in the console). Now comes the part where I have issues:
I have created a debug configuration in Eclipse (Run > Debug Configurations...) under GDB Hardware Debugging. Relevant parameters are:
Main:
C/C++ Application: output\project_UT1.elf
Debugger:
C:\CodeSourcery\bin\arm-none-eabi-gdb.exe
Startup:
Reset and Delay checked (2-seconds)
Halt checked
Initialization commands:
target remote localhost:3333
monitor flash device = LPC1756
monitor flash download = 1
monitor flash breakpoints = 1
monitor endian little
monitor speed 100
monitor speed auto
monitor reset halt
monitor writeu32 0x400FC040 = 0x00000001
monitor clrbp
Load image: not checked
Load symbols: checked
Runtime options: none of Set program counter, set breakpoint or resume checked
Run commands:
monitor reg sp = 0x10001ffc
monitor reg pc = 0x00001278
continue
Using "Standard GDB Hardware Debugging Launcher"
(NOTE: I've got the pc set to 0x00001278 as that was the address of my Reset_Handler; I know it should be 0x00000004 but I was experimenting; when it was 0x00000004 I got the same problems...)
When I attempt to debug using this set up I get a message saying "GDB Hardware Debugging Suspended", the PC appears to be at the bootloader 0x1FFF0080 and my debugger no longer seems to be connected. In the console I see stuff like:
.
.
.
target remote localhost:3333
0x1fff0080 in ?? ()
.
.
.
continue
Program received signal SIGINT, Interrupt.
0x1fff0080 in ?? ()
For example, in the disassembly window I can search for and find things like "main" or "Reset_Handler" but the disassembly is all "movs r0, r0" -- all zeros, basically. I can't single step (obviously, suspended...) Even at 0x1fff0080 it's displaying ""movs r0, r0". I do seem to be able to read the CPU registers (e.g. the sp shows 0x10001ffc and the pc shows 0x1fff0081 so maybe the JTAG interface isn't dead...)
My flashed image is supposed to be at 0x00000000 (i.e. the vector table there). When I do a dump_image, it appears the device is programmed and the vector table entries look right. Code protection? If so, how can I do an apparently successful "dump+image"?
However, even plugging the device in without the JTAG connected results in no operation. I've seen posts similar to this for the LPC1768 but haven't found anything that works for me. Any advice or suggestions greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
debug.cfg
中的reset-init
处理程序执行了太多无用的mwb
指令。您应该只执行mwb 0x400FC40 1
,因为这会将 0x0000 处的向量表从 ROM 重新映射到闪存。在调试器配置中,您执行
monitor Resethalt
- 将其更改为monitor Reset init
。然后它会显示
加载图像:未检查
:您真的忘记启用加载了吗?这将导致 gdb 不将您的图像加载到 flash。The
reset-init
handler in yourdebug.cfg
does too many uselessmwb
instructions. You should only do themwb 0x400FC40 1
as this will remap the vector table at 0x0000 from ROM to Flash.In your debugger config, you do
monitor reset halt
- change that tomonitor reset init
.Then it reads
Load image: not checked
: Did you really forget to enable loading? That wolud cause gdb to not load your image to flash.