トップ 一覧 Farm 検索 ヘルプ RSS ログイン

Diary/2020-12-2の変更点

  • 追加された行はこのように表示されます。
  • 削除された行はこのように表示されます。
!Ubuntu/ZCU111の続き
https://www.wasamon.net/miyo/index.cgi?page=Diary%2F2020%2D12%2D1 の続き

:: U-bootで自動的に起動するようにする
uEnv.txtじゃなくてboot.scrを使う.手で入力してたコマンドを boot.script に保存.
 fatload mmc 0 0x10000000 Image
 fatload mmc 0 0x02a00000 zynqmp-zcu111-revA.dtb
 setenv bootargs earlycon clk_ignore_unused consoleblank=0 root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait
 booti 0x10000000 - 0x02a00000
で,
 $ ${WORK}/u-boot-xlnx/tools/mkimage -A arm64 -O linux -T script -C none -a 0 -e 0 -n "boot.scr" -d boot.script boot.scr
として boot.scr を作る.これを BOOT.binとか置いたパーティションにコピー.

:: PLの再コンフィギュレーション
これは,ZYNQでやってたときと同じ.
fpga.dtsを用意して
 /dts-v1/;
 / {
     fragment@0 {
         target-path = "/fpga-full";
         __overlay__ {
             firmware-name = "fpga.bin";
         };
     };
 };
dtcでdtsからdtbを作成
 dtc -I dts -O dtb -o fpga.dtb fpga.dts
fpga-bit2bin.pyでbitファイルからbinファイルを作って,
/lib/firmware/fpga.bin に配置して
 mkdir -p /sys/kernel/config/device-tree/overlays/fpga
 cp fpga.dtb /sys/kernel/config/device-tree/overlays/fpga/dtbo

:: RFdcアプリの実装のためにライブラリの準備
実機で作業してしまう
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/84378586/Building+RFDC+application+from+git+sources+for+ZCU111 ベースにしつつ,実機なのでちょっと違う

libsysfs-devやcmakeやらが必要らしいのでaptでインストール 
 sudo apt install libsysfs-dev cmake

一式を取得.ホームディレクトリの下で作業する.
 cd ~/
 git clone https://github.com/Xilinx/embeddedsw
 cd embeddedsw
 git checkout xilinx-v2019.1

libmetalのビルド
 cd ThirdParty/sw_services/libmetal/src/libmetal
 mkdir build_libm; cd build_libm
 cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/zynqmp-linux.cmake
 make -k
 sudo make install/fast 
test関連のソースのビルドでエラーがでるので,ごにょごにょとスキップ.

 cd ~/embeddedsw/XilinxProcessorIPLib/drivers/rfdc/src/
 make -f Makefile.Linux

:: RFdcのサンプルを動かしてみる,が.

 user@zcu111:~/embeddedsw/XilinxProcessorIPLib/drivers/rfdc/examples$ ./rfdc-read-write
 RFdc Read and Write Example Test
 metal_sys_init
 success: sysfs_get_mnt_path
 success: fopen /dev/urandom
 success: metal_init_page_sizes
 try: metal_linux_bus_init
 metal_linux_bus_init
 metal_linux_probe_bus
 try: sysfs_open_bus: platform
 success: sysfs_open_bus: platform
 try: metal_linux_probe_driver
 metal_linux_probe_driver
 try: sysfs_open_driver platform uio_pdrv_genirq
 result: sysfs_open_driver (nil)
 metal_linux_probe_driver
 try: sysfs_open_driver platform uio_dmem_genirq
 result: sysfs_open_driver (nil)
 error: metal_linux_probe_driver
 metal_linux_probe_bus
 try: sysfs_open_bus: pci
 success: sysfs_open_bus: pci
 try: metal_linux_probe_driver
 metal_linux_probe_driver
 try: sysfs_open_driver pci vfio-pci
 result: sysfs_open_driver (nil)
 metal_linux_probe_driver
 try: sysfs_open_driver pci uio_pci_generic
 result: sysfs_open_driver (nil)
 error: metal_linux_probe_driver
 ERROR: Failed to run metal initialization
 Read and Write Example Test failed
 user@zcu111:~/embeddedsw/XilinxProcessorIPLib/drivers/rfdc/examples$
