2016-06-30

How to Windows Kernel debugging between Virtual marchine with Network

How to Windows Kernel debugging between Virtual marchine with Network .


Test Setting

Debugger and Debugee have same settings.

  1. Windows 2012 R2
  2. Visual Studio 2013
  3. WDK 8.1
  4. 1 - NIC


Basically, Kernel debugging dodel is a diagram that is following <fig .1>.


<fig .1>

Therefore, It needs 2 PCs or 2 VMs for debugging, and it has to be connected by Network  each o other.
And, Network kernel debugging is suppored by WDK 8 and later..
However, Despite of Supprting formally, From the ‘msconfig’ GUI wizard , it does not choose ‘NET’ mode…
ㅜ.,ㅜ….


But, It became more simpler than using a serial port.
hoooray~.

Steps for the Debuggee



  1. Setting up the debug mode with a network address , then Run commands next..
bcdedit /debug on
bcdedit /dbgsettings net hostip:192.168.2.8 port :50000
※  A parameter hostip means address of ‘Debugger’ that is connected with ‘Debugee’.
※ A command returns Key and you should to note or rememeber that key.
And, you are going to see your debug settings with following command.
(bcdedit /dbgsettings)


  1. and Reboot


Steps for The Debugger

  1. Start  a Windbg.
  2. Click on the File > ‘Kernel Debug’
  3. Move on ‘NET’ tab of the popup window.
  4. Enter value of  port and Key you memo. ( ex . sdkjhs8sjhdksjd87sdjhksjdnnjhskd9sdks)
  5. Click ‘OK’
  6. It will printed “Waiting connect..” .

    If it still connecting…
  7. Reboot debuggee , and click on the Debug > break .

    After it is connected, you want to boot debugee continually.
  8. Click on the Debug > go.


How to start Windows Kernel debugging on Virtual marchine with Serial port

How to start Windows Kernel debugging on Virtual marchine with Serial port .

Test Setting
Debugger and Debugee have same settings.

  1. Windows 2012 R2
  2. Visual Studio 2013
  3. WDK 8.1
  4. 1 NIC
  5. 1 Serial port

Basically, Kernel debugging dodel is a diagram that is following <fig .1>.

<fig .1>


Therefore, It needs 2 PC for debugging.

Steps for the Debuggee

