This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Setting watchpoint on nRF52832DK with GDB

Hi,

I've recently come across a problem where in some cases my device's memory gets trashed.

Ideally I'd be able to set a watchpoint on a memory location so that I could see what the offending code is - and it would appear that the nRF52832 has all the debug hardware needed to do this.

I'm using the latest JLinkGDBServer with the latest GCC/GDB on Linux, but adding a watchpoint with watch causes it to fall back to single-stepping and checking every single instruction - which is so slow that I believe the watchdog resets will kick in.

Am I missing something? Is there some way to enable proper hardware watchpoints?

thanks!

  • Good morning Gordon,

    Did you try to use awatch <var> instead of watch <var>? I'd recommend to disable the WDT when debugging, as the debugger will halt the CPU, but not any peripherals in the background. This will cause the WDT to reset your system after the bkpt has reached.

    Cheers, Håkon

  • Hi, thanks - I tried awatch before and it said Expression cannot be implemented with read/access watchpoint.. I've actually just tried this again and found that awatch array[5] and awatch &array[5] fails, but awatch array works, as does awatch *(uint32_t*)0x20003898 so I guess I was just using it wrong - thanks! Interestingly when I use normal watch with the different expressions it says Hardware watchpoint 11 as opposed to Watchpoint 11 when I manually specify the address. Do you have a link for info on disabling the WDT in GDB? That always made things very painful and I assumed it wasn't something I could do anything about.

  • Hi Gordon! Forgot about this feature on nRF52, but it has the option to pause the WDT when the CPU is halted. This is field C (bit 3) in the NRF_WDT->CONFIG register, and the reset value is '0', so make sure this field is set to '0', and the WDT shouldn't cause any issues when debugging.

  • thanks! Sorry - I'd expected 'convert to answer' to pull the comment and all comments after it. This is great news - so the WDT gets set by softdevice init, so I could maybe add an #ifdef DEBUG macro in my code that removed it for debug builds - or could just do it in GDB manually.

Related