って感じでmetal_initで失敗.
ちなみにTRDで実行してみると
 root@xilinx-zcu111-2020_2:/media/sd-mmcblk0p2/home/user/embeddedsw/XilinxProcessorIPLib/drivers/rfdc/examples# ./rfdc-read-write
 RFdc Read and Write Example Test
 metal: info:      Registered shmem provider linux_shm.
 metal: info:      Registered shmem provider ion.reserved.
 metal: info:      Registered shmem provider ion.ion_system_contig_heap.
 metal: info:      Registered shmem provider ion.ion_system_heap.
 metal: info:      metal_linux_dev_open: checking driver vfio-platform,b0040000.usp_rf_data_converter,uio_pdrv_genirq
 metal: info:      metal_linux_dev_open: checking driver uio_pdrv_genirq,b0040000.usp_rf_data_converter,uio_pdrv_genirq
 metal: info:      metal_linux_dev_open: driver uio_pdrv_genirq bound to b0040000.usp_rf_data_converter
 metal: warning:   reading attribute /sys/devices/platform/amba/b0040000.usp_rf_data_converter/uio/uio5/maps/map1/offset yields result -22
 metal: info:      metal_linux_dev_open: checking driver vfio-platform,b0040000.usp_rf_data_converter,(null)
 metal: warning:   reading attribute /sys/devices/platform/amba/b0040000.usp_rf_data_converter/uio/uio5/maps/map1/offset yields result -22
 Segmentation fault
 root@xilinx-zcu111-2020_2:/media/sd-mmcblk0p2/home/user/embeddedsw/XilinxProcessorIPLib/drivers/rfdc/examples#
とか
ためしにTRDでsys以下をfindしてみると
 root@xilinx-zcu111-2020_2:/sys# find . -name \*uio\* -print
 ./class/uio
 ./class/uio/uio1
 ./class/uio/uio4
 ./class/uio/uio2
 ./class/uio/uio0
 ./class/uio/uio3
 ./devices/platform/amba/fd0b0000.perf-monitor/uio
 ./devices/platform/amba/fd0b0000.perf-monitor/uio/uio1
 ./devices/platform/amba/fd490000.perf-monitor/uio
 ./devices/platform/amba/fd490000.perf-monitor/uio/uio2
 ./devices/platform/amba/ffa00000.perf-monitor/uio
 ./devices/platform/amba/ffa00000.perf-monitor/uio/uio0
 ./devices/platform/amba/b0010000.axi_perf_mon/uio
 ./devices/platform/amba/b0010000.axi_perf_mon/uio/uio4
 ./devices/platform/amba/ffa10000.perf-monitor/uio
 ./devices/platform/amba/ffa10000.perf-monitor/uio/uio3
 ./bus/platform/drivers/uio_pdrv_genirq
 ./bus/platform/drivers/uio_dmem_genirq
 ./module/uio_xilinx_ai_engine
 root@xilinx-zcu111-2020_2:/sys# find . -name \*pci\* -print
 ./kernel/debug/clk/pcie_ref_mux
 ./kernel/debug/clk/pcie_ref_div1
 ./kernel/debug/clk/pcie_ref
 ./class/pci_bus
 ./bus/platform/drivers/xilinx-pcie
 ./bus/platform/drivers/xilinx-xdma-pcie
 ./bus/platform/drivers/nwl-pcie
 ./bus/pci
 ./bus/pci/drivers/ps_pcie_dma
 ./firmware/devicetree/base/amba/pcie@fd0e0000
 ./firmware/devicetree/base/__symbols__/pcie
 ./firmware/devicetree/base/__symbols__/pcie_intc
 ./module/edac_core/parameters/edac_pci_panic_on_pe
 ./module/edac_core/parameters/check_pci_errors
