Skip to content

Latest commit

 

History

History
378 lines (282 loc) · 15 KB

readme.md

File metadata and controls

378 lines (282 loc) · 15 KB

Promoscreens Backend Setup

Set up the Promoscreen by logging in to the backend with your credentials. (?Source of credentials?)
Login: Promoscreens Backend

? Create a User and get the Username/Mail and API TOKEN. ?

? Other steps to do ?

Raspberry-Pi Promoscreen

Setup of Raspberry-Pi Promoscreen devices running with raspios 32bit (armhf)

Hardware

Used Hardware:

  • Raspberr Pi Official USB-C Power Supply
  • Raspberry PI 4 Computer, Model B 8GB RAM
  • PureLink CInema Seriers Micro HDMI - HDMI Cable (CS1200-030)
  • SandDisk Extreme Plus 32GB For the GUI set up, you will also need a USB Keyboard and Mouse.

Note: Make sure the Micro HDMI cable is conected to the HDMI0 Port on the Raspberr Pi. (HDMI0 PORT is next to the usbc power supply port. Do NOT use HDMI1 port)

Image

For the stable raspios 32bit (armhf) image go to raspberrypi.org and Download the newest version of the raspios_armhf image.

https://downloads.raspberrypi.org/raspios_armhf/images/raspios_armhf-2021-05-28/2021-05-07-raspios-buster-armhf.zip

(Instructions Tested under version: raspios_armhf-2021-05-28)

Unpack the File and continue with the unpacked "2021-05-07-raspios-buster-armhf.img" image.

Pi Imager

Install Raspberry Pi OS by Flash the downloaded image onto an clean microSD card. Use flashing software like: Raspberry Pi Imager or balenaEtcher


Image Setup

For setting up the Device, open the just flashed MicroSD which now should be displayed as "boot" drive. Before removing the SD and the first boot, the image needs the following steps.
If the image/drive is not or not showing as boot, manually remove the drive and reinsert it into your card reader.

Device config.txt

Inside the boot folder directory find config.txt and replace the file with the config.txt from this repo.

(Note: Currently, the device setup is intended for wired LAN connections only. The config disables: wifi, bluetooth and sound on the device.)

Setup SSH-Access

For a headless setup, SSH can be enabled by placing a file named ssh, without any extension, onto the boot partition of the SD card. This will activate SSH on the Pi.

host => raspberrypi.local
username => pi
paswword => raspberry

Connect via ssh terminal:

Removing local cached fingerpint for IP on your device

In case you already used the Raspberry Pi device with an SSH connection to the pies IP before, you may get an SSH Key Error. Resolve this error by removing the cached fingerprint on your machine.

ssh-keygen -R 192.168.1.2  #Local IP of your Raspberry-Pi.

Device Setup

Finally, remove the flashed & configured microSD card from your machine and insert it into the Raspberry-Pi. The following Steps take place on the Raspberry-Pi device.

The first boot can take up to 3-5 minutes. During the first boot, the device may restart multiple times.

When using the setup with gui:
If the first boot was successful, you now should be greeted with the "Welcome to the Raspberry Pi Desktop!" Setup window on the desktop of the Pi.

Follow the Setup Guide instructions:

  • Set Country, Language, and Timezone
  • Set user and password Raspberry-Pi.
  • Set Up your screen in case you see black borders.
  • skip wifi installation (if using wired LAN connection.)
  • Update & Install Software (This can take up to 10-20 minutes. On success, it will show a "System is up to date" window.)
  • Set Up Complete, Restart the Raspberry-Pi

Tipp: after the reboot, open this repo in the installed browser of the Raspberry-Pi, and follow the instructions there, to easily copy and paste commands from your browser directly

Firmeware Update

Befor starting
(again) Update & Upgrade the Raspberry-Pi dependencies and packages:
(This should not take much time since the pi should already be up to date.)

