shadow-1 / yi-hack-v3

Alternative Firmware for Xiaomi Cameras based on Hi3518e Chipset
GNU General Public License v3.0
1.16k stars 154 forks source link

Creating Linux images from scratch #124

Open diegosueiro opened 6 years ago

diegosueiro commented 6 years ago

@shadow-1,

Today I found this repository and I'm wondering if you already tried this. It should be interesting if we have the possibility of booting an alternate Linux image (kernel and rootfs) from the micro sdcard. I'm especially interested in getting this working for the Yi Dome 1080p and I will invest some time on this. But I'm still not sure how your current hack works. If you could give details on what happens after the kernel boots it will help me a lot.

Another thing is, do you have details of the Dome 1080p hardware? Which camera sensor is, flash and ram size and other aspects? Do you know if it is possible to have access to the SoC UART console?

As a side note. I read that you are currently trying to get rtsp working (which is wonderful), have you already saw this project?

FunkyM commented 6 years ago

Cool find. This appears to be a fork of the https://buildroot.org/ project with injected hisilicon board configuration and some SDK files for audio/video support. The goal appears to be to compile a "live-streamer" RTSP application for the camera but it doesn't appear complete.

I managed to add the missing pieces and a custom toolchain for the Yi 1080p Dome and everything "buildroot" compiles appears to work fine on the camera. It appears I might even already have proper jffs2 images being generated for the camera, too.

I am going to test the video functionality and to get "live-streamer" running properly before attempting to flash the generated images but it looks very promising since the binaries work nicely.

diegosueiro commented 6 years ago

@FunkyM,

Yes, it is based on Buildroot.

Thanks for your report. Do you know if the original image has support for kexec (both Kernel and userspace tool)? If so, it is easy to get it booting an alternate kernel and rootfs from micro sd and no modifications will be needed at bootloader stage.

If the live-stream project that I linked works fine I think it's a good candidate to bring rtsp server into the hack.

FunkyM commented 6 years ago

No kexec support is enabled in the installed kernel but one can simply compile the same kernel with it enabled and use it just fine on the camera. You don't even have to modify the bootloader (which would also work just fine) as you can simply use the existing u-boot with the new kernel and fs images. Since it attempts to load specifically named files from the SD card on boot you can hardly break things either.

I currently managed to build and run many packages bundled with buildroot on the camera. All work fine. The live-streamer tool, using the latest v2.0 branch, now also runs, as well as the popular live555 RTSP media server. Mind that only live-streamer supports a live camera RTSP implementation.

I think it will finally all work out and provide a proper fully customized firmware for the whole Yi range of devices (no hacks needed) but there is one last thing I'd need to fix in my code now. The camera uses a custom sensor implementation that is not open-source and appears to handle video ram buffers differently from what live-streamer or the OEM SDKs suggest. Thus currently the media engine (video/audio) does not fully initialize correctly. Asides, I also found out that many of the bundled apps are actually slightly modified examples from the OEM SDKs...

Once I got some more time I might further look into extending live-streamer to support loading the specific sensor libraries correctly, then I am sure it will work without much issues. As buildroot is flexible enough, this will support all Yi cameras which have a toolchain available and finally allow them to work as a proper ip camera.