Tuesday, 23 November 2021

How to make Batocera working on small LCD display (such as MHS35) for RPi4

 

This tutorial is on how to make Batocera display work on small LCD screens such as MHS35 (as shown below) for Raspberry Pi 4. The same principle can be applied to other models of LCD display as well as other Raspberry models.

This is an advanced tutorial, you are assumed to be familiar with basic Linux working principle, can SSH into Raspbian and Batocera, copy files in and out, and have already made your small LCD screen working on Raspbian OS.

The steps are mainly divided into 2 categories, kernel level and user level:

  1. Kernel level

    a) Copy the overlay driver module files (e.g., for MHS35 LCD screen, mhs35.dtbo, mhs35-overlay.dtb) into /boot/overlays/ folder from Raspbian’s /boot/overlays/ folder


    b) Create a new folder /boot/overlays.bak/ and copy /boot/overlays/vc4-kms-v3d-pi4.dtbo into it for backup; then copy /boot/overlays/vc4-fkms-v3d.dtbo into /boot/overlays/vc4-kms-v3d-pi4.dtbo , this is to force Batocera to load the LCD’s 3D driver instead of HDMI’s 3D driver

    c) Adjust settings in /boot/config.txt and /boot/cmdline.txt

    i) In /boot/config.txt , add the LCD driver line dtoverlay=mhs35:rotate=90 ; add the GPU 3D acceleration line dtoverlay=vc4-fkms-v3d,noaudio ; you can optionally add the display resolution lines, you can use either fixed resolution (e.g., 800×480):

    hdmi_group=2
    hdmi_mode=87
    hdmi_cvt 800 480 60 6 0 0 0

    hdmi_drive=2

    Or flexible resolution (with initial resolution, e.g., 85 for 1280×720, please refer to Raspberry Pi official link):

    hdmi_group=2
    hdmi_mode=85
    hdmi_drive=2

    ii) In /boot/cmdline.txt , append console=serial0,115200 fbcon=map:10 fbcon=font:ProFont6x11 to the line (don’t create a new line), these optional settings are for console display

  2. User level

    a) Create a new folder (e.g., mybin ) inside the system folder, transfer the frame-buffer copier program, /usr/local/bin/fbcp, into that folder

    b) Copy the dependent libraries (such as libvchiq_arm.so.0, libvcos.so.0, etc.) into the folder; you can get the dependency libraries of a Linux executable by running ldd -v fbcp in Raspbian

    c) Create the auto-start script /system/custom.sh (if absent), add the line to run fbcp, LD_LIBRARY_PATH=/userdata/mybin /userdata/mybin/fbcp & into the script

Take note that if you SSH into Batocera to modify things, the /boot folder is mounted as read-only, if you want to modify files, you need to remount it as read/write, mount /boot -o remount,rw ; the root folder (excluding /userdata) is ramfs (file-system in memory), any change will be reverted upon reboot, so all new files or modifications must be in /userdata folder, which is the data partition (/media/<your-username>/SHARED) if you mount the SD card in a PC.

No comments:

Post a Comment