Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 149
» Latest member: gonzaloastri
» Forum threads: 58
» Forum posts: 254

Full Statistics

Online Users
There are currently 10 online users.
» 0 Member(s) | 10 Guest(s)

Latest Threads
DomU I/O and Communicatio...
Forum: Public Support
Last Post: david_norwood
06-22-2017, 07:54 PM
» Replies: 1
» Views: 38
Yocto image as domU
Forum: Public Support
Last Post: Nathan.Studer
05-19-2017, 02:36 PM
» Replies: 10
» Views: 29
XZD Yocto Layer
Forum: Knowledge Base
Last Post: Nathan.Studer
04-12-2017, 03:23 PM
» Replies: 0
» Views: 239
Trouble overriding Petali...
Forum: Getting Started
Last Post: brettstahlman
04-10-2017, 06:53 PM
» Replies: 11
» Views: 1,294
Kernel panic when launchi...
Forum: Public Support
Last Post: Nathan.Studer
04-06-2017, 06:01 PM
» Replies: 1
» Views: 1,974
What type of dom0 Image d...
Forum: Public Support
Last Post: brettstahlman
03-17-2017, 02:45 PM
» Replies: 4
» Views: 1,074
Question on format of dom...
Forum: Public Support
Last Post: brettstahlman
03-14-2017, 06:40 PM
» Replies: 0
» Views: 451
Qemu launches but boot ha...
Forum: Getting Started
Last Post: brettstahlman
02-28-2017, 07:55 PM
» Replies: 19
» Views: 3,147
Zynq mpsoc dev kit not ab...
Forum: Public Support
Last Post: paresh.chaudhary
02-21-2017, 10:28 PM
» Replies: 2
» Views: 1,032
Interprocess commnication...
Forum: Public Support
Last Post: jarvis_roach
02-15-2017, 07:36 PM
» Replies: 1
» Views: 812

 
  QEMU, Multiple NICs
Posted by: jarvis_roach - 06-18-2015, 07:53 PM - Forum: Public Support - No Replies

1. In dts/xen.dts, change status = "disabled"; to status = "okay"; for each Ethernet controller you want to use in the QEMU target.
2. Rebuild /tftpboot/xen.dtb from dts/xen.dts using make install-xen-dtb or dtc.
3. For each NIC you want to use, including the first one, add "-net nic,vlan=0 -net user,vlan=0" options to the QEMU invocation.
4. From dom0, issue 'udhcpc -i ethN' for each NIC other than eth0 that you want the QEMU DHCP server to assign an address to.
   *Note that using vlan=0 for each configuration pair means that all NICs will be on the same virtual network, and the DHCP server will assign a unique IP address. If you assign each NIC to its own vlan (by using unique vlan IDs for each configuration pair), then the DHCP server will assign the same IP address (10.0.2.15 by default) to each NIC.

From the qemu monitor (normally entered by ctl-a c from serial0)  info network will show how the NICs are configured. With the first two Ethernet controllers enabled and put on the same vlan, info network returns:
hub 0

 \ user.1: index=0,type=user,net=10.0.2.0,restrict=off
 \ ps7-ethernet@0xFF0C0000: index=0,type=nic,
 \ user.0: index=0,type=user,net=10.0.2.0,restrict=off
 \ ps7-ethernet@0xFF0B0000: index=0,type=nic,
ps7-ethernet@0xFF0D0000: index=0,type=nic,
ps7-ethernet@0xFF0E0000: index=0,type=nic,

Print this item

  Enabling UART1 on QEMU MPSoC
Posted by: jarvis_roach - 06-18-2015, 02:29 PM - Forum: Public Support - No Replies

The Zynq MPSoC has two standard UART controllers which, on REMUS and the actual chip, can be used for two independent serial connections. Unfortunately, the default configurations for QEMU in the Beta2 release actively disables the second UART. Fortunately, with a few minor modifications you can enable UART1 and setup QEMU to run so that serial port is connected to a telnet session (or pipe, pty, or file). 

At the high level, you need to enable UART1 in the dtb (device tree blob) that is passed to QEMU which tells it which devices to emulate, you need to update the dtb that is passed to Xen on boot to fix an interrupt issue, and finally you need to invoke QEMU with the options to redirect the input/output of UART1 to a device/file/pipe on your host.