In other word, Debuggee is called “Target PC”.
  1. Power off  the VM (debuggee).
  2. VM Workstation > Setting> click ‘add…’ > click ‘Serial port’
  3. Choose ‘Named Pipe’ and Enter a pipe name with format. ( ex ‘\\.\pipe\debug’)
  4. Choose “this is … server “ for the near end.
  5. Choose “this is … Application” for the Far end.
  6. Dselect the “Yield on CPU Poll” on the check box
  7. Click ‘ok’ ( Remeber new added serial Port Number )
  8. Power on the VM.

    After booting
  9. Open ‘Device Manager’
  10. Expand the ports that is tree item.
  11. Confirm the new serial port  that you added is working nomally.
    (Recommend to use view menu ‘hidden device show’.
  12. Check the Properties if it is corrent value or not when you had added a new serial port.
  13. Setting up the debug mode with a serial port you made before a step.
bcdedit /debug on
bcdedit /dbgsettings serial debugport:2 baudrate:115200

And, you can see your debug settings with following command.
(bcdedit /dbgsettings)

  1. and Reboot.




Steps for The Debugger

  1. Start  a Windbg.
  2. Click on the File > ‘Kernel Debug’
  3. Move on ‘COM’ tab of the popup window.
  4. Enter value a pipe name on port. ( ex ‘\\.\pipe\debug’ - you entered before )
  5. Select the ‘pipe’ check box, then click ‘OK’
  6. It will printed “Waiting connect..” .

    If it still connecting…
  7. Reboot debuggee , and click on the Debug > break .

    After it is connected, you want to boot debugee continually.
  8. Click on the Debug > go.

2016-06-24

#3 아두이노 초음파 센서 사용해보기

#3 아두이노 초음파 센서 사용해보기 

초음파센서

왼쪽 T 에서 나간 초음파의 반사를 오른쪽 R에서 수신하여 거리를 판단합니다.
따라서 너무 초음파를 반사하기에 너무 작거나, 흡수하는 재질일 경우 오차가 발생한다.
- 스펙 -
동작전압 DC 5V
동작전류 15mA
동작 주파수 40Hz
발생 주파수 40kHz
측정 거리 2cm ~ 400cm
정밀도 0.3cm
측정 각도 15도
크기 45x20x15mm

- 핀 정보 -
Vcc : 전원 공급
Trig :  초음파 발신
Echo : 초음파 수신
Gnd : 접지 (선 연결)

- 초음파 센서의 원리 -
 Trig핀에서 특정 파형을 만들고, 일정 파형을 만들면 Echo핀이 High 상태로 변경됩니다.
이때 초음파를 감지하게되면 다시 Low상태로 변합니다. 이 사이의 시간으로 값을 측정합니다.
이 측정 값을 계산하는 식을 아두이노 코드로 만들면 원하는 단위로 센서값을 출력할 수 있습니다

기본 연결

구성도
실제

스크래치 코드


void setup()
{
 Serial.begin(9600);
 pinMode(2,OUTPUT); // 센서 Trig 핀
 pinMode(3,INPUT); // 센서 Echo 핀
}

void loop()
{
 long duration, cm;

 digitalWrite(2,HIGH); // 센서에 Trig 신호 입력
 delayMicroseconds(10); // 10us 정도 유지
 digitalWrite(2,LOW); // Trig 신호 off

 duration = pulseIn(3,HIGH); // Echo pin: HIGH->Low 간격을 측정
 cm = microsecondsToCentimeters(duration); // 거리(cm)로 변환

 Serial.print(cm);
 Serial.print("cm");
 Serial.println();
 delay(300); // 0.3초 대기 후 다시 측정
}

long microsecondsToInches(long microseconds)
{
 return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds)
{
 return microseconds / 29 / 2;
}

동작결과

시리얼 모니터로 결과를 확인해 보면 다음과 같다.

잘못된 사용예


사선일 경우 오차 발생

대상이 너무 작을 경우 오차 발생

참고 

http://makeshare.org/bbs/board.php?bo_table=arduinosensor&wr_id=2


2016-06-23

#2 아두이노 스크레치

#2 아두이노 & 스크레치 

아주 간단하 LED 조정 프로그램을 스크레치를 사용해서 동작시켜 본자.

우선 #1 에서 UNO 보드를 사용해 보았으니, 스크레치를 설치해 보자



  1.  https://www.arduino.cc/ 에서 자신의 플랫폼에 밪는 스크레치 프로그램을 다운받는다. 스크레치 개발 환경은 아두이노에 대한 많은 예제를 자체적으로 가지고 있어서 편리하다.
  2. 스크레치를 실행한다.
  3. 아두이노 보드를 PC에 연결하여  인식되었는지를 확인한다.
    스케치의 툴 > 포트 에 연결한 보드와 COM4등의 포트 등이 할당되어 있다면 인식되어 있다고 볼수 있다.
    (간혹 중국제 보드에서는 중국보드에 맞는 드라이버를 따로 설치해줘야 볼수 있다고 함.)
  4. 파일 > 예제 > basic > Blink 예제를 선택하여 열어준다.
    (만인의 예제 Blink를 사용한다. -__-;;)

  5. 다음 그림과 같이 보드를 조작해준다.
    LED에 저항을 붙여준 이유는 5v 전압이 LED의 수명을 갉아 먹는다고 해서 붙여줬다
    LED 에 대한 자세한 스펙을 구할수 없어서 그냥 그렇게만 이해함..

    여튼 실제적으로 저항을 부착시키면, 저항의 크기에 따라 LED의 밝기가 변화 한다.
    ( 보드와 브레드 보드를 연결할때는, 보드의 핀 번호를 정확히 해줘야만 한다.)


    (※ 보드의 디지털 핀 번호를 보면 물결무늬('~') 가 붙은 핀이 있는데, 물결 무늬가 있는 핀의 경우 0,1의 2진값 이외에도 가변값을 가질수 있다는 특징이 있다.)
  6. 스크레치 프로그램 왼쪽위의 (→) 버튼을 클릭하면 , 컴파일및 아두이노 보드에 업로드가 완료된다.




    void setup() { // initialize digital pin 13 as an output. pinMode(13, OUTPUT); 핀번호가 중요하다. } // the loop function runs over and over again forever void loop() { digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }

    1.   완성된 모습


    2016-06-21

    #1 아두이노 시작



    #1 아두이노 시작


    • 아두이노는 마이크로 콘트롤러(Micro controller)다.
           이말은 OS 가 내장되지 않는 다는 말로, 
           단순히 코딩된 프로그램만을 반복 수행하는 것 만이 가능하다는 의미이다.

           우리가 쓰는 PC는 복수의 프로세서가 동작하는 멀티 프로세서(Multi Processor)로,
           이보다 좀더 작은 규모의 것이 라즈베리 파이같은 마이크로 프로세서(Micro Processor)이다.
           위와 같은 프로세서는 기본적으로 운영체제(규모는 작지만...)가 존재하고 그 프레임 안에서 프로그램을 만들 수 있다.    

    • 아두이노 기본 보드 UNO R3
           가장 기본이되는 UNO 보드 부터 사용해 보자. 특징은,
           - 3.3 v , 5v 레귤레이터 내장으로 두가지 전원 공급이 가능한다.
           - 모든 확장 보드 (Shield:쉴드라고 부름)의 기본 보드로 쉴드와의 적합성이 좋다.
           - USB 및 일반 전원 포트로 동작이 가능하다.
           - RAM 2k, flash 32k, CPU ATmega328을 사용 합니다.
           
            보다 많은 핀과, IOT 용으로 작게 나온 보드들이 있지만 


                           <기본 UNO 보드 이미지>

                          <기본 UNO 보드 실사진>



    • 동작을 시켜보자 
        ( 일단 스크레치를 이용한 프로그램은 나중에 해보도록 한다 )

    1. 일단 USB  를 이용해 전원을 넣어준다.
    2.  LED를 꽂아 전원이 들어온것을 확인한다.
       (↗에 ON 확인)

    3.  5V 전원과 GND 사이에 LED를 넣어 동작을 확인한다.

       (LED 점등 확인)

    4. 시뮬레이터로 보면 다음과 같다.


    ※ LED 를 연결시 LED의 다리가 짧은 쪽이 GND쪽으로 가게 한다.