I have a problem with Arduino MEGA2560 dev board. The onboard chip used to upload program (AtMega16U2) is damaged due to overvoltage so I am unable to upload the code on AtMega2560. which implies Serial0 used to upload program serially is not working properly because of the damaged IC.
So I modified the source file of bootloader (stk500boot.c) to use Serial1 instead of Serial0.(Atmega2560 has 4 serial ports).
Then I uploaded the new generated .hex file using another programmer (usbasp), but the issue is that the code goes to the application part of the flash.
So how can I load the code to Bootloader part of the flash? Should I modify the fuse settings before uploading to the flash and how can it be done?