It shouldn't be too complicated if the chip has the usual features. 8535 is pretty old.There's no guide, but it's not very much code. Getting the fuses and code addresses and such right is probably harder than the code modifications.

I have started a separate thread on my issues trying to get optiboot run on Attiny84. http://arduino.cc/forum/index.php?topic=108989.0I have come to a dead end, although Luminet (Attiny84 based) is said to work, I couldn't get results. If someone has walked that path, please advice on any tricks that need to be pulled down the sleeve.

I have found a bug in Optiboots software UART. Basically, when compiled the inline assembler for getch() does something rather weird. Both the recieved char (what is returned to the variable ch) and the bit count (how many bits to recieve) both end up using the same register which means it doesn't correctly recieve chars, and in some cases it gets stuck in an infinite loop.

Thanks Tom!Based on your hints I've just added support for ATtiny85 to optiboot.As there is no hardware bootloader in ATtiny85, the code exceeds 512 bytes due to virtual boot partition implementation.Bootloader seems to work well even with the factory calibrated RC oscillator. Still, one might need to adjust the OSCCAL register when the communication speed error exceeds some limits.

I have a working version of optiboot as well for both tiny85's and tiny84's. As you say it does require the oscillator to be tuned, so I am currently working on including tinyTuner in the bootloader when you first burn it which will then callibrate the oscillator and store the calibrated value in program memory and apply it each time it loads.

My version of optiboot for the tiny's is 576 bytes, which is a bit smaller than the stock version as I made several other enhancements to make optiboot smaller - using unions in some places for example.

Once I have got the TinyTuner code added (it wont increase the size of the bootloader as it will be overwritten when you download the first sketch) I will release my bootloader, along with a partly rewritten Tiny core I am working on.

Just so you know, the OSCCAL value is not like the fuses; it is not sticky. The value is always set to the factory default on reset. You will have to store the value in EEPROM or Flash and then, ideally, transfer it to OSCCAL at the start of the bootloader.

In my case, I store the tuned value at the end of EEPROM (E2END) with some other configuration data and bracketed by guard bytes.

I have almost completed a bootloader which when you burn it includes TinyTuner. At the end of tinyTuner running, it saves the tuned value into the program memory as part of the bootloader, along with another byte which tells the bootloader to not run the tuning process again. Once tuned, the bootloader is unlocked and the tuning code is erased. From then on in, the OSCCAL value is set from the value stored in program memory.I have got everything working apart from after the first program is downloaded using the bootloader it nothing works anymore and I haven't yet figured out why.EDIT:I know why it doesn't work, I am just trying to figure out how to make the compiler put a function in a specific place.EDIT2:Got it working! I now have a self rewriting bootloader which has tiny tuner build in, but takes up no more space than it did before.(https://github.com/TCWORLD/ATTinyCore/tree/master/tiny/bootloaders/optiboot)

Yeah, it works as long as you don't try and overwrite code that is currently being executed (causes a crash) - provided that you write all data on a page. Also, if you need to set bits from 0 to 1 in a byte, you have to back up all flash that is on that page, erase the whole page, and then rewrite in all but the byte you wanted to change bit in. Fortunately is a byte is 0xFF to begin with, it is easy to write to by simply writing that byte to what you want, and all others on the page to 0xFF (leaves them unchanged as it can't program from 0 to 1).This is what I came up with the make it work:

uint16_t addrPtr; //For this code we are assuming that the cleared value of each byte in the temporary page buffer is 0xFF //This is important as we have to write a page at a time which means that we will be overwriting bytes we //don't want to change - by using 0xFF this isn't an issue as programming can only convert a bit from a 1 //to a 0 (otherwise it needs to erase which is not being done here). So if say you had 0b00100101, and reprogrammed //it with 0b11111111, the result would be 0b00100101 as none on the 0's can be turned into 1's. addrPtr = (uint16_t)(void*)ver; //get the pointer to the ver array in the flash memory.

SPMCSR = CTPB; //clear the temporary page buffer - this sets all bytes to 0xFF so as not to change any bytes we don't want to twoByte oscProg; oscProg.array[1] = OSCCAL; //store the new OSCCAL value in the program memory so it can be restored by the bootloader at startup. oscProg.array[0] = (uint8_t)0x00; //tells the bootloader not to call tinyTuner again (good as it will be overwritten by bootloader later. __boot_page_fill_short((uint16_t)(void*)addrPtr,oscProg.integer); //store the two oscProg bytes to the temporary buffer __boot_page_write_short((uint16_t)(void*)addrPtr); //program the whole page. Any byte where temp=0xFF will remain as they were. boot_spm_busy_wait(); //wait for completion

putstr_t(PSTR("Removing call to TinyTuner to reduce bootloader size by 2.3kbytes\r\n"));

addrPtr = (uint16_t)(void*)bootloader; //get the page on which to bootloader starts; addrPtr += 0x0A; //move to the correct place in the bootloader (where the RCALL to tinyTuner() is)

SPMCSR = CTPB; //clear the temporary page buffer - this sets all bytes to 0xFF so as not to change any bytes we don't want to __boot_page_fill_short((uint16_t)(void*)addrPtr,(uint16_t)0x00); //write a NOP instruction to prevent calling tinyTuner when it doesn't exist anymore. __boot_page_write_short((uint16_t)(void*)addrPtr); //program the whole page. Any byte where temp=0xFF will remain as they were. boot_spm_busy_wait(); //wait for completion