/Self-replicating-Arduino

Self replicate daisy-chained Arduino Nanos using SoftwareSerial

Primary LanguageC++MIT LicenseMIT

self_replicating_arduino

Self replicate daisy-chained Arduino Nanos using SoftwareSerial

This sketch will read its own programmed flash memory and use the data to replicate itself onto a different Arduino (Nano) connected through SoftwareSerial.

Dependencies: SoftwareSerial

SK_LEN should store the sketch compiled length in bytes as displayed in the IDE after compile (Ctrl+R) (example: Sketch uses 6266 bytes (20%) of program storage space. Maximum is 30720 bytes.) Copier file uses SoftwareSerial (RX is digital pin 10, TX is digital pin 11) for programming the next Arduino in the chain (which uses Serial) and so on. The reset line to the next Arduino should use pin RESET_PIN (default digital pin 4).

Sample avrdude communication:
  • > 0x30 0x20
  • < 0x14 0x10

  • > 0x30 0x20
  • < 0x14 0x10

  • > 0x30 0x20
  • < 0x14 0x10

  • > 0x41 0x80 0x20
  • < 0x14 0x02 0x10

  • > 0x41 0x81 0x20
  • < 0x14 0x01 0x10

  • > 0x41 0x82 0x20
  • < 0x14 0x10 0x10

  • > 0x41 0x98 0x20
  • < 0x14 0x03 0x10

  • > 0x41 0x84 0x20
  • < 0x14 0x00 0x10

  • > 0x41 0x85 0x20
  • < 0x14 0x00 0x10

  • > 0x41 0x86 0x20
  • < 0x14 0x00 0x10

  • > 0x41 0x87 0x20
  • < 0x14 0x00 0x10

  • > 0x41 0x89 0x20
  • < 0x14 0x00 0x10

  • > 0x41 0x81 0x20
  • < 0x14 0x01 0x10

  • > 0x41 0x82 0x20
  • < 0x14 0x10 0x10

  • > 0x42 0x86 0x00 0x00 0x01 0x01 0x01 0x01 0x03 0xff 0xff 0xff 0xff 0x00 0x80 0x04 0x00 0x00 0x00 0x80 0x00 0x20
  • < 0x14 0x10

  • > 0x45 0x05 0x04 0xd7 0xc2 0x00 0x20
  • < 0x14 0x10

  • > 0x50 0x20 //Program mode
  • < 0x14 0x10

  • > 0x75 0x20 //upload
  • < 0x14 0x1e 0x95 0x0f 0x10

  • > 0x55 0x00 0x00 0x20 //Address start
  • < 0x14 0x10

  • > 0x64 0x00 0x80 0x46 + (128 bytes) + 0x20
  • < 0x14 0x10

  • > 0x55 0x40 0x00 0x20 //Address start + 0x40
  • < 0x14 0x10

  • > 0x64 0x00 0x80 0x46 + (128 bytes) + 0x20
  • < 0x14 0x10

  • > 0x51 0x20 //Quit
  • < 0x14 0x10

Fritzing sketch

fritzing