This procedure assumes you have downloaded XZD and created a Xilinx MPSoC project.


1. Enable UART1 in QEMU dtb

a. Convert the QEMU dtb file to dts (device tree specification).


source <petalinux dir>/settings.sh

dtc -I dtb -O dts <project directory>/images/linux/xilinx-ronalado-arm.dtb  -o qemu.dts


b. Delete the line disabling UART1 in qemu.dts (file you just created). Search for serial@FF010000 in your favorite text editor and delete the offending text at line 1013. Save your changes.

  serial@0xFF010000 {

                        compatible = "xlnx,ps7-uart-1.00.a", "xlnx,xuartps";
                        current-speed = <0x1c200>;
                        interrupts = <0x16>;
                        port-number = <0x0>;
                        reg = <0x0 0xff010000 0x1000>;
                        xlnx,has-modem = <0x0>;
                        xlnx,uart-clk-freq-hz = <0x2faf080>;
                        clock-names = "ref_clk", "aper_clk";
                        clocks = <0x29 0x29>;
                        ttrig-polarity = <0x1>;
                        status = "disabled";
                };


c. Convert the modified dts file back to dtb.

dtc -I dts -O dtb qemu.dts -o <project directory>/images/linux/xilinx-ronalado-arm.dtb



2. Update the Xen dtb file

a. Edit the xen.dts file provided in the XZD, located at <XZD path>/dts/xen.dts, and change the UART1's interrupt from level triggered to edge triggered (line 363, change 0x4 to 0x1), and delete the text on 361. Save your changes.


  serial@ff010000 {
                        compatible = "cdns,uart-r1p8";
                        status = "disabled";
                        interrupt-parent = <0x1>;
                        interrupts = <0x0 0x16 0x1>;
                        reg = <0x0 0xff010000 0x1000>;
                        clock-names = "uart_clk", "pclk";
                        clocks = <0x2 0x2>;
                };


b. Rebuild the xen.dtb file.

$ cd <XZD directory>
$ make install-xen-dtb



3. Invoke QEMU with options to redirect UART1 to host device (in this case a telnet session)

a. Run standard QEMU to get default parameters. Copy the QEMU arguments.


$ cd <XZD directory>

$ make boot


Was PetaLinux settings.sh sourced? YES

touch /home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/.running
# Note, this target won't ever finish until the device is powered off...
cd /home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/Xilinx-ZynqMP && petalinux-boot --qemu --u-boot --qemu-args "-drive file=/home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/Xilinx-ZynqMP/images/dom0.qcow,format=qcow2,id=sata-drive -device ide-drive,drive=sata-drive,bus=ahci@0xFD0C0000.0 -redir tcp:2222::22" | tee /home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/.running && rm -f /home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/.running
qemu_cmd=qemu-system-aarch64
--------------------------------------------------------------------
Xilinx QEMU Apr  9 2015 20:01:21.
--------------------------------------------------------------------
INFO: TCP PORT is free 
INFO: Starting aarch64 QEMU
INFO:  qemu-system-aarch64 -L /home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/petalinux-v2015.SW_Beta2-final/etc/qemu -M arm-generic-fdt -device loader,addr=0xfd1a0104,data=0x8000000e,data-len=4   -serial mon:stdio -serial /dev/null -display none -device loader,file=/home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/Xilinx-ZynqMP/images/linux/bl31.elf,cpu=0 -device loader,file=/home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/Xilinx-ZynqMP/images/linux/u-boot.elf -gdb tcp::9000  -tftp /tftpboot -drive file=/home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/Xilinx-ZynqMP/images/dom0.qcow,format=qcow2,id=sata-drive -device ide-drive,drive=sata-drive,bus=ahci@0xFD0C0000.0 -redir tcp:2222::22 -hw-dtb /home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/Xilinx-ZynqMP/images/linux/xilinx-ronaldo-arm.dtb -pflash /home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/Xilinx-ZynqMP/images/linux/nand0.qcow2 -pflash /home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/Xilinx-ZynqMP/images/linux/nand0.qcow2


