telmomarques / xiaomi-360-1080p-hacks

Hacks for the Xiaomi Mi 360 1080p camera (MJSXJ02CM).
766 stars 129 forks source link

Compatibility with Mijia 1080p MJSXJ05CM ? #18

Open Jayah59 opened 4 years ago

Jayah59 commented 4 years ago

Hi !

Is this compatible ? I tried downloading tf_recovery.bin to sdcard and flashing but it did not work and I worse, I think my camera is bricked ...

LED amber is not blinking, it is permanent on and the camera does not move. Same observation without sd card

.<

rezmus commented 3 years ago

@viktorxda

#:~/manu_test$ openssl rsautl -verify -in md5sum.dat -inkey public-key.pem -pubin -out md5sum1.txt
#:~/manu_test$ md5sum -c md5sum1.txt
manu.bin: OK

yeah it will work ;) however factory mode prevents camera services from running, so i did something like this

#!/bin/sh

/etc/init.d/S50perp start
/etc/init.d/S60service start

if [ -f "/mnt/sdcard/manu_test/manu.sh" ]; then
    /mnt/sdcard/manu_test/manu.sh
fi
2879597772 commented 3 years ago

@viktorxda

#:~/manu_test$ openssl rsautl -verify -in md5sum.dat -inkey public-key.pem -pubin -out md5sum1.txt
#:~/manu_test$ md5sum -c md5sum1.txt
manu.bin: OK

是的,它将起作用;)但是工厂模式阻止了相机服务的运行,所以我做了这样的事情

#!/bin/sh

/etc/init.d/S50perp start
/etc/init.d/S60service start

if [ -f "/mnt/sdcard/manu_test/manu.sh" ]; then
  /mnt/sdcard/manu_test/manu.sh
fi

Is your ssh service normal? My ssh service seems to be started, and the account password is set on the web page, and the account password I set is entered in the ssh client, but I cannot connect because it prompts me that the password is wrong

2879597772 commented 3 years ago

Has anyone successfully used hacks ssh service? I cannot connect to the ssh service, and tell me in ttl: Login attempt for nonexistent user

I am pretty sure that I created and entered the correct account and password. Does anyone know how to solve it?

telmomarques commented 3 years ago

@2879597772 the dropbear server (ssh) reads virtual users from a configuration file, so you can't login using "root".

2879597772 commented 3 years ago

@ 2879597772 dropbear服务器(ssh)从配置文件读取虚拟用户,因此您不能使用“ root”登录。

@ 2879597772 dropbear服务器(ssh)从配置文件读取虚拟用户,因此您不能使用“ root”登录。

I changed other usernames, but they are still unavailable, and told me: Login attempt for nonexistent json config user

2879597772 commented 3 years ago

@2879597772 the dropbear server (ssh) reads virtual users from a configuration file, so you can't login using "root".

Can you tell me how you compile dropbear? I tried it myself but failed

telmomarques commented 3 years ago

@2879597772 I was looking into it and turns out there's an issue with the virtual users on 05 cam. I'll have to take a deeper look.

fumanchi commented 3 years ago

I eventually managed to compile the mija-framegrabber using a buildroot environment and running it manually via the rtsp-server srvices from the alpha.v3 works fine... telnet and web-config work fine... but web-config has actually no influence on the processes running on the cam and the rtsp-server must be called manually via telnet to actually get a running stream... any ideas?

thewh1teagle commented 3 years ago

@jandy123 after i compile the mjpg streamer, how to i use it? i mean, how do i pipe the frames from the camera into it? you can also talk with me on telegram https://t.me/thewh1teagle

telmomarques commented 3 years ago

@fumanchi current runit compilation is not working on this camera, working on it.

fumanchi commented 3 years ago

@telmomarques isn't it possible to use busybox to run/controll the services? Is the webconfig depending on runit? btw, i am a professional c++ developer... as i have kids my spare time is quite limited but if there is something i could do, just give me a hint :)

I actually do not want the xiaomi cloud/app working... is it possible to just stop these services?

My aim is to install the cam at our utility room's ceiling in the cellar to monitor the dryer and washing machine... the surface-mounted ethernet jack (providing power via poe using a splitter) is already installed :)

