Was getting strange behaviour on return from
DSTATUS disk_initialize (void)
So as shown below, after the return from disk_initialize, the return value is compared to zero. If equal then the condition is entered.
However it seems to never compare the return to zero, rather to 0x9F (contents of R01), and the if (res==0x00) condition is never entered. I’m a bit confused as to what is going on.
Am debugging a 328p via debug wire (Atmel Dragon). Optimisation is –Os, but the same thing happens with –O1. Also res is declared volatile. Edit - forgot to say the code runs in the bootloader section, but the code size easily fits.