i uploaded my code in arduino while back but now i deleted my firmware i did not find my source code and i want my arduino uploaded code.
I have USBasp programmer with me and i have all the required components for ICSP programming.
also my Arduino mega fuse bits and lok bitsare
L=0xFF
H=0xD9
E=0xFD
LB=0xFF
I do some research about how to get hex file from arduino i tried different methods but i am filed to get hex file from arduino.
So any one can solution for getting hex file from arduino using USBasp programmer???
You run it from a command line / bash shell. Note: the Mega uses wiring for the -c parameter, not arduino (corrected below). The full command for my Windows system
Note if you're running an older IDE (1.8.x) where the AVR board package was not updated, you can find the avrdude command in C:\Program Files (x86)\Arduino\hardware\tools\avr\bin and avrdude.conf in C:\Program Files (x86)\Arduino\hardware\tools\avr\etc
Now I am able to Read hex file from my arduino but problem is that my hex file not that where I want I uploade that hex file in another arduino and that arduino board is not work like current board.
I also found that arduino mega flash memory is 256 KB but my hex file size is around 615 KB that could be issue?
The hex file is a human readable interpretation (in a specific format) of the binary that goes in the flash memory. It will at least be twice as big (because is byte is represented in ascii) as the actual binary data that you did read back from the Mega; add some additional stuff and you get to that 600-something bytes. See Intel HEX - Wikipedia.
A USBasp programmer is not required because the bootloader has flash read capabilities in addition to write. You can read the hex file even when the board is connected to your computer with a USB cable as usual. The only time you would need an ISP programmer is if there was no bootloader on the microcontroller (as is the case if you uploaded the sketch via Upload Using Programmer instead of doing a normal upload).
The procedure is described in the post at the link shared by theeccentricgenius in post #5. My impression is that @EDExpert has already been successful in reading the hex file.
Here is a simple (GUI) program: GA Flasher. That can not only read the sketch (hex), but also write it back without the need for an external programmer https://gra-afch.com/download/46108/