cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
danielgp
Visitor
Visitor
184 Views
Registered: ‎02-15-2019

Testing CAN in Petalinux QEMU 20.1

Hi!

According to https://www.xilinx.com/support/documentation/sw_manuals/xilinx2020_1/ug1169-xilinx-qemu.pdf now we can use CAN with Xilinx QEMU:

danielgp_0-1619697999474.png

I have some questions:

1) Reading the new section about CAN, it only refers to ZynqMP... that means that we cannot use this interface in the QEMU for zynq devices (e.g. zedboard)?

2) Even not being sure about 1), I gave it a try. I created a new design and added the CAN0 controller. Then created a new Petalinux 20.1 project with this new design and booted on QEMU. I get the device when I execute "ifconfig can0":

danielgp_1-1619698463620.png

However, when I try to enable the CAN device by executing "ifconfig can0 up", I get the following error:

danielgp_2-1619698495541.png

It seems that the PS cannot communicate with the CAN0 controller.. According to https://www.xilinx.com/support/documentation/user_guides/ug585-Zynq-7000-TRM.pdf (page 796), if I read the reg in address 0xE000802C, I should be getting 0x00003F3F, however, I always get 0x00000000. Am I missing something? or simply this is not possible due to 1)?

Just to mention, the XILINX_CAN driver is enabled (already by default for this petalinux 20.1 version) in petalinux-config.

Note: If useful, here is what is printed in dmesg about can:

danielgp_3-1619698568829.png

Thank you for your help!

Tags (3)
0 Kudos
1 Reply
danielgp
Visitor
Visitor
89 Views
Registered: ‎02-15-2019

Ok, I have made some progress.

First, it seems that the CAN interface for QEMU only works for ZynqMP devices. Therefore, I tried it with the default zcu102 BSP and finally I managed to initialize the can0 driver (fortunately, the default BSP from Xilinx Downloads website has CAN1 controller already enabled):

danielgp_0-1620034903922.png

In my host machine, I have vcan0 enabled. To associate the CAN1 controller to the vcan0 interface, I simply started the boot by executing this command: petalinux-boot --qemu --kernel --qemu-args "-object can-bus,id=canbus1 -global driver=xlnx.zynqmp-can,property=canbus1,value=canbus1 -object can-host-socketcan,id=socketcan1,if=vcan0,canbus=canbus1"

When running "cangen vcan0 -v" in the host machine and "candump can0" in the guest machine (QEMU) in order to send data from the host to the guest machine via CAN, unfortunately, the data I am sending is not the same I am receiving. Check it out:

danielgp_1-1620035407028.png

On the left, you can see the CAN frames received on QEMU. On the right bottom, is the data I am sending via the host machine and on the right top I am also reading in order to check I am sending that data. As you can check, when receiving data on QEMU, the ID is always wrong (000) and the bytes of the payload are completely in the wrong order..

As the support with CAN on the QEMU is something really recent, is this a bug? Some misconfiguration in the CAN Controller? I really need some support as there is no other documentation or forum thread as once again this feature is quite recent.

Thanks!

0 Kudos