ros-acceleration / acceleration_examples

ROS 2 package examples demonstrating the use of hardware acceleration.
Apache License 2.0
39 stars 19 forks source link

Not able to run emulation #1

Closed jasvinderkhurana closed 3 years ago

jasvinderkhurana commented 3 years ago

I am trying to run Emulation for kv260, but I get below error:

[14:11 jasvinde@xhdjasvinde41 krs_ws] > colcon acceleration emulation sw_emu install-kv260
WARNING:colcon.colcon_mixin.mixin:Mixin 'zcu102' from file '/home/jasvinde/.colcon/mixin/zcu102/zcu102.mixin' is overwriting another mixin with the same name
WARNING:colcon.colcon_mixin.mixin:Mixin 'zcu102-debug' from file '/home/jasvinde/.colcon/mixin/zcu102/zcu102.mixin' is overwriting another mixin with the same name
SECURITY WARNING: This class invokes explicitly a shell via the shell=True argument of the Python subprocess library, and uses admin privileges to manage raw disk images. It is the user's responsibility to ensure that all whitespace and metacharacters passed are quoted appropriately to avoid shell injection vulnerabilities.
- Verified that install/ is available in the current ROS 2 workspace
- Confirmed availability of raw image file at: /scratch/Work/Ros2/krs_ws/acceleration/firmware/select/sd_card.img
- Finished inspecting raw image, obtained UNITS and STARTSECTOR P1/P2
- Image mounted successfully at: /tmp/sdcard_img_p2
No prior overlay ROS 2 workspace found at: /tmp/sdcard_img_p2/ros2_ws, creating it.
- Copied 'install-kv260' directory as a ROS 2 overlay workspace in the raw image.
- Umounted the raw image.
- Generated PMU and QEMU files.
- Launching emulation...
cd /scratch/Work/Ros2/krs_ws/acceleration/firmware/select/emulation && /proj/xbuilds/SWIP/2020.2_1118_1232/installs/lin64/Vitis/2020.2/bin/launch_emulator -device-family ultrascale -target sw_emu -qemu-args-file /scratch/Work/Ros2/krs_ws/acceleration/firmware/select/emulation/qemu_args.txt -pmc-args-file /scratch/Work/Ros2/krs_ws/acceleration/firmware/select/emulation/pmu_args.txt -sd-card-image /scratch/Work/Ros2/krs_ws/acceleration/firmware/select/sd_card.img -enable-prep-target $*
Running SW Emulation
INFO :  [LAUNCH_EMULATOR] pl_sim_dir option is not provided.
Starting QEMU
 - Press <Ctrl-a h> for help
Waiting for QEMU to start. qemu_port 8968
Qemu_pids 2200966 2200967
qemu-system-aarch64: -chardev socket,path=./qemu-rport-_pmu@0,server,id=pmu-apu-rp: info: QEMU waiting for connection on: disconnected:unix:./qemu-rport-_pmu@0,server
QEMU started. qemu_pid=2200966.
Waiting for PMU to start. Qemu_pids 2200970 2200971
qemu-system-aarch64: -chardev socket,id=pl-rp,host=127.0.0.1,port=7783,server: info: QEMU waiting for connection on: disconnected:tcp:127.0.0.1:7783,server
PMC started. pmc_pid=2200970
Starting PL simulation.Generating PLLauncher commandline
running PLL Launcher
qemu-system-aarch64: Could not reopen file: Permission denied
qemu-system-microblazeel: /pmu@0: Disconnected clk=5517356585 ns

[LAUNCH_EMULATOR] INFO: 14:11:45 : PMU/PMC-QEMU  exited
[LAUNCH_EMULATOR] INFO: 14:11:47 : PS-QEMU exited
[LAUNCH_EMULATOR] INFO: 14:11:47 : PMU/PMC-QEMU exited
[LAUNCH_EMULATOR] INFO: 14:11:47 : Trying to kill PLLauncher forcefully because QEMU exited
[LAUNCH_EMULATOR] INFO: 14:11:47 : PLLauncher exited by force
Please refer PS /simulate logs at /scratch/Work/Ros2/krs_ws/acceleration/firmware/kv260/emulation for more details.
DONE!
INFO: Emulation ran successfully

I have executed below steps to run emulation:


509  [30/08 14:06:13] source /<path_to_vitis>/Vitis/2020.2/settings64.sh
  510  [30/08 14:06:25] source /opt/ros/foxy/setup.bash
  511  [30/08 14:06:38] export PATH="/usr/bin":$PATH
  512  [30/08 14:08:43] colcon acceleration select kv260
  513  [30/08 14:09:02] colcon acceleration list
  514  [30/08 14:09:58] source install-kv260/setup.bash
  515  [30/08 14:10:01] colcon acceleration list
  516  [30/08 14:10:16] colcon acceleration select kv260
  517  [30/08 14:10:19] colcon acceleration list
  518  [30/08 14:10:37] colcon build --build-base=build-kv260 --install-base=install-kv260 --merge-install --mixin kv260 --packages-select publisher_xilinx
  519  [30/08 14:10:47] colcon acceleration linux vanilla
  520  [30/08 14:11:34] colcon acceleration emulation sw_emu install-kv260

