openfang icon indicating copy to clipboard operation
openfang copied to clipboard

[T20L Xiaomi Mijia 2018] Settings are gone after every reboot

Open martin-schlossarek opened this issue 5 years ago • 28 comments

No matter how I set the settings, whether via the web interface or via nvram set, they disappear after every reboot. Is this an expected behavior?

martin-schlossarek avatar May 09 '19 21:05 martin-schlossarek

No. What camera are you using and version ?

anmaped avatar May 09 '19 21:05 anmaped

I'm using Mijia 2018.

$ cat /opt/version 
rc05_01-46-g5dd319b

martin-schlossarek avatar May 09 '19 21:05 martin-schlossarek

You are using an old version, I recommend you to compile the last one or wait for rc6. I'll provide it soon. But as far as I know this version should be working well, try to setup the model, reboot, and setup the model again and reboot, it should solve your issue.

anmaped avatar May 09 '19 21:05 anmaped

Hmm.. rc05_01-46-g5dd319b is from third most recent commit (5dd319b8390b8961f4ccdab9ff43c43d84c4ed36).

I built a new image from the latest commit (b1c396e2c087abf78fef47c629da56b9a551a613), but this version doesn't boot. The LED flashes orange for ~25 seconds (sometimes also blue), stays orange for ~3 seconds and then goes out. The whole thing then repeats itself again and again.

martin-schlossarek avatar May 10 '19 21:05 martin-schlossarek

I will introduce a fix for old bootloaders, but this is due to the lack of the last bootloader which includes the auto device detection.

anmaped avatar May 11 '19 03:05 anmaped

Or, you can also add hwversion=SXJ02ZM to the uEnv.txt file in the bootargs parameter.

anmaped avatar May 11 '19 03:05 anmaped

Still no success.

5dd319b with hwversion=SXJ02ZM bootargs parameter: settings gone after reboot ~~b1c396e with hwversion=SXJ02ZM bootargs parameter: not bootable~~

//edit b1c396e boots up with hwversion=SXJ02ZM bootargs parameter, but still no savable settings

martin-schlossarek avatar May 13 '19 22:05 martin-schlossarek

b1c396e you have to set up hwversion=SXJ02ZM again, since the uEnv.txt file is replaced by a fresh one.

anmaped avatar May 13 '19 23:05 anmaped

Have it solved your problem?

anmaped avatar May 15 '19 03:05 anmaped

I will try it again this evening because I'm not home right now. I'll keep you posted.

martin-schlossarek avatar May 15 '19 05:05 martin-schlossarek

Ok, I added hwversion=SXJ02ZM to bootargs twice and now it's persisent. But still no look with nvram set. Everything is lost after a reboot:

image

martin-schlossarek avatar May 15 '19 17:05 martin-schlossarek

You have to use nvram commit to turn it persistent. You can also use the web UI for the majority of the things.

anmaped avatar May 15 '19 19:05 anmaped

Yes... forgot to use nvram commit for the screenshot, but I already tried it with no luck:

image

Changes on the web ui also don't survive a reboot.

martin-schlossarek avatar May 15 '19 20:05 martin-schlossarek

Try 'nvram clear rtdev; nvram commit; reboot' to factory reset the settings. The certificate should also be renewed by this action.

You can also try to clear all the sections of the nvram, use nvram layout to check them.

As a last resource you have to enable the debug mode on nvram. Some people have tried the fw and it worked well, so I assume it's something wrong with your setting.

anmaped avatar May 16 '19 04:05 anmaped

Hi anmaped!

I have same issue. Is it possible make revert back to stock?

HorseDickJoseph avatar May 16 '19 11:05 HorseDickJoseph

@HorseDickJoseph Can you describe which issue you have?

anmaped avatar May 16 '19 15:05 anmaped

You can also try to clean the mtd partition using flash_eraseall /dev/mtdX, where X is the number of the config mtd partition that you can check using cat /proc/mtd.

I tried to replicate the issue and I was not able to get it in the same camera and different models.

anmaped avatar May 16 '19 15:05 anmaped

I tried both approaches nvram clear rtdev; nvram commit and flash_eraseall /dev/mtd4. Still no success.

I followed the installation instructions from TheRoss and desoldered a leg of the SOP8 chip so I could flash the bootloader with a programmer clip. Then I soldered the leg back on. I booted the camera, opened the web ui, changed the wifi settings and the admin password and restarted the camera. When the camera didn't connect to the wifi network, started an AP again and the admin password didn't change, I noticed that no settings are saved at all.

Is it possible that the chip was somehow damaged during the soldering process so that it only runs in "read only" mode?

martin-schlossarek avatar May 16 '19 18:05 martin-schlossarek

@martin-schlossarek It's strange, I'll upload the image and the bootloader and you can flash them and try (you can also try the gitter chat). Here I can't reproduce such issue, but let's see what @HorseDickJoseph has to say (he said same issue).

anmaped avatar May 16 '19 18:05 anmaped

@anmaped I have a sami issue, like @martin-schlossarek. After I saved the settings and reboot, lost everything what Im set it. Looks like after the reboot, this is the first reboot after the flashing.

HorseDickJoseph avatar May 17 '19 12:05 HorseDickJoseph

