kentindell / canhack

The Yes We CAN project of Canis Labs
MIT License
344 stars 64 forks source link

CANHack sometimes freezes, killing USB on a Raspberry Pi host #8

Closed kentindell closed 3 years ago

kentindell commented 3 years ago

Sometimes the CANHack library freezes with interrupts locked and this causes the USB to freeze, which causes the USB subsystem in a Raspberry Pi host to fail (requiring a reboot).

A solution is to run the CANHack code on the second core in the RP2040 and use a RAM variable to signal a return code so that if it hangs then at least host does not hang (because USB is driven from the main CPU core).

kentindell commented 3 years ago

Failed due to noise on SPI (which can come from attaching logic analyzer probes where the analyzer isn't grounded). Firmware now tolerates SPI noise and provides a diagnostics API for showing when corrupted register values have happened.

https://github.com/kentindell/canhack/commit/56fe2ae909a51186a4fd109f70ebac7bdd10f0af