My final goal is to replicate the process with which the PC programs the arduino. I have gone through the commands.h file and made a couple of attempts to get the logic right. But no success at flashing the arduino. Is there any way to view the Hex commands that are written to the arduino from the PC? Something like verbose but list every hex command. My idea is that I will just replicate the same commands and try uploading hex files from SD card.
Add the flag
-vvvv to the
avrdude command. That will show you the flow of data between the computer and the Arduino.
You can copy and paste the executed command from the IDE and run it in a terminal / command window adding the flag manually. Or you could modify the platform.txt file for the AVR core.