I can get the version of a (recent) Optiboot with:
printf("Optiboot version: 0x%04x\r\n", pgm_read_word(0x7FFE));
but trying the same trick in assembler doesn't read the correct address
(I don't know exactly what address it does read, that's the problem):
__asm__ volatile (
"ldi r31, 0x7f \n\t"
"ldi r30, 0xfe \n\t"
"ld r0, Z \n\t"
"mov %0, r0 \n\t"
: "=r" (VERSION_store) :
);
Does anyone know how to use the Z register to read from the boot loader code?
Thanks - Will