OptiLoader port to Particle and SPI clock stretching

#13 · closed · 0 comments

View on GitHub ↗

macdonaldtomw

(cross posted to [avrfreaks](https://www.avrfreaks.net/forum/optiloader-port-particle-and-spi-clock-stretching)) Hi @WestfW , I'm trying to port OptiLoader over to the Particle Platform so that I can use an Electron to flash Optiboot to an ATmega328PB I'm having difficulties that I believe are arising from the peculiar timing of SPI signals used to implement the AVR ISP protocol. Here is a logic analyzer grab of my AVR pocket programmer burning Optiboot: ### **Overview** ![image](https://user-images.githubusercontent.com/6575957/52610229-b75e8180-2e56-11e9-9542-e4960e79e8df.png) ### **Programming Enable Instruction** ![image](https://user-images.githubusercontent.com/6575957/52610238-bfb6bc80-2e56-11e9-8705-ce1b4b3a4588.png) ### WTF Am I seeing things correctly? It would appear that there is some sort of SPI clock stretching going on here.... I didn't think SPI could do that..... When I try OptiLoader on a Particle Electron, I get the same as above except the SCK signal is at 117 kHz and it never stretches, and all I get is 0xFF back from the ATmega It actually _did_ work once out of 30 times but I wasn't able to replicate upon further testing. **My problems:** - Slowest the SPI peripheral of the Electron can go is 30/256 Mhz = 117 kHz (the AVR pocket programmer goes at ~87 kHz) - SPI clock stretching is not supported by the SPI peripheral **Questions for you:** - Does OptiLoader implement SPI clock stretching? - Can you see any reason why a non-clock-stretched sketch using a hardware SPI peripheral running at 117 kHz would not work?

Comments