Introduction¶
This document describes how to use VNC server on a CCpilot display.
Overview¶
Virtual Network Computing, VNC, allows someone to remotely view and control a computer, or in this case a display. Each of our CCpilot displays can be extended with a VNC server which means you may remotely connect and control the display from a VNC Client. The VNC server has been developed to be a standalone service, without use of Qt or other services.
The screen mirroring module contains tar archives for each of our i.MX8 devices. The tar packages contain the following:
VNC binary (
ccvncserver, with LibVNCServer linked statically)Start script (
start-ccvncserver.sh) that selects the touch scaling and options for the displaySystemd service file for auto start
Glossary¶
Word/Abbrevation |
Explanation |
|---|---|
VNC |
Virtual Network Computing |
fps |
Frames Per Second |
client |
The device that want to see the content of another device on screen |
server |
The device that will send its content over the network to a client |
DRM/KMS |
Linux Direct Rendering Manager / Kernel Mode Setting, the display controller interface the server reads the screen from |
Blitter (G2D) |
The 2D graphics hardware of the i.MX SoC, used to copy the screen and draw overlay planes |
Overlay plane |
A hardware layer on top of the main screen, for example video shown with |
JPEG |
Picture compression used by the Tight encoding; the server can encode it in hardware |
CCVNC server¶
CrossControl has made a VNC server implementation based on the open-source library LibVNCServer. This server will forward mouse clicks from a VNC client to multi touch events on the display.
The server requires CC Linux 5.1 or later and runs as root (the systemd service does this).
How the screen is captured¶
The server reads the screen from the display controller (DRM/KMS), so it works with any application that shows its picture through KMS, for example Qt with eglfs_kms or a Wayland compositor such as Weston. It does not need a special Qt graphics integration. It does not keep DRM master and waits if nothing is shown yet, so it can be started before or after the application or compositor. If DRM capture is not possible the server falls back to /dev/fb0.
Pixel formats. The screen buffer must be 32 bit
XRGB8888,ARGB8888,XBGR8888orABGR8888. Linear buffers always work. Vivante tiled and super-tiled buffers (Weston) are copied and untiled by the 2D blitter, so they need it.Overlay planes (for example
kmssinkvideo) are drawn into the picture by the 2D blitter with the position, scaling, colour conversion and alpha used by the display. Supported plane formats are linearXRGB8888,ARGB8888,XBGR8888,ABGR8888,RGB565,YUYV,UYVY,NV12andNV21, at most 4 planes. Other formats and tiled planes are left out. Plane alpha, rotation and YUV colour range are ignored. Use--drm-infoto list the planes.2D blitter copy. The screen is first copied by the blitter into cacheable memory, which the CPU can read much faster than the display memory. If the blitter is not available the screen is read directly (
--read-method=neon32forces this), but then tiled screens and overlay planes cannot be shown.Change detection. The server only reads the screen after a page flip, or at least every 0.5 s. Changed areas are found with a CRC32 hash of the screen (no copy of the previous frame is kept) and sent as up to 8 rectangles. Programs that draw directly into the framebuffer without page flips (
fbdevsink) are found by the timed looks, which follow--fpswhile the screen changes.
Hardware JPEG encoder¶
With --encoder=hw-rect the changed screen areas are JPEG-encoded by the hardware encoder of the SoC (mxc-jpeg, V4L2) instead of by the CPU. This gives a higher frame rate and a lower CPU load. It is used for clients that use the Tight encoding with JPEG. Other clients, 256-colour clients, and all clients if no hardware encoder is found, are served in software.
The JPEG quality and chroma subsampling follow the quality setting of the client. Lossless settings (zlib, ZRLE) do not use JPEG and are much slower. Set the client quality to 6 or 7 for the best frame rate. Lower quality settings give smaller JPEGs and less network load.
Every changed rectangle is sent as JPEG, also flat user interface areas and text, and grayscale client settings are sent as colour. Use
--encoder=swif that is not wanted.The hardware encoder sometimes produces a damaged JPEG. The server checks every JPEG before sending it and encodes it again at a slightly lower quality, or in software, when needed.
--hw-pipeline(experimental) is for screens that change completely at a high frame rate. It encodes the next frame before the client asks for it.
Command line options¶
The different CCpilot display types use the same software but needs some specific options to be able to handle the difference in screen sizes. The following command line options are available:
Option |
Description |
|---|---|
|
Port number to connect to. Default 5900. |
|
Password to view server content. Default: no password. |
|
No input from client to server possible. |
|
Turn on VNC server logging and print the changed areas. |
|
Highest number of screen captures per second. Default 2 (the start script uses 10). Higher FPS makes interaction more responsive but with increased CPU and network load. |
|
Scaling of the touch coordinates. Default 125. See the start script. |
|
Invert x/y scaling. |
|
For displays without multi touch. |
|
Touch device to be used. Default |
|
Rotation of the screen when being sent to the client. Default 0. |
|
|
|
Threads used to read and compare the screen. Default 2. |
|
Force the hardware JPEG quality instead of following the client. |
|
Chroma format given to the hardware encoder. Default |
|
V4L2 JPEG encoder device. Default is to find it. |
|
Rectangles smaller than this are encoded in software. Default 0. |
|
Threads that encode the rectangles of an update while the main thread sends them. Default 2, 0 encodes in the sending thread. |
|
Encode rectangles of at least this many pixels as two strips. Default 0 (off). |
|
Experimental, needs |
|
How the screen memory is read: |
|
Copy a screen buffer only after the next vblank, to avoid half-drawn frames from GPU compositors such as Weston. |
|
Read the screen every frame instead of only after a page flip. |
|
Find changed areas by comparing with a copy of the previous frame instead of CRC32 hashes. |
The following options are for diagnostics and troubleshooting:
Option |
Description |
|---|---|
|
List the CRTCs and planes (format, size, modifier, position) and which plane is captured, then exit. Run it when something is missing from the picture. |
|
Print timing statistics every 2 seconds. See Measuring performance. |
|
Measure the screen read speed for all methods and thread counts, then exit. |
|
Compare the blitter copies with a direct read and report differences in |
|
Decode every hardware JPEG before it is sent. A bad one is logged and saved as |
|
Every 5 seconds write |
|
With |
To connect to the VNC server in the CC display you will need to start a VNC client/viewer on your remote device and connect to the CC display with the IP address. You should see the display screen mirrored on your VNC client and be able to control the display from the VNC client. TigerVNC, TurboVNC, TightVNC and Remmina have been tested.
Installation on i.MX8 devices¶
CCVNC server can be installed on the target in two different ways.
Supported devices¶
i.MX8:
CCPilot V510
CCPilot V700
CCPilot V705
CCPilot V710
CCPilot V1000
CCPilot V1200
CCPilot V1090
CCPilot V1290
RAUC bundle¶
For production use the CCVNC server should be installed on the target using a RAUC bundle.
Reference the CC Linux - Using RAUC documentation on the support web site for more information about how to generate a RAUC bundle.
Installing it manually for development/testing¶
During development or testing of the CCVNC server it can be installed on the target manually by unlocking appfs and manually unpacking the tarball, tar.gz, under appfs.
Unlock /appfs for development/testing¶
Open an ssh session to the target:
ssh ccs@<IP-ADDRESS>Change write permissions of /appfs:
sudo mount -o remount,rw /appfs
Check which version partition /appfs is mounted to:
rauc statusUnmount /appfs:
sudo umount /appfs
Format the partition:
sudo mkfs.ext4 /dev/<PARTITION>
Remount /appfs:
sudo mount /dev/<PARTITION> /appfs
Unpacking tarball¶
Download the tarball, ccvncserver-ccl51_
_imx8.tar.gz (for example ccvncserver-ccl51_2.0_imx8.tar.gz), from the support site under:Software & Solution -> Screen sharing -> Downloads -> Device downloads -> <TARGET>Transfer the tar.gz package to device:
scp ccvncserver-ccl51_<VERSION>_imx8.tar.gz ccs@<IP-ADDRESS>:/tmp
Open an ssh session to the target:
ssh ccs@<IP-ADDRESS>Change directory to
/tmp:cd /tmp
Run the following code to unpack it:
sudo tar xzf ccvncserver-ccl51_<VERSION>_imx8.tar.gz -C /appfs
CCVNC server will not automatically start at boot. See Example usage.
Example usage¶
After unpacking the tar.gz package the VNC server will not start automatically. See below for how to enable auto start of the server. Once the service has been started it will run the script /appfs/vncserver/start-ccvncserver.sh, which starts the VNC server as root.
The script reads the display resolution from the device EEPROM (ccsettingsconsole), or from the framebuffer if the EEPROM has no resolution, and selects the touch scaling for 800x480 (V700), 1280x800 (V1X00) and 1920x1080 displays. It starts the server with the hardware JPEG encoder at 10 fps:
/appfs/vncserver/ccvncserver --fps 10 --x-scale <X_SCALE> --y-scale <Y_SCALE> --encoder=hw-rect
To enable or disable the VNC server at boot use
sudo systemctl enable ccvncserver
sudo systemctl disable ccvncserver
To change FPS or other options, edit /appfs/vncserver/start-ccvncserver.sh and restart the service or reboot the device:
sudo systemctl restart ccvncserver
For smoother video (camera streams of 30 fps, animations) raise FPS in the script. The CPU load goes up with it, so check it on the target. To add a password and change the port, add for example --passwd <password> --port 5901 to the command line in the script.
Measuring performance¶
Run the server with --profile to print timing statistics every 2 seconds. Times are average/maximum milliseconds. The most useful lines are:
capture: frames per second, page flips per second of the screen (capture should follow it) and time per frame.hwjpeg: JPEGs per second, size and time to encode.hwjpeg damagedis only printed if a damaged JPEG was found and repaired.vnc: updates per second and time to send each.clientshows the time between two updates (gap).time spent: where the sending thread spends its time. A high share waiting for the client means that the viewer or the network is the limit, not the server.tcp: throughput, round trip time and how long the connection was limited by the client’s receive window or send buffer.g2d: blitter copy times, and with overlay planes theoverlay_*timers.
If something is missing from the picture, run ccvncserver --drm-info to list the planes and which one is captured. For picture errors, --dump-frame shows whether the error comes from the screen copy or from the change detection and encoding.
Known limitations:¶
CCpilot X900 & X1200¶
The CCpilot X900 and X1200 does currently not support a VNC connection using CCVNC server. Alternative approach is to use Qt and the built-in “VNC” platform as covered in the QT VNC platform plugin section.
CCpilot VS¶
Wayland works good but EGLFS doesn’t work as expected. The mouse clicks behaves odd when running Qt-apps.
All i.MX8 and i.MX9 devices¶
The server needs root, because it reads the screen through DRM/KMS and DMA-BUF. The service runs as root.
The 2D blitter library (
libg2d) is needed for tiled screens (Weston) and overlay planes. Without it only linear buffers are read, directly, and overlay planes are not shown.Plane alpha, plane rotation and the YUV colour range of overlay planes are not handled, and tiled overlay planes are left out.
A video producer that commits frames as fast as it can (
kmssink sync=falseon a non-live source) limits the capture to about 20 fps. Cameras and live sources are not affected.A hardware cursor that only moves is shown at the next capture, up to 0.5 s later on a quiet screen.
In-place drawing without page flips (
fbdevsink) can tear briefly and costs more CPU. Use--fps 30for a 30 fps source.With
--encoder=hw-rectevery changed area is sent as JPEG, and the picture is not lossless. A client set to lossless encodings (zlib, ZRLE) is much slower. Use--encoder=swfor grayscale or palette clients.Qt applications no longer need to be started with
eglfs_vivandQT_QPA_EGLFS_FORCE888. The screen is captured through DRM/KMS, soeglfs_kmsand Wayland compositors work.
Qt VNC platform plugin¶
An alternative approach instead of using the CCVNC server is to use the Qt platform plugin “vnc”. A Qt application can be started with the flag “-platform vnc” to start a VNC server session. This will render graphics to a VNC offscreen buffer instead of the display screen and all graphics will be sent over the network. The drawback with this approach is that the Qt application must be restarted in VNC mode and the display screen will be black during this time. But if this is an acceptable behaviour during a service session, the performance is superior in this approach compared to running the CCVNC server.
VNC Client¶
Currently the displays do not support using a VNC client, i.e. viewing/interacting with a remote computer from a CCpilot display.
Security considerations¶
Some customers have had problems with the default VNC port (5900). There is a possibility that this port number attracts a huge number of login tries if a display is public accessible on the Internet. That amount of data traffic can slow down the communication and might also add a traffic cost.
Change the server to use a different VNC port number to avoid easy detection from malicious botnets and similar.
A password is always recommended before allowing a client to attach to the display.
Only enable VNC server for a limited time, during a service session, and not enabled by default.
License¶
The CCVNC server builds on libvnc which uses a GPL v2 license and this software will also use GPL v2 license.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
A written offer to get the source code will be included in the downloadable package.