Skip to content

Latest commit

 

History

History
220 lines (116 loc) · 11.4 KB

README2.md

File metadata and controls

220 lines (116 loc) · 11.4 KB

warning: these steps require an intermediate experience with Linux commands

7. Building your own system

7.1 Create a Linux virtual machine

  • Login as a regular user: find its IP with "ip a", and from Putty or Linux terminal, connect with SSH. In the example below, the address is 192.168.1.131

7.2 Download the Armbian OS building script from Github

  • mkdir armbian-2023.05

  • cd armbian-2023.05

  • git clone --depth=1 --branch=main https://github.com/armbian/build

  • cd build

  • ./compile.sh

  • You will be presented the Armbian "TUI" (text user interface)

  • Keep the default option: "Do not change the kernel configuration"

  • In the next screens, select"orangepizero", "Choose a kernel: current ... LTS kernel", "Bullseye Debian 11", and "Standard image with console interface"

  • Then the script will start preparing the packages, sources, patches.

  • The scrip will perform large downloads and take a long time. Sit tight!

  • Once it finishes, the OS image is written in ../output/images. Use Balena Etcher.

  • Run this OS in the OrangePi Zero, to make sure you have a good OS building system. Test that you can login with SSH.

  • Congratulations! Now you have your own standard Armbian OS, which you built yourself!

7.3 Add the TV encoder driver to the Linux kernel source

  • Next, you will be sohwn the Kernel Config screen. Go to "Device Drivers", "Graphics Support", find "LIMA (DRM support...".

  • Press "SPACE" until you see "". This means that the kernel module will be compiled as a loadable .ko module. If you select "", it will be incorporated in the kernel. The ko location will be /lib/modules/6.1.15-sunxi/kernel/drivers/gpu/drm/lima/lima.ko

  • Since you have new user patches and new kernel module selected, the armbian script will download THE LINUX KERNEL SOURCE VERSION 6.1 This may take 1 hour. Don't sit tight, go outside and stretch! 😸

  • Then you will see the u-boot compilation process. This will take a few minutes.

  • Then you will see the LINUX KERNEL compilation. This may take 2 hours, and it may fail if the C code is bad due to the patches

  • BIG NOTEIf your downloaded Linux kernel is not version 6.1, you may need to manually fix the patches, to harmonize with the new Linux source. Sometimes, the line numbers change. Sometimes a function gets moved or deleted. Sometimes the parts of patch is "mainlined" (added to the official kernel), so the patch would have to have that part removed. If you make the patch work in another kernel version, let me know, so I can include it in this Github repository.

  • You will end up with a Armbian_23.05.0-trunk_Orangepizero_bullseye_current_6.1.15.img file. Write it on the microSD with Balena Etcher.

7.4 First time with your OWN Armbian OS, with your OWN changes 🤟

  • Test it in the OrangePi Zero. Repeat the same account configuration as the first time, though serial or SSH.

  • Run "armbian-config". In the "TUI" select "System", "Hardware". Find "tve" and select it.

  • Press "enter". Do not reboot yet. Select "Bootenv". In "console=serial", replace "serial" with "both". This allows the kernel to print on the TV screen during startup.

  • Notice that the previous step has added "tve" at the right side of "usbhost3". This is the place where we tell the bootloader "Uboot" to insert the "dtbos" (device tree binary overlays) in the "dtb", before running the Linux kernel, so that it knows where the new hardware is (bus and addresses).

7.5 You will need a new video cable

  • Modify a composite video cable (yellow AV cable) with 2 female "Dupont" connectors and a 50 ohm resistor as shown below

insert photo of video cable for orangepi zero

  • Connect them to the pins "GND" and "TVOUT" in the OrangePi Zero. Connect the AV connector to the TV, and turn the TV on.

  • Reboot with "sudo reboot"

  • You will be greeted with the Linux boot up screen on the TV 🙂

  • The text is overflowing to the left, right, upper, lower edges of the TV, due to "overscan".

  • This flaw was not present in Kernel 4.x. This is a flaw in the current driver that we as a community should try to resolve.

8. Install the X11 and xlde desktop

  • apt install xinit xterm xauth x11-apps xserver-xorg lightdm

  • Reboot Orangepi Zero

  • You should see a graphical logic screen

  • The lxde desktop will be "overscanned" beyond the edges of the TV. You will have to live with this until someone comes up with a solution.

  • Tip: from a terminal (Xterm or LXDterm) in the "LXDE start menu", execute this to check and change the resolution

    • xrandr --output Composite-1

    • xrandr --output Composite-1 --mode NTSC (or PAL)

    • xrandr --display :0.0 --output Composite-1 --mode NTSC (if executing from SSH)

    • you can replace "--display" with "-d" and ":0.0" with ":0"

    • xrandr may be a way to mitigate the overscan problem, but the true solution would be to improve the TV encoder driver

9. Activate 3D graphics acceleration and test

  • The OrangePi Zero ARM CPU, Allwinner Sun8i H3 has an embedded Mali 400 GPU.

  • Fortunately, the open source Lima.ko driver for this GPU is already included by default in Armbian 😄

  • Run "sudo modprobe lima" and check that this kernel module, driver for the Mali 400 GPU, is loaded in Linux.

  • Run "lsmod" and check that the resulting lines have "lima" and "gpu_sched". This means that the 3D driver is loaded.

  • Log out of the lxde session, and log back in.

  • "sudo apt install mesa-util g3dviewer"

  • Test the 3d graphics by opening a terminal: "glxinfo -B" to confirm that the "lima" 3D driver is in use.

  • Type "glxgears" and "g3dviewer" to see a demo of the OrangePi Zero 3D acceleration 🌠

  • Tip: if you want to do the previous 2 steps from SSH, first execute "export DISPLAY=:0.0"

  • Install some 3D screensavers: "sudo apt install xscreensavers xscreensavers-gl xscreensavers-gl-extra"

    • cd /usr/libexec/xscreensavers

    • ./glsnake

10. Activate and use analog audio

  • Enter "armbian-config" again. Select "System", "Hardware". Check the first item "analog-codec"

  • Reboot. Then install the audio driver "sudo apt install alsa-utils"

  • and prepare another AV cable with 2 coax connector, ideally white and red, and terminate it with "Dupont" connectors as shown below:

insert photo of audio cable

11. Install and test H264 video codec hardware acceleration

  • The OrangePi Zero ARM CPU, Allwinner Sun8i H3 has an embedded video encoder and decoder, and H264 is one of the most useful codecs in there.

  • Fortunately the open source sunxi-cedrus.ko which handles the codec, is already included in Armbian.

  • Type "sudo modprobe sunxi-cedrus" to load the kernel module. Type "lsmod" to see the several kernel modules that were loaded at the same time.

  • Install non-accelerated video players, to measure the initial performance: "sudo apt install mpv ffmpeg".

  • Test the non-accelerated video playing: "mpv yourh264file.mp4" and "ffplay yourh264file.mp4".

  • With another terminal window, run "htop" and see the CPU load (the H3 has 4 CPU cores). Also notice the video smoothness.

  • Install the accelerated video players: NOT DONE YET

  • References: baresip/baresip#2241 , https://forum.armbian.com/topic/17187-understanding-hardware-accelerated-video-decoding/ , vainfo , libva , ffmpeg --hwaccels , ffplay , libvdpau1 , vdpauinfo, gst-launch , ffmpeg -hide_banner -h decoder=h264