2014년 9월 26일 금요일

Embedded Linux 자동 로그인 & 특정 Application 실행

Embedded Linux 자동 로그인 & 특정 Application 실행



1) /etc/inittab 수정
2) /etc/profile 에서 특정 Application 실행하도록 script 추가



inittab 수정

/etc/inittab에서
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty23:2345:respawn:/sbin/mingetty tty3

T0::respawn:/sbin/gettty tty4
위와 같은 기본값에서 아래와 같은 파라메터값을 추가해 준다.
 -n : no login
-l : script될 실행 화일, 일부 리눅스 Distribution에서는 화일이 추가되어 있긴하지만(디폴트는 제외)

T0:12345:respawn:/sbin/gettty -L -n -l/root/nologin ttySAC1 115200 vt100 # default 설정


다음과 같은 source 코드를 getty가 spawn 되었을때 아래의 프로그램이 실행하도록 해준다.

autologin_fred.c 


int main() {
   execlp( "login", "login", "-f", "fred", 0);
}

위의 소스에서 "fred"는 내가 원하는 특정 ID로 변경 시킬수 있다.
위의 화일을 compile 하면
# arm-linux-gnueabihf-gcc -o autologin autologin_fred.c
-o 옵션: 컴파일 완료후 출력물의 화일이름 지정


정리
1) /etc/inittab 파일 수정
1:2345:respawn:/sbin/gettty -L -n -l"myapplication or autologin" ttyS0 115200

2) /etc/profile 혹은 로그인 완료된 계정의 .bashrc를 수정하여 내가 원하는 script추가







2011년 6월 14일 화요일

Big Endianness / Little Endiannes Detect code


현재 개발하는 시스템이 빅엔디안인지 리틀엔디안인지 잘 모를 경우가
Embedded system 개발 중에는 자주 발생 한다....
특히 골치 아픈 mips system일 경우는 자주....
그럴 경우 사용하는 코드

#include
int main(void)
{
int i = 0x00000001;
if ( ((char *)&i)[0] )
printf("LITTLE_ENDIAN\n");
else
printf("BIG_ENDIAN\n");
}

2011년 6월 13일 월요일

Arm 에서 Profiling with Oprofile

Profiling Oprofile Cross-compile

모 업체에서 양산중인 보드의 성능 점검을 요청해 와서,
해당 타겟이 사용 중인 Board에 Oprofile로 Profiling하는 과정

기존 보드에 SD 카드를 /mnt 폴더로 mount 해서 Oprofile 추가 설치함

이번 경우엔 root 이미지를 직접 쓰기 혹은 변경 시킬 없어서 /mnt 사용

# mount /dev/mmcblk0p1 /mnt

Arm-marvell-linux-gnueabi Oprofile cross-compile 방법
Host PC로 ubuntu linux 사용하였으며 (host: i386-linux) arm-linux (build target: arm-linux) cross-compile 하였습니다.

Cross-compiler Path 지정

arm-marvell-linux-gnueabi-gcc 위치하는 폴더를 PATH 지정

# export PATH=/your path/arm-marvell-linux-gnueabi/bin:$PATH

Libpopt Cross-compiling (Oprofile에서 요구되어지는 library)

1) Popt library Download 받아 설치한다.
#./configure --prefix=/mnt/Oprofile –-build=arm-linux -–host=i386-linux -–target=arm-marvell-gnueabi

2) Make & make install

3) Add LD_LIBRARY_PATH
# export LD_LIBRARY_PATH=/mnt/Oprofile/lib:$LD_LIBRARY_PATH

4) ADD PKG_CONFIG_PATH
# export PKG_CONFIG_PATH=/mnt/Oprofile/lib:$PKG_CONFIG_PATH


Libz Cross-compiling

Libz library Download 받아 설치한다.
#./configure --prefix=/mnt/Oprofile

# Make & make install

If you use different prefix, ADD LD_LIBRARY_PATH and PKG_CONFIG_PATH (Use same path with libpopt library)

Bfd library Cross-compiling

1) Binutils 다운 받는다.
# wget
http://ftp.gnu.org/gnu/binutils/binutils-X.XX.tar.gz

2) Untar binutils
# tar xvf binutils-X.XX.tar.gz

3) Bfd 폴더로 이동한다
# cd binutils-X.XX
# cd bfd
(binutil
모든 unility들을 모두 사용할 것은 아니므로 bfd폴더에서 bfd 컴파일)

4) Bfd library 설치
# ./configure --prefix=/mnt/Oprofile/binutils --build=arm-linux --host=i386-linux --target=arm-marvell-linux-gnueabi --disable-nls --enable-install-libbfd

5) Make & make install

6) ADD LD_LIBRARY_PATH and PKG_CONFIG_PATH with installed bfd library path.
ex) # export LD_LIBRARY_PATH=/mnt/Oprofile/binutils/i386-linux/arm-marvell-linux-gnueabi/lib:$LD_LIBRARY_PATH