Please guide what possibly I am doing wrong.

vmayoral commented 3 years ago

Thanks for raising the ticket @jasvinderkhurana. See:

qemu-system-aarch64: Could not reopen file: Permission denied

Do you have your file system set with the permissions to launch this? I suspect not.

jasvinderkhurana commented 3 years ago

I tried with root permissions as well but then I get failed to allocate memory, and I think my PC has enough available memory:

root@xhdjasvinde41:/scratch/Work/Ros2/krs_ws# colcon acceleration emulation sw_emu install-kv260
SECURITY WARNING: This class invokes explicitly a shell via the shell=True argument of the Python subprocess library, and uses admin privileges to manage raw disk images. It is the user's responsibility to ensure that all whitespace and metacharacters passed are quoted appropriately to avoid shell injection vulnerabilities.
- Verified that install/ is available in the current ROS 2 workspace
- Confirmed availability of raw image file at: /scratch/Work/Ros2/krs_ws/acceleration/firmware/select/sd_card.img
- Finished inspecting raw image, obtained UNITS and STARTSECTOR P1/P2
- Image mounted successfully at: /tmp/sdcard_img_p2
- Successfully cleaned up prior overlay ROS 2 workspace at: /tmp/sdcard_img_p2/ros2_ws
- Copied 'install-kv260' directory as a ROS 2 overlay workspace in the raw image.
- Umounted the raw image.
- Generated PMU and QEMU files.
- Launching emulation...
cd /scratch/Work/Ros2/krs_ws/acceleration/firmware/select/emulation && /proj/xbuilds/SWIP/2020.2_1118_1232/installs/lin64/Vitis/2020.2/bin/launch_emulator -device-family ultrascale -target sw_emu -qemu-args-file /scratch/Work/Ros2/krs_ws/acceleration/firmware/select/emulation/qemu_args.txt -pmc-args-file /scratch/Work/Ros2/krs_ws/acceleration/firmware/select/emulation/pmu_args.txt -sd-card-image /scratch/Work/Ros2/krs_ws/acceleration/firmware/select/sd_card.img -enable-prep-target $*
Running SW Emulation
INFO :  [LAUNCH_EMULATOR] pl_sim_dir option is not provided.
Starting QEMU
 - Press <Ctrl-a h> for help
Waiting for QEMU to start. qemu_port 8013
Qemu_pids 2203336 2203337
qemu-system-aarch64: -chardev socket,path=./qemu-rport-_pmu@0,server,id=pmu-apu-rp: info: QEMU waiting for connection on: disconnected:unix:./qemu-rport-_pmu@0,server
QEMU started. qemu_pid=2203336.
Waiting for PMU to start. Qemu_pids 2203342 2203343
qemu-system-aarch64: -chardev socket,id=pl-rp,host=127.0.0.1,port=8011,server: info: QEMU waiting for connection on: disconnected:tcp:127.0.0.1:8011,server
PMC started. pmc_pid=2203342
Starting PL simulation.Generating PLLauncher commandline
running PLL Launcher
Failed to allocate memory: Cannot allocate memory
qemu-system-microblazeel: /pmu@0: Disconnected clk=8279495343 ns