b. Paste the QEMU invocation to a command prompt, replace the "-serial /dev/null" option with "-serial telnet::4444,server".

qemu-system-aarch64 -L /home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/petalinux-v2015.SW_Beta2-final/etc/qemu -M arm-generic-fdt -device loader,addr=0xfd1a0104,data=0x8000000e,data-len=4   -serial mon:stdio -serial telnet::4444,server -display none -device loader,file=/home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/Xilinx-ZynqMP/images/linux/bl31.elf,cpu=0 -device loader,file=/home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/Xilinx-ZynqMP/images/linux/u-boot.elf -gdb tcp::9000  -tftp /tftpboot -drive file=/home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/Xilinx-ZynqMP/images/dom0.qcow,format=qcow2,id=sata-drive -device ide-drive,drive=sata-drive,bus=ahci@0xFD0C0000.0 -redir tcp:2222::22 -hw-dtb /home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/Xilinx-ZynqMP/images/linux/xilinx-ronaldo-arm.dtb -pflash /home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/Xilinx-ZynqMP/images/linux/nand0.qcow2 -pflash /home/jarvis/CONFIDENTIAL_Zinq_Next_Gen_Hypervisor_2132/Xilinx-ZynqMP/images/linux/nand0.qcow2


Note the bolded text is what you can change for other redirection options (such as file:<path to file>, pipe:<path to pipe>, pty, etc). For more details see QEMU User Doc.

c. From another terminal, run telnet:

$ telnet localhost 4444

At this point, the QEMU should boot to a dom0 login prompt (user: root, pwd: root). From the dom0 shell, you will see that ttyPS0 was installed (ls /dev or dmesg | grep tty). Writing to or reading from /dev/ttyPS0 from the guest will result in reverse operation on the host device. For example, echo hello > /dev/ttyPS0 will cause "hello" to appear on the telnet terminal, and cat /dev/ttyPS0 will display strings of data entered in the telnet terminal after a newline (return) is entered.

From dom0:

[root@xilinx-dom0 ~]# dmesg | grep tty

[    4.225433] xuartps ff010000.serial: ttyPS0 at MMIO 0xff010000 (irq = 54, base_baud = 1562500) is a xuartps
[root@xilinx-dom0 ~]# echo hello > /dev/ttyPS0
[root@xilinx-dom0 ~]# cat /dev/ttyPS0
This data is coming from the telnet session
blah
asdfasd;gja;lsdgja;klgja;lksdgja;lkdfgja;lsdfkgjakl;gja;klgha;klghakl;dgal;ksdgjal;skghakl;gha;lskdgha;lskdgha;lsdkgha;lsgha;lsdghka;slgkha;sdklgha;slgkhas;lgkha;slgkha;sdlghka;gklhal;sdgkha;sgklhasd;gklahdg;lkhadg;khasd;ghklasd;gkahsd;gklahsd;gklahsdg;ahsdg;aklshdg;aklsdhg;alskdgh;aklsdgh;alsdkgha;sldkgha;sdlgh;alskdgh;asdghka;sdlgkha;sdlghka;sdghasdkl;gha;sdghka;sdklghas;dklgha;sldkgha;sdklgha;sdlgkha;sdlgha;sdlgkhasdl;gkhasdl;gkhas;dlgkhasdl;gkah
String is sent when enter/return/newline is typed in telnet session



From the host terminal:


$ telnet localhost 4444

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
hello
This data is coming from the telnet session
blah

asdfasd;gja;lsdgja;klgja;lksdgja;lkdfgja;lsdfkgjakl;gja;klgha;klghakl;dgal;ksdgjal;skghakl;gha;lskdgha;lskdgha;lsdkgha;lsgha;lsdghka;slgkha;sdklgha;slgkhas;lgkha;slgkha;sdlghka;gklhal;sdgkha;sgklhasd;gklahdg;lkhadg;khasd;ghklasd;gkahsd;gklahsd;gklahsdg;ahsdg;aklshdg;aklsdhg;alskdgh;aklsdgh;alsdkgha;sldkgha;sdlgh;alskdgh;asdghka;sdlgkha;sdlghka;sdghasdkl;gha;sdghka;sdklghas;dklgha;sldkgha;sdklgha;sdlgkha;sdlgha;sdlgkhasdl;gkhasdl;gkhas;dlgkhasdl;gkah

