Post Go back to editing

HI How to port AD9364 driver to xilinx petalinux

Category: Software
Product Number: AD9364
Software Version: Petalinux2021

Hi Team,

Could you help me port driver. I have modules AD-FMCOMMS-4 EBZ board and Xilinx Zinq Ultrascale HW-Z1-ZCU102.

I have planing to port below drivers from ADI  git repo to my petalinux repo in build/tmp/work-shared/zynqmp-generic/kernel-source/drivers/iio/adc

ad9361.c
ad9361.h
ad9361_conv.c
ad9361_ext_band_ctrl.c
cf_axi_adc.h
cf_axi_adc_core.c

--- a/drivers/iio/adc/Makefile
+++ b/drivers/iio/adc/Makefile
@@ -66,6 +66,14 @@ obj-$(CONFIG_MAX9611) += max9611.o
obj-$(CONFIG_MCP320X) += mcp320x.o
obj-$(CONFIG_MCP3422) += mcp3422.o
obj-$(CONFIG_MCP3911) += mcp3911.o
+
+cf_axi_adc-y := cf_axi_adc_core.o
+obj-$(CONFIG_CF_AXI_ADC) += cf_axi_adc.o
+
+ad9361_drv-y := ad9361.o ad9361_conv.o
+ad9361_drv-$(CONFIG_AD9361_EXT_BAND_CONTROL) += ad9361_ext_band_ctrl.o
+obj-$(CONFIG_AD9361) += ad9361_drv.o

Please help me is that correct procedure.

Thanks,