/scratch/Work/Ros2/krs_ws/acceleration/firmware/kv260/emulation/emu_qemu_scripts/start_qemu.sh: line 3: 2203338 Aborted                 (core dumped) $QEMU_GDB_COMMAND /proj/xbuilds/SWIP/2020.2_1118_1232/installs/lin64/Vitis/2020.2/data/emulation/qemu/unified_qemu_v5_0/sysroots/x86_64-petalinux-linux/usr/bin/qemu-system-aarch64 -M arm-generic-fdt -serial /dev/null -serial mon:stdio -display none -device loader,file=/scratch/Work/Ros2/krs_ws/acceleration/firmware/select/emulation/../bl31.elf,cpu-num=0 -device loader,file=/scratch/Work/Ros2/krs_ws/acceleration/firmware/select/emulation/../u-boot.elf -device loader,file=/scratch/Work/Ros2/krs_ws/acceleration/firmware/select/emulation/../device_tree/u-boot.dtb,addr=0x00100000,force-raw -gdb tcp::9000 -net nic -net nic -net nic -net nic -net user,hostfwd=tcp:127.0.0.1:2222-10.0.2.15:22 -hw-dtb /scratch/Work/Ros2/krs_ws/acceleration/firmware/select/emulation/../zynqmp-qemu-multiarch-arm.dtb -global xlnx,zynqmp-boot.cpu-num=0 -global xlnx,zynqmp-boot.use-pmufw=true -m 4G "" -hw-dtb /proj/xbuilds/SWIP/2020.2_1118_1232/installs/lin64/Vitis/2020.2/data/emulation/dtbs/zynqmp/zynqmp-arm-cosim.dtb -drive "file=/scratch/Work/Ros2/krs_ws/acceleration/firmware/select/sd_card.img,if=sd,format=raw,index=1" -display "none" -machine-path "." -chardev "socket,path=./qemu-rport-_pmu@0,server,id=pmu-apu-rp" -chardev "socket,id=pl-rp,host=127.0.0.1,port=8011,server"
[LAUNCH_EMULATOR] INFO: 15:07:19 : PS-QEMU exited
[LAUNCH_EMULATOR] INFO: 15:07:21 : PS-QEMU exited
[LAUNCH_EMULATOR] INFO: 15:07:21 : PMU/PMC-QEMU exited
[LAUNCH_EMULATOR] INFO: 15:07:21 : Trying to kill PLLauncher forcefully because QEMU exited
[LAUNCH_EMULATOR] INFO: 15:07:21 : PLLauncher exited by force
Please refer PS /simulate logs at /scratch/Work/Ros2/krs_ws/acceleration/firmware/kv260/emulation for more details.
DONE!
INFO: Emulation ran successfully
Finalized successfully.
vmayoral commented 3 years ago

Yeah, @jasvinderkhurana, sounds like an issue with your system:

Failed to allocate memory: Cannot allocate memory
qemu-system-microblazeel: /pmu@0: Disconnected clk=8279495343 ns

/scratch/Work/Ros2/krs_ws/acceleration/firmware/kv260/emulation/emu_qemu_scripts/start_qemu.sh: line 3: 2203338 Aborted                 (core dumped) $QEMU_GDB_COMMAND /proj/xbuilds/SWIP/2020.2_1118_1232/installs/lin64/Vitis/2020.2/data/emulation/qemu/unified_qemu_v5_0/sysroots/x86_64-petalinux-linux/usr/bin/qemu-system-aarch64 -M arm-generic-fdt -serial /dev/null -serial mon:stdio -display none -device loader,file=/scratch/Work/Ros2/krs_ws/acceleration/firmware/select/emulation/../bl31.elf,cpu-num=0 -device loader,file=/scratch/Work/Ros2/krs_ws/acceleration/firmware/select/emulation/../u-boot.elf -device loader,file=/scratch/Work/Ros2/krs_ws/acceleration/firmware/select/emulation/../device_tree/u-boot.dtb,addr=0x00100000,force-raw -gdb tcp::9000 -net nic -net nic -net nic -net nic -net user,hostfwd=tcp:127.0.0.1:2222-10.0.2.15:22 -hw-dtb /scratch/Work/Ros2/krs_ws/acceleration/firmware/select/emulation/../zynqmp-qemu-multiarch-arm.dtb -global xlnx,zynqmp-boot.cpu-num=0 -global xlnx,zynqmp-boot.use-pmufw=true -m 4G "" -hw-dtb /proj/xbuilds/SWIP/2020.2_1118_1232/installs/lin64/Vitis/2020.2/data/emulation/dtbs/zynqmp/zynqmp-arm-cosim.dtb -drive "file=/scratch/Work/Ros2/krs_ws/acceleration/firmware/select/sd_card.img,if=sd,format=raw,index=1" -display "none" -machine-path "." -chardev "socket,path=./qemu-rport-_pmu@0,server,id=pmu-apu-rp" -chardev "socket,id=pl-rp,host=127.0.0.1,port=8011,server"

Note nevertheless that as highlighted in the docs, sw_emu capabilities are limited to the file system inspection itself, since Vitis 2020.2 does not provide support for running sw_emu kernels for KV260. This is a roadmap item as far as I'e been told.

So in a nutshell, I'd encourage you to move forward to hardware and report issues there (or alternatively, try the ZCU102 one which is polished).

You can open another ticket if you encounter another hurdle @jasvinderkhurana. Can we close this one for now?

vmayoral commented 3 years ago

Ping @jasvinderkhurana, can we close this ticket since the initial issue seems resolved?

jasvinderkhurana commented 3 years ago

@vmayoral I am trying the same on a different machine.. gimme some more time.. to check if the issue persists there as well, and then we can close the ticket

jasvinderkhurana commented 3 years ago

@vmayoral , I tried on another machine and emulation works as expected. Closing the ticket! Thanks for the support!