gtxaspec / wz_mini_hacks

wz camera mods... make your camera better.
1.33k stars 114 forks source link

Add overlay image support #631

Closed archandanime closed 11 months ago

archandanime commented 1 year ago

I have looked around to see scripts that see /opt as SD Card mount point and modified them to make them work normally. I don't know if I missed some files till I test it out.

Also would you mind compiling the boot image factory_t31_ZMC6tiIDQN, please? It's better to let you do that I guess.

archandanime commented 1 year ago

Upgrade is successful. upgrade_wz_mini.log

archandanime commented 1 year ago

What tested working:

archandanime commented 1 year ago

Now the only thing left is to compile factory_t31_ZMC6tiIDQN and update its hash.

archandanime commented 1 year ago

I forgot to mention the overlay image after extract is 128MiB. Though 64MiB is enough for most people, I made it 128MiB in case someone needs extra space.

archandanime commented 1 year ago

Added /opt/bin and /opt/sbin to PATH variables if overlay image is used: Because /etc/profile is not backed by upgrade-run.sh script, user has to edit it after every upgrade which is inconvenient.

archandanime commented 1 year ago

Pull request is ready!

archandanime commented 1 year ago

There are modification limitations of overlay rootfs, which mean you can't/shouldn't modify these files/directories:

  1. /system is still read-only because it is the mount point of a squashfs partition.

  2. /configs is not mounted as overlay. Though you can modify it, modification on this directory can NOT be rolled back. Be careful because if you delete something, it can NOT be undone(without backup).

  3. /params(for T20 devices) is not mounted as overlay. Same with configs, modification on this directory can NOT be rolled back.

  4. Files/directories that are bind mounted by wz_mini_hacks(/bin/busybox, /etc/fstab, /etc/inittab, /etc/profile, /lib/modules, /etc/hostname, /etc/shadow) can't be directly modified, but you can modify corresponding files/directories in wz_mini directory. They won't be reset if you reset the overlay image.

Limitations with (1.), (2.) and (3.) can be negated by mounting them as overlay in a future pull request, but (4.) is very likely to be unchanged because wz_mini_hacks needs to modify them by injection to be functional.

Note that:

To reset overlay image, you can delete everything inide /overlay or delete overlay image wz_mini-overlay.img on SD Card. After you do this, an immediate reboot is required.

archandanime commented 1 year ago

Now pull request is ready! After it's merged I'll make modifications if something doesn't work or the code needs improvements.

archandanime commented 1 year ago

I have an idea to negate the (4) limitations:

Except for /lib/modules which is required for wz_mini_hacks operations, with all other files: /bin/busybox, /etc/fstab, /etc/inittab, /etc/profile, /etc/hostname, we can modify wz_mini/etc/init.d/S01bind to skip bind mounting them if these files present in the upper directory of overlay mounted /.

Let's call this option to allow us to skip bind mounting OVERLAY_DONT_BIND_MOUNT_FILES="true"

Current S01bind automatically mounts the /bin/busybox, /etc/fstab, etc. files at boot. If the option is enabled(of course it requires a running overlay rootfs), new S01bind would:

We can also do the same thing with /etc/shadow from S08passwd. About /system/bin/factorycheck, this doesn't work until we have overlay for /system. One expected behavior is that if you delete these files, they will show up on the next boot with the contents from wz_mini directory.

Then, not only we can modify these files without touching wz_mini_hacks original files and rollback our changes on them by resetting the overlay image, df -h command would look cleaner too :)) Instead of:

[root@WCV3-Outdoor:~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
devtmpfs                 46680       680     46000   1% /dev
/dev/mtdblock2            3840      3840         0 100% /rom
/dev/mmcblk0p1        31150192   3401104  27749088  11% /sdcard
/dev/loop0              121299     13521     98604  12% /overlay
overlayfs               121299     13521     98604  12% /
/dev/mmcblk0p1        31150192   3401104  27749088  11% /opt/wz_mini
/dev/mmcblk0p1        31150192   3401104  27749088  11% /bin/busybox
/dev/mmcblk0p1        31150192   3401104  27749088  11% /etc/fstab
/dev/mmcblk0p1        31150192   3401104  27749088  11% /etc/inittab
/dev/mmcblk0p1        31150192   3401104  27749088  11% /etc/profile
/dev/mmcblk0p1        31150192   3401104  27749088  11% /lib/modules
/dev/mmcblk0p1        31150192   3401104  27749088  11% /etc/hostname
/dev/mmcblk0p1        31150192   3401104  27749088  11% /opt/record
tmpfs                    46680        24     46656   0% /opt/wz_mini/tmp
tmpfs                    46680     11348     35332  24% /tmp
/dev/mtdblock3            3840      3840         0 100% /system
tmpfs                    46680        24     46656   0% /etc/shadow
/dev/mmcblk0p1        31150192   3401104  27749088  11% /system/bin/factorycheck
tmpfs                    46680       680     46000   1% /dev
tmpfs                    46680         8     46672   0% /run
media                    46680         0     46680   0% /media
/dev/mtdblock6             384       112       272  29% /configs
none                         4         0         4   0% /tmp/Upgrade
/dev/mmcblk0p1        31150192   3401104  27749088  11% /media/mmc

we would have:

[root@WCV3:~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
devtmpfs                 46680       680     46000   1% /dev
/dev/mtdblock2            3840      3840         0 100% /rom
/dev/mmcblk0p1        30517648    485152  30032496   2% /sdcard
/dev/loop0              121299      1896    110229   2% /overlay
overlayfs               121299      1896    110229   2% /
/dev/mmcblk0p1        30517648    485152  30032496   2% /opt/wz_mini
/dev/mmcblk0p1        30517648    485152  30032496   2% /lib/modules
tmpfs                    46680        24     46656   0% /opt/wz_mini/tmp
tmpfs                    46680     13704     32976  29% /tmp
/dev/mtdblock3            3840      3840         0 100% /system
/dev/mmcblk0p1        31150192   3401104  27749088  11% /system/bin/factorycheck
tmpfs                    46680       680     46000   1% /dev
tmpfs                    46680         8     46672   0% /run
media                    46680         0     46680   0% /media
/dev/mtdblock6             384       104       280  27% /configs
/dev/mmcblk0p1        30517648    485152  30032496   2% /media/mmc

I tested on my V3 camera and it worked. This will be on the next Pull Request!