I am looking for a bootloader For Mega2560 for 12 MHZ crystal. (all boatloader is for 16 mHZ only)
Using prescaler 8, I can get a 3KHz PWM on the pins,
16 MHZ crystal give 4KHZ PWM on the pins,
I have tried to replace the crystal after burning my project to the MEga2560 and give me 3khz PWM, but wont allow me to load another program. So I return again the 16 MHZ crystal so I can upload another program.
Does it really have to be 3000 Hz ? Is that for 8-bit PWM ?
The bootloader takes care of uploading a sketch, and the bootloader has to know the cpu clock as well.
You could use a programmer and the ICSP header to upload a sketch, or make a bootloader for 12MHz with Optiboot.
If you are going to use the ATmega2560 at 12MHz, a new definition can be added to the "boards.txt" file. Copy the settings from the normal Mega board, and give it a new name with 12MHz as clock.
The "mega.build" is what the compiler uses to compile a sketch.
The "upload.speed" is the baudrate to upload a sketch via the bootloader.
With the 16MHz bootloader at 12MHz, the baudrate will become 86400.
Perhaps you can use that as upload speed. It is not a standard baudrate, I doubt if it will work.
Original Optiboot doesn't support Atmega2560.
You could check my fork as it have support for it, here: GitHub - majekw/optiboot at supermaster
Then it should be enough to change AVR_FREQ to 12000000L and compile things.
You'll also need Avrdude 6.1 or newer to work properly with this bootloader (Arduino is shipped with older version and you'll have problems with accessing all flash).