High-voltage Serial Programming ATtiny25/45/85 Flash programming

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Community

 

I need to program Tiny25/45/85 Devices with HVSP because i use the Reset-Pin as IO. For that i've built an HVSP-Adapter on my own. The Adapter works fine( i'm able to program the fuse-Bits now) but i have a Problem with the Description of the High-voltage Serial Programming Instructions for writing to the Flash, see Datasheet Chapter 20.7 (http://www.atmel.com/devices/attiny25.aspx)

 

Instruction "Load Flash High Address and Program Page", Table 20-16:

- SDI Data of Instr. 1 is described as 0_0000_000a_00.

- Footnote 1. a=address high bits

- Footnote 2. For page sizes less than 256 words, parts of the address (bbbb_bbbb) will be parts of the page address.

 

For my understanding:

- the Tiny25 has a 16Bit-ProgrammCounter(PCPAGE[9:4],PCWORD[3:0]), so the SDI Data of Instr 1 should be 0_0000_00aa_00

- the Tiny45 has a 16Bit-ProgrammCounter(PCPAGE[10:5],PCWORD[4:0]), so the SDI Data of Instr 1 should be 0_0000_0aaa_00

- the Tiny85 has a 16Bit-ProgrammCounter(PCPAGE[11:5],PCWORD[4:0]), so the SDI Data of Instr 1 should be 0_0000_aaaa_00

 

Question 1: Did anyone implemented the Flashprogramming with HVSP and knows if I'm right and the Datasheet is wrong/incomplete?

 

 

 

 

An other Problem is the Operation Remark of the same Instruction "Load Flash High Address and Program Page":

"Wait after Instr 3 until SDO goes high. Repeat Instr. 2 - 3 for each loaded Flash Page until the entire Flash or all data is programmed. Repeat Instr. 1 for a new 256 byte page.(2)"

 

First of all, I think word would be correct here, but none of this Devices has a Pagesize over 32Words? And what really confused me: i don't find anything about multiple Pages?

Question 2: Did the Tiny25-85 has more than one Page-buffer???

 

Thanks for any help.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello:

Quick question: Are you designing this as a school project, as a hobby-based programming tool or as a commercial development?  

 

If you need the HVSP ability for a school project or a hobby-based programming tool and have access to an ARDUINO, there are many pages of projects that perform this function for you.  I have not taken the time to research them but here are some that a quick search using "ARDUINO HVSP programmer" returned:

 

http://mightyohm.com/blog/products/hv-rescue-shield-2-x/

 

http://www.rickety.us/2010/03/arduino-avr-high-voltage-serial-programmer/

 

https://arduinodiy.wordpress.com/2015/05/16/high-voltage-programmingunbricking-for-attiny/

 

https://arduinodiy.wordpress.com/2015/05/16/high-voltage-programmingunbricking-for-attiny/

 

https://www.tindie.com/products/gzip/avr-attiny-rescue-kit-hvsp-wing-shield-for-arduino/ ($5 programming shield)

 

If you are working on a commercial product and need to program for HVSP under say Linux or WINDOWS, check out the source code for "avrdude".  You are likely to find code snippets that you can merge into your own code.  The likely place to look would be for the "DRAGON_HVSP" programmer.

 

I have recently been working with the "self-programming" feature of the mega and tiny devices.  In answer to your "question 2", I believe that the same internal hardware is the same for "self-programming" and any of the supported programming interfaces (SPI and HVSP).  Thus, there is only one temporary buffer, which has a size of "PAGESIZE" words (2x for bytes).  Also, it might be helpful for you to look through the information for "Self-Programming" in the ATtiny25/45/85" datasheet.  In the "01/08" version, it starts on page 145.  That section explains the PCPAGE and PCWORD definitions fairly well.  

 

As you know, per the datasheet, for the tiny25, the PAGESIZE is 32 words (64 bytes), for the tiny45 and tiny85, the PAGESIZE is 64 words (128 bytes).  

 

On the "Repeat Instr. 1 for a new 256 byte page" question/comment, since the maximum PAGESIZE is 64 words (128 bytes) for the tiny45/85, it is likely a typo and should read "for a new PAGESIZE * 2 byte page". 

 

To load the temporary buffer, for the "bbbb_bbbb" address you are referring to, it represents a page number; 0 to 31 for tiny 25 and 0 to 63 for tiny45/85.

 

As for the single "a" (address designation) for the "Load FLASH address and program page" instruction, that is confusing to me as well.

 

Hope that helps.

 

Peace and blessings,

Scott

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Scott

 

Thanks for your Answer. It's a hobby Project, nothing commercial...

 

After some testing i can confirm my assumption: SDI Data for the Instruction "Load Flash High Address and Program Page" for a Tiny25 is definitely 0_0000_00aa_00

 

Based on this i'm quite sure the SDI Data for a tiny45 is 0_0000_0aaa_00 and for the Tiny85 0_0000_aaaa_00.

(Because i have just a Tiny25  i can't confirm/test this right now...)

 

Regards

Andi

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Andi,

 

I stumbled over this thread as I'm modifying Nick Gammon's HVSP-Programmer for my purposes using a custom PCB.

At the moment I have the problem, that this "Program Page" command is only programming the filled page buffer to the same flash address (0x00000) every time.
So could you please share your code with us?

This is the code I'm using to "Commit" the page buffer into the flash:
 

// commit page to flash memory
void commitPage (unsigned long addr, bool showMessage)
  {
  if (showMessage)
    {
    Serial.print (F("Committing page starting at 0x"));
    Serial.println (addr, HEX);
    }
  else
    showProgress ();

  addr >>= 1;  // turn into word address

  HVtransfer (SII_LOAD_ADDRESS_HIGH, addr >> 8);
  HVtransfer (SII_WRITE_LOW_BYTE, 0);
  HVtransfer (SII_WRITE_LOW_BYTE | SII_OR_MASK, 0);

  pollUntilReady ();
  clearPage();  // clear ready for next page full
  HVtransfer (SII_LOAD_COMMAND, CMD_NO_OPERATION);

  }  // end of commitPage

This is my code snippet for testing the writing procedure:

for (uint16_t address = 0x0000; address < 64;){
  writeFlashPage (address++, 0x4F);
  writeFlashPage (address++, 0xAB);
}
commitPage (0, false);

for (uint16_t address = 0x0000; address < 64;){
  writeFlashPage (address++, 0xDD);
  writeFlashPage (address++, 0x3E);
}
commitPage (0 + 0x40, false); //increment address by pagesize (64 bytes for ATTiny85)

As result from the serial monitor after reading the flash I get "0x4D" and "0x2A" which is "0x4F & 0xDD" and "0xAB & 0x3E", so the second page is also programmed to flash address "0x000000 (as PCPAGE has 6 bits width).
The "commit" address is most likely wrong, as it's bit shifted right 9 times in this function equalling to "0" in both cases.

I also sent a support request to Microchip to clear up the single "a" mistery.
 

Regards, 
Hannes

Update: I got a reply from the support :) See attached image
 

Attachment(s):