20 April 2020

Custom Firmware for Yi Home Cameras for use with Home Assistant

Hello all,
Here are my notes on flashing the firmware on Yi Home Cameras versions: 720p and 1080p, for use with Home Assistant.  The assembly consists of a black puck (the camera) and a white stand, see below:
The camera can be rotated within the stand or detached from it.  The camera is powered by a USB psu rated at 5V 1A, though the camera - unfortunately there are different versions of the same model number - hence the creation of this post consumes up to 3.5W for the most recent versions.

I bought my first pair of cameras: a 720p and a 1080p version back in 2016 and played with, but I never really found a use for them until now. 

The second pair of cameras I bought in a 'family' pack on promotion for £37.99 using discount code 'yihome22' from Amazon https://www.amazon.co.uk/YI-Wireless-Security-Detection-Surveillance/dp/B07CPRK6C5.  Normally, priced at £48.99.
 
Another two I have on order direct from Xiaomi Yi Store on Aliexpress at £14.59 each and a couple of pounds shipping from Spain, instead of China.  The only downside for the savings of £7 or £14 for the pair, compared with individual pricing, was that the USB supplies will be European or Schuko pinned.  This is no great loss since USB 5V 1A supplies can be readily sourced from Aliepxress for around £1.35 each or twin USB versions rated at 2A for £1.60: UK USB PSUs.

Hardware and Firmware Versions

Anyway onto the differences, since unfortunately the same model number 1080p, comes with different architectures and revisions: boo!  When will manufacturers and more specifically marketing departments learn *not* to reuse model numbers for different products?

The cameras bought in 2016 are based on the HiSilicon Hi3518e V200 chipset and the project for these is called yi-hack-v3.  The work is based on three other projects and credit where it is due:

  1. fritz-smh : https://github.com/fritz-smh/yi-hack
  2. niclet : https://github.com/niclet/yi-hack-v2
  3. xmflsct : https://github.com/xmflsct/yi-hack-1080p

This custom firmware gives additional functionality:

  1. SSH server - Enabled by default.
  2. Telnet server - Disabled by default.
  3. FTP server - Enabled by default.
  4. Web server - Enabled by default.
  5. Proxychains-ng - Enabled by default. Useful if the camera is region locked.

Flashing an updated firmware is a relatively straightforward affair where the two hardware specific files are loaded onto a microSD card, this is inserted into the camera and it is powered on.  The process is automatic and consists of the camera updating its onboard firmware while flashing its orange led for about 30-40 seconds.

Camerarootfs partitionhome partitionRemarks
Yi Home--Not yet supported.
Yi Home 17CN / 27US / 47USrootfs_y18home_y18Firmware files required for the Yi Home 17CN / 27US / 47US camera.
Yi 1080p Homerootfs_y20home_y20Firmware files required for the Yi 1080p Home camera.
Yi Domerootfs_v201home_v201Firmware files required for the Yi Dome camera.
Yi 1080p Domerootfs_h20home_h20Firmware files required for the Yi 1080p Dome camera.
Yi Outdoorrootfs_h30home_h30Firmware files required for the Yi Outdoor camera.
The 720p camera needed: rootfs_y18 and home_y18.  These files do not have an extension.
The 1080p camera needed: rootfs_y20 and home_y20, from the same location.
Final configuration is through the Yi Home app to set wifi credentials and through the web browser front-end visible at the default address of: http://yi-hack-v3, if your home network has mDNS, or via the IP address of the camera that can be found with the Yi Home app, under camera settings > network info.

New Cameras

The newest cameras are based on another chip the MStar chip and these require different firmware from: https://github.com/roleoroleo/yi-hack-MStar/releases
To identify which files to copy onto your freshly FAT32 formatted microSD card refer to the table below copied from the github page:

CameraFirmwareFile prefixRemarks
Yi 1080p Home 4FUS4.5.0*y203c-
Yi 1080p Home 6FUS4.5.0*y203c-
Yi 1080p Home 9FUS4.5.0*y203c-
Yi 1080p Home BFUS4.5.0*y203c-
Yi 1080p Dome 6FUS4.6.0*h201cThanks to @skylarhays
Yi 1080p Dome BFUS4.6.0*h201cThanks to @skylarhays
Yi 1080p Home 4FUS4.2.0*y25-
Yi 1080p Home 9FUS4.2.0*y25-
Yi 1080p Home 6FCNunknowny203c-
So by referring to the back of the latest cameras, the identifier is: BFUS

