warning: these steps require an intermediate experience with Linux commands
-
Download and install VirtualBox: https://www.virtualbox.org/wiki/Downloads
-
Download a Server Ubuntu "Jammy Jellyfish" system: https://releases.ubuntu.com/jammy/ (recommended compilation OS on March 2023)
-
Create a virtual machine with 1 GB RAM and "bridged networking"
-
Start the VM, install Ubuntu Jammy Jellyfish.
- 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
-
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!
-
Download these patches:
-
sunxi-6.1/0036-wip-h3-h5-cvbs-armbian.patch : makes additions to the "dts", which tells the kernel where are the new devices. Adds kernel code to interact with the tv encoder. With my modifications, now it is applicable to Armbian (this patch came from the LibreElec github).
-
sunxi-6.1/zzzz2-tv.patch : by Armbian user "gleam2003", adds directives to make sure that the dtbo (device tree binary overlay) is compiled
-
sunxi-6.1/zzzz3-tv.patch : more additions to the "dts" and "dtsi" (like C include files), which I noticed were included in "yam" patch, but missing from the LibreElec patch
-
Reference: https://forum.armbian.com/topic/16804-solved-orange-pi-pc-h3-armbian-focal-5104-sunxi-av-tv-out-cvbs-enable/page/2/ and https://forum.armbian.com/topic/22226-orange-pi-zero-lts-tv-out-in-2022/
-
-
Move them to ~/armbian-2023.05/build/userpatches/kernel/archives/sunxi-6.1 (using the scp command or sshfs)
-
Run ./compile.sh again. In the "TUI", ask to CHANGE KERNEL CONFIGURATION. Continue with the rest of configurations as before.
-
The script will apply the patches you downloaded. This is the part that will fail if a patch is mis-formatted, or there are errors in the content if the patch. The script will tell you which patch, and what part was bad.
- 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.
-
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).
- 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.
-
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
-
-
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
-
- 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
-
Connect the OrangePi Zero to the TV audio inputs or speakers (amplified, not a speaker by itself)
-
Verify that the audio driver sees your audio hardware: "aplay -L" and "arecord -L"
-
Configure the audio hardware.
-
Type "alsamixer", then with the arrow keys increase the "Line Out" level to 25%. Then press "ESC" to exit
-
Install audio application: "sudo apt install mpg123"
-
Test with a WAV file: aplay yoursoundfile.wav
-
Test with a MIDI file: aplaymidi yourmidifile.midi
-
Test with an MP3 file: mpg123 yourmp3file.mp3
-
References: https://forum.armbian.com/topic/7216-orange-pi-zero-problem-with-onboard-soundcard/#comment-58239
-
https://trac.ffmpeg.org/wiki/Capture/ALSA , https://dev.to/ethand91/how-to-record-webcam-video-and-audio-using-ffmpeg-419c , https://www.baeldung.com/linux/ffmpeg-webcam-stream-video
-
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