672 | | |
673 | | [=#X11] |
674 | | == Adding X11 Support == |
675 | | You can easily add X11 support to a base image created with the debootstrap instructions above by adding a few package groups. You will need the following: |
676 | | * X11 server - ie Xorg |
677 | | * Display Manager - this controls the login to the X session |
678 | | * Window Manager - manages window position, re-sizing, decorations, etc for X clients |
679 | | |
680 | | A common solution is to install a Desktop Environment such as the [http://lxde.org/ Lightweight X11 Desktop Environment (LXDE)] that is used for Lubuntu. LXDE includes the Xorg X11 server, the lxdm Display Manager, the openbox Window Manager, and a slew of useful user applications including the Chromium browser: |
681 | | {{{ |
682 | | #!bash |
683 | | apt-get update |
684 | | apt-get upgrade |
685 | | apt-get install lxde xinit # adds ~434MB to a base console image |
686 | | }}} |
687 | | |
688 | | Notes: |
689 | | * you will need to add a non-root user with {{{adduser}}} for Chromium browser to work. You may choose to set up auto-login for that user by editing /etc/lxdm/default.conf and setting the {{{autologin}}} property in the {{{base}}} section at the beginning of the config file. |
690 | | * you will need to use a kernel with the vivante GPU driver built as a module or the Xorg server will crash |
691 | | |
692 | | === Hardware GPU Acceleration for X11 === |
693 | | |
694 | | ''' Note the below information has not been 100% proved out, proceed at your own risk ''' |
695 | | |
696 | | To add hardware GPU acceleration to X11 you need to add some libraries and drivers provided by Freescale from the imx-gpu-viv package. This requires signing Freescales End User License Agreement (EULA). This package provides the following: |
697 | | - libg2d - a documented low-level API to the GPU (used by things like libimxvpuapi for gstreamer-imx and the gpu-core drivers) |
698 | | - gpu-core - provides all the various OpenGL libs (libGL, libGLESv1_CM, libGLESv1_CL, libGLESv2, libGLSLC, libCLC, libEGL, libGAL, libOpenCL, libOpenVG) typically provided by the mesa project. Note that several versions of libEGL/libGAL/libGLESv2/libVIVANTE are provided for different backend rendering systems: dfb, fb, wl, x11. |
699 | | |
700 | | Procedure: |
701 | | 1. Install Freescale Vivante GPU libs (EULA): |
702 | | {{{ |
703 | | #!bash |
704 | | wget http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/imx-gpu-viv-5.0.11.p4.5-hfp.bin |
705 | | /bin/sh imx-gpu-viv-*.bin # accept EULA |
706 | | cd imx-gpu-viv-* |
707 | | # install just the g2d headers/libs |
708 | | cp g2d/usr/include/g2d.h /usr/include/ |
709 | | cp -d g2d/usr/lib/libg2d* /usr/lib/ |
710 | | # install gpu-core headers/libs |
711 | | cp -Pr gpu-core/usr/* /usr |
712 | | # install vivante driver for accelerated X11: |
713 | | cp vivante_drv.so /usr/lib/xorg/modules/drivers/ |
714 | | chmod 644 /usr/lib/xorg/modules/drivers/vivante_drv.so |
715 | | # optional: install demos |
716 | | cp -r gpu-demos/opt / |
717 | | # optional: install gpu tools |
718 | | cp -axr gpu-tools/gmem-info/usr/bin/* /usr/bin/ |
719 | | # fix lib collision between fsl/viv gpu-core and libgl1-mesa package |
720 | | rm /usr/lib/arm-linux-gnueabihf/mesa/libGL.so* |
721 | | # fix lib collision between fsl/viv gpu-core and libegl1-mesa package |
722 | | rm /usr/lib/arm-linux-gnueabihf/mesa-egl/libEGL.so* |
723 | | # fix lib collision between fsl/viv gpu-core and libgles1-mesa package |
724 | | #rm /usr/lib/arm-linux-gnueabihf/libGLESv1_CM.so* |
725 | | #rm /usr/lib/arm-linux-gnueabihf/mesa-egl/libGLESv1_CM.so* |
726 | | # fix lib collision between fsl/viv gpu-core and libgles2-mesa package |
727 | | #rm /usr/lib/arm-linux-gnueabihf/libGLESv2.so* # not there |
728 | | rm /usr/lib/arm-linux-gnueabihf/mesa-egl/libGLESv2.so* |
729 | | # fix lib collision between fsl/viv gpu-core and libopenvg1-mesa package |
730 | | rm /usr/lib/arm-linux-gnueabihf/mesa-egl/libOpenVG.so* |
731 | | }}} |
732 | | * Note: this could be better handled by creating a package and using Ubuntu/Debian 'alternatives' to handle library selection |
733 | | |
734 | | 2. switch to gpu-core x11 backend: |
735 | | {{{ |
736 | | #!bash |
737 | | backend=x11 |
738 | | ln -sf libEGL-${backend}.so /usr/lib/libEGL.so |
739 | | ln -sf libEGL-${backend}.so /usr/lib/libEGL.so.1 |
740 | | ln -sf libEGL-${backend}.so /usr/lib/libEGL.so.1.0 |
741 | | ln -sf libGAL-${backend}.so /usr/lib/libGAL.so |
742 | | ln -sf libGLESv2-${backend}.so /usr/lib/libGLESv2.so |
743 | | ln -sf libGLESv2-${backend}.so /usr/lib/libGLESv2.so.2 |
744 | | ln -sf libGLESv2-${backend}.so /usr/lib/libGLESv2.so.2.0.0 |
745 | | ln -sf libVIVANTE-${backend}.so /usr/lib/libVIVANTE.so |
746 | | ln -sf libGAL_egl.dri.so /usr/lib/libGAL_egl.so |
747 | | for i in egl glesv1_cm glesv2 vg; do |
748 | | cp /usr/lib/pkgconfig/${i}_${backend}.pc /usr/lib/pkgconfig/${i}.pc |
749 | | done |
750 | | # remove the other backends we no longer need |
751 | | rm /usr/lib/*-dfb.so /usr/lib/*-fb.so /usr/lib/*-wl.so |
752 | | }}} |
753 | | |
754 | | 3. make vivante kernel module (GPU kernel driver) load on boot: |
755 | | {{{ |
756 | | #!bash |
757 | | echo vivante >> /etc/modules |
758 | | cat << EOT > /etc/udev/rules.d/10-imx.rules |
759 | | KERNEL=="galcore", MODE="0660", GROUP="video" |
760 | | KERNEL=="mxc_asrc", MODE="0666" |
761 | | EOT |
762 | | }}} |
763 | | |
764 | | 4. create an xorg.conf configured for the Vivante fbdev driver: |
765 | | {{{ |
766 | | #!bash |
767 | | cat << EOT > /etc/X11/xorg.conf |
768 | | Section "Device" |
769 | | Identifier "i.MX Accelerated Framebuffer Device" |
770 | | Driver "vivante" |
771 | | Option "fbdev" "/dev/fb0" |
772 | | Option "vivante_fbdev" "/dev/fb0" |
773 | | Option "HWcursor" "false" |
774 | | EndSection |
775 | | |
776 | | Section "ServerFlags" |
777 | | Option "BlankTime" "0" |
778 | | Option "StandbyTime" "0" |
779 | | Option "SuspendTime" "0" |
780 | | Option "OffTime" "0" |
781 | | EndSection |
782 | | EOT |
783 | | }}} |
784 | | |
785 | | 5. Optional: re-build gstreamer-imx ([#gstreamer-imx above]) if you wish to use gstreamer-imx IPU/VPU/GPU acceleration within an OpenGL window (egl) |
786 | | |
787 | | 6. Sync filesystem and reboot |
788 | | |
789 | | |
790 | | Examples: |
791 | | * The {{{imxeglvivsink}}} allows hardware accelerated display to a window on the X11 host: |
792 | | {{{ |
793 | | #!bash |
794 | | DISPLAY=:0.0 gst-launch-1.0 videotestsrc ! imxeglvivsink |
795 | | }}} |
796 | | - See the [wiki:Yocto/gstreamer Gstreamer wiki page] for more details. |
797 | | * The {{{glxgears}}} application is a demo of OpenGL that often is used to benchmark rendering performance |
798 | | {{{ |
799 | | #!bash |
800 | | DISPLAY=:0.0 glxgears -info # ~300fps on IMX6Q |
801 | | }}} |