telmomarques commented 3 years ago

@fumanchi busybox contains runit, but using it just for runit is overkill. I already pushed a commit on my runit repo to fix that, I'm just taking care of the rest of the hacks to make sure everything runs on 05 before publishing.

To manage xiaomi's services you can use perp (try perpls on the camera, for example).

If you want to help please join the discord server :) it's where I publish alpha versions before pushing them as releases on github.

fumanchi commented 3 years ago

@telmomarques i installed discord but how to "enter" your group?

telmomarques commented 3 years ago

There's a discord badge at the top of the readme, just click it

jandy123 commented 3 years ago

@thewh1teagle: mjp-streamer doesn't use the framegrabber, as that spits out h265 encoded video stream. Re-encoding itinto mjpeg would be overkill for the camera. Instead, mjp-streamer captures jpg snapshots to make the mjpeg stream.

To run it, see my post above . You also need to point LD_LIBRARY_PATH to the dir. where you unpacked the archive.

thewh1teagle commented 3 years ago

@jandy123 I compiled the mjpg-streamer you sent me , and i run it like that on the camera: D_LIBRARY_PATH=$(pwd) ./mjpg_streamer -o "output_http.so -w ./www"

The http server is working on port 8080 but i can't see my camera stream there. 2020-09-16_21-29

jandy123 commented 3 years ago

@thewh1teagle: Try ./mjpg_streamer -i input_snapshot.so -o output_http.so

thewh1teagle commented 3 years ago

@jandy123 Tried...

#  D_LIBRARY_PATH=$(pwd) ./mjpg_streamer -i input_snapshot.so -o "output_http.so -w ./www"
MJPG Streamer Version: svn rev: 
ERROR: could not find input plugin
       Perhaps you want to adjust the search path with:
       # export LD_LIBRARY_PATH=/path/to/plugin/folder
       dlopen: input_snapshot.so: cannot open shared object file: No such file or directory
# 

With absolute path:

#  D_LIBRARY_PATH=$(pwd) ./mjpg_streamer -i $(pwd)/input_snapshot.so -o "output_http.so -w ./www"
MJPG Streamer Version: svn rev: 
ERROR: could not find input plugin
       Perhaps you want to adjust the search path with:
       # export LD_LIBRARY_PATH=/path/to/plugin/folder
       dlopen: libshbf.so.0.2: cannot open shared object file: No such file or directory
# 

Just want to make sure we talk about the same model. my camera model is MJSXJ02CM

jandy123 commented 3 years ago

@thewh1teagle: Well, I'm on 05CM; this explains it.

You'll need to try recompile. Modify the makefile and link appropriate libraries (which you should pull from the cmaera); see for instance Makefile for mija-framebuffer, in this repo. I have no clue if this will work out.

On the camera, do you have /mnt/data/bin/shbf_client ? If you do not have it, it's likely mjpg-streamer won't work.

Edit: One more thing. Maybe first try:

# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)

thewh1teagle commented 3 years ago

@jandy123 I succeeded to run it like that. The server is running , but again - I can't see the camera stream.

jandy123 commented 3 years ago

@thewh1teagle: Do you see any wired output ? Like cannot load some shared library, etc. Do you have executable /mnt/data/bin/shbf_client ?

Do you use the correctpath ? http://cam_ip:8080/?action=stream. You should be able to see the mjpeg stream.

To take a snapshot use: http://cam_ip:8080/?action=snapshot.

thewh1teagle commented 3 years ago
  1. I don't see any wired output.
  2. I have /mnt/data/bin/shbf_client
  3. I tried the path http://:8080/?action=stream it just try to load it but nothing. (http://:8080 display the server [ i sent image earlier] )
jandy123 commented 3 years ago

@thewh1teagle: I guess you mean: http://ip_of_camera:8080/?action=stream

Make sure that camera is not in standby and post me the output of mjpg_streamer when you start it.

thewh1teagle commented 3 years ago

@jandy123 ssh ssh1

No different output after i visited the site from the browser..

jandy123 commented 3 years ago

@thewh1teagle: I see... Looks like mjpg-streamer is not working on 02CM.

