nickgammon / arduino_sketches

Publicly-released sketches for the Arduino microprocessor
651 stars 334 forks source link

incompatibilities between hex uploader sketches #90

Closed Kingbuzz0 closed 3 weeks ago

Kingbuzz0 commented 4 months ago

I spent a good amount of time troubleshooting my first attempt at a standalone programmer based on your wonderful examples. I had errors on my initial testing of the fixed filename sketch. As suggested, I moved to the standard Hex Uploader sketch for further debug. While the main behavior is expected to be the same I did run across a couple of important differences that caused me some additional pain in troubleshooting. These are minor, but I am documenting in case you wish to polish things up or in case someone else runs into similar problems;

1) In Atmega_Hex_Uploader_Fixed_Filename, the instructions are to use "firmware.hex". However if this is loaded on the SD, Atmega_Hex_Uploader will never list it, as the file search is specifically looking for *.HEX. This gave me the impression I was having inconsistent SD card reading. The case sensitive check is in the File_Utils file line 327; if (len > 4 && strcmp (&name [len - 4], ".HEX") == 0)

I changed this to ".hex" to keep it consistent. Also will note that the examples provided by the SdFat library were helpful in verifying SD card communications as well.

2) The signature list for Atmega_Hex_Uploader_Fixed_Filename is outdated and did not include the specific device I was trying to program (ATmega328PB). It did correctly report both signature errors with the LED flashes, but being new to the code, I again first looked to compare with Atmega_Hex_Uploader for more information. The Signatures.h file included with Atmega_Hex_Uploader is more up to date and does include ATmega328PB, so it detected the chip correctly. This difference in behavior gave me the impression that the bit-bang SPI was behaving differently between the two sketches. Once the source of the error was found, it was easy to just copy the updated device info over. For consistency (and ease of maintenance?) I suggest using the same Signature.h file for both versions.

Thanks again for the providing these examples, Rob

nickgammon commented 3 months ago
  1. Try changing strcmp to stricmp.
  2. I have a signature for the ATmega328PB. Is it not right?
  { { 0x1E, 0x95, 0x16 }, "ATmega328PB", 32 * kb,       512,   128,  highFuse, false },