Xilinx / systemctlm-cosim-demo

QEMU libsystemctlm-soc co-simulation demos.
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/862421112/Co-simulation
Other
130 stars 46 forks source link

PL memory blocks doesnot work #21

Open mksaksms opened 3 years ago

mksaksms commented 3 years ago

I tried to implement the whole tutorial with following steps. So far I was been able to connect the petalinux qemu with system c socket and I can boot the os in linux. But I couldnot read the values of the IPs that was included in the hardware design by calling devmem command. Could you guide me on emulating PL side ?

This was my pl.dtsi contents of the petalinux project : This memory addresses is giving wrong values in emulation. /*

/ { amba_pl: amba_pl {

address-cells = <1>;

    #size-cells = <1>;
    compatible = "simple-bus";
    ranges ;
    apb_wrapper_policy_s_0: apb_wrapper_policy_server@43c00000 {
        compatible = "xlnx,apb-wrapper-policy-server-1.0";
        reg = <0x43c00000 0x10000>;
    };
    apb_wrapper_puf_0: apb_wrapper_puf@43c10000 {
        compatible = "xlnx,apb-wrapper-puf-1.0";
        reg = <0x43c10000 0x10000>;
    };
    apb_wrapper_rsa_0: apb_wrapper_rsa@43c20000 {
        compatible = "xlnx,apb-wrapper-rsa-1.0";
        reg = <0x43c20000 0x10000>;
    };
    apb_wrapper_trng_0: apb_wrapper_trng@43c30000 {
        compatible = "xlnx,apb-wrapper-trng-1.0";
        reg = <0x43c30000 0x10000>;
    };
};

};

My question is if export the a soc design with several IP block and create a custom petalinux project, can I read the values of this PL side ?

franciscoIglesias commented 3 years ago

Hi Muhammed,

Which of the demos are you trying to launch? If it is the zynq_demo this blog by Rick Wertenbroek contains a script with commands on how to create the hardware dtb: generate_qemu_device_tree_zynq7.sh using petalinux commands. For the ZynqMP/Versal demos the hardware cosim dts to use when launching QEMU are found in the qemu-devicetrees repository (meanning that you don't need to build one by your own).

My command lines for launching the zynq_demo are found below (where I renamed the petalinux built system.dtb using the commands from the script, and containing remote-port connections, to system-cosim.dtb):

# Launch qemu
$ qemu-system-aarch64 -M arm-generic-fdt-7series -machine linux=on -serial /dev/null -serial mon:stdio -display none -kernel /home/user/Downloads/xilinx-zc702-2021.1/pre-built/linux/images/u-boot.elf -dtb system-cosim.dtb  -device loader,addr=0xf8000008,data=0xDF0D,data-len=4 -device loader,addr=0xf8000140,data=0x00500801,data-len=4 -device loader,addr=0xf800012c,data=0x1ed044d,data-len=4 -device loader,addr=0xf8000108,data=0x0001e008,data-len=4 -device loader,addr=0xF8000910,data=0xF,data-len=0x4   -device loader,file=/home/user/Downloads/xilinx-zc702-2021.1/pre-built/linux/images/system.dtb,addr=0x00100000 -machine-path /tmp/qemu

# Launch systemctlm-cosim-demo zynq_demo in a second terminal
$ ./zynq_demo  unix:/tmp/qemu/qemu-rport-_cosim@0 1000000

Best regards, Francisco Iglesias

mksaksms commented 3 years ago

Hi Francis, Thanks a lot for reply. Actually I was using their script but I believe you and his script was downloading the zynq-pl-remoteport.dtsi from xilinx website and generating a dtb file. Will that make any difference ? Should I try with your code ?

Is it ok to try the petalinux flow command ?

petalinux-boot --qemu --kernel --qemu-args " -hw-dtb ./qemu_cosim/qemu_hw_system.dtb -machine-path ./qemu_cosim -icount 1 -sync-quantum 10000"

Here this dtb was created by Ricks script .

franciscoIglesias commented 3 years ago

Hi again Muhammed,

The answers is yes to both questions, you need to use zynq-pl-remoteport.dtsi (this file contains the remote-port descriptions that will make QEMU create connections to SystemC), and it is ok to run it through the petalinux command as you mention above. From the Linux command line you can try below that will hit the debugdev and output a trace print.

# Terminal 1
$ petalinux-boot --qemu --kernel --qemu-args " -hw-dtb ./qemu_cosim/qemu_hw_system.dtb -machine-path /tmp/qemu_cosim -icount 1 -sync-quantum 10000"
...
<boot>
...
root@xilinx-zc702-2021_2:~# devmem 0x40000000 32 0xaa

# Terminal 2 (will output the 'TRACE..' line when above is written)
$ ./zynq_demo unix:/tmp/qemu_cosim/qemu-rport-_cosim@0 10000
...
TRACE:  aa 27911022155 ns diff=27204969120 ns

Best regards, Francisco Iglesias