sofiactl icon indicating copy to clipboard operation
sofiactl copied to clipboard

Is it possible to get a full firmware backup

Open nospam2k opened this issue 4 years ago • 5 comments

I have full access to my camera (telnet root) which uses sofia. I would like to extract the full firmware bin. Is this possible with sofiactl or by some other means?

nospam2k avatar Jul 27 '20 18:07 nospam2k

You could configure NFS server, mount nfs from cam and dump MTD partitions using dd or similar. Here is a steps which I used for restoring accounts by replacing files on mounted NFS partition (Ubuntu), but didn't tried to dump MTD. And you still need to create files in firmware update format from dumps if you are going to use firmware upgrade for your device. Be careful with preparing own firmware upgrade - you can kill your device.

On server:

  1. apt-get install nfs-common nfs-server -y
  2. mkdir -p /home/nfs
  3. chmod 777 /home/nfs
  4. add to /etc/exports

/home/nfs *(rw,sync,no_root_squash,fsid=0,crossmnt,no_subtree_check)

  1. exportfs -a

  2. service rpcnind start

On DVR/IPC:

  1. telnet as root
  2. mkdir -p /var/tmp/nfs
  3. mount -t nfs <SERVER IP>:/home/nfs -o nolock /var/tmp/nfs

667bdrm avatar Jul 27 '20 19:07 667bdrm

Thanks for the info. I'll definitely work on that. I figured I needed to dump mtd partitions, but my goal is to have a full firmware backup. I have 5 cameras that are the same hardware but 2 of them are a different firmware with less features. My hope is to extract the firmware from one camera to use on another. I'm having a difficult time sourcing the target firmware. V5.00.R02.00030665.10010.245306.00000 (RA50X20).

nospam2k avatar Jul 27 '20 19:07 nospam2k

The firmware is a archive with partition images. If you are able to dump mtd partitions I think it is possible to repack the firmware, but it is a risk operation. Currently the problem that camera shell is missing dd command. I was able to dump partitions following way:

  1. mount nfs partition on your local server to /var/tmp/nfs per instructions above
  2. get list of partitions:

cat /proc/partitions

  1. show mounted filesystems parameters:

mount

  1. for each /dev/mtdblock device execute following:

cat /dev/mtdblockX > /var/tmp/nfs/mtdblockX.img

(X - mtd partition number)

The images could be mounted:

mount -t filesystem -o ro,loop mtdblockX.img

(filesystem - from mount on camera output for that mtdblock, X - mtdblock partition number)

On my camera root partition is mtdblock2, filesystem type cramfs

667bdrm avatar Sep 13 '20 19:09 667bdrm

mount -t filesystem -o ro,lool mtdblockX.img Thanks for the info. Is lool correct or a typo for loop?

nospam2k avatar Sep 13 '20 21:09 nospam2k

Yes, correct loop

667bdrm avatar Sep 13 '20 21:09 667bdrm