2014년 9월 22일 월요일

망고520 CPU Temperature 읽어오기-20140923


  1. 포팅하기


Datasheet를 보면 , Table이 있습니다.
“Thermal Management Unit” Chapter에 보면


레지스터는

입니다.



    1. 커널 configuration


커널 버전은 3.0.31을 기준으로 설명합니다.





$ ./build_kernel config

명령 실행 후

System Type  --->
[*] Use thermal management
선택 후
컴파일 하여 , 커널 이미지를 다시 Write하면 됩니다.

관련 드라이버 소스는


arch/arm/mach-exynos/tmu-exynos.c


에 있습니다.

관련 코드는 아래와 같습니다.

static int get_cur_temp(struct tmu_info *info)
{
       int curr_temp;
       int temperature;

       /* After reading temperature code from register, compensating
        * its value and calculating celsius temperatue,
        * get current temperatue.
        */
       curr_temp = __raw_readl(info->tmu_base + CURRENT_TEMP) & 0xff;

       /* compensate and calculate current temperature */
       temperature = curr_temp - info->te1 + TMU_DC_VALUE;
       if (temperature < 10) {
               /* temperature code range are between min 10 and 125 */
               pr_alert("Current temperature is in inaccurate range->"
                       " check if vdd_18_ts is on or room temperature.\n");
       }

       return temperature;
}



    1. CPU 온도 읽기




[root@Mango520 ~]# cat /sys/devices/platform/tmu/temperature
53

섭씨 53도 임을 알수 있습니다.

2014년 9월 12일 금요일

Buildroot 파일 시스템에서 SSH 서버 설정 및 접속-20140912


  1. 부팅 후 설정



[root@Mango520 ~]#  /etc/init.d/S50sshd start
Starting sshd: /var/empty must be owned by root and not group or world-writable.
OK
[root@Mango520 ~]# chown root.root /var/empty
[root@Mango520 ~]#  /etc/init.d/S50sshd start

위와 같이 명령을 수행을 합니다.
Password를 설정을 합니다.

[root@Mango520 ~]# passwd
Changing password for root
New password:
Bad password: too short
Retype password:
Password for root changed by root


  1. 접속하기


Tera Term 실행합니다.
보드에 IP는 “ifconfig” 명령으로 확인합니다

아래와 같이 화면이 나옵니다.


“Continue” 버튼을 클릭합니다.


ID와 Password를 입력합니다.

“OK” 버튼을 클릭하면 접속이 가능합니다.

실행 결과

2014년 9월 11일 목요일

IOTG100 Test Guide_140811





  1. Booting Test


    1. 최초 부팅 작업


Sending select for 192.168.57.245...
Lease of 192.168.57.245 obtained, lease time 86400
deleting routers
route: SIOCDELRT: No such process
adding dns 192.168.57.1
Starting lighttpd: OK
Welcome to MangoBoard
mangoC210 login:

로그인 ID, Password는 모두 root 입니다.

    1. 리셋 버튼 동작 시험


최초 부팅 시와 동일한 메시지가 출력되어야 합니다.

  1. Ethernet Test


    1. DHCP 기능


[root@mangoC210 ~]# udhcpc -i eth0
udhcpc (v1.20.2) started
Sending discover...
Sending select for 192.168.57.245...
Lease of 192.168.57.245 obtained, lease time 86400
deleting routers
route: SIOCDELRT: No such process
adding dns 192.168.57.1

udhcpc -i eth0 명령으로 IP를 할당 받을 수 있습니다.

    1. Ethernet 케이블 장착 후 부팅


