Changes between Version 76 and Version 77 of Developer/Simulators/QEMU/CANEmulation


Ignore:
Timestamp:
Nov 7, 2013, 4:05:58 PM (6 years ago)
Author:
Phipse
Comment:

some spelling fixes

Legend:

Unmodified
Added
Removed
Modified
  • Developer/Simulators/QEMU/CANEmulation

    v76 v77  
    11= QEMU with CAN Emulation =
    22
    3 =  Introduce  =
    4 
    5 Actually this is a project of GSoC2013. At first I try to port a CAN driver LinCAN to RTEMS. But we don't have a common hardwate platform to test the driver, so how to test the driver become the most significant problem here. Finaly we decide to build a software environment to test the dirver. This environment is built using the open source machine emulator QEMU and SJA1000 is simulated to test the driver. For the sake of simplicity, we test it in Linux(as it's familiar) and use SocketCAN(as it's maintlined into Linux) as a driver.
    6 
    7 Also, we decide to use PCI CAN controller and simulate on x86 Linux platform . Since, PCI as a general standard is easy to extend and pci device can seperate from others. Then this PCI device can be used with x86, so QEMU (with KVM) would be much faster and use less resource than other platform such as ARM.
     3=  Introduction  =
     4
     5Actually this is a project of GSoC2013. At first I tried to port a CAN driver LinCAN to RTEMS.
     6But we don't have a common hardware platform to test the driver, so how to test the driver become the most significant problem here.
     7Finally, we decide to build a software environment to test the driver.
     8This environment is built using the open source machine emulator QEMU and SJA1000 is simulated to test the driver.
     9For the sake of simplicity, we test it in Linux(as it's familiar) and use SocketCAN(as it's mainlined into Linux) as a driver.
     10
     11Also, we decide to use a PCI CAN controller and simulate on x86 Linux platform.
     12Since, PCI as a general standard is easy to extend and pci devices can be separate from others.
     13Then this PCI device can be used with x86, so QEMU (with KVM) would be much faster and use less resources than other platform such as ARM.
    814
    915=  Environment  =
    1016
    11 The CAN simulation environment is based on QEMU-1.4.2, because 1.5.0 was just released, and we wanted a solid starting point. The OS will be Linux and the current CAN driver to test will be Socket CAN (as it's maintlined into Linux)
    12  *  Host: The host is Ubuntu-13.04 including the basic building tools and some other softwares.
    13  *  Guest: This is also a Linux environment which we build from scratch. The linux kernel is [https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.4.48.tar.bz2 Linux-3.4.48], the commands are statically compiled using [http://www.busybox.net/downloads/busybox-1.21.0.tar.bz2 Busybox-1.21.0] and also some other files including configure files, start scripts, etc.
     17The CAN simulation environment is based on QEMU-1.4.2, because 1.5.0 was just released, and we wanted a solid starting point.
     18The OS will be Linux and the current CAN driver tested will be Socket CAN (as it's mainlined into Linux)
     19 *  Host: The host is Ubuntu-13.04 including the basic building tools and some other software.
     20 *  Guest: This is also a Linux environment which we build from scratch. The Linux kernel is [https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.4.48.tar.bz2 Linux-3.4.48], the commands are statically compiled using [http://www.busybox.net/downloads/busybox-1.21.0.tar.bz2 Busybox-1.21.0] and also some other files including configure files, start scripts, etc.
    1421 *  Others: [http://wiki.qemu-project.org/download/qemu-1.4.2.tar.bz2 Qemu-1.4.2]
    15 
    1622
    1723=  Use Cases / Testing  =
     
    1925  -chardev can,id=sja1000,port=vcan0
    2026  -device pci-can,chardev=sja1000,model=SJA1000
    21 and use Linux mainlined SocketCAN API to connect virtual device to real CAN hardware (SocketCAN allows multiple applications access) or to SocketCAN Virtual CAN (vcan - TCP/IP lo equivalent). This is straightforward and would result in minimal overhead and latency.
    22 
    23 The above options just connect the ''can'' backend to the PCI-CAN device. Just explain the options simply.
    24  *  '''-chardev can,id=sja1000,port=vcan0'''  specify which backend should we open, here can. ''id'' used for the -device option; ''port'' which interface should we open, we use virtual socketcan device here.
     27and use Linux mainlined SocketCAN API to connect virtual device to real CAN hardware (SocketCAN allows multiple applications access) or to SocketCAN Virtual CAN (vcan - TCP/IP lo equivalent).
     28This is straightforward and would result in minimal overhead and latency.
     29
     30The above options connect the ''can'' back end to the PCI-CAN device. Just explain the options briefly.
     31 *  '''-chardev can,id=sja1000,port=vcan0'''  specify which back end should we open, here can. ''id'' used for the -device option; ''port'' which interface should we open, we use virtual socketcan device here.
    2532 *  '''-device pci-can,chardev=sja1000,model=SJA1000''' we use pci-can device. ''chardev'' the value '''MUST''' equal to the id specified in chardev option; ''model'' is an optional parameter, default value is SJA1000 and we only support SJA1000 now.
    2633
    27 
    2834=  Step 1: Building a Minimal Linux Environment in Qemu  =
    2935
    30 The purpose of starting with a minimal Linux (as opposed to RTEMS) environment in qemu is the software configurations have been more thoroughly tested and documented. The first phase of the project should start out using the last stable release... unless it's minor digit is a 0... usually the minor digit being anything above a 0 means the free and open source software FOSS had some bug-fix releases.
     36The purpose of starting with a minimal Linux (as opposed to RTEMS) environment in qemu is the software configurations have been more thoroughly tested and documented.
     37The first phase of the project should start out using the last stable release... unless it's minor digit is a 0... usually the minor digit being anything above a 0 means the free and open source software FOSS had some bug-fix releases.
    3138=  Installing Qemu  =
    3239
    33 The project is hosted in a public repository which the developer has access to. For Summer of Code projects for RTEMS, as of 2013, github was the preferred repository.
     40The project is hosted in a public repository which the developer has access to.
     41For Summer of Code projects for RTEMS, as of 2013, github was the preferred repository.
    3442
    3543You can download the qemu-can project from https://github.com/Jin-Yang/QEMU-1.4.2 or get a copy using the following command(Linux).
    3644  git clone https://github.com/Jin-Yang/QEMU-1.4.2.git .
    3745
    38 '''NOTE:''' before you compile QEMU, "libglib2-dev" should be installed, or you will get the error "ERROR: glib-2.12 required to compile QEMU". In Ubuntu, to do that we use command ''sudo apt-get install libglib2-dev''
    39 
    40 First, we should configure QEMU using the following command, this will take about two minutes. QEMU has two modes to simulate a platform, the user mode and the system mode. We only need the i386 system simulation environment here, so only system mode (i386-softmmu) is needed. In order to save time, we just compile the source-code that relates to i386-softmmu.
     46'''NOTE:''' before you compile QEMU, "libglib2-dev" should be installed, or you will get the error "ERROR: glib-2.12 required to compile QEMU".
     47In Ubuntu, to do that we use command ''sudo apt-get install libglib2-dev''
     48
     49First, we should configure QEMU using the following command, this will take about two minutes.
     50QEMU has two modes to simulate a platform, the user mode and the system mode.
     51We only need the i386 system simulation environment here, so only system mode (i386-softmmu) is needed.
     52In order to save time, we just compile the source-code that relates to i386-softmmu.
    4153
    4254'''NOTE:''' For simplicity of coding, we select the hard-coded --prefix=/opt/qemu so we can write scripts assuming that's where our installed qemu is.
     
    4860 *  --enable-sdl: we also need the sdl (Simple DirectMedia Layer) support.
    4961
    50 To call the just installed qemu you can add ''/opt/qemu/bin'' to the PATH environment variable or just use ''/opt/qemu/bin/qemu-system-i386'' to start QEMU. Here, we just write a simple shell script and you can start the qemu just use command ''sudo ./qemu.sh''
     62To call the just installed qemu you can add ''/opt/qemu/bin'' to the PATH environment variable or just use ''/opt/qemu/bin/qemu-system-i386'' to start QEMU.
     63Here, we just write a simple shell script and you can start the qemu just use command ''sudo ./qemu.sh''
    5164=  Building Linux Environment  =
    5265==  Building the Kernel  ==