Language:EN / NE / AE / DE / IT

안녕하세요. 


이번에는 네이티브 화면 출력을 이용해서 리눅스 데스크톱 환경을 사용해 보도록 하겠습니다.


관련 영상은 아래를 참고하시길 바랍니다.



아직 테스트 중이며 잘 작동이 되지 않을 수 있습니다.


1. 아예 시작이 되지 않을 때가 간혹 있음

2. 소리가 안나오는 경우 있음

3. 그래픽 가속은 지원되지 않음 (영상 디코딩도 포함)

4. 최근에 사용되는 wayland 는 제가 무엇인지 잘 모릅니다. 질문은 제발.. ㅠㅠ 

5. 라즈베리파이보다 빠릅니다. 그러나 라즈베리파이는 최근에 xserver 관련 그래픽 가속 드라이버가 추가 되었습니다. 부드러움이나 영상재생은 라즈베리파이보다 못합니다. 참고하시길 바랍니다.


시작해 보겠습니다.





1. xserver-xorg , xinit 설치 및 키보드 마우스 찾기


아래의 명령으로 설치를 진행합니다.


apt-get install xserver-xorg xinit


다음으로 설정을 진행합니다. 


일단 마우스와 키보드 입력을 찾아내야 합니다.


root@AOL-Debian:/dev/input# ls


event0 event1 event2 mice  mouse0  mouse1


일단은 우측의 mice 부분은 신경쓸 필요가 없습니다. event0 event1 event2 가 중요한데요. 


상기는 U5PVR 에 아무것도 꼽지 않은 상태에서 진행한 것입니다. 제가 정확하게 체크를 해보지 않았지만, event0 은 IR리모컨입니다. event1 과 event2 는 정확하게 모르겠습니다. 가상으로 생기는 것인지 잘 모르겠네요.


evtest 를 사용해서 체크를 해보실 수 있습니다.


root@AOL-Debian:/dev/input# apt-get install evtest

Reading package lists... Done

Building dependency tree        

Reading state information... Done

evtest is already the newest version.

0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.

root@AOL-Debian:/dev/input# evtest

No device specified, trying to scan all of /dev/input/event*

Available devices:

/dev/input/event0: Hi keyboard

/dev/input/event1: Hi mouse

/dev/input/event2: qwerty

Select the device event number [0-2]: 


상기 화면에서 디바이스를 입력하고 키 입력을 주시면 확인이 가능합니다. 혹은 아래의 명령으로 반응이 있는지만 간단하게 체크해 보실 수 있습니다.


root@AOL-Debian:/dev/input# cat /dev/input/event0



그러면 키입력을 줄 때 이상한 글자들이 창에 나올것입니다.


저의 경우 event3 가 키보드 event4 가 마우스로 잡혔는데요. 동일하게 cat 으로 입력을 받아보면 키보드를 누를때 랜덤값이 찍히고, 마우스를 움직일 때 랜덤값이 찍힙니다.


(쉽게는 USB 키보드 마우스 꼽았을 때 어떤 파일이 생기는지 보시면 됩니다.)


자동으로 디바이스를 등록하는 방법에 대해서는 정확하게 모르겠습니다.


키보드 입력을 상기와 같은 방법으로 찾고 아래의 파일을 수정합니다.


root@AOL-Debian:~# cd /usr/share/X11/xorg.conf.d/

root@AOL-Debian:/usr/share/X11/xorg.conf.d# nano 10-evdev.conf 



#
# Catch-all evdev loader for udev-based systems
# We don't simply match on any device since that also adds accelerometers
# and other devices that we don't really want to use. The list below
# matches everything but joysticks.

# Device 에 번호를 상황에 맞게 변경하시길 바랍니다.
Section "InputDevice"
        Identifier      "Keyboard0"
        Driver          "evdev"
        Option          "Device"        "/dev/input/event3"
        Option          "Protocol"      "usb"
EndSection

Section "InputDevice"
        Identifier      "Mouse0"
        Driver          "evdev"
        Option          "Device"        "/dev/input/event4"
        Option          "Protocol"      "usb"
EndSection


다음으로 U5PVR 은 테스트 끝에 framebuffer 를 /dev/graphics/fb0 를 사용한다는 것을 알게 되었습니다. 


랜덤값을 /dev/graphics/fb0 에 쓰면 화면의 색깔이 변하거든요. 실제로 그렇게 해보니 일정량 색깔 변화가 있었습니다.


그래서 아래의 파일은 새로 생성을 하여 fbdev 드라이버를 사용하여 화면을 출력하도록 설정을 변경합니다.


(fbdev 드라이버는 소프트웨어로 작동하며 하드웨어 가속의 지원은 없습니다. 가속이 되려면 하이실리콘에서 xorg 에 맞는 드라이버를 제공해야합니다. 리눅스 SDK 에 혹시나 포함이 되어 있는지 모르겠으나 차후에 찾게 되면 방법은 공개 드리도록 하겠습니다.)


root@AOL-Debian:/usr/share/X11/xorg.conf.d# nano 99-fbdev.conf 


##  /etc/X11/xorg.conf.d/99-fbdev.conf
Section "Device"
        Identifier "Card0"
        Driver "fbdev"
Option "fbdev" "/dev/graphics/fb0"
EndSection

Section "ServerLayout"
        Identifier      "Layout0"
        Screen          "Screen0"
        InputDevice     "Mouse0"        "CorePointer"
        InputDevice     "Keyboard0"     "CoreKeyboard"
EndSection

