Changes to HardwareSerial.h no longer working after boards update 1.6.21

I have a project where it's important for me to increase the size of the hardware serial buffers on my Arduino Mega 2560 board, else I lose data coming in from my attached Bluetooth module.

In the past I have fixed this by editing the following file:

(install location)/hardware/arduino/avr/cores/arduino/HardwareSerial.h

Inside that file, I edit these lines:


And I change them to 128 and 256, respectively, and then when I run my Arduino sketch, everything is great and the additional buffer space prevents dropped characters. So far so good.

But just yesterday, I had a problem. The Arduino IDE prompted me with "There are updates to some of your boards". Answering the prompt, it opened the Boards Manager screen (the equivalent of "Tools", "Board", "Boards Manager"), and it updated the boards, the section titled "Arduino AVR Boards". It updated them from version 1.6.20 to version 1.6.21.

The problem is that with version 1.6.21 of the boards, my edits to HardwareSerial.h no longer have any effect. In order to get those edits to have an effect, I have to roll back "Arduino AVR Boards" to version 1.6.20.

What is the correct way to increase the buffer size on 1.6.21 of "Arduino AVR Boards"?

(PS: I'm sure someone will reply with a post saying that I should be implementing my own ring buffer in my own code instead of increasing the built in ones. But this isn't a question about the correct method, it's a question about what changed in 1.6.21 and how to access the values that I need to access.)

Hardware packages updated/installed via Boards Manager are installed to a different location. So even though you still see an Arduino AVR Boards hardware package at (install location)/hardware/arduino/avr/cores/arduino/HardwareSerial.h, that's not the package that the Arduino IDE is actually using.

The easiest way to find the active hardware package location is as follows:

  • Select a board from the hardware package from the Tools > Board menu
  • File > Examples > SPI > BarometricPressureSensor
  • Sketch > Show Sketch Folder
  • Move up folder levels until you reach the one that contains boards.txt

You will then find HardwareSerial.h in the cores/arduino subfolder.

That's fantastic, thanks so much for the quick response. I'll try that out as soon as possible.