24 June 2020

Raspberry Pi SSH and VNC Server

Hello Everyone,
As part of a netbooting Pi project I needed to image a freshly configured install, but encountered this screen with connecting to the VNC server:
Normally, this should be a quick fix, a bit of searching et voila!  However, this was not the case and there are many posts about resolving this, and I followed the instructions in a couple, but none resolved this issue, so that is why this post exists: concise instructions.  I remember thinking at the time when last did this that it was fiddly and that I should keep some notes about how to set this up, but I didn't, so I'm doing it now.

The Process 

After imaging a new SD card create a file "ssh", without the quotes - no dot or file suffix, in the root/top directory.  This enables the SSH service on boot.  Transfer the SD card, connect up the wired ethernet and apply power.  I use PuTTY to SSH into the RPi either use the IP or hostname "raspberrypi" and use the default username "pi" and password "raspberry".

Edit the config.txt file in the boot directory: sudo nano /boot/config.txt
Uncomment the hdmi_force_hotplug=1, by deleting the preceding hash symbol.
Ctrl+x to exit
Press y and enter to confirm saving of the file.

Run the configuration tool: sudo raspi-config

Select 3 Boot Options
Select B1 Desktop / CLI
Select B3 Desktop, to enable booting to the desktop and provide graphics for the VNC Server to display.

Select 5 Interfacing Options
Select P3 VNC
then Yes to enable VNC Server

Select Finish and then Yes to reboot.

You should now be able to connect to the Pi with a VNC Viewer. Enjoy.

31 May 2020

Elite this is not! Docking SpaceX with the International Space Station simulation


Hello,
This is not one of my typical posts, but I was tipped off by my friend Tatwang to a simulation whereby you get to attempt the docking procedure between a SpaceX vessel with the International Space Station.
Decades ago, and the proud owner of a BBC B Micro, I played a lot of Elite, hours and hours and hours.  It was a lot of fun and it's amazing to think of the time and effort involved extracting every last bit of performance from the hardware - a radical change from contemporary coding practices with teetering stacks of frameworks.  Anyhow, I was good at Elite, so I should be good at this: how difficult could this be?  It's not like the ISS spins on an axis like the space stations did in Elite...


SpaceX Controls

Lateral controls
Rotational controls
Operated by mouse the SpaceX controls are more sophisticated than the simple roll, pitch and thrust you get in Elite - in addition to these, the SpaceX vessel provides yaw and lateral thrusters and even the ability to go backwards!  Though the ISS does not spin like a space station in Elite, successfully docking with the ISS requires more delicate control and has stringent final requirements on orientation: 0.2deg or better, velocity: 0.2m/s or less and positional alignment better than 20cm...


Could I do it? 

Of course, I could!
The process is definitely is a tad slower than I remember the practised equivalent in Elite.  This version is neither practised or a top-speed approach carefully tuned to make full and robust use of available shields to cushion the final 'landing', but surface to say the skills are similar.  I wonder about all the time saving that could be achieved if Elon had only outfitted all SpaceX craft with comparable shielding. :)


Yes, but how fast?

I recorded an Elite-esque demonstration for you to see my approach.  In retrospect, I think the creators missed an opportunity by randomising the initial position and orientation of the craft which appears to be fixed when starting each new game.


The SpaceX ISS simulation can be found here: https://iss-sim.spacex.com.  Let me know how you get on in the comments.

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.