sudo apt-get update
sudo apt-get upgrade -y

Update & Upgrade the Raspberry-Pi 4s bootloader:
(This should not take much time since the pi should already be up to date.)

sudo rpi-eeprom-update
sudo rpi-eeprom-update -a

Browser Installation & Setup

Prerequisites

Before setting up the Browser and Chromedriver, install required Graphic Drivers and dependencies in advance.

sudo apt-get install -y curl unzip xvfb libxi6 libgconf-2-4
sudo apt-get install libgles2-mesa libgles2-mesa-dev xorg-dev

Browser

The 32bit version of the RaspiOs, comes with the correct chromium-browser already installed. If you followed the instructions above correctly, you should also have the correct version. To confirm that,
Enter:        chromium-browser --product-version

Driver

When using the 32bit version of RaspiOs you will need to install chrome driver via chromium-chromedriver. Install the regular chromedriver by:

sudo apt-get install chromium-chromedriver

To confirm installation was correct, and see if chromedriver matches your chromium-browser

Enter:        chromium-browser --product-version
And:          chromedriver --product-version

Both Versions should match.

Raspi Config Configuration

To open the Raspberry-Pi's Command line Settings enter in Terminal:

sudo raspi-config

Inside Raspi Configuration Window, configure the following settings:

Configuration Set
Disable sleep mode of Display Display Options → D4 Screen Blanking → No.
Video Resolution to 1920x1080/60hz Display Options → 1920x1080/60hz.
GL Driver Advanced Options → GL Driver → G2 GL (Fake KMS)
Disable the compositor. Advanced Options → Compositor → No

Reboo and Check 3D Drivers

After making these changes, you should be prompted to reboot the Pi.
Do so, alternatively run

sudo reboot

After the reboot, check if the settings took effect.

cat /proc/device-tree/soc/firmwarekms@7e600000/status
cat /proc/device-tree/v3dbus/v3d@7ec04000/status

If both commands return 'okay', then the Graphic drivers are correctly installed and activated.

Chrome

Additonal Plugins

Currently, for the Raspberry-Pi with 32bit architecture are no recommended Plugins for further Performance Improvements

Enable Chrome Flags:

To enhance the Chrome browser performance. You have to enable special Chrome-Flags inside the Browser.  
To do that enter following Chrome URLs inside the URL bar

Enable: chrome://flags/#ignore-gpu-blocklist
Enable: chrome://flags/#enable-gpu-rasterization

afterwards restart the Chrome browser.

To check the Chrome browser Graphics Feature Status enter: chrome://gpu
All features should show a green status text (except Vulkan).
Currently on (32bit), The Video Decode features will show 'Software only..'

Screenshot of settings

Clone Github Repository

Make sure you have an ssh public key and have access to the repository. (Only in case this repository is not public anymore)

ssh-keygen
cat ~/.ssh/id_rsa.pub

Clone this Repo as scripts folder.

git clone https://github.com/codebar-ag/raspberry-pi-kiosk-32bit scripts 

then enter the scripts folder.

cd scripts

Inside the Repo (scripts folder):

Install Pyhton Dependencies

On raspi os explicitly use the 'python3' & 'pip3' commands to call python. run:

pip3 install -r requirements.txt

Autostart Config Set Up.

NOTE: SECRETS SHOULD NOT BE VISIBLE IN GIT AND USED WITH ENV VARS.

To run the autostart script, the config has to be set up correctly.

To establish a connection and AUTH to your server the script needs, a base URL of your backend endpoint, and to authenticate to the endpoint, a Username(email) and Token has to be provided.
The scripts config looks for the corresponding environment variables AUTH_TOKEN, AUTH_USER and SCREENURL_BASE inside the script's Current Working Directory (CWD, where the autostart.py is located).

There are two ways to provide the environment variables:

I. Make use of the .env File

