I am building a device that runs Android OS. So is there any way I can prevent the OS from crashing due to frequent power cuts?
I am building a device that runs Android OS. The device would be often switched off abruptly, so the OS would not be shut down properly. This can result in OS crash. So is there any way I can prevent the OS from crashing from these frequent power cuts? I am not allowed to use a battery for backup power
Ideally, you'd have a battery (or supercapacitor) that'd keep you alive long...
Ideally, you'd have a battery (or supercapacitor) that'd keep you alive long enough to allow you to detect the main power supply cut-off and perform a clean shutdown. In the absence of that, anything else is merely damage limitation.
That said, some suggestions:-
* Use different filesystems for data areas of the system (e.g. /data), and mount OS filesystems (e.g. /system) read-only. That should prevent OS components from being corrupted, unless the user is foolish enough to begin an OS upgrade before cutting the power.
* Mount data filesystems with synchronous writes enabled. This will impair performance, and on reduce the life of flash memory-hosted filesystems by increasing the total number of writes committed.
* Give the use an obvious "clean shutdown" option.
* If your device is battery powered, monitor the remaining battery capacity and shutdown at some empirically-determined "safe" minimum level (e.g. 5% remaining).
If you don't need to keep changes between executions, you can mount the...
If you don't need to keep changes between executions, you can mount the filesystem as ro, with only some temporal folders mounted on RAM. If some configurations have to be keep, a partition in ROM can be mounted only for this end.