Backing Up Firmware - spectrality-github/tesla_Lunars GitHub Wiki

From Quantum`post at https://www.diyelectriccar.com/forums/showthread.php/howto-tesla-backing-up-firmware-201819.html

So now you've successfully rooted your firmware and have access to your CID either through an Arduino Yun or whatever in the car from a switch, or over a VPN.

It is highly recommended to back up your firmware, either to the car's nanocomputer, your home LAN, or both. It is especially important to back up partitions 3 and 4 since they are specific to your car, and partition 3 is destined to wear out due to system logging.

I recommend backing up each partition, 1, 2, 3, 4, and then the whole flash. This latter is important as partition 1 does not start at the beginning of the flash. When you have to replace a burned-out flash it is necessary to lay down the whole image.

Needless to say, as you update firmware be sure to back it up. If you restore a lower-rev partition 1 or 2, it will not match the boot flash (Spansion) and the CID will not boot due to code-signing.

The first thing you should know is which is currently the -active- partition, 1 or 2?

# cat /proc/mounts

... Either mmcblk0p1 or 2 will be mounted, and so that is your current active one. They switch with each firmware update.

The second thing you'll want to know is what is your current software version?

# cat /deploy/platform.ver

Backing up is easy. I prefer to compress the backups to save bandwidth and disk space, but it's not necessary.

  • Log in as root to the CID.
  • Make sure the CID doesn't go to sleep. (Hat tip to verygreen)

# sdv GUI_neverSleep true

# sdv GUI_sleepAtNight false

# sdv GUI_enableSleep false

# while :; do sleep 120 ; sdv GUI_lastTouchTime date +%s ; done &

  • Keep cid-updater out of the way:

# while true; do pkill cid-updater; sleep .5; done &

  • Now you're free to make image copies:

# dd if=/dev/mmcblk0p1 bs=4M | gzip -1 - | ssh {user}@{dest. IP} dd of={dest. path}/mmcblk0p1.gz

# dd if=/dev/mmcblk0p2 bs=4M | gzip -1 - | ssh {user}@{dest. IP} dd of={dest. path}/mmcblk0p2.gz

# dd if=/dev/mmcblk0p3 bs=4M | gzip -1 - | ssh {user}@{dest. IP} dd of={dest. path}/mmcblk0p3.gz

# dd if=/dev/mmcblk0p4 bs=4M | gzip -1 - | ssh {user}@{dest. IP} dd of={dest. path}/mmcblk0p4.gz

# dd if=/dev/mmcblk0 bs=4M | gzip -1 - | ssh {user}@{dest. IP} dd of={dest. path}/mmcblk0.gz

  • Properly reboot the CID to clear all your interference. (Hat tip to ce2078)

# emit-reboot-gateway