thus the files I need are prefixed y203c.  So following the link there are .tgz compressed archives from which the files can be extracted using 7zip.  Then copy them onto another microSD card in preparation for flashing.
Unfortunately, this time things did not go to plan - there was no flashing orange led for forty seconds - signifying the update process, and instead, the camera started as if the files were absent with its audible setup sequence.  So I checked the files again, nothing, formated the card with the SD Association official formatter software, as I have for other projects like RPi work needed to properly prepare the storage, and reload the files again nothing.  So I turned to the forums and it turns out others were having similar problems, but with different hardware.  I explained what I was experiencing and described my process so far and I received a prompt reply, thanks roleo: "Try another SD card."
It transpires the Samsung 8GB card I was using, and had been using in a RPi just wasn't playing nicely and that other users had experienced similar problems, but the cause has yet to be determined.  Swapping for another card, an old 16GB Samsung class 10 affair, the firmware update executed as expected.
So to help others and potentially unearth the unknown cause I uploaded details of the problem card, see images below:

16 July 2019

Flash Non-Volatile Storage Bandwidth RPi4

Updated 10/01/2020 with Sandisk Ultra 128GB USB3 Flash Drive
Updated 28/07/2019 with Sandisk Ultra 64GB USB3 Flash Drive
Updated 23/07/2019 with Netac 32GB Class 10 U1 SDHC and Sandisk Ultra 64GB SDXC added
Updated 17/07/2019 with Sandisk 64GB Extreme SDXC added


Not all types and formats of non-volatile memory are the same.  Varying in interface and access times and speeds.  The performance of different devices will understandably affect performance and 'performance' is something I am interested in for the new RPi4 with USB3.

My new RPi has arrived and I am interested in the relative performances of some microSD cards I have.  Using CrystalDiskMark v6.0.4 a utility for benchmarking storage devices I ran the test and the results are shown below:

Samsung MicroSD 32GB Class 10
Formatted with FAT32


Sandisk MicroSD 128GB Ultra
Formatted with exFAT

As a comparison with other storage types:
USB3 Sandisk Flair 64GB Flash Drive
Formatted with FAT32

Samsung 860 EVO 500GB SSD connected to SATA bus
Formatted with NTFS
The SSD, of course, trounces the other storage options in performance and cost per GB, but not in terms of format, because it requires a connection to the SATA bus.  I am interested in microSD format performance for using an RPi4 as a NAS device running two USB3 WD 10TB drives in RAID1.

Update
Sandisk Extreme microSD 64GB
Formatted with exFAT

Revised conclusion
Given the price premium attached to the Extreme model and the nominal existing good performance of the 128GB Ultra version I would recommend the 128GB version given the extra available space.

Update 2
Netac 32GB Class10 U1 SDHC
Formatted with FAT32
Sandisk Ultra 64GB SDXC
Formatted with exFAT
Update 3
Sandisk Ultra 64GB USB3 Flash Drive
Formatted FAT32

Formatting the USB drive with the exFAT filesystem, for comparison, the results are realistically unchanged.
Update 4
Sandisk Ultra 128GB USB3 Flash Drive
Formatted FAT32


Strangely, this drive performs slower than its smaller 64GB sibling and I am unable to explain why.

16 June 2019

GIMP generating a SVG from a picture

The generation of a SVG in GIMP requires a path to be made around the shapes of interest.  This in turn requires the shapes of interest to be selected, because from there paths can be generated by placing a single path point using the path tool that looks like a pen and line with three dots:

click inside the area of interest, right-clicking and choose Select > To Path.

The generated path points can then be changed or simplified as needed.
Then from the path toolbox select the path and right-click selecting Export Path. 

Remember to add the file suffix of .svg

Et volia!

15 June 2019

I2C 12bit DAC MCP4725 Addressing



Hello everyone today a pack of MCP4725 modules arrived.  The MCP4725 is a single channel, 12-bit, voltage output Digital-to-Analog Converter with integrated EEPROM and an I2C Compatible Serial Interface.

I am posting this because the module didn't work, out of the pack, with the Adafruit library: https://github.com/adafruit/Adafruit_MCP4725
The specific module I am using was bought from and cost about 66 pence each:
https://www.aliexpress.com/item/32428403866.html

Problem

The IC was generating a static voltage of 1.625v and not the expected slow-varying sinewave defined in firmware. The code relevant to addressing the chip is:

  // For Adafruit MCP4725A1 the address is 0x62 (default) or 0x63 (ADDR pin tied to VCC)
  // For MCP4725A0 the address is 0x60 or 0x61
  // For MCP4725A2 the address is 0x64 or 0x65
  dac.begin(0x60);  // corrected address from 0x62

The default address is 0x62 and assumes a MCP4725A1 part.  The supplied part is a MCP4725 and the address select pads are unsoldered - see pads circled in blue:


Now ICs can have internal pull-ups and pull-downs, but checking the datasheet: https://www.microchip.com/datasheet/MCP4725
There doesn't appear to be any bias on the A0 pin and so I measuring it with the part powered up and it is 0,02v, so LOW.  

Solution

The default address for the part is 0x60 and if the ADDR and VCC pads are bridged then 0x61.

Happy prototyping!

Supporting Library

https://www.dropbox.com/s/46g9dr2213adhj9/MCP4725-master.zip