@anmaped You have any news? How can I revert to stock the camera firmware? (I read the FAQ, if I remove the SD card, normal boot starting. But the camera isnt start.) You have the original bootloader? My mistake, I forgot saving first :(

HorseDickJoseph avatar May 27 '19 12:05 HorseDickJoseph

Today arrived my second camera (same). I save the bootloader, and write back to the old one. Write is successful, but the camera wont boot..... original.zip

But the size is very different

HorseDickJoseph avatar May 28 '19 10:05 HorseDickJoseph

@HorseDickJoseph I didn't understood your problem.

You have the full dump in https://github.com/anmaped/openfang/blob/master/doc/sxj02ZM/dump.tar.xz since December 2018. You can use it.

Edit: you can also find the unpacked FW in https://github.com/anmaped/openfang/tree/master/doc/sxj02ZM/unpacked

anmaped avatar Jun 03 '19 15:06 anmaped

@martin-schlossarek Any news ? Have you solved the problem ?

anmaped avatar Jun 03 '19 15:06 anmaped

@martin-schlossarek Any news ? Have you solved the problem ?

No sorry I was not able to solve the problem. Is there anything I can do to find out what's going wrong? Logs, debug data ...?

martin-schlossarek avatar Jun 03 '19 19:06 martin-schlossarek

@HorseDickJoseph I didn't understood your problem.

You have the full dump in https://github.com/anmaped/openfang/blob/master/doc/sxj02ZM/dump.tar.xz since December 2018. You can use it.

Edit: you can also find the unpacked FW in https://github.com/anmaped/openfang/tree/master/doc/sxj02ZM/unpacked

Can you tell me how can I use this files?

HorseDickJoseph avatar Jun 05 '19 12:06 HorseDickJoseph

I unfortunely have to same problem. The only setting that remains is het ntp-server.. Setting via the nvram set command and nvram commit doesn't persist either. /opt/version == 2018-11-21 02:01 (latest version on https://github.com/anmaped/openfang/releases )

It's a v3 version of the camera and I've flashed the bootloader with the programmer and de-soldered the vcc-pin (and re-soldered it again after flashing).

QuantumSingularity avatar Dec 26 '19 12:12 QuantumSingularity

I have found out a work-a-round.

I changed the settings in the webinterface. After that I check the nvram with: nvram layout Then per section: nvram show uboot nvram show 2860 nvram show rtdev nvram show cert nvram show wapi

After that I edited the init.d file /etc/init.d/S02factory on the sdcard.

$ cat S02factory 
#!/bin/sh

case "$1" in 
	start)
		section_names=$(nvram layout | sed -n '/name:/p' | awk -F' ' '{print $3}')
		factory=$(nvram get rtdev factory >&2)
		if [ $? != 0 ]; then

			for sec in $section_names
			do
				echo "Clearing sec: $sec"
				nvram clear $sec
			done

			#nvram set rtdev factory 1
			#nvram set rtdev fw_version "$(cat /opt/version)"
			#nvram set wapi adminpasswd "admin"

			# Create a SSL certificate
			#export OPENSSL_CONF=/etc/ssl/openssl.cnf
			#openssl req -new -x509 -keyout /etc/ssl/lighttpd.pem -out /etc/ssl/lighttpd.pem -days 365 -nodes -subj "/C=DE/ST=.../L=.../O=.../OU=.../CN=.../emailAddress=..."
			#chmod 400 /etc/ssl/lighttpd.pem

			#nvram set rtdev certificate "$(cat /etc/ssl/lighttpd.pem)"



			nvram set rtdev factory 0
			nvram set rtdev fw_version "$(cat /opt/version)"
			# restore the SSL certifcate
			nvram set rtdev certificate "$(cat /etc/ssl/lighttpd.pem)"
			nvram set rtdev model "T20L_M"
			nvram set rtdev motion_script_on "sh /opt/scripts/motion-script-on.sh"
			nvram set rtdev motion_script_off "sh /opt/scripts/motion-script-off.sh"
			nvram set rtdev motor false


			nvram set 2860 blue_led_pin "led_blue1"
			nvram set 2860 yellow_led_pin "led_yellow1"
			nvram set 2860 ir_pin 72


			nvram set wapi adminpasswd "<<your password>>"
			nvram set wapi mac "<<your_mac>>"
			nvram set wapi wmode "STA"
			nvram set wapi wssid "<<your ssis>>"
			nvram set wapi wpassword "<<your password>>"
			nvram set wapi wkeymgmt "KEY"

			nvram commit


		else
			[ "$(nvram get rtdev fw_version)" != "$(cat /opt/version)" ] && nvram set rtdev fw_version "$(cat /opt/version)"
			
			# restore the SSL certifcate
			nvram get rtdev certificate > "/etc/ssl/lighttpd.pem"
			chmod 400 /etc/ssl/lighttpd.pem
		fi
		;;
	stop)
		echo "do nothing"
		;;
	restart|reload)
		"$0" stop
		"$0" start
		;;
	*)
		echo "Usage: $0 {start|stop|restart}"
		exit 1
esac

exit $?
$ 

QuantumSingularity avatar Dec 28 '19 15:12 QuantumSingularity