Stand-alone .hex file uploader for your chips - testers wanted

The sketch has been updated to allow you to changes fuses or the lock byte. Example session:

Actions:
 [E] erase flash
 [F] modify fuses
 [R] read from flash (save to disk)
 [V] verify flash (compare to disk)
 [W] write to flash (read from disk)
Enter action:
F
LFuse = 0xC2 
HFuse = 0xDE 
EFuse = 0xFD 
Lock byte = 0xCF 
Choose fuse (LOW/HIGH/EXT/LOCK) ...
LOW
Current value of low fuse = 0xC2 
Enter new value for low fuse (2 hex digits) ...
FF
WARNING: Fuse changes may make the processor unresponsive.
Confirm change low fuse from 0xC2 to 0xFF . Type 'YES' to confirm ...
YES
Changing low fuse ...
Fuse written.
LFuse = 0xFF 
HFuse = 0xDE 
EFuse = 0xFD 
Lock byte = 0xCF

Sketch now slightly larger:

Binary sketch size: 25998 bytes (of a 32256 byte maximum)

If I uncomment the free memory test:

Free memory = 632

I am working on a project now and want to use your code. However, I would love the option to not have to have a pc. What would be the easiest way to implement an LCD screen. I would want it to show a list of the files. Would having a separate processor that talks serial to the programmer work the best?

Currently it compiles to:

Binary sketch size: 27,404 bytes (of a 32,256 byte maximum)

So you have around 5k left. Maybe you could squeeze in an LCD screen into that, maybe not.

A separate processor might be simpler (or just use a chip with more capacity like the 644 chip). I think if I was doing that I would talk via I2C which works well over short ranges, although if you stuck to serial the "main" processor could be virtually unchanged, I suppose, since it already uses serial.

One interim approach might be to add a couple of switches and LEDs, since the sketch already remembers the name of the last file you uploaded. If you are doing an upload / test / fix bugs / re-upload cycle, then you could have a switch that you hit to send the last file again and a couple of LEDs (eg. red, green) to indicate when it was done, and if there was an error.

Alright, I have decided to use two processors. I bought an OLED screen from adafruit (128x64 1.5") as well as some buttons and micro sd card breakout. I have ordered an sd card from Amazon. What I have gotten so far is the screen working as well as a menu type system to select files. I will be integrating with the "main" processor soon.

I use Atmel Studio to program all of my devices. It produces an elf file as well as a hex file. The elf contains information on the target processor as well as the fuses that need to be programmed. It would be really awesome if your code could support this. I am looking into the formatting of the elf file and will post back if I get it to work. It would allow me to program the fuses as well as the EEPROM and flash all with one file.

It produces an elf file as well as a hex file.

General statement for Arduino users, the Arduino GUI also produces the elf file.
In the Windows environment the file is buried in a directory structure in the %temp% directory. Use the Verbose GUI setting during compile to easily determine the directory name. Other OS's... Just search... This has been discussed often in the forum.

Ray

I would be interested to see what you come up with, but as Mrburnette said, you get an .elf file out of the Arduino build process.

I don't want to over-egg the pudding too much, the exact fuses you want would depend on the clock speed, what sort of crystal you have (if any), whether or not you want brown-out detection and so on. I don't think it can be fully automated.

What another Auzzie gem requiring a translation? That's like two in two days. :wink:

I don't think this one is Aussie. :slight_smile:

http://en.wiktionary.org/wiki/over-egg

Basically you spoil something by trying to improve it too much.

Ah, gilding the Lilly are we.

I have gotten my hardware to work as well as a gui and was wondering how to program the fuses. I want to write certain fuses before it programs the chip and then after it verifies, program the lock bit. I am able to do all of the fuse programming and lock bit with my computer programmer. Here is the code that I have:

For writing:

case 'W': 
      startProgramming ();
      writeFuse(0xFF,fuseCommands[0]);
      writeFuse(0xD7,fuseCommands[1]);
      writeFuse(0xFD,fuseCommands[2]);
 
      writeFlashContents (); 
      break;

For verifying:

case 'V':        
      verifyFlashContents (); 
      startProgramming ();
      writeFuse(0xC0,fuseCommands[3]); //Lock it
      break;

This doesn't seem to work as I can still read the flash contents. I am checking now if setting the fuses at the beginning will work.

The code works to set the fuses up top. However, the lockbit fuse still doesn't. I tried removing the "startProgramming()" thinking that that was the only difference... same results.

Anything? I still can't figure it out. Am I not able to program the lock bit?

Hey, sorry for the long wait. I forgot about this thread. I managed to get this to work. I ended up putting the lock bit code in the wrong spot. Everything works great now.

I have a new question. This one is for Nick: I have recently stumbled upon this FRAM from Adafruit: Adafruit I2C Non-Volatile FRAM Breakout - 256Kbit / 32KByte : ID 1895 : $9.95 : Adafruit Industries, Unique & fun DIY electronics and kits
It seems to me that this could be a perfect solution for anyone looking to just program an Atmega328 (or smaller) with just one firmware. It can hold 32 Kbytes of memory, is nonvolatile and really fast. I would think that the hardest part of this would be figuring out a way to upload a binary file to this. I don't know, just an idea. Would love to see it work though. I don't have time now to work on stuff like this but it will definitely be on my mind.

Nick.G seems to have left the building, and not posted to this forum for 3 or 4 months.

????????????

He is still updating his GIT items.

I wonder what happened.

Displeasure over the state of spamming in the forum I believe.

CrossRoads:
Displeasure over the state of spamming in the forum I believe.

I can imagine that for moderators trying to keep the forums clean, that would be most frustrating. Heck, I have to take time-out over the do-my-homework-for-me kids.

Anyway, he is a great asset, I'll just have to keep abreast of his postings in his own space.

Ray

It is possible to make the code run on Arduino Due as programming board?

I suppose so, although the bit about generating the clock pulse would have to be omitted or altered (this won't matter unless the target doesn't have a clock).

The Due uses 3.3V levels, and normal Arduinos use 5V levels, so a level-shifter would be in order for the programming lines. Alternatively you might get away with running the target at 3.3V and omitting the level shifting.

Conceptually it should work. :slight_smile:

I have a 2nd version of this card in hand (but not built up yet) that uses spare 3.3V drivers in the 74HC4050 (used to buffer the SD signals) for a 2nd slave ICSP header - so now 5V or 3.3V boards can be powered & programmed.
The 15 pin connector (only used by a certain customer) is gone, replaced by the slave ICSP headers, and the program buttons are placed in a more user friendly location.