Setting the correct clock speed for Arduino Uno ATMega16U2

Hello, I've designed a custom board based on Arduino Uno and I'm trying to upload the bootloader to ATMega16U2.
I've tried using flip software and the hex file included in the installation files of arduino and the board is now recognized as "Arduino Uno" by the IDE.
The problem is, that the clock is set to a lower speed and I can't upload a sketch serially to ATmega328P, as it seems that they are running in different baud rates.

I soldered on my board an ATMega16U2 from an actual Arduino Uno rev3 board which had the correct firmware and uploading sketches serially works fine, so it seems it's a firmware issue.

My question is, how can I change the clock speed of ATMega16U2? (It seems that is set to 1/8)
Also, where can I find a .hex file with a firmware for ATMega16U2 that is compatible with the bootloader for ATMega328P to upload serially a sketch?
Thanks in advance.

Is it only based on the UNO or is it compatible? If the later, post complete schematics of your board!

If you used a wrong clock setting the USB bus probably won't communicate with the PC. So I guess you either forgot to install the bootloader on the ATmega328p or used a wrong clock setting there. But that's wild guessing as almost all needed information is missing.

Please specify which exact firmware file you uploaded to your ATmega16U2!

In the Arduino IDE in the firmwares folder.

I never used that software, my chips are flashed using the avrdude software the Arduino IDE also uses.