Resetting µC with HVP AND flash Firmware via ISP in one Go

Hi there,

So I built several PCBs (200) with the Reset Pin of an ATTiny alternatively configured as GPIO. That qualifies the µC to be reset only by High Voltage Programming.
I built a "needle adaptor" to place my PCBs on that to reset the fuses, via a sketch I modified to my purposes. This part works.
Now I want to reprogram the µC right after it was reset while still pressing the PCB onto my needle adaptor.
But I couldn't find a solution where the Arduino/Leonardo can load a .hex-file by itself and write it to the µC's flash.

What can I do? The .hex-file has a size of 11KB so maybe it could be put into the ATMEGA's memory or alternatively loaded from a folder on my computer via USB?

Right now I connect my standalone ISP-Programmer and flash via avrdude.
I sometimes change/optimize the software of my project so it would be pretty handy to have a solution that only needs power to do the job. Apart from updating the relevant .hex-file of course.

Thank you

There are a ton of standalone ISP programming sketches; here is one of the top google results, though unless it's more clever than I've realized, it's grotesquely inefficient (storing in hex format on flash to carry the actual sketched is IIRC like a 3:1 penalty? Worst case it's just a couple of regexes to massage a raw hex file into pairs of 2 hex digits all representing data (ie, hex file line lengths and the like removes), put a 0x on the front of each pair of hex digits and commas between them... add }; on the end, const uint8_t hexfile={ on the front..., ctrl+A->C->Tab->V and you're ready to rock-and-roll and rocket-bowl... I'm almost positive someone who hangs out here has something that loads hex files off an SD card GitHub - adafruit/Standalone-Arduino-AVR-ISP-programmer: A standalone programmer for mass-programming AVR chips. HVSP uses the same pins as ISP programming plus one more or something like that right? If you can get on both the HVSP and ISP pins, I'd just combine your existing sketch with one of the standalone programmer sketches, to get a solution with minimal effort...

if you've got the hardware all sorted, this would be easy-peasy comparatively.

Hello DrAzzy,

Thank you for the project hint.

I ran into a problem as the compiler is telling me, that the initial code is using 99% of my target's ATMEGA32U4 with 32K flash. And this is already without my additional hex data. :o

Also weird is that removing the program data in the images.cpp doesn't change the required flash size after recompiling it again.

Am I missing something?

Yeah, you probably are - but I don't have time to try to figure it out, especially since you haven't posted any of the information that we would need in order you help you out.

especially since you haven't posted any of the information that we would need in order you help you out.

But I was talking about the code from the github page. Without touching it, the compiler tells me that it takes up 99% of my Arduino Leonardo's µC flash.

So what information do you exactly need?

Could anyone please check the sketch if it also shows these weird compilation results with a different system?

If you check out the source file optiLoader.h you'll see a large static buffer declared for the hex image:

byte image_hexcode[19000]

Just paste your hex file in and see what happens.

Thank you very much! :slight_smile:

I didn't look deeply into the type definition of the image struct and somehow thought that the memory consumption of the hex array would be calculated during compilation.

This important fact is unfortunately nowhere mentioned on the adafruit tutorial page.