[Ovmsdev] Factory reset methods

Michael Balzer dexter at expeedo.de
Mon Apr 16 19:12:17 HKT 2018

Am 16.04.2018 um 03:05 schrieb Mark Webb-Johnson:
> Michael,
> Nice work. I like both options.

Thanks. Not much work, hopefully helps.

> One suggestion:
>     At the moment, you can do a ‘sd unmount’ and then hold the BOOT button to factory reset. It can even be mounted during this reset process.
>         OVMS# sd unmount
>         Unmounted SD CARD
>         W (1321564) ovms-module: SW2 pushed, factory reset in 9 seconds
>         W (1322564) ovms-module: SW2 pushed, factory reset in 8 seconds
>         OVMS# sd mount
>         Error: SD CARD could not be mounted
>         E (1323204) sdmmc_cmd: sdmmc_card_init: send_scr (1) returned 0x109
>     For safety, is it worth checking isinserted() as well as ismounted() and only allow this to factory reset if the SD is not actually inserted (as well as
>     not mounted)? We’ve had so many troubles with SD CARD support in ESP IDF, I am terrified of going anywhere near it.

I have only thought about the SW2 reading being influenced by SD data yet, not vice versa. I don't think there would be any data transmission if the SD is only
inserted, but it doesn't hurt changing the check.

For the other direction, I'll add a check of the SW2 state to the mount methods, so no mount is attempted while the button is pressed. I think that should be
possible, as we already take care of the insertion detection ourselves.

We should add a general warning to the guide though, that pushing the button with an SD card inserted should ultimately be avoided. I guess if you hit the right
moment on a write, you can trash the SD filesystem.


> Regards, Mark.
>> On 15 Apr 2018, at 11:24 PM, Michael Balzer <dexter at expeedo.de <mailto:dexter at expeedo.de>> wrote:
>> Reality has proven we need some simple way to do a factory reset, we've got users that don't know how to use a serial USB terminal.
>> I've implemented the button and SD card methods discussed earlier.
>> To do a factory reset you can now alternatively to using "module factory reset"…
>>   * a) Insert an SD card that has a file "factoryreset.txt" in the root directory. The file will be erased, as will be your configuration.
>>   * b) Open the module, remove any SD card, power the module up, wait for 2-3 seconds until boot has finished, then push and hold SW2 for 10 seconds.
>> The SD card needs to be remove for method b because SW2 grounds SD_DATA0 as well. Besides the slight chance to trigger 10 false readings from a running
>> transmission, I also found the SD driver to be unforgiving about pushing SW2 during a transfer. It will eventually lock up the module completely needing a
>> hard reboot. So it's better to require SD removal for this method.
>> Regards,
>> Michael
>> Am 22.02.2018 um 07:30 schrieb Greg D.:
>>> Ha, good thought!  Put a text file in the root directory named
>>> "factoryreset.txt" containing "OVMSv3" as a key, stick it in, and power
>>> up.  Done.  Brilliant.
>>> It probably should remove said file once the config is cleared, as a
>>> fail-safe.  Don't want it to act as a poison pill.
>>> Only "gotcha" is that finding things that can write to a micro SD card
>>> is becoming harder.  No to the iPhone.  Also my latest Android, though
>>> it does have an OTG adapter so I can get there with a USB reader.  The
>>> ecosystem is trying to force storage to a (paid, data mine-able) cloud,
>>> I think, using space and cost savings as a ruse.
>>> Greg
>>> Mark Webb-Johnson wrote:
>>>> The other option is SD CARD.
>>>> Firmware update can work that way. Put an ovms3.bin in the root of an SD card, plug it in, and it will be auto-flashed to update firmware.
>>>> We could have special files on SD CARD doing certain things. Like safe boot. Factory reset. Wifi AP. etc.
>>>> Can we write an SD CARD from an iPad? :-)
>>>> Regards, Mark.
>> Am 22.02.2018 um 06:22 schrieb Greg D.:
>>> We have two buttons:
>>>>  1. Hardwired RESET. That resets the chip.
>>>>  2. IO0 BOOT. If held during BOOT, that goes into firmware download mode.
>>>> So, only #2 is usable, and that only after boot. I guess we could have a boot delay to allow time for it to be pressed after power up.
>>> Yes, something like that.  I've worked on products where holding button #2 after releasing #1 would first take the product into a reset-to-defaults mode for
>>> about 10 seconds, then if you kept holding it after that, would take you to the downloader.
>>>> But, that would require opening up the case to get to the button. Nasty. Plugging it into a PC is probably easier?
>>> Hooking to a PC wouldn't necessarily be easier, but certainly safer.  I take it that the buttons on the 3.1 hardware aren't anywhere that can be accessed
>>> through a proverbial paper clip-sized hole, nor in such a way that a metal paper clip wouldn't be in danger of hitting something live.  Opening my box, I
>>> see the 3.0 hardware is not set up that way.  The switches would need to be moved to the back side of the board for that, and the holes put in the case. 
>>> Are we too late?
>>> I guess we can assume that our customers are at least somewhat technology-literate, and in the event that they lose their AP pass key, a USB serial console
>>> might be a reasonable way to reset things.  But if the only "PCs" they own are a smart phone and tablet, or in the event that the module is password
>>> protected too, use of the buttons would still be required.  Or, they can cash in their "phone a friend" token.  :)  PCs aren't totally obsolete, yet. 
>> -- 
>> Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
>> Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
>> _______________________________________________
>> OvmsDev mailing list
>> OvmsDev at lists.openvehicles.com <mailto:OvmsDev at lists.openvehicles.com>
>> http://lists.openvehicles.com/mailman/listinfo/ovmsdev
> _______________________________________________
> OvmsDev mailing list
> OvmsDev at lists.openvehicles.com
> http://lists.openvehicles.com/mailman/listinfo/ovmsdev

Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20180416/ecd1eef6/attachment.htm>

More information about the OvmsDev mailing list