用JLink和GDB读取cortexm0单片机外围寄存器

用JLink和GDB读取cortexm0单片机外围寄存器,gdb,cortex-m,peripherals,Gdb,Cortex M,Peripherals,我试图使用GDB读取MCU ADC寄存器,但我似乎找不到它是如何完成的 在gdb中使用x\10x 0x40012708只会返回零,就像我尝试读取的任何内存映射外围寄存器一样 这有可能吗?如果是,是如何做到的 谢谢 我建议首先验证您的设置是否正常。 例如,您可以尝试读取所有Cortex-M0处理器上的CPUID寄存器-请参阅本手册的第4.3节 它位于地址0xE000ED00,应包含值0x410CC200。 如果你能读懂,这将是一个好兆头 您可能应该首先尝试使用J-Link commander,然后

我试图使用GDB读取MCU ADC寄存器,但我似乎找不到它是如何完成的

gdb
中使用
x\10x 0x40012708
只会返回零,就像我尝试读取的任何内存映射外围寄存器一样

这有可能吗?如果是,是如何做到的


谢谢

我建议首先验证您的设置是否正常。 例如,您可以尝试读取所有Cortex-M0处理器上的CPUID寄存器-请参阅本手册的第4.3节

它位于地址0xE000ED00,应包含值0x410CC200。 如果你能读懂,这将是一个好兆头

您可能应该首先尝试使用J-Link commander,然后使用GDB服务器和GDB。此后,我使用LPC1114/301 Cortex-M0在Olimex板上运行了该过程。我使用的是J-Link软件和arm none eabi gdb版本7.10.1.20151217-cvs,它是arm Cortex-M处理器包的一部分

使用以下选项启动JLink.exe:

jlink.exe -if SWD -speed 4000  -AutoConnect 1 -device Cortex-M0
您应该看到类似的内容:

SEGGER J-Link Commander V5.10n (Compiled Feb 19 2016 18:39:46)
DLL version V5.10n, compiled Feb 19 2016 18:39:11<br/>
Connecting to J-Link via USB...O.K.
Firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46
Hardware version: V8.00
S/N: [My J-Link EDU Serial Number]
License(s): FlashBP, GDB
OEM: SEGGER-EDU
Emulator has Trace capability
VTref = 3.313V
Device "CORTEX-M0" selected.

Found SWD-DP with ID 0x0BB11477
Found Cortex-M0 r0p0, Little endian.
FPUnit: 4 code (BP) slots and 0 literal slots
CoreSight components:
ROMTbl 0 @ E00FF000
ROMTbl 0 [0]: FFF0F000, CID: B105E00D, PID: 000BB008 SCS
ROMTbl 0 [1]: FFF02000, CID: B105E00D, PID: 000BB00A DWT
ROMTbl 0 [2]: FFF03000, CID: B105E00D, PID: 000BB00B FPB
Cortex-M0 identified.
J-Link>
您应该得到:

E000ED00 = 410CC200
如果是这样的话,我会说你的J-Link/Cortex-M0设置可能是正常的。我们现在可以验证GDB服务器和GDB是否工作正常

使用以下选项启动JLinkGDBServerCL.exe:
JLinkGDBServerCL.exe-如果是SWD-速度4000-设备Cortex-M0

SEGGER J-Link GDB服务器V5.10n命令行版本 JLinkARM.dll V5.10n(dll于2016年2月19日18:39:11编译)

保持GDB服务器运行,并在其他Windows控制台会话中启动GDB:

arm-none-eabi-gdb
GNU gdb (GNU Tools for ARM Embedded Processors) 7.10.1.20151217-cvs
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
如果您再次获得0x410cc200,您的J-Link/Cortex-m0/GDB服务器/GDB设置应该正常工作,现在您应该使用以下命令再次尝试读取ADC寄存器:

x/1xw 0x40012708
如果您能够读取CPUID寄存器,但不能读取ADC寄存器,并且如果ADC寄存器的地址正确,我现在就无法解释这种行为-了解您使用的MCU的确切品牌/型号当然可以进一步帮助

请注意,从现在起,您应该指定MCU的确切型号作为-device J-Link Commander/GDB服务器选项的参数,而不是Cortex-M0。您可以通过输入命令获取列表?在J-Link指挥官命令提示符下

arm-none-eabi-gdb
GNU gdb (GNU Tools for ARM Embedded Processors) 7.10.1.20151217-cvs
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target remote localhost:2331
Remote debugging using localhost:2331
0xfffffffe in ?? ()
(gdb) monitor halt
(gdb) monitor reset
Resetting target
(gdb) x/1xw  0xE000ED00
0xe000ed00:     0x410cc200
(gdb)
x/1xw 0x40012708