Dhananjay Khairnar @. Powered by Blogger.

19 February 2016

How to debug serial port Device Drivers using virtual box:

Today’s world most of computers uses Linux as their operating system. Some of them need to communicate with outside world (other devices). The serial protocol ( RS232  ) is used by most of devices. It is job of operating system programmer to write device driver for the serial port for proper data transfer. There are some other techniques to debug serial port device drivers. One of the technique I am going to post.
               Here I use OpenSuse 13.2 installed on virtual box. You need to do some setting for that as followed by.
*Install OpenSuse or any other Linux that you are going to develop device driver for.
1 ) Go to settings
2 )then Serial Port
3 ) check Enable Serial Port.
4 ) Select port mode Raw File.
5 ) Port File path select where to store logged data for port 1.
6) Click Ok.
7 ) Start Virtual machine.
8 ) open terminlal and give command
        $ lsdev | grep serial
        serial                       02f8-02ff 03f8-03ff
>in output you will find your serial port and it IO address
        >Now it’s time to find which file is associated with our serial port for that you have to know port IO address. From above output IO address is 03f8 which is 0x3f8
> give comman
$ dmesg | grep 3f8
[    2.978010] 00:03: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
>here you get the output like this .in this output 00:03:ttyS0 is the full address of our port including bus address. “ttyS0” is file which is associated with our serial port means if we write something on this file it get written on actual device.
>ttyS0 file is located at /dev/ttyS0.
               9 ) for write on our device we have to give following command
               $ su
               $ Password:<enter root password here>
               $ echo "hello Linux. I am writing on serial port." > /dev/ttyS0

Echo command indirectly write of file of device that is internally use write() system call. 


About DK

Hi, My Name is DK. I am a embedded system designer and embedded programmer. I am a certified holder of Diploma in Embedded system designing. We have a team of professinal programmers, developers work together and implement innovative concepts.


Post a Comment