Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
martin-schlossarek opened this issue May 9, 2019 · 28 comments
Open

Comments

@martin-schlossarek
Copy link

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?

@anmaped
Copy link
Owner

anmaped commented May 9, 2019

No. What camera are you using and version ?

@martin-schlossarek
Copy link
Author

I'm using Mijia 2018.

$ cat /opt/version 
rc05_01-46-g5dd319b

@anmaped
Copy link
Owner

anmaped commented May 9, 2019

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.

@martin-schlossarek
Copy link
Author

martin-schlossarek commented May 10, 2019

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

I built a new image from the latest commit (b1c396e), 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.

@anmaped
Copy link
Owner

anmaped commented May 11, 2019

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
Copy link
Owner

anmaped commented May 11, 2019

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

@martin-schlossarek
Copy link
Author

martin-schlossarek commented May 13, 2019

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

@anmaped
Copy link
Owner

anmaped commented May 13, 2019

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

@anmaped
Copy link
Owner

anmaped commented May 15, 2019

Have it solved your problem?

@martin-schlossarek
Copy link
Author

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

@martin-schlossarek
Copy link
Author

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

@anmaped
Copy link
Owner

anmaped commented May 15, 2019

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

@martin-schlossarek
Copy link
Author

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.

@anmaped
Copy link
Owner

anmaped commented May 16, 2019

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
Copy link
Owner

anmaped commented May 16, 2019

@HorseDickJoseph Can you describe which issue you have?

@anmaped
Copy link
Owner

anmaped commented May 16, 2019

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.

@martin-schlossarek
Copy link
Author

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?

@anmaped
Copy link
Owner

anmaped commented May 16, 2019

@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
Copy link
Owner

anmaped commented Jun 3, 2019

@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
Copy link
Owner

anmaped commented Jun 3, 2019

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

@martin-schlossarek
Copy link
Author

@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 ...?

@QuantumSingularity
Copy link

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
Copy link

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 $?
$ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@anmaped @QuantumSingularity @martin-schlossarek and others