Debugging Mega2560 with GDB avr-stub and TWI / I2C devices

Can you check if this problem goes away when you use a newer avr-gcc / avr-gdb toolchain version?

Assuming you’re using Windows or Linux, you can

  1. download avr toolchain 14.1.0 at https://github.com/ZakKemble/avr-gcc-build/releases
  2. Unpack it to any folder (e.g., C:\Users\<user>\Desktop\new-toolchain)
  3. copy the file C:\Users\<user>\.platformio\packages\toolchain-atmelavr\package.json to the root of the unpacked folder
  4. Modify your platformio.ini to point to your new toolchain by adding the lines
platform_packages =
   toolchain-atmelavr@symlink://C:\Users\<user>\Desktop\new-toolchain
  1. Retry debugging