Post Go back to editing

"Resetting" AD9361 from software?

I'm leveraging Analog Device's reference design for the AD9361 for a design of my own on the ZC702/Zedboard.  I've removed a lot of the components I don't need (HDMI, spdif, XADC, some GPIOs) from the HDL and devicetree.  I'm of course still using the interface (control and DMA) to the AD9361 in my design, but I'm only using the RX capability.

I'd like to be able to reload FPGA bitstreams on the fly from the ARM.  Xilinx has made this straightforward in terms of how to do it on the ARM, but when I switch bitstreams the interface to the AD9361 (specifically the ability to get IQ samples) unsurprisingly no longer works.

I realize bitstream partial reconfiguration is the proper way to do this, but creating partial reconfiguration bitstreams is a huge pain.  This is probably a a loaded question, but would there be someway to '"reset" the AD9361 (or is it just the HDL logic?) via the ARM after I reload a bitstream and could then resume getting IQ samples from the RFIC?

  • Looking into this more, what I suspect I have to do is to reload the module, which is currently statically in the kernel. I haven't studied the source, so what's the chances if I make this a loadable module, loading/unloading dynamically would work?

    As for the ad9361_phy driver, I can still change parameter values after loading a new image, so I'm thinking that that driver is still working fine.

  • I made loadable kernel modules for ad9361.ko and cf_axi_adc.ko.  I can load them fine, and cf_axi_adc.ko unloads fine (ad9361.ko unloads with errors).  I unload cf_axi_adc before a flash, perform the flash, then reload it.  At this point, I can write/read the cf_axi_adc parameters like channel enables, so it looks like the AXI-Lite is up and running.  However, once I try to get IQ from the DMA, the IIO device becomes locked.

    My next step is trying to make the PL330/Xilinx DMA/etc drivers loadable and see what happens

  • Hi,

    You don't necessarily need to build the drivers as a module. You can bind/unbind a driver by writing sysfs attributes. Before loading the new bitstream you should unbind all drivers for devices that are found in the FPGA fabric and after loading the bistream bind them again.

    For example to unbind/bind the DMA driver do the following:

    echo 7c40000.dma > /sys/bus/platform/drivers/dma-axi-dmac/unbind

    echo 7c42000.dma > /sys/bus/platform/drivers/dma-axi-dmac/unbind

    # reload bitstream

    echo 7c40000.dma > /sys/bus/platform/drivers/dma-axi-dmac/bind

    echo 7c42000.dma > /sys/bus/platform/drivers/dma-axi-dmac/bind

    - Lars

  • Thanks Lars, I'll give that a try.

    What I did find that worked for me was loading in the following order (1. virt-dma.ko, 2. dma-axi-dmac.ko, 3. cf-axi-adc.ko, ad9361.ko) and unloading in the reverse order, excluding ad9361.ko.

    Your way is cleaner though so I'll give that a try.

  • Would you mind sharing how you were able to build loadable kernel modules for all of these drivers?  If I just set them to 'm' in my kernel config I get a bunch of undefined errors.

  • Nick:

    Just to be clear (for others who may find this via search) -- there is no way of "resetting" the AD9361 via software (SPI writes). It must be done via the GPIO which is connected to the RESETB input of the AD9361 (pin K5).


  • Yes you'll get errors if you try to compile as modules. I unfortunately don't have my code modifications any more, but I remember it being all standard kernel driver stuff.

    It would be nice if ADI's source would build as modules.

  • Should be fixed now with this commit:

    drivers/iio: Fix MODULE building · analogdevicesinc/linux@9a6fef6 · GitHub

    Thanks for pointing out.

    P.S. We always accept also patches


    michael@mhenneri-D04:~/devel/hdl/github-linux-build/linux$ make modules | grep iio

      CC [M]  drivers/iio/adc/ad7266.o

      CC [M]  drivers/iio/adc/ad7291.o

      CC [M]  drivers/iio/adc/ad7298.o

      CC [M]  drivers/iio/adc/ad7476.o

      CC [M]  drivers/iio/adc/ad7791.o

      CC [M]  drivers/iio/adc/ad7793.o

      CC [M]  drivers/iio/adc/ad7887.o

      CC [M]  drivers/iio/adc/ad799x.o

      CC [M]  drivers/iio/adc/cf_axi_adc_core.o

      CC [M]  drivers/iio/adc/cf_axi_adc_ring.o

      CC [M]  drivers/iio/adc/cf_axi_adc_ring_stream.o

      LD [M]  drivers/iio/adc/cf_axi_adc.o

      CC [M]  drivers/iio/adc/ad9467.o

      CC [M]  drivers/iio/adc/ad9361.o

      CC [M]  drivers/iio/adc/admc_adc.o

      CC [M]  drivers/iio/adc/admc_speed.o

      CC [M]  drivers/iio/adc/admc_ctrl.o

      CC [M]  drivers/iio/adc/ad_adc.o

      CC [M]  drivers/iio/adc/ad6676.o

      CC [M]  drivers/iio/adc/cf_axi_fft_core.o

      CC [M]  drivers/iio/adc/cf_axi_jesd204b.o

      CC [M]  drivers/iio/adc/cf_axi_jesd204b_v51.o

      CC [M]  drivers/iio/adc/cf_axi_jesd204b_gt.o

      CC [M]  drivers/iio/adc/xilinx-xadc-core.o

      CC [M]  drivers/iio/adc/xilinx-xadc-events.o

      LD [M]  drivers/iio/adc/xilinx-xadc.o

      CC [M]  drivers/iio/amplifiers/ad8366.o

      CC [M]  drivers/iio/dac/ad5360.o

      CC [M]  drivers/iio/dac/ad5380.o

      CC [M]  drivers/iio/dac/ad5421.o

      CC [M]  drivers/iio/dac/ad5624r_spi.o

      CC [M]  drivers/iio/dac/ad5064.o

      CC [M]  drivers/iio/dac/ad5504.o

      CC [M]  drivers/iio/dac/ad5446.o

      CC [M]  drivers/iio/dac/ad5449.o

      CC [M]  drivers/iio/dac/ad5592r.o

      CC [M]  drivers/iio/dac/ad5592r-base.o

      CC [M]  drivers/iio/dac/ad5593r.o

      CC [M]  drivers/iio/dac/ad5755.o

      CC [M]  drivers/iio/dac/ad5764.o

      CC [M]  drivers/iio/dac/ad5791.o

      CC [M]  drivers/iio/dac/ad5686.o

      CC [M]  drivers/iio/dac/ad7303.o

      CC [M]  drivers/iio/frequency/ad9517.o

      CC [M]  drivers/iio/frequency/ad9523.o

      CC [M]  drivers/iio/frequency/ad9548.o

      CC [M]  drivers/iio/frequency/adf4350.o

      CC [M]  drivers/iio/frequency/adf5355.o

      CC [M]  drivers/iio/frequency/cf_axi_dds.o

      CC [M]  drivers/iio/frequency/cf_axi_dds_buffer_stream.o

      CC [M]  drivers/iio/frequency/ad9122.o

      CC [M]  drivers/iio/frequency/ad9144.o

      CC [M]  drivers/iio/gyro/adis16080.o

      CC [M]  drivers/iio/gyro/adis16130.o

      CC [M]  drivers/iio/gyro/adis16136.o

      CC [M]  drivers/iio/gyro/adis16260.o

      CC [M]  drivers/iio/gyro/adxrs450.o

      CC [M]  drivers/iio/imu/adis16400_core.o

      CC [M]  drivers/iio/imu/adis16400_buffer.o

      LD [M]  drivers/iio/imu/adis16400.o

      CC [M]  drivers/iio/imu/adis16480.o

      CC      drivers/iio/adc/ad6676.mod.o

      LD [M]  drivers/iio/adc/ad6676.ko

      CC      drivers/iio/adc/ad7266.mod.o

      LD [M]  drivers/iio/adc/ad7266.ko

      CC      drivers/iio/adc/ad7291.mod.o

      LD [M]  drivers/iio/adc/ad7291.ko

      CC      drivers/iio/adc/ad7298.mod.o

      LD [M]  drivers/iio/adc/ad7298.ko

      CC      drivers/iio/adc/ad7476.mod.o

      LD [M]  drivers/iio/adc/ad7476.ko

      CC      drivers/iio/adc/ad7791.mod.o

      LD [M]  drivers/iio/adc/ad7791.ko

      CC      drivers/iio/adc/ad7793.mod.o

      LD [M]  drivers/iio/adc/ad7793.ko

      CC      drivers/iio/adc/ad7887.mod.o

      LD [M]  drivers/iio/adc/ad7887.ko

      CC      drivers/iio/adc/ad799x.mod.o

      LD [M]  drivers/iio/adc/ad799x.ko

      CC      drivers/iio/adc/ad9361.mod.o

      LD [M]  drivers/iio/adc/ad9361.ko

      CC      drivers/iio/adc/ad9467.mod.o

      LD [M]  drivers/iio/adc/ad9467.ko

      CC      drivers/iio/adc/ad_adc.mod.o

      LD [M]  drivers/iio/adc/ad_adc.ko

      CC      drivers/iio/adc/admc_adc.mod.o

      LD [M]  drivers/iio/adc/admc_adc.ko

      CC      drivers/iio/adc/admc_ctrl.mod.o

      LD [M]  drivers/iio/adc/admc_ctrl.ko

      CC      drivers/iio/adc/admc_speed.mod.o

      LD [M]  drivers/iio/adc/admc_speed.ko

      CC      drivers/iio/adc/cf_axi_adc.mod.o

      LD [M]  drivers/iio/adc/cf_axi_adc.ko

      CC      drivers/iio/adc/cf_axi_fft_core.mod.o

      LD [M]  drivers/iio/adc/cf_axi_fft_core.ko

      CC      drivers/iio/adc/cf_axi_jesd204b.mod.o

      LD [M]  drivers/iio/adc/cf_axi_jesd204b.ko

      CC      drivers/iio/adc/cf_axi_jesd204b_gt.mod.o

      LD [M]  drivers/iio/adc/cf_axi_jesd204b_gt.ko

      CC      drivers/iio/adc/cf_axi_jesd204b_v51.mod.o

      LD [M]  drivers/iio/adc/cf_axi_jesd204b_v51.ko

      CC      drivers/iio/adc/xilinx-xadc.mod.o

      LD [M]  drivers/iio/adc/xilinx-xadc.ko

      CC      drivers/iio/amplifiers/ad8366.mod.o

      LD [M]  drivers/iio/amplifiers/ad8366.ko

      CC      drivers/iio/dac/ad5064.mod.o

      LD [M]  drivers/iio/dac/ad5064.ko

      CC      drivers/iio/dac/ad5360.mod.o

      LD [M]  drivers/iio/dac/ad5360.ko

      CC      drivers/iio/dac/ad5380.mod.o

      LD [M]  drivers/iio/dac/ad5380.ko

      CC      drivers/iio/dac/ad5421.mod.o

      LD [M]  drivers/iio/dac/ad5421.ko

      CC      drivers/iio/dac/ad5446.mod.o

      LD [M]  drivers/iio/dac/ad5446.ko

      CC      drivers/iio/dac/ad5449.mod.o

      LD [M]  drivers/iio/dac/ad5449.ko

      CC      drivers/iio/dac/ad5504.mod.o

      LD [M]  drivers/iio/dac/ad5504.ko

      CC      drivers/iio/dac/ad5592r-base.mod.o

      LD [M]  drivers/iio/dac/ad5592r-base.ko

      CC      drivers/iio/dac/ad5592r.mod.o

      LD [M]  drivers/iio/dac/ad5592r.ko

      CC      drivers/iio/dac/ad5593r.mod.o

      LD [M]  drivers/iio/dac/ad5593r.ko

      CC      drivers/iio/dac/ad5624r_spi.mod.o

      LD [M]  drivers/iio/dac/ad5624r_spi.ko

      CC      drivers/iio/dac/ad5686.mod.o

      LD [M]  drivers/iio/dac/ad5686.ko

      CC      drivers/iio/dac/ad5755.mod.o

      LD [M]  drivers/iio/dac/ad5755.ko

      CC      drivers/iio/dac/ad5764.mod.o

      LD [M]  drivers/iio/dac/ad5764.ko

      CC      drivers/iio/dac/ad5791.mod.o

      LD [M]  drivers/iio/dac/ad5791.ko

      CC      drivers/iio/dac/ad7303.mod.o

      LD [M]  drivers/iio/dac/ad7303.ko

      CC      drivers/iio/frequency/ad9122.mod.o

      LD [M]  drivers/iio/frequency/ad9122.ko

      CC      drivers/iio/frequency/ad9144.mod.o

      LD [M]  drivers/iio/frequency/ad9144.ko

      CC      drivers/iio/frequency/ad9517.mod.o

      LD [M]  drivers/iio/frequency/ad9517.ko

      CC      drivers/iio/frequency/ad9523.mod.o

      LD [M]  drivers/iio/frequency/ad9523.ko

      CC      drivers/iio/frequency/ad9548.mod.o

      LD [M]  drivers/iio/frequency/ad9548.ko

      CC      drivers/iio/frequency/adf4350.mod.o

      LD [M]  drivers/iio/frequency/adf4350.ko

      CC      drivers/iio/frequency/adf5355.mod.o

      LD [M]  drivers/iio/frequency/adf5355.ko

      CC      drivers/iio/frequency/cf_axi_dds.mod.o

      LD [M]  drivers/iio/frequency/cf_axi_dds.ko

      CC      drivers/iio/frequency/cf_axi_dds_buffer_stream.mod.o

      LD [M]  drivers/iio/frequency/cf_axi_dds_buffer_stream.ko

      CC      drivers/iio/gyro/adis16080.mod.o

      LD [M]  drivers/iio/gyro/adis16080.ko

      CC      drivers/iio/gyro/adis16130.mod.o

      LD [M]  drivers/iio/gyro/adis16130.ko

      CC      drivers/iio/gyro/adis16136.mod.o

      LD [M]  drivers/iio/gyro/adis16136.ko

      CC      drivers/iio/gyro/adis16260.mod.o

      LD [M]  drivers/iio/gyro/adis16260.ko

      CC      drivers/iio/gyro/adxrs450.mod.o

      LD [M]  drivers/iio/gyro/adxrs450.ko

      CC      drivers/iio/imu/adis16400.mod.o

      LD [M]  drivers/iio/imu/adis16400.ko

      CC      drivers/iio/imu/adis16480.mod.o

      LD [M]  drivers/iio/imu/adis16480.ko


  • Just merged branch '2014_R2' into 2014_R2_altera. In theory on our release branches this should always go pretty painless. Regarding this out of tree repo - everything is feasible, the question is only if it makes sense.

    Since our goal is to mainline everything.

    I'll discuss this internally.


  • Thanks for the quick update, Michael.

    I noticed that you only made these updates in the xcomm_zynq branch.  This is exactly why I was asking about which drivers/source code are required for the AD9361 the other day.  My only options as of now are to wait for those changes to make their way into the Altera branch or to start patching things myself.

    I'm curious - do you think it would be feasible to make a repo that enables "out of source" builds for the kernel modules?  It would be great if instead of cloning the entire Linux kernel I could just clone a small repo that contains the source for these modules and a makefile.  Then I could just edit the makefile to point to the kernel sources already on my machine.