OProfile Cross-Compiling

1) Oprofile 다운 받는다.
# wget http://prdownloads.sourceforge.net/oprofile/oprofile-X.X.X.tar.gz

2) Untar Oprofile
# tar xvf oprofile-X.X.X.tar.gz

3) Cd Oprofile
# cd oprofile-X.X.X

4) OProfile 설치
# ./configure --prefix=/mnt/Oprofile --with-kernel-support --build=arm-linux --host=i386-linux --target=arm-marvell-linux-gnueabi

5) Make & make install

6) ADD LD_LIBRARY_PATH & PKG_CONFIG_PATH


Target 에서 OProfile 환경 설정

#export PATH=/mnt/Oprofile/bin:$PATH

# export LD_LIBRARY_PATH=/mnt/Oprofile/lib:
/mnt/Oprofile/binutils/i386-linux/arm-marvell-linux-gnueabi/lib:
$LD_LIBRARY_PATH

만일 저처럼 Root write 없는 상태가 아니라면, 아래와 같이 설정하시면 됩니다.

위에서 prefix –-prefix=/usr/local 사용한다면

#export PATH=/usr/local/bin:$PATH

# export LD_LIBRARY_PATH=/usr/local/lib:
/usr/local/binutils/i386-linux/arm-marvell-linux-gnueabi/lib:
$LD_LIBRARY_PATH


2011년 5월 26일 목요일

scratchbox 2 자주 쓰이는 Command

sb2-init

sb2-init은 반드시 target 의 root로 사용할 directory에서 실행되어야 하며,
sb2-init --help를 통하여 내가 가지고 있는 가상 Root의 종류가 나열된다.

sb2

sb2 -t Tegra2QPA
위와 같이 sb2-init 에서 지정했던 TargetName을 지정해 주면 Default Target으로 설정된다.

2011년 5월 4일 수요일

Kbuntu 에서 nabi 입력기를 사용하도록 변경하는 방법

KDE는 nabi를 실행하기 전에 xim을 nabi로 지정하고
“QT_IM_MODULE=xim”를 해줘야 입력기가 붙는다.

이를 위해서 아래와 같이 한다.

1. 기본 입력기를 nabi로 선택한단.
% im-switch -c

2. “QT_IM_MODULE=xim” 를 추가한다.
% cd $HOME/.xinput.d
% cat ko_KR
XIM=nabi
XIM_PROGRAM=/usr/bin/nabi
XIM_ARGS=
GTK_IM_MODULE=xim
QT_IM_MODULE=xim

현재 ko_KR에 “QT_IM_MODULE=xim” 가 왜 안들어가 있는지 모르겠다.

% ls -al $HOME/.xinput.d/ko_KR
lrwxrwxrwx 1 x 28 2011-02-14 15:03 ko_KR /etc/X11/xinit/xinput.d/nabi

2010년 10월 24일 일요일

Ubuntu에서 한글 입력 도구 설정하기

Ubuntu에서 한글 입력 도구 설정하기

다음과 같은 방법으로 현재 사용하는 Desktop의 Hangul Input Method를 확인 할 수 있다.
#im-switch -l

codeguru@Boleo:/etc/alternatives$ im-switch -l
Your input method setup under ko_KR locale as below.
=======================================================
The configuration "/home/codeguru/.xinput.d/ko_KR" is defined as a link pointing to
nabi
This private configuration supersedes the system wide default.
=======================================================
The system wide default is pointed by "/etc/alternatives/xinput-ko_KR" .
xinput-ko_KR - auto mode
링크가 현재 ibus을(를) 가리키는 중
ibus - 우선순위 60
imhangul - 우선순위 49
nabi - 우선순위 50
현재 가장 '좋은' 버전은 ibus입니다.
=======================================================
The available input method configuration files are:
default default-xim ibus ibus-kde imhangul lo-gtk nabi none th-gtk th-xim
=======================================================

만일 KDE 와 Gnome 사이를 왔다 갔다 하면서 Application을 사용하는 User라면
위의 im-switch -l 을 통하여
현재의 im module이 어떤 우선 순위를 가지고 쓰이는 알게된다.
우선순위를 조절하려면 해당 파일을 조정하면 원하는 대로 선택 할 수 있게 된다.

#sudo im-switch -c
위의 command를 통하면 현재 가지고 있는 System IME 중 하나를 선택 할 수 있게 된다.

아래의 예제를 참조하길

codeguru@Boleo:~$ im-switch -c

There are 10 candidates which provide IM for /home/codeguru/.xinput.d/ko_KR:

Selection Alternative
-----------------------------------------------
1 default
2 default-xim
3 ibus
4 ibus-kde
5 imhangul
6 lo-gtk
* 7 nabi
8 none
9 th-gtk
10 th-xim
System wide default for ko_KR (or all_ALL) locale is marked with [+].
Press enter to keep the current selection[*], or type selection number: 2