By renaming the provided template file .env.dist to .env or creating your own, then edit the .env file as follows. Uncomment all needed lines and insert your credentials at the corresponding placeholder. (see example below)  
Make sure to set your correct base URL for SCREENURL_BASE="".
Note: Only set the base url without paths - especially dont use any /api/identification path.

For more information about the AUTH Process with the Promo screens Backend, see the API documentation

In terminal use:

cp .env.dist .env   # rename env file with cp
nano .env           # edit the .env file 

Inside the File:

#MY_ENV_VAR="This is my env var content."
SCREENURL_BASE="< PLACE BASE URL eg. https://promoscreens.yourdomain.com >"
AUTH_USER="<PLACE YOUR USER EMAIL HERE>"
AUTH_TOKEN="<PLACE YOUR TOKEN HERE>"

The Config script will automatically load the token and other environment variables from the env. file to the config.yaml.

II. Or temporarily set the Environment Variables using export

Inside the Scripts CWD run:

export SCREENURL_BASE="< PLACE BASE URL >"
export AUTH_USER="<PLACE YOUR USER EMAIL HERE>"
export AUTH_TOKEN="<PLACE YOUR TOKEN HERE>" # add environment variable to CWD

This will be overwritten/deleted on every boot of the Raspberry-Pi.

The config.yaml provides a way to manually set and configure different options***

Config.yaml File Settings

Config File Settings
Screenurls & Endpoints
placed underneath screenurls:
Option Description
base sets the base URL to your backend (Default: this is set via environmental variables and env file)
identification the relative URL path to the backend's API identification endpoint.
browser_start_url The URL to the first page the Kiosk Browser loads on opening, before any request to the backend was made. (Default: Internal-Offline-Fallbackpage)
browser_start_url_is_internal set to True/1 if config browser_start_url is a relative internal file path will then be read as file://. (eg. offlinefallback/index.html)
fallback the relative internal path to the Internal-Offline-Fallbackpage (Default: offlinefallback/index.html)
Server Auth
placed underneath auth:
Option Description
user username (email) for basic authenticate (Default: this is set via environmental variables and env file)
token token for basic authenticate (Default: this is set via environmental variables and env file)
Other Options
Option Description
homecall_period Interval in seconds between every call from device to the backend to check and update the current screen URL (Default: 60 seconds)

Python Autostart Script

NOTE: The Current Working Director of the script is the autostart directory! Change one directory up to the autostart folder.

cd /home/pi/scripts/autostart

then run with python3

python3 autostary.py

autostart will open the chromium in Fullscreen kioskmode.

Note: To exit the kioskmode close it with ALT+F4

Configure Autostart to automatically start on boot

To continuously automatically start the autostart python script and open the Adscreen after every boot, add start_on_boot.sh script to the Raspberry-Pi´s lxsession file.
Copy the full/absolute path to the start_on_boot.sh file inside the assets directory.
eg.: /home/pi/scripts/assets/start_on_boot.sh

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

and add the following line inside the file (with your corresponding file path eg.:) :

@/bin/bash /home/pi/scripts/assets/start_on_boot.sh

Save.
Now on every reboot the browser kiosk will open.


Common Exceptions:

Common Exceptions on running the python script.

Wrong Driver Version (64bit Image)

If you run the python script and receive:

Errors:

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 93
Current browser version is 88.0.4324.187 with binary path /usr/bin/chromium-browser

This means: Your Browser and Driver versions are different and do not match. in this example, the ChromeDriver only supports Chrome-Browser version 93. And you have version 88 Installed.

Wrong Driver Binary (64bit Image)

If you run the python script and receive:

OSErrors:

OSError: [Errno 8] Exec format error: 'chromedriver'

run: which chromedriver If this returns

bash: /usr/bin/chromedriver: cannot execute binary file: Exec format error

This means: you possibly installed a false chromedriver architecture binary. eg. ia32 instead of needed armv7l. Delete the chromedriver binary and download the right armv7l binary version.