Section "Screen"
        Identifier      "Screen0"
        Device          "Card0"
        DefaultDepth    16
                SubSection      "Display"
                        Depth 16
                EndSubSection
EndSection


상기 설정은 크게 건드릴 것이 없습니다. 24비트로 하면 화면 색깔이 조금 깨지는 부분이 있습니다. 이 원인은 잘 모르겠습니다. XFCE4 가 24비트를 지원하지 않는 것인지.. 리눅스 armhf 레포에 들어있는 기본 드라이버가 문제가 있는것인지 아직 파악이 안되었습니다.


그래서 16비트로 설정을 바꾸면 잘 나오게 됩니다. 해상도 부분은 따로 설정이 되어 있지 않고 현재 연결되어 있는 모니터의 최대 해상도로 화면 출력이 이루어 집니다. 참고하시길 바랍니다.


일단 xorg 를 사용할 환경은 되었습니다.





2. 데스크톱 환경 설치하기


일단 기본적으로 tasksel 을 실행해 보시면 아래와 같이 사용할 수 있는 데스크톱 환경이 있습니다. 그런데 armhf 용으로 제공되는 환경이 lxde 와 xfce 밖에 없습니다. 아쉬운 부분입니다.


각기 환경을 설치할 수 있는 방법은 아래와 같습니다. 사용하실 것 하나만 설치하세요.


# lxde

apt-get install lxde


# xfce4

apt-get install xfce4


# enlightenment ui

apt-get install e17


위 3가지의 보통 화면은 이렇습니다.


1. lxde (초기 라즈비안 UI)



2. xfce4 (라즈비안 기본 UI)



3. enlightenmnet ui



일단 기본적으로 startx 하면 셋중에 하나가 설치된 UI 로 시작이 됩니다. 


그러나. 시작이 되지 않을 경우에는 아래의 방법을 이용하시길 바랍니다.


# lxde

root@AOL-Debian:/usr/share/X11/xorg.conf.d# nano ~/.xinitrc 


exec startlxde

root@AOL-Debian:/usr/share/X11/xorg.conf.d# startx

# xfce4
root@AOL-Debian:/usr/share/X11/xorg.conf.d# startxfce4


# enlightenment ui

root@AOL-Debian:/usr/share/X11/xorg.conf.d# nano ~/.xinitrc 


exec enlightenment_start

root@AOL-Debian:/usr/share/X11/xorg.conf.d# startx


상기 실행방법은 방식에 조금 차이가 있습니다. 명령어에 xorg 서버 실행과 그 다음 UI 를 실행하는지, 혹은 그 기능이 없으면 exec 로 지정해 주셔야합니다. 해당은 UI 마다 차이가 있어서.. 


여러가지 UI를 설치하지 마시고 사용하실 UI 하나만 설치하시길 바랍니다. 그럼 startx 만 해도 자동으로 그 UI가 실행됩니다.


게시글 첫번째에 영상은 xfce4 UI 입니다.





3. 안드로이드 환경 멈춘 후 진입 스크립트 작성


아래는 작성중이던 코드가 들어가 있습니다.

(리모컨 입력이 일정량 쌓이면 시작되도록 만들다가 그냥 공개합니다.)


root@AOL-Debian:/usr/bin# nano /usr/local/bin/startgui


#!/bin/bash

adb disconnect

adb connect localhost > /dev/null


#evtest /dev/input/event0 | grep time > /dev/keypressed &

#sleep 3

#pkill -9 -ef evtest


#NUM=`cat /dev/keypressed | wc -l`


#if [ ${NUM} -gt 3 ]; then

# 바로 스탑 후 xorg 가 화면을 잡으면 문제가 생김으로 5초 기달 해야됩니다.

adb shell 'stop media;stop zygote;stop surfaceflinger'

sleep 5


# xorg 및 xfce4 UI 실행

startxfce4 &

adb disconnect

#fi


#exit 0


root@AOL-Debian:/usr/bin# chmod a+x /usr/local/bin/startgui 


그리고 이런 상태에서 리눅스 부팅이 완료 된 다음 PC 에서 startgui 하면 안드로이드 화면이 나가고 리눅스 화면이 뜨게 됩니다.


한편, /etc/rc.local 에 등록해서 자동시작하게 되면 아래와 같습니다.


root@AOL-Debian:/usr/bin# cat /etc/rc.local

#!/bin/sh -e

#

# rc.local

#

# This script is executed at the end of each multiuser runlevel.

# Make sure that the script will "exit 0" on success or any other

# value on error.

#

# In order to enable or disable this script just change the execution

# bits.

#

# By default this script does nothing.


/etc/init.d/hostname.sh start

su root -c "nohup /usr/local/bin/startgui &"



exit 0


필요할 때만 켜두고 필요없을때는 # 으로 코멘트 처리하시면 문제 없을 듯 합니다.


(차후에 조금 더 좋은 방법을 생각해 보겠습니다.)


그럼 아래 영상처럼 작동합니다.






4. 추가 패키지 설치하기


# firefox

apt-get install firefox-esr


# midori web broser

apt-get install midori


# gimp image editor

apt-get install gimp


# libreoffice 

apt-get install libreoffice


# hangle input method (아직 성공 못함)

apt-get install ibus-hangul


# hangul font : nanum

apt-get install fonts-nanum


# gnome system monitor

apt-get install gnome-system-monitor


.....





5. 미리 세팅된 이미지 다운로드


- 자동 리눅스 데스크톱 환경 비활성화를 위해서는 /etc/rc.local 설정을 변경해야됨


- 파일 공개 6월 4일 04:00 





감사합니다.