Showing posts with label raspberry pi. Show all posts
Showing posts with label raspberry pi. Show all posts

Thursday, June 18, 2015

Raspberry pi DS1307 RTC rc.local 스크립트을 올바른 사용방법

DS1307 RTC칩을 i2c로 raspberry pi 에서 사용할 때 주의할점이 있음.

/etc/modules 에 다음을 추가
rtc-1307


/etc/rc.local 에 다음을 추가

echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
sleep 1
hwclock -s


** Raspberry pi Compute module 또는 2.0 에서는  i2c-1 이고, Raspberry pi 1 모델에서는
i2c-0 임.

** sleep 1  이부분이 중요.
enew_device에 ds1307을 0x68주소로 등록하라고 시킨 후 o/s에서 이를 인식하고 사용하기 까지 약간의 시간이 필요한것 같다. 그래서 sleep 을 줘야함.

hwclock -s 명령이 성공할때도 있고 실패할때도 있었음.



-------------------
If hwclock-s command returens error, use sleep few seconds before "hwclock -s" command.




Tuesday, May 5, 2015

라즈베리파이에서 FrameBuffer를 통한 한글 출력

라즈베리파이에 fbtft_device 드라이버를 통해 lcd를 연결 한 후
framebuffer 접근 방식으로 한글을 출력했다.

한글 폰트는 윈도우에서 글자 하나하나를 캡쳐했고 캡쳐한 글자는 총
2350자(KSC5601 코드)이다.

개발언어는 c언어.

기능: 한글 출력, 각종 폰트 효과(굵게, 테두리, 밑줄, 회전)
폰트 크기 : 16x16, 24x24 그 외 크기는 비트맵을 늘려서 표현
색상 : 16비트 컬러. 글자색과 배경색 지정가능, 배경 투명도 가능



리눅스 콘솔화면에서 커서 안보이게 하기(Hide cursor(caret) on console screen)

다음 명령을 실행한다.

setterm -cursor off


만약 부팅 후 표시되는 기본 콘솔창에서도 커서를 안보이게 하고 싶다면

/etc/rc.local 에 위 명령어를 추가한다.



* run bellow command

setterm -cursor off


* hide curosr on default console:

append "setterm -cursor off" to /etc/rc.local




Wednesday, April 1, 2015

Raspberry pi 에서 FT232 칩을 tty로 사용하기. (Use FT232 as tty on Raspberry pi )

1. FT232를 사용한 USB Serial port를 USB 포트에 연결한다.
2. lsusb 명령으로 FT232가 잡힌것을 확인한 후 ( ttyUSB0 로 잡힌것으로 가정 )

3. loopback 테스트를 위하여 rs-232 커넥터의 2번과 3번 핀을 서로 연결한다.

4. 다음과 같이 minicom을 실행하여 시험한다.
여기서 중요한것은 -s옵션을 줘서 setup으로 들어가서 Flow control을 None으로 하는것이다.
만약 Flow control이 Hardware로 되어있는경우 rx와 tx만 연결한 loopback 테스트에서 먹통이다. 물론 rts, dtr 등등 flow control에 사용되는 핀들을 모두 loop를 걸었다면 바로 잘 될것이다.

minicom실행방법:

minicom -D /dev/ttyUSB0 -b 115200 -s


minicom을 받아서 설치하는것은
sudo apt-get install minicom   명령으로 할 수 있다.


---------------------
If you fail on loopback test ( wiring rx - tx closed ),
Use minicom with No flow control option.

run minicom and enter to menu(ctrl + a , z key) ->  config minicom -> serial port setup -> Hardware flow control -> No 


Friday, February 27, 2015

raspberry pi에 USB Flash Memory(FAT32) 읽기 쓰기가 가능하도록 마운트 (Mount FAT32 usb stick read,write permission)

USB Flash memory를 FAT32로 포맷하고 이것을 마운트 하려면 다음과 같이 한다.

굵은 글씨는 명령어.

pi@rpi ~ $ lsusb
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 005: ID 0781:5580 SanDisk Corp.
Bus 001 Device 004: ID 0d8c:0105 C-Media Electronics, Inc. CM108 Audio Controller


USB Flash memory가 lsusb에 나타났다.

pi@rpi ~ $ tail -f /var/log/messagesFeb 28 05:09:34 rpi kernel: [58069.795528] usb-storage 1-1.2:1.0: USB Mass Storage device detected
Feb 28 05:09:34 rpi kernel: [58069.796076] scsi host0: usb-storage 1-1.2:1.0
Feb 28 05:09:34 rpi kernel: [58069.820379] usbcore: registered new interface driver uas
Feb 28 05:09:35 rpi kernel: [58070.793472] scsi 0:0:0:0: Direct-Access     SanDisk  Extreme          0001 PQ: 0 ANSI: 6
Feb 28 05:09:35 rpi kernel: [58070.796241] sd 0:0:0:0: [sda] 31277232 512-byte logical blocks: (16.0 GB/14.9 GiB)
Feb 28 05:09:35 rpi kernel: [58070.797056] sd 0:0:0:0: [sda] Write Protect is off
Feb 28 05:09:35 rpi kernel: [58070.797777] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
Feb 28 05:09:35 rpi kernel: [58070.802944]  sda: sda4Feb 28 05:09:35 rpi kernel: [58070.806540] sd 0:0:0:0: [sda] Attached SCSI disk
Feb 28 05:09:35 rpi kernel: [58070.825946] sd 0:0:0:0: Attached scsi generic sg0 type 0

꼽았을때 sda4로 잡혔음을 알 수 있다.

그렇다면 sda4를 마운트 하면됨.
pi@rpi ~ $ sudo mount -t vfat /dev/sda4 /media/usbstick -o rw,umask=111,dmask=000
pi@rpi ~ $ ls /media/usbstick/ -l

total 8
drwxrwxrwx 3 root root 8192 Feb 28 05:28 log


이제 usb flash memory의 내용이 잘 보임. 마운트가 잘되었음.

pi@rpi /media/usbstick/log/201502 $ ls -l
total 8
-rw-rw-rw- 1 root root 15 Feb 28 05:29 20150228142900.txt


중요한것은 umask와 dmask에 따라서 디렉토리와 파일의 권한이 달라진다는점.


Thursday, February 26, 2015

Raspberry pi에 vsftpd 쉽게 설정하기. (easy configuration for raspberry pi vsftp)

vsftpd 설치( install vsftpd )
명령어(command): sudo apt-get install vsftpd


설정파일 편집 (open configuration file)
명령어(command): sudo nano /etc/vsftpd.conf


모든 내용을 지운다. (erase all content of vsftpd.conf file)

아래 내용을 입력하고 저장. (fill content as bellow text, and write)

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
xferlog_enable=YES
xferlog_std_format=YES
xferlog_file=/var/log/vsftpd.log
pam_service_name=vsftpd
session_support=YES
chroot_local_user=NO
listen=YES
listen_port=21


vsftpd 재시작. (restart vsftpd service)

명령어(command) : sudo service vsftpd restart


이제 pi 계정으로 로그인(Login ftp as "pi")