Could you login on the camera using ssh and execute /mnt/data/bin/shbf_client ? Leave ot run for a few minutes and see if it saves jpg files in the root of the sdcard. Let me know.

Also, see if you have /run/jpeg_snap and /run/jpeg_snap/control.

jandy123 commented 3 years ago

@thewh1teagle: No need. I already checked. shbf_client exists and is identical in functionality to the one on 05CM. But the libraries are different. How did you manage to compile input_snapshot.so ? You should have chnaged that makefile and linked to your own libraries pulled from the camera. Did you do that ?

I think input_snapshot.so silently fails to load...

jandy123 commented 3 years ago

@thewh1teagle: Try this new sources and compile plugins/input_snapshot using Makefile_02 from that folder. For plugins/output_http and mjp-streamer itself use your own makefiles. Of course point the gcc compiler to your own compiler.

Sorry for all this, but I've changed the sources in the meantime.

https://drive.google.com/file/d/13CN5ZCKjFMERSXmM73K0BKPRPbrbi7LY/view?usp=sharing

Jayah59 commented 3 years ago

Hello ! I'm back after a long, long time!

It's been a few days since I went back to it and it's amazing the progress you've made. I have since bought another camera and it is still an 05 but with a different flash chip. My first is a W25Q128.F and the new one is an EN25QH128.

The first one was completely bricked but thanks to the new one, I was able to make a backup of the flash and restore the other with programmer. I now have 2 working cameras. For the moment, they are both totally twin (@MAC and other) but that's another problem : D I will try to modify the vendor.bin an other day

Thanks to all of you. I was able to unbrick my camera, hack the firmware with @none815 post et grab a remote access with the alpha3. Now, I play with ssh thanks to @telmomarques and the latest comit on the different tools. I even have access to sftp and it's much more flexible to work with. I haven't managed to get the RTSP server to work yet, but I'm working on it. I saw @telmomarques recent post on Discord where he says he has an alpha for 05 and is looking for testers. I'm hot Telmo =)

:)

thewh1teagle commented 3 years ago

@jandy123

https://github.com/telmomarques/xiaomi-360-1080p-hacks/issues/18#issuecomment-694197249 "Leave ot run for a few minutes and see if it saves jpg files in the root of the sdcard."

_"Also, see if you have /run/jpeg_snap and /run/jpegsnap/control."

https://github.com/telmomarques/xiaomi-360-1080p-hacks/issues/18#issuecomment-694204056 _"How did you manage to compile inputsnapshot.so?"

https://github.com/telmomarques/xiaomi-360-1080p-hacks/issues/18#issuecomment-694216324 _"For plugins/outputhttp and mjp-streamer itself use your own makefiles."

And news: I used your latest link to google drive and created a repo from that so we can work on that In a more convenient way. https://github.com/thewh1teagle/mjpg_stream_xiaomi_1080_360

Edit: I tried input_snapshot with debug options using the make_02 makefile. that's the output:

2020-09-18_16-33

jandy123 commented 3 years ago

@thewh1teagle: Ok, the good part is that the on_recv_photo_stream() is called and the params seem ok. What is not good is the message about memory allocation. Have a look where that one comes from. At first sight, seems still a problem with the linked libraries.

thewh1teagle commented 3 years ago

@jandy123 Where did you got from the make_02 libs?

jandy123 commented 3 years ago

@thewh1teagle: from this firmware: https://github.com/telmomarques/xiaomi-360-1080p-hacks/tree/master/firmware/3.4.2_0062

Ok I spotted the problem from your log above. The line --- Receiver FrameInfo: 180 2 0 3068896880 The third number is the jpg file size. Above is 0, which obviously is not fine. Then, the "could not allocate memory\n" comes from callback on_recv_photo_stream from input_snapshot.c.

In my case, for instance if I run ./shbf_client I get output such as: Receiver FrameInfo is [2, 0, 168319, 98245875929]. Third param above is 168319 and not 0 as in your case. Could you also run /mnt/data/bin/shbf_client and see what you get ?

jandy123 commented 3 years ago

@thewh1teagle: could you allow me to make changes to the repo https://github.com/thewh1teagle/mjpg_stream_xiaomi_1080_360 ?

