susi_linux icon indicating copy to clipboard operation
susi_linux copied to clipboard

To add a hardware button that will trigger the factory reset process

Open sansyrox opened this issue 6 years ago • 4 comments

Actual Behaviour

Right now the factory reset process can be triggered only by the terminal

Expected Behaviour

To use hardware switch to allow factory reset

Would you like to work on the issue?

Yes

sansyrox avatar May 31 '18 20:05 sansyrox

Here is an approach mentioned by @hongquan

OpenWrt approach:

  1. Divide storage (flash) to 2 partitions: Read-Only one (1) and Writable (2).
  2. Programs are placed in 1st partitions. Their default configuration are also placed in 1st partition. Changed configuration are placed in 2nd partition. They then use some technique (called "overlay") to place the configuration of the 2nd partition to be on of top 1st partition. For example: they have the network config at /etc/config/network. But if user changes it (change SSID & password), the new content are stored in 2nd partition and later access of this file will get the content from the 2nd partition, not the 1st.
  3. They reserve a hardware button for resetting, connected to a GPIO port. If this button is pressed, a program is triggered, which will erase the content of 2nd partition: All configuration are reset to default, corresponding to what stored in partition 1.

mariobehling avatar Jun 22 '18 07:06 mariobehling

Now, I think we cannot follow totally OpenWrt's approach, because:

  • Our software is just an app, not an OS. We cannot define how partition should be.
  • Changing partition layout will involving modify Raspbian build script. If we do too much modification, we will end up maintaining a new OS!

So, instead of dividing to 2 partitions (read-only and writable), we can divide our app to 2 parts:

  • Software body, saved in root-owned folder (/usr/local/ or /opt), so that it cannot be overwritten.
  • Configuration, saved in user's home directory, or /etc/.

For resetting, we just delete the configuration files.

hongquan avatar Jun 22 '18 08:06 hongquan

@hongquan , we already make a config.json file , we can delete just that and uninstall and install all the packages. Using this method would contain the factory reset in a single script

sansyrox avatar Jul 09 '18 23:07 sansyrox

But we also need the body of application to stay read-only, to prevent overwriting by accident.

hongquan avatar Jul 10 '18 07:07 hongquan