Post Go back to editing

AD9361's userspace driver on linux

Category: Software
Product Number: AD9361
Software Version: 2021_R1

Hi,

I am running the no-OS AD9361 driver on Linux.

It looks like ad9361_init is initialising the axi_adc_init but I would have to initialise the axi_dac_init manually, fair enough, I'm doing something like this:



module_initialize_ad9361() {
    int32_t ret = ad9361_init(&ad9361_phy, init_param);
    axi_dac_init(&ad9361_phy->tx_dac, &tx_dac_init);
    axi_dac_set_datasel(ad9361_phy->tx_dac, -1, AXI_DAC_DATA_SEL_DMA);
}


Given that I want to switch between TDD and FDD, I also created a function to remove the allocated memory, hence I'm able to call module_initialize_ad9361 again, passing a modified version of init_param struct:

module_remove_ad9361() {
     axi_dac_remove(&ad9361_phy->tx_dac);
     int32_t ret = ad9361_remove(ad9361_phy);
}


However, this doesn't work on 1RX1TX mode(but it works on 2RX2TX), I have to initialize the axi_dac only once and not remove it anymore:

module_initialize_ad9361() {
     static bool once{false};

     int32_t ret = ad9361_init(&ad9361_phy, init_param);
     if(!once) {
         axi_dac_init(&ad9361_phy->tx_dac, &tx_dac_init);
         axi_dac_set_datasel(ad9361_phy->tx_dac, -1, AXI_DAC_DATA_SEL_DMA);

         once=true;

     }

}

module_remove_ad9361() {
    int32_t ret = ad9361_remove(ad9361_phy);
}


is this the expected way to modify the AD9361_InitParam struct?


On the other hand, as I already mentioned, the ad9361_init will initialise the axi_adc_init:
ad9361_init --> axi_adc_init --> axi_adc_init_begin --> malloc(axi_adc)

However, I am not able to find where the axi_adc struct is freed, could you tell me where that allocated memory is released?

Thanks



Indentation
[edited by: JFelipe at 5:18 PM (GMT -5) on 15 Dec 2022]
Parents Reply Children
  • Hi  ,

    I apologize for the delayed response. In the meantime, the problem has been fixed on the main branch. Below is the output from the project that runs the code you signaled had problems (axi_dac_init->axi_dac_remove->axi_dac_init):

    PMU-FW is not running, certain applications may not be supported.
    cf-ad9361-lpc: Successfully initialized (122891235 Hz)
    ad9361_init : AD936x Rev 2 successfully initialized
    	 Init
    cf-ad9361-dds-core-lpc: Successfully initialized (122891235 Hz)
    	 Remove
    	 Reinit
    cf-ad9361-dds-core-lpc: Successfully initialized (122891235 Hz)
    DMA_EXAMPLE: address=0x4d100 samples=65536 channels=4 bits=16
    Done.

    You can remove the ADC component by executing

    axi_adc_remove(ad9361_phy->rx_adc);

    Regards,

    George