thewh1teagle commented 3 years ago

That's the output of shbf_client

2020-09-19_00-49

And I changed the permission in the repo
So you can edit it yourself.

Can we talk on telegram?

jandy123 commented 3 years ago

@thewh1teagle: When you run shbf_client, do you get valid jpeg images in the root of the sdcard ? Like previously, what I see above tells me that the file size should be 0....

Sorry no telegram here ;).

thewh1teagle commented 3 years ago

@jandy123 No. the jpeg files is completly empty.

jandy123 commented 3 years ago

@thewh1teagle: Huh, so this is the bloody problem... This why mjpg-streamer is not working either.

Could you modify input_snapshot.c and add something like

DBG("header %s\n", Parm2 + 14);

before

DBG("Receiver FrameInfo: %d %d %d %llu\n", *Parm2, Parm2[1], Parm2[4], Parm2[2], Parm2[3]);

and recompile using debug, run it and show me what you get ? Like you did above.

Maybe the jpeg is captured but somehow the length info is wrong...

thewh1teagle commented 3 years ago

I solved the shbd_client problem - i had a custom firmware. i reflashed to latest firmware from this repo and now shbf_client capture correct images. now, when i running mjpg_stream and try to navigate into http://192.168.1.108:8080/?action=stream that's the result: 2020-09-19_02-19

( same result in http://192.168.1.108:8080/?action=snapshot )

Another screenshot:

2020-09-19_02-23

jandy123 commented 3 years ago

Ok, now it looks good :). So the input plugin definitely works now, but I do not get the 404 not found, invalid plugin number.

Did you change anything in the Makefiles ?

Edit: Could you just run it using:

./mjpg_streamer -i ./input_snapshot.so -o ./output_http.so

I mean without the "$(pwd)/www" stuff ?

thewh1teagle commented 3 years ago

@jandy123 Yes, any change I did i commited into the new repo i created from your code. tried to run as you said. didn't worked.

jandy123 commented 3 years ago

That error message can be found in plugins/output_http/httpd.c. I've never seen that error before...

Edit: Compile the output_http and mjpg_streamer with debug info.

thewh1teagle commented 3 years ago

@jandy123 I did few changes in the repo, recompiled everything and now it's finally working! - snapshot & stream!

jandy123 commented 3 years ago

@thewh1teagle: Oke, glad it works.

Yeah, the makefiles need to be rewritten to support both targets, rather than use different ones. One the other hand, for 05CM I use a custom toolchain based on uclibc, whereas 02CM is based on standard libc... Well, don't know. I'll stop here for now.

thewh1teagle commented 3 years ago

@jandy123 Thank you very much.

jandy123 commented 3 years ago

@thewh1teagle: Sure, no problem.

jandy123 commented 3 years ago

@thewh1teagle: Maybe since now we know it works on 02CM and 05CM, @telmomarques can include it in the "standard distro" :).

Since the xiaomi app seems to be h265-only, as far as I know, using it is the only way to have all app functionality together with basic streaming based on mjpeg to e.g., hassio.

thewh1teagle commented 3 years ago

@jandy123 Actually I already used h264/5 rtsp with onvif on hassio. The cool thing about mjpg stream is that it works in the browser. h265/4 are not working in the browser.

jandy123 commented 3 years ago

@thewh1teagle:

Actually I already used h264/5 rtsp with onvif on hassio.

Ok, good to know. And how were you able to see the h265 stream ? I get only garbage using ffmpeg integration.

Also, you were talking about a custom firmware. Does such a thing exist on 02CM ???

thewh1teagle commented 3 years ago

I don't remember, it was a long time ago. ask in the discord chat that appers on the readme of this repo. About the custom firmware - @telmomarques created custom firmware that has full rw permission on the whole fs.

giomasce commented 3 years ago

It might occur that the SOIC clip will also power up the camera, this will interfere the flash programming. One solution is to cut HOLD (pin7) and VCC (pin8) to reduce power delivery, this can be done with some dupont wires:

I don't understand: when you say you have to cut pin 7 and 8, you mean cut the pin from the PCB, or just from the programmer?