Mahi87

  • You would need much more than that.

    The easiest would be to use the ADI kernel (which is based off the Xilinx kernel tree) directly with petalinux.

    You can follow the instructions here:

    https://github.com/analogdevicesinc/meta-adi/tree/master/meta-adi-xilinx

    -Michael

  • Hi Michael,

    Thanks for the very quick update. Let me try you solution. But We have to go with our exsting kernel and only we need to add the AD9364 driver alone. Is not possible with my aproach I have mentioned before. 

    If it possible could you correct me what do I need to add extra bit.

    Thanks,

    Mahi

  • Here is a rebased patch set for AD936x on a vanilla xilinx-4.9  

    https://github.com/analogdevicesinc/linux/commits/ad9361-xilinx-4.9

    Some pieces in the IIO core might no longer been needed, depending on which kernel you're targeting.

    -Michael

  • Hi Michael,

    I have planed for 5.10 Kernel and petalinux version 2021.2. Let me try

    Thanks,

    Mahi

  • Hi Michal,

    I have followed above link you provided.I have one clarification. Below process for device tree addition to petalinux is correct?. I am using ZCU102 rev 1.0 reference board and AD-FMCOMMS-4 EBZ board

    echo "KERNEL_DTB=\"pl-zynqmp-zcu102-rev10-ad9361-fmcomms2-3-overlay\"" >> project-spec/meta-user/conf/petalinuxbsp.conf

    I have follwed below procedure. kindly have look and let me anything is wrong.


    #This I have used 5.10 Kernel and petalinux version 2021.2 source <path-to-installed-PetaLinux>/settings.sh

    petalinux-create -t project --template <PLATFORM> --name <PROJECT_NAME>, where <PLATFORM> is: * zynqMP (for UltraScale + MPSoC) git clone github.com/.../meta-adi.git
    cd <path-to-project>
    # Check the Building HDL link below petalinux-config --get-hw-description=<path to hdf file>
    # Presently I am using the default .xsa file going forward I will used our custom created one.
    #added below step
    ##Go to Yocto Settings->User layers and add the meta-adi-xilinx and meta-adi-core layers.

    # Select the devicetree that fits the project being built
    echo "KERNEL_DTB=\"${dts_to_use}\"" >> project-spec/meta-user/conf/petalinuxbsp.conf
    cd build petalinux-build


    Thanks for your support. Much appreciated
    Thanks,
    Mahi
  • Hi Mahi,

    echo "KERNEL_DTB=\"pl-zynqmp-zcu102-rev10-ad9361-fmcomms2-3-overlay\"" >> project-spec/meta-user/conf/petalinuxbsp.conf

    This looks suspicious... Do you want to use overlays? Have you selected that with 'petalinux-config'? 

    i would also say that the devicetree you need to use is "zynqmp-zcu102-rev10-ad9364-fmcomms4.dts" which is not supported in meta-adi. That said, you need to follow this section of the README file.

    On a last note, I see you're using petalinux 2021.2. Note that version is not supported and was never tested. You need to use 2021.1 with meta-adi otherwise we cannot give you full support on this.

    - Nuno Sá

  • Hi ,

    Just changing the question bit now I have zc102 and ad9361 board. I have followed the below procedure from the below link. 

    https://github.com/analogdevicesinc/meta-adi/tree/master/meta-adi-xilinx

    source  <path-to-installed-PetaLinux>/settings.sh
    petalinux-create -t project --template <PLATFORM> --name <PROJECT_NAME>, where <PLATFORM> is:
    	* zynqMP (for UltraScale + MPSoC)
    	* zynq (for Zynq)
    	* microblaze (for MicroBlaze)
    git clone https://github.com/analogdevicesinc/meta-adi.git
    cd <path-to-project>
    # Check the Building HDL link below petalinux-config --get-hw-description=<path to hdf file>
    # Select the devicetree that fits the project being built

    echo "KERNEL_DTB=\"${zynqmp-zcu102-rev10-ad9361-fmcomms2-3}\"" >> project-spec/meta-user/conf/petalinuxbsp.conf

    cd build
    petalinux-build

    I could see the below error

    ERROR: device-tree-xilinx-v2021.1+gitAUTOINC+252758eb1f-r0 do_compile: Error executing a python function in exec_python_func() autogenerated:

    The stack trace of python calls that resulted in this exception/failure was:
    File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
    0001:
    *** 0002:devicetree_do_compile(d)
    0003:
    File: '/home/mahesh/raj/labsat_plus/components/yocto/layers/core/meta/classes/devicetree.bbclass', lineno: 131, function: devicetree_do_compile
    0127: if not(os.path.isfile(dtspath)) or not(dts.endswith(".dts") or devicetree_source_is_overlay(dtspath)):
    0128: continue # skip non-.dts files and non-overlay files
    0129: except:
    0130: continue # skip if can't determine if overlay
    *** 0131: devicetree_compile(dtspath, includes, d)
    0132:}
    0133:
    0134:devicetree_do_install() {
    0135: for DTB_FILE in `ls *.dtb *.dtbo`; do
    File: '/home/mahesh/raj/labsat_plus/components/yocto/layers/core/meta/classes/devicetree.bbclass', lineno: 119, function: devicetree_compile
    0115: dtcargs += ["-i", i]
    0116: dtcargs += ["-o", "{0}.{1}".format(dtname, "dtbo" if isoverlay else "dtb")]
    0117: dtcargs += ["-I", "dts", "-O", "dtb", "{0}.pp".format(dts)]
    0118: bb.note("Running {0}".format(" ".join(dtcargs)))
    *** 0119: subprocess.run(dtcargs, check = True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    0120:
    0121:python devicetree_do_compile() {
    0122: includes = expand_includes("DT_INCLUDE", d)
    0123: listpath = d.getVar("DT_FILES_PATH")
    File: '/home/mahesh/raj/components/yocto/buildtools/sysroots/x86_64-petalinux-linux/usr/lib/python3.8/subprocess.py', lineno: 512, function: run
    0508: # We don't call process.wait() as .__exit__ does that for us.
    0509: raise
    0510: retcode = process.poll()
    0511: if check and retcode:
    *** 0512: raise CalledProcessError(retcode, process.args,
    0513: output=stdout, stderr=stderr)
    0514: return CompletedProcess(process.args, retcode, stdout, stderr)
    0515:
    0516:
    Exception: subprocess.CalledProcessError: Command '['dtc', '-@', '-p', '0x1000', '-@', '-i', '/home/mahesh/raj/labsat_plus/build/tmp/work-shared/zynqmp-generic/kernel-source/scripts/dtc/include-prefixes', '-i', '/home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0', '-i', '/home/mahesh/raj/labsat_plus/project-spec/configs/../../components/plnx_workspace/device-tree/device-tree', '-o', 'system-top.dtb', '-I', 'dts', '-O', 'dtb', 'system-top.dts.pp']' returned non-zero exit status 1.

    Subprocess output:
    Error: /home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0/pl-delete-nodes-zynqmp-zcu102-rev10-ad9361-fmcomms2-3.dtsi:2.1-14 syntax error
    FATAL ERROR: Unable to parse input tree

    ERROR: Logfile of failure stored in: /home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0/temp/log.do_compile.37273
    ERROR: Task (/home/mahesh/raj/labsat_plus/components/yocto/layers/meta-xilinx/meta-xilinx-bsp/recipes-bsp/device-tree/device-tree.bb:do_compile) failed with exit code '1'
    NOTE: Tasks Summary: Attempted 5341 tasks of which 4438 didn't need to be rerun and 1 failed.

    Summary: 1 task failed:
    /home/mahesh/raj/labsat_plus/components/yocto/layers/meta-xilinx/meta-xilinx-bsp/recipes-bsp/device-tree/device-tree.bb:do_compile
    Summary: There was 1 ERROR message shown, returning a non-zero exit code.
    ERROR: Failed to build project. Check the /home/mahesh/raj/labsat_plus/build/build.log file for more details...
    mahesh@Yocto:~/raj/labsat_plus$ cd build/
    mahesh@Yocto:~/raj/labsat_plus/build$ petalinux-build
    [INFO] Sourcing buildtools
    [INFO] Building project
    [INFO] Sourcing build environment
    [INFO] Generating workspace directory
    INFO: bitbake petalinux-image-minimal
    NOTE: Started PRServer with DBfile: /home/mahesh/raj/labsat_plus/build/cache/prserv.sqlite3, IP: 127.0.0.1, PORT: 32809, PID: 36307
    Loading cache: 100% |#######################################################################################################################################| Time: 0:00:01
    Loaded 5096 entries from dependency cache.
    Parsing recipes: 100% |#####################################################################################################################################| Time: 0:00:01
    Parsing of 3475 .bb files complete (3461 cached, 14 parsed). 5110 targets, 221 skipped, 0 masked, 0 errors.
    NOTE: Resolving any missing task queue dependencies
    Initialising tasks: 100% |##################################################################################################################################| Time: 0:00:05
    Checking sstate mirror object availability: 100% |##########################################################################################################| Time: 0:00:03
    Sstate summary: Wanted 226 Found 22 Missed 204 Current 1646 (9% match, 89% complete)
    NOTE: Executing Tasks
    ERROR: device-tree-xilinx-v2021.1+gitAUTOINC+252758eb1f-r0 do_compile: Error executing a python function in exec_python_func() autogenerated:

    The stack trace of python calls that resulted in this exception/failure was:
    File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
    0001:
    *** 0002:devicetree_do_compile(d)
    0003:
    File: '/home/mahesh/raj/labsat_plus/components/yocto/layers/core/meta/classes/devicetree.bbclass', lineno: 131, function: devicetree_do_compile
    0127: if not(os.path.isfile(dtspath)) or not(dts.endswith(".dts") or devicetree_source_is_overlay(dtspath)):
    0128: continue # skip non-.dts files and non-overlay files
    0129: except:
    0130: continue # skip if can't determine if overlay
    *** 0131: devicetree_compile(dtspath, includes, d)
    0132:}
    0133:
    0134:devicetree_do_install() {
    0135: for DTB_FILE in `ls *.dtb *.dtbo`; do
    File: '/home/mahesh/raj/labsat_plus/components/yocto/layers/core/meta/classes/devicetree.bbclass', lineno: 119, function: devicetree_compile
    0115: dtcargs += ["-i", i]
    0116: dtcargs += ["-o", "{0}.{1}".format(dtname, "dtbo" if isoverlay else "dtb")]
    0117: dtcargs += ["-I", "dts", "-O", "dtb", "{0}.pp".format(dts)]
    0118: bb.note("Running {0}".format(" ".join(dtcargs)))
    *** 0119: subprocess.run(dtcargs, check = True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    0120:
    0121:python devicetree_do_compile() {
    0122: includes = expand_includes("DT_INCLUDE", d)
    0123: listpath = d.getVar("DT_FILES_PATH")
    File: '/home/mahesh/raj/components/yocto/buildtools/sysroots/x86_64-petalinux-linux/usr/lib/python3.8/subprocess.py', lineno: 512, function: run
    0508: # We don't call process.wait() as .__exit__ does that for us.
    0509: raise
    0510: retcode = process.poll()
    0511: if check and retcode:
    *** 0512: raise CalledProcessError(retcode, process.args,
    0513: output=stdout, stderr=stderr)
    0514: return CompletedProcess(process.args, retcode, stdout, stderr)
    0515:
    0516:
    Exception: subprocess.CalledProcessError: Command '['dtc', '-@', '-p', '0x1000', '-@', '-i', '/home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0', '-i', '/home/mahesh/raj/labsat_plus/project-spec/configs/../../components/plnx_workspace/device-tree/device-tree', '-i', '/home/mahesh/raj/labsat_plus/build/tmp/work-shared/zynqmp-generic/kernel-source/scripts/dtc/include-prefixes', '-o', 'system-top.dtb', '-I', 'dts', '-O', 'dtb', 'system-top.dts.pp']' returned non-zero exit status 1.

    Subprocess output:
    Error: /home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0/pl-delete-nodes-zynqmp-zcu102-rev10-ad9361-fmcomms2-3.dtsi:2.1-14 syntax error
    FATAL ERROR: Unable to parse input tree

    ERROR: Logfile of failure stored in: /home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0/temp/log.do_compile.36872
    ERROR: Task (/home/mahesh/raj/labsat_plus/components/yocto/layers/meta-xilinx/meta-xilinx-bsp/recipes-bsp/device-tree/device-tree.bb:do_compile) failed with exit code '1'
    NOTE: Tasks Summary: Attempted 3507 tasks of which 3340 didn't need to be rerun and 1 failed.

    Summary: 1 task failed:
    /home/mahesh/raj/labsat_plus/components/yocto/layers/meta-xilinx/meta-xilinx-bsp/recipes-bsp/device-tree/device-tree.bb:do_compile
    Summary: There was 1 ERROR message shown, returning a non-zero exit code.
    ERROR: Failed to build project. Check the /home/mahesh/raj/labsat_plus/build/build.log file for more details...
    mahesh@Yocto:~/raj/labsat_plus/build$ vim Error: /home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0/pl-delete-nodes-zynqmp-zcu102-rev10-ad9361-fmcomms2-3.dtsi:2.1-14 syntax error
    4 files to edit
    mahesh@Yocto:~/raj/labsat_plus/build$ vim Error: /home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0/pl-delete-nodes-zynqmp-zcu102-rev10-ad9361-fmcomms2-3.dtsi:2.1-14
    bitbake-cookerdaemon.log build.log.old conf/ config.log.old misc/ tmp/
    build.log cache/ config.log downloads/ sstate-cache/
    mahesh@Yocto:~/raj/labsat_plus/build$ vim Error: /home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0/pl-delete-nodes-zynqmp-zcu102-rev10-ad9361-fmcomms2-3.dtsi:2.1-14 ^C
    mahesh@Yocto:~/raj/labsat_plus/build$ vim /home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0/temp/log.do_compile.36872
    mahesh@Yocto:~/raj/labsat_plus/build$ gedit /home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0/temp/log.do_compile.36872
    Unable to init server: Could not connect: Connection refused

    (gedit:7116): Gtk-WARNING **: 00:21:33.442: cannot open display:
    mahesh@Yocto:~/raj/labsat_plus/build$ gvim /home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0/temp/log.do_compile.36872

    mahesh@Yocto:~/raj/labsat_plus/build$ cat /home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0/temp/log.do_compile.36872
    DEBUG: Executing python function do_compile
    DEBUG: Executing python function devicetree_do_compile
    NOTE: Processing system-top [system-top.dts]
    NOTE: Running gcc -E -nostdinc -undef -D__DTS__ -x assembler-with-cpp -I/home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0 -I/home/mahesh/raj/labsat_plus/project-spec/configs/../../components/plnx_workspace/device-tree/device-tree -I/home/mahesh/raj/labsat_plus/build/tmp/work-shared/zynqmp-generic/kernel-source/scripts/dtc/include-prefixes -o system-top.dts.pp /home/mahesh/raj/labsat_plus/project-spec/configs/../../components/plnx_workspace/device-tree/device-tree/system-top.dts
    NOTE: Running dtc -@ -p 0x1000 -@ -i /home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0 -i /home/mahesh/raj/labsat_plus/project-spec/configs/../../components/plnx_workspace/device-tree/device-tree -i /home/mahesh/raj/labsat_plus/build/tmp/work-shared/zynqmp-generic/kernel-source/scripts/dtc/include-prefixes -o system-top.dtb -I dts -O dtb system-top.dts.pp
    ERROR: Error executing a python function in exec_python_func() autogenerated:

    The stack trace of python calls that resulted in this exception/failure was:
    File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
    0001:
    *** 0002:devicetree_do_compile(d)
    0003:
    File: '/home/mahesh/raj/labsat_plus/components/yocto/layers/core/meta/classes/devicetree.bbclass', lineno: 131, function: devicetree_do_compile
    0127: if not(os.path.isfile(dtspath)) or not(dts.endswith(".dts") or devicetree_source_is_overlay(dtspath)):
    0128: continue # skip non-.dts files and non-overlay files
    0129: except:
    0130: continue # skip if can't determine if overlay
    *** 0131: devicetree_compile(dtspath, includes, d)
    0132:}
    0133:
    0134:devicetree_do_install() {
    0135: for DTB_FILE in `ls *.dtb *.dtbo`; do
    File: '/home/mahesh/raj/labsat_plus/components/yocto/layers/core/meta/classes/devicetree.bbclass', lineno: 119, function: devicetree_compile
    0115: dtcargs += ["-i", i]
    0116: dtcargs += ["-o", "{0}.{1}".format(dtname, "dtbo" if isoverlay else "dtb")]
    0117: dtcargs += ["-I", "dts", "-O", "dtb", "{0}.pp".format(dts)]
    0118: bb.note("Running {0}".format(" ".join(dtcargs)))
    *** 0119: subprocess.run(dtcargs, check = True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    0120:
    0121:python devicetree_do_compile() {
    0122: includes = expand_includes("DT_INCLUDE", d)
    0123: listpath = d.getVar("DT_FILES_PATH")
    File: '/home/mahesh/raj/components/yocto/buildtools/sysroots/x86_64-petalinux-linux/usr/lib/python3.8/subprocess.py', lineno: 512, function: run
    0508: # We don't call process.wait() as .__exit__ does that for us.
    0509: raise
    0510: retcode = process.poll()
    0511: if check and retcode:
    *** 0512: raise CalledProcessError(retcode, process.args,
    0513: output=stdout, stderr=stderr)
    0514: return CompletedProcess(process.args, retcode, stdout, stderr)
    0515:
    0516:
    Exception: subprocess.CalledProcessError: Command '['dtc', '-@', '-p', '0x1000', '-@', '-i', '/home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0', '-i', '/home/mahesh/raj/labsat_plus/project-spec/configs/../../components/plnx_workspace/device-tree/device-tree', '-i', '/home/mahesh/raj/labsat_plus/build/tmp/work-shared/zynqmp-generic/kernel-source/scripts/dtc/include-prefixes', '-o', 'system-top.dtb', '-I', 'dts', '-O', 'dtb', 'system-top.dts.pp']' returned non-zero exit status 1.

    Subprocess output:
    Error: /home/mahesh/raj/labsat_plus/build/tmp/work/zynqmp_generic-xilinx-linux/device-tree/xilinx-v2021.1+gitAUTOINC+252758eb1f-r0/pl-delete-nodes-zynqmp-zcu102-rev10-ad9361-fmcomms2-3.dtsi:2.1-14 syntax error
    FATAL ERROR: Unable to parse input tree

    DEBUG: Python function devicetree_do_compile finished
    DEBUG: Python function do_compile finished
  • Hi,

    echo "KERNEL_DTB=\"${zynqmp-zcu102-rev10-ad9361-fmcomms2-3}\"" >> project-spec/meta-user/conf/petalinuxbsp.conf

    You could just do echo "KERNEL_DTB=\"zynqmp-zcu102-rev10-ad9361-fmcomms2-3\"" >> project-spec/meta-user/conf/petalinuxbsp.conf...

    Are you still using petalinux 2021.2? Also make sure that you are using bash as your shell...

    - Nuno Sá

  • How to use the libiio driver with a custom hardware with Zynq ultrascale+ 5ev coupled with AD9364 to the SPI?

Before You Switch


Switching languages will make ADI Explorer unavailable. Resume your session by switching back to English and reopening ADI Explorer.