2

I use openocd, arm-none-eabi-gdb and STLinkV2-1 to debug STM32F411CE chip. I use also LL and CMSIS libraries. The problem is that to check the value of e.g. a pin I have to look up in the datasheet the register boundary addresses for the specific GPIO port (e.g. 0x4002 0000 - 0x4002 03FF for GPIOA) and then check whats the offset for the register I want to read (e.g. 0x10 for GPIOx_IDR). Then to check a specific bit I have to check once more in datasheet what's the offset for it in the register and calculate from hex value the value of the bit. So for gdb it will be:

(gdb) x 0x40020010
0x40020010: 0xa8280000 

Is there an easier approach to get the value, by typing something like that:

get bit value in register GPIOA IDR

I couldn't find anything in openocd datasheet or in the Internet which answers my question.

K. Koovalsky
  • 596
  • 4
  • 17
  • 2
    looking at the chip docs like you did is the easiest way IMO...you could take that mass of headers and write a tiny function unsigned int fun ( void ) { return(GPIOA_IDR); } compile then disassemble and it will show. openocd is not connected to CMSIS (thankfully) it is its own deal, would be a nightmare if such a thing were to happen with all the possible chips it is able to connect to. the telnet/gdb interfaces are documented and you can easily write your own program that interfaces them and any tables you wish to create. – old_timer Feb 04 '18 at 15:47

1 Answers1

4

I have found a solution.

CMSIS defines all the peripherals, so we can make use of it:

  1. Compile the project with -gdwarf-4 -g3 gcc flags to use preprocessor macros within gdb
  2. Run gdb:

    arm-none-eabi-gdb -nw program.elf
    
  3. Make use of CMSIS definitions: to check e.g. 3rd pin on PORTB used as input:

    (gdb) p (GPIOB->IDR & GPIO_BSRR_BS_3)
    
K. Koovalsky
  • 596
  • 4
  • 17