[root@mangoC210 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:40:5C:26:0A:5B  
         inet addr:192.168.57.245  Bcast:192.168.57.255  Mask:255.255.255.0
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

ifconfig로 할당받은 IP를 확인할 수 있습니다.

[root@mangoC210 ~]# ping google.com
PING google.com (173.194.126.225): 56 data bytes
64 bytes from 173.194.126.225: seq=0 ttl=48 time=102.130 ms
64 bytes from 173.194.126.225: seq=1 ttl=48 time=96.564 ms
64 bytes from 173.194.126.225: seq=2 ttl=48 time=102.440 ms
--- google.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 96.564/100.378/102.440 ms

구글 사이트로 ping 시험을 수행합니다.

  1. RTC Test


아래와 같이 시험을 수행합니다.

[root@mangoC210 ~]# rdate -s time.bora.net
[root@mangoC210 ~]# hwclock -u --systohc

rdate를 이용해서 정확한 system 시간을 설정합니다.
hwclock 설정 시에 -u 옵션을 꼭 설정해야 합니다. 이는 UTC 시간으로 설정하는 것입니다.
이후 보드의 전원을 완전히 제거하고 다시 부팅하였을때 이전에 설정한 시간으로 다시 설정되어 있는 것을 확인할 수 있습니다.

[root@mangoC210 ~]# date
Thu Aug  7 14:59:33 KST 2014

전원 케이블을 분리한 후 다시 부팅을 하였을 때 현재 시간이 정확히 출력되어야 합니다.

  1. LED Test


LED_1: GPX1_4, gpio chip # 258
LED_2: GPX1_5, gpio chip # 259
LED_3: GPX1_6, gpio chip # 260

LED 3개의 핀 번호와 gpio chip 번호는 위와 같습니다.

echo 258 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio258/direction

gpio chip # 258번을 초기화 하는 방법은 위와 같습니다.

echo 0 > /sys/class/gpio/gpio258/value
echo 1 > /sys/class/gpio/gpio258/value

0을 주면 LED를 끄는 것이고, 1을 주면 LED를 켜는 것입니다.

[root@mangoC210 ~]# ./led_test.sh init
LED all init
[root@mangoC210 ~]# ./led_test.sh on
LED all On
[root@mangoC210 ~]# ./led_test.sh off
LED all Off

led_test.sh 쉘 스크립트를 만들어 두었습니다. led_test.sh init을 수행하면 초기화가 진행되고, on, off를 주면 전체 LED가 켜지거나 꺼지게 됩니다.

  1. Buzzer Test


부저 역시 LED와 마찬가지의 동작을 수행합니다.

[root@mangoC210 ~]# ./buzzer_test.sh init
buzzer init

init을 수행하면 초기화가 진행됩니다.

[root@mangoC210 ~]# ./buzzer_test.sh on 2
buzzer On
time is 2 seconds.

on을 주면서 시간을 설정하면 그 시간동안 부저가 동작합니다.

  1. Button Test


    1. GPIO 설정


각각의 핀에 대한 설정은 아래와 같습니다.

static struct mango_keys_button mango_gpio_keys_table[] = {
{
.code = KEY_BACK,
.gpio = S5PV310_GPX2(4),
.active_low = 1,
.desc = "GPX2_4",
.type = EV_KEY,
.wakeup = 1,
// .debounce_interval = 5,
.irq = IRQ_EINT(20),
.config = (0xf << 0x0),
.pull = S3C_GPIO_PULL_NONE,
.long_code = KEY_HOME,
.long_interval = 200,
},
{
.code = KEY_MENU,
.gpio = S5PV310_GPX2(5),
.active_low = 1,
.desc = "GPX2_5",
.type = EV_KEY,
.wakeup = 1,
// .debounce_interval = 5,
.irq = IRQ_EINT(21),
.config = (0xf<<4),
.pull = S3C_GPIO_PULL_NONE,
.long_code = KEY_POWER,
.long_interval = 400,
},
};

버튼 2개는 각각 GPX2(4) KEY_BACK 할당, GPX2(5) KEY_MENU를 할당하였습니다. long code는 각각 KEY_HOME, KEY_POWER가 할당되어 있습니다.

    1. Button Test



hexdump를 수행했을 때는 위와 같은 형태의 데이터를 얻게 됩니다.

[root@mangoC210 ~]# hexdump /dev/input/event0
0000000 0315 0000 f3ea 0005 0001 009e 0001 0000
0000010 0315 0000 f436 0005 0000 0000 0000 0000
0000020 0315 0000 7c61 0007 0001 009e 0000 0000
0000030 0315 0000 7cdf 0007 0000 0000 0000 0000
0000040 0319 0000 61cf 0007 0001 008b 0001 0000
0000050 0319 0000 6218 0007 0000 0000 0000 0000
0000060 0319 0000 dab5 0008 0001 008b 0000 0000
0000070 0319 0000 daf7 0008 0000 0000 0000 0000

hexdump /dev/input/event0를 수행한 후에 버튼을 눌러보면 위와 같이 출력됩니다.

/include/linux/input.h에 보면 아래와 같은 정의를 발견할 수 있습니다.

#define KEY_BACK 158 /* AC Back */
#define KEY_MENU 139 /* Menu (show menu) */

키를 누르면 value값은 1을 가집니다. 떼게 되면 0을 가지게 됩니다.
158은 Hex로 0x9E 값을 가집니다.
139은 Hex로 0x8B 값을 가집니다.

0000080 0031 0000 46ac 0004 0001 0066 0001 0000
0000090 0031 0000 46f2 0004 0000 0000 0000 0000
00000a0 0031 0000 cd7b 0005 0001 0066 0000 0000
00000b0 0031 0000 cdbb 0005 0000 0000 0000 0000
00000c0 0035 0000 d162 0003 0001 0074 0001 0000
00000d0 0035 0000 d1a7 0003 0000 0000 0000 0000
00000e0 0035 0000 5841 0005 0001 0074 0000 0000
00000f0 0035 0000 5882 0005 0000 0000 0000 0000

버튼을 길게 눌렀을 경우는 위와 같이 출력됩니다. 이것은 각각 KEY_HOME, KEY_POWER가 출력되는 것입니다.

  1. USB Host Test


hub 1-0:1.0: state 7 ports 3 chg 0000 evt 0002
s5p-ehci s5p-ehci: GetStatus port:1 status 001803 0  ACK POWER sig=j CSC CONNECT
hub 1-0:1.0: port 1, status 0501, change 0001, 480 Mb/s
hub 1-0:1.0: debounce: port 1: total 100ms stable 100ms status 0x501
s5p-ehci s5p-ehci: port 1 high speed
s5p-ehci s5p-ehci: GetStatus port:1 status 001005 0  ACK POWER sig=se0 PE CONNECT
usb 1-1: new high speed USB device using s5p-ehci and address 2
s5p-ehci s5p-ehci: port 1 high speed
s5p-ehci s5p-ehci: GetStatus port:1 status 001005 0  ACK POWER sig=se0 PE CONNECT
usb 1-1: default language 0x0409
usb 1-1: udev 2, busnum 1, minor = 1
usb 1-1: New USB device found, idVendor=1908, idProduct=0222
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: USB2.0 Device
usb 1-1: Manufacturer: Generic
usb 1-1: SerialNumber: 20101227120006
usb 1-1: usb_probe_device
usb 1-1: configuration #1 chosen from 1 choice
usb 1-1: adding 1-1:1.0 (config #1, interface 0)
usb-storage 1-1:1.0: usb_probe_interface
usb-storage 1-1:1.0: usb_probe_interface - got id
scsi0 : usb-storage 1-1:1.0
usb-storage 1-1:1.0: device found
usb-storage 1-1:1.0: waiting for device to settle before scanning
scsi 0:0:0:0: Direct-Access     Generic  Flash-Disk       1.05 PQ: 0 ANSI: 2
sd 0:0:0:0: Attached scsi generic sg0 type 0
sd 0:0:0:0: [sda] 15523840 512-byte logical blocks: (7.94 GB/7.40 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Assuming drive cache: write through
usb-storage 1-1:1.0: scan complete
sd 0:0:0:0: [sda] Assuming drive cache: write through
sda:
sda1
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] Attached SCSI removable disk

USB 메모리를 USB Host 커넥터에 연결하면 위의 메시지가 출력됩니다.

[root@mangoC210 ~]# mount /dev/sda1 /media/
[root@mangoC210 ~]# cd /media/
[root@mangoC210 ~]# ls

위 내용은 /media 폴더와 마운트를 수행하는 것입니다. /media 폴더에서 USB 메모리 내용을 확인할 수 있습니다.

  1. USB Device Test


android_usb gadget: high speed config #1: UMS Only (Not debugging mode)

USB device 케이블을 연결하면 위의 메시지가 출력됩니다.


PC의 장치관리자를 보면 위와 같이 휴대용 장치로 잡히게 됩니다.


속성을 살펴보면 위와 같습니다.

  1. ZigBee CC2530 Test


    1. 디바이스 인식 시험


CC Debugger를 사진과 같이 연결한 후, CC Debugger의 리셋 버튼을 눌렀을 때 녹색 LED가 켜지면 정상적으로 디바이스가 인식된 것입니다.


    1. SmartRF Studio 통신 시험



두 보드에 동일하게 연결하고 TI SmartRF Studio를 수행해서 한쪽은 TX, 다른 한쪽은 RX로 설정해서 통신이 원활하게 수행되는가를 검사합니다.

    1. ZigBee Serial Test


./rs232_test 115200 /dev/ttySAC3
./rs232_test 115200 /dev/ttySAC0

위 명령으로 UART3와 통신을 할 수 있습니다. ZigBee CC2530과 연결된 것입니다.
rs232_test 소스는 app/rs232_test_app 부분에 존재합니다.

  1. 센서 연결 시험


아래 사진과 같이 센서 연결 커넥터를 장착합니다.


반대편에 조도 센서를 연결합니다.

[root@mangoC210 ~]# ./sensor_test_AL
[Test_AL] Power On
[Test_AL] Start Ambient Light Sensor
[Test_AL] i2c device open done
[Test_AL] set_slave_addr done
[Test_AL] AL sensor start done
[Test_AL] read data: 0x0000, Lux: 0.000000
[Test_AL] read data: 0x00D7, Lux: 179.166672
[Test_AL] read data: 0x00D7, Lux: 179.166672
[Test_AL] read data: 0x00D7, Lux: 179.166672
[Test_AL] read data: 0x00DF, Lux: 185.833328
[Test_AL] read data: 0x0046, Lux: 58.333332
[Test_AL] read data: 0x002C, Lux: 36.666668
[Test_AL] read data: 0x002E, Lux: 38.333332
[Test_AL] read data: 0x0052, Lux: 68.333336
[Test_AL] read data: 0x00DB, Lux: 182.500000
[Test_AL] read data: 0x00DA, Lux: 181.666672
[Test_AL] read data: 0x00DA, Lux: 181.666672

sensor_test_AL을 수행해서 조도 측정을 수행합니다.

  1. SSH 연결 시험


최초 부팅을 수행하면 아래와 같이 키 생성 작업을 수행하게 됩니다.

Generating RSA Key...
Generating public/private rsa1 key pair.
Your identification has been saved in /etc/ssh_host_key.
Your public key has been saved in /etc/ssh_host_key.pub.
The key fingerprint is:
50:7c:d7:cf:5c:7b:99:89:47:8f:9c:7e:3b:62:83:ee
The key's randomart image is:
+--[RSA1 2048]----+
|       ..    .   |
|       .. . . ...|
|      .  . . .o*B|
|       .     .+**|
|        S    .. .|
|              . .|
|            .  ..|
|           . + o |
|          oE. o .|
+-----------------+
... ... ... ... ... ... ...
Starting sshd: OK

Starting sshd: OK가 수행되면 정상적으로 데몬이 떠 있는 것입니다.

보드의 ip 주소는 192.168.57.245 입니다.


PuTTy에서 보드로 접속을 시도합니다.


최초에는 위와 같이 경고 메시지가 보이게 됩니다. 예를 선택하면 됩니다.


root, root로 접속하면 터미널에서의 모습과 동일한 환경을 만날 수 있습니다.