No dice - now once it gets code (blink) uploaded once, the LED flashes very rapidly (same behavior as you see with and it can't be reprogrammed except via ISP (and AVRdude complains about verification failure when I upload the sketch: "first mismatch at byte 0x0002 0x5c != 0x00" - not that i particularly care)
I'm a little fuzzy on what exactly is supposed to be happening here. I recognize that the first bunch of words in the flash are the interrupt vectors. 0x0000 is reset, and 0x000C (these are word addresses, i guess, so that means address 0x0018 by bytes) is the WDT interupt.
Straight up after programming, I can then read out the data via ISP, and see what the vectors are... but they're the same as they are after programming on a normal optiboot!
All except RESET are JMP to 0x006E (which itself appears to be JMP to 0x0000, ie, reset vector), except TIM0_OFV (millis), which is JMP to 0x0088, and reset is JMP 0x005C.
Wouldn't we need the reset vector pointing to the bootloader when we're using a virtual boot partition?
That starts at byte address 0x7D00, that's word address 3E80. Okay, so I change that and write it back - and sure enough, that makes it run the bootloader... but not the sketch. I guess what I'm unclear on is how control is ever supposed to get back to the.... That's what you're using the WDT vector for! So let's put 0x005C at word address 0x000C... and bootloader works, and sketch runs!
So we need the WDT vector to be what the reset vector originally was, and the reset vector pointing at the bootloader. Oh ya, that's what the comments say it's doing... so why isn't it...?
Aaah! After all this:
rst_vect1 should be 3, not 4.
need to test if address==0, not ==rst_vect0, since rst_vect0 is 2, but we'll be checking against the start address, which will be zero.
Badabingkapowie! It works! Now, to optimize the makefile a bit for the virboot328 to minimize wasted space, and then get to work on tiny1634!
Woohoo!