Update program using SPI interface trough SPI<>CAN bus adapter

I am working on Smart Home system that uses decentralized network bus (CAN bus) to communication.

I have smart switches that consists of Arduino Nano and SPI<>CAN adapter (MCP25515). I am sending data when switch gets clicked over the CAN bus to the pre-designated address of an Relay actor. The actor switches the 230V light.

I am trying to find solution, how to re-program the Arduino (replace sketch) by OTA update trough CAN bus. As far as I know, Arduino (or ESP or similar) can be programmed by SPI, but I only know how to do it using another Arduino or programmer, not trough the CAN adapter.

Any ideas? Are the SPI frames for programming documented somewhere?

That depends on what Arduino you are using!

How I said. I am using Nano.

Which Nano there are several in the same form factor with different processors.

ATmega328 :wink:

To the best of my knowledge you will have to rewrite the boot loader or add that to your code and the CAN function must also be part of that boot loader. You need to read the data sheet to determine how to program the internal FLASH.