Print this item

  Ethernet Passthrough
Posted by: Robert.VanVossen - 06-12-2015, 03:14 PM - Forum: Public Support - Replies (4)

Some people have been interested in a guide on doing ethernet passthrough, so I thought I would write one here. 

First off you need to modify your Xen device tree that is loaded through U-Boot. Disable the Ethernet gem and enable Xen passthrough:

Code:
        gem1: ethernet@ff0c0000 {
            #stream-id-cells = <0x1>;
            compatible = "cdns,gem";
            interrupt-parent = <0x1>;
            interrupts = <0x0 0x4b 0x4>;
            reg = <0x0 0xff0c0000 0x1000>;
            clock-names = "pclk", "hclk", "tx_clk";
            clocks = <0x2 0x2 0x2>;
            #address-cells = <0x1>;
            #size-cells = <0x0>;

+            xen,passthrough = <1>;
+            status = "disabled";
        };

Then add the device as an mmu-master to the smmu in the same device tree:

Code:
              smmu0: smmu0@0xFD800000 {
                       compatible = "arm,mmu-500";
                       reg = <0x0 0xfd800000 0x20000>;
                       #global-interrupts = <1>;
                       interrupt-parent = <&gic>;
                       interrupts = <0 157 4>,
                               <0 157 4>, <0 157 4>, <0 157 4>, <0 157 4>,
                               <0 157 4>, <0 157 4>, <0 157 4>, <0 157 4>,
                               <0 157 4>, <0 157 4>, <0 157 4>, <0 157 4>,
                               <0 157 4>, <0 157 4>, <0 157 4>, <0 157 4>;

-                        mmu-masters = <&gem0 0x874 >;
+                        mmu-masters = <&gem0 0x874 &gem1 0x875 >;
               };

After that, you will need to modify the configuration file for the guest through which you are passing the Ethernet gem. You will need to define the following options:

dtdev - The absolute path of the device to passthrough in the device tree
device_tree - dom0 path to partial device tree to be passed to the guest
irqs - irq to be given to the guest
iomem = the physical pages to be passed in to the guest

Here are the values added to a configuration file for gem1 being passed through:

Code:
dtdev = [ "/amba/ethernet@ff0d0000" ]
device_tree = "/etc/xen/xen-partial.dtb"
irqs = [ 109 ]
iomem = [ "0xff0c0,1" ]
 
The last step is to create the partial device tree that the configuration file points to. This is used to let the guest know how to setup the passthrough device. Here is how to configure the file:
Code:
/dts-v1/;

/ {
    #address-cells = <0x2>;
    #size-cells = <0x1>;

    passthrough {
        compatible = "simple-bus";
        ranges;
        #address-cells = <0x2>;
        #size-cells = <0x1>;

        misc_clk {
            #clock-cells = <0x0>;
            clock-frequency = <0x17d7840>;
            compatible = "fixed-clock";
            linux,phandle = <0x2>;
            phandle = <0x2>;
        };

        ethernet@ff0c0000 {
            #stream-id-cells = <0x1>;
            compatible = "cdns,gem";
            reg = <0x0 0xff0c0000 0x1000>;
            interrupts = <0x0 0x4b 0x4>;
            clock-names = "pclk", "hclk", "tx_clk";
            clocks = <0x2 0x2 0x2>;
            #address-cells = <0x1>;
            #size-cells = <0x0>;
            local-mac-address = [00 0a 35 00 02 02];
            phy-handle = <0x1>;
            phy-mode = "rgmii-id";

            phy@0 {
                reg = <0x0>;
                max-speed = <0x64>;
                linux,phandle = <0x1>;
                phandle = <0x1>;
            };
        };
    };
};

Then generate the dtb using the following command:
Code:
dtc -I dts -O dtb -o xen-partial.dtb xen-partial.dts

Then when you start your guest, it should initialize gem1 and have exclusive access to the device.

Print this item