で,自分でセットアップした方は,
 root@zcu111:/sys# find . -name \*uio\* -print
 ./class/uio
 ./class/uio/uio1
 ./class/uio/uio2
 ./class/uio/uio0
 ./class/uio/uio3
 ./devices/platform/amba/fd0b0000.perf-monitor/uio
 ./devices/platform/amba/fd0b0000.perf-monitor/uio/uio1
 ./devices/platform/amba/fd490000.perf-monitor/uio
 ./devices/platform/amba/fd490000.perf-monitor/uio/uio2
 ./devices/platform/amba/ffa00000.perf-monitor/uio
 ./devices/platform/amba/ffa00000.perf-monitor/uio/uio0
 ./devices/platform/amba/ffa10000.perf-monitor/uio
 ./devices/platform/amba/ffa10000.perf-monitor/uio/uio3
 root@zcu111:/sys# find . -name \*pci\* -print
 ./kernel/debug/clk/pcie_ref_mux
 ./kernel/debug/clk/pcie_ref_div1
 ./kernel/debug/clk/pcie_ref
 ./class/pci_bus
 ./bus/platform/drivers/nwl-pcie
 ./bus/pci
 ./firmware/devicetree/base/amba/pcie@fd0e0000
 ./module/edac_core/parameters/edac_pci_panic_on_pe
 ./module/edac_core/parameters/check_pci_errors
 root@zcu111:/sys#
たしかに,uio_pdrv_genirqやuio_dmem_genirqがいない.
Linuxの.configをみると,
 CONFIG_UIO_PDRV_GENIRQ=m
 CONFIG_DMEM_GENIRQ=m
だったので,
 CONFIG_UIO_PDRV_GENIRQ=y
 CONFIG_DMEM_GENIRQ=y
にしてビルド。
 /sys/bus/platform/drivers/uio_pdrv_genirq
 /sys/bus/platform/drivers/uio_dmem_genirq
がはえた.というわけで再実行.
 user@zcu111:~/embeddedsw/XilinxProcessorIPLib/drivers/rfdc/examples$ ./rfdc-read-write
 RFdc Read and Write Example Test
 metal_sys_init
 success: sysfs_get_mnt_path
 success: fopen /dev/urandom
 success: metal_init_page_sizes
 try: metal_linux_bus_init
 metal_linux_bus_init
 metal_linux_probe_bus
 try: sysfs_open_bus: platform
 success: sysfs_open_bus: platform
 try: metal_linux_probe_driver
 metal_linux_probe_driver
 try: sysfs_open_driver platform uio_pdrv_genirq
 result: sysfs_open_driver 0x55bb715e20
 metal_linux_probe_driver
 try: sysfs_open_driver platform uio_dmem_genirq
 result: sysfs_open_driver 0x55bb715fc0
 success: metal_linux_probe_driver
 try: metal_linux_register_bus
 metal_linux_probe_bus
 try: sysfs_open_bus: pci
 success: sysfs_open_bus: pci
 try: metal_linux_probe_driver
 metal_linux_probe_driver
 try: sysfs_open_driver pci vfio-pci
 [sudo] password for user:
 result: sysfs_open_driver (nil)
 metal_linux_probe_driver
 try: sysfs_open_driver pci uio_pci_generic
 result: sysfs_open_driver (nil)
 error: metal_linux_probe_driver
 success: metal_linux_bus_init
 success: open /proc/self/pagemap
 success: metal_linux_irq_init
 metal: info:      Registered shmem provider linux_shm.
 metal: error:     metal_ion_shm_provider_init: failed to open ion dev file.
 success: metal_linux_init_shmem
 metal: warning:   metal_linux_irq_handling: Failed to set scheduler: Unknown error -1.
 metal: error:
 Invalid device id 0Read and Write Example Test failed
 user@zcu111:~/embeddedsw/XilinxProcessorIPLib/drivers/rfdc/examples$
とりあえず,metal_initは通ったよう.
 Invalid device id 0Read and Write Example Test failed
は,DACやADCのエントリがないから仕方ない気がする(次の仕事だと思う).
ちょっとlibmetalを分かってからじゃないと次すすめないな.