How to access floating point registers in Cortex-M4F via JLink?

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • How to access floating point registers in Cortex-M4F via JLink?

    Hi There,

    I have been using JLink to connect to my Freescale board (TWR-K70F120M) for some time. It works fine but I couldn't find a way to access FP registers in my board. So I wonder whether the current JLink GDB server can access FP registers in cortex-m4. If not, when will the feature be done?

    The software information is as below:


    SEGGER J-Link GDB Server V4.41g (beta)

    JLinkARM.dll V4.41g (DLL compiled Jan 27 2012 19:11:21)

    The server has been started with the following settings:
    ---Server related settings---
    GDBInit file: none
    Listening port: 2331
    SWO thread listening port: 2332
    Accept remote connection: yes
    Logfile: off
    Verify download: off
    Init regs on start: on
    Silent mode: off
    Single run mode: off
    ---J-Link related settings---
    J-Link script: none
    Target interface: JTAG
    Host interface: USB
    Target endian: big
    Target interface speed: 5kHz

    Waiting for J-Link connection...
    J-Link is connected.
    Firmware: J-Link ARM V8 compiled Feb 8 2012 14:30:39
    Hardware: V8.00
    S/N: 68000222
    OEM: J-Link-CE
    Listening on TCP/IP port 2331
    Waiting for GDB connection...

    Thanks.

    Terry
  • For accessing the FP registers, I mean I can't view FP registers like s0, s1 in GDB. After I connect to JLink GDB server via command "target remote localhost:2331", the gdb command "monitor regs" only return the following registers:


    R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
    R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
    R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
    R12= 00000000, R13= 00000000, MSP= 00000000, PSP= 00000000
    R14(LR) = 00000000, R15(PC) = 00000000
    XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
    CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00

    There isn't any FP register info. GDB command like "i r s0" also doesn't work. I know that some work must be done in GDB in order to view FP registers. But I think this relies on whether the JLink GDB server can retrieve FP registers info in board.
  • I know this thread is rather old, but for the benefit of future readers, I figured I would add my experiences.

    I also wanted to access the FPU registers on a Cortex M4F (STM32F4 specifically), and found that the JLink would not expose them.

    Since the ARM debug registers (see ARMv7-M Architecture Reference Manual, Section C1.6) are accessible through the JLink, they can be queried directly to read the desired registers. Simply write the register number to read to the Debug Core Register Selection Register (DCRSR) and then read its contents from the Debug Core Register Data Register (DCRDR). This worked well from within GDB, and can easily be scripted.

    You can find a Python script I wrote at github.com/prattmic/F4OS/blob/master/tools/fpu_regs.py. Once added to GDB (in GDB, run 'source fpu-regs.py'), it adds the 'info fpu-regs' command, which behaves just like 'info regs'. With no argument, it will print s0-s31 and the FPSCR. Using an argument, only a specific register can printed.

    The primary downside with the script is that the FPU registers are not first class registers; eg. GDB does not recognize them in its register map, and they can't be set like normal registers ('set $r0 = 5'). Presumably, a man-in-the-middle GDB server could inject support for these registers into transactions between GDB and the JLink GDB server, but this would require considerably more work.

    Hopefully this will help someone out, and hopefully Segger will add official support soon!
  • Hi,

    We added FPU registers support for Cortex-M4 to GDB Server in version 4.59b (downloadable at: segger.com/jlink-software-beta-version.html).
    The registers can be shown with "info float" or "info all" and set like normal registers with "set $s0 = 5"

    Best regards
    Johannes
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.