libiio Questions

Hello,

I'm at the moment of using libiio for a Zedboard project that uses AD4020.  I'm using 2019_R2 meta-adi now, just to be on the safe side based on my previous questions on 2020.1.  I did my research on some questions here in the forum and in libiio wiki articles.  I have some questions though.

1. How do I update the libiio version in my 2019_R2 meta-adi Zedboard setup?  Right now it's v0.21, but I would like to upgrade it to v0.23 (which is the latest).  The reason is that v0.21 does not include serial as one of its supported backends (based on iio_info) while v0.23 supports it.  Is there have to be changes in the meta-adi recipes for this?  I've already checked this link (https://wiki.analog.com/resources/tools-software/linux-software/embedded_arm_images) and I'm not sure if those SD images are applicable to my ad4020 zedboard application.

2. How to set up and start the serial backend in v0.23 libiio?  I also need to connect to the serial UART (uart0 preferably since uart1 is the console).  I'm not sure if I missed anything about serial backend setup in your libiio wiki pages, if I did so please point it out.

Thanks!

Top Replies

  • 0
    •  Analog Employees 
    on Sep 9, 2021 10:34 AM

    Hi,

    1. How do I update the libiio version in my 2019_R2 meta-adi Zedboard setup?  Right now it's v0.21, but I would like to upgrade it to v0.23 (which is the latest).  The reason is that v0.21 does not include serial as one of its supported backends (based on iio_info) while v0.23 supports it.  Is there have to be changes in the meta-adi recipes for this?  I've already checked this link (https://wiki.analog.com/resources/tools-software/linux-software/embedded_arm_images) and I'm not sure if those SD images are applicable to my ad4020 zedboard application.

    v0.21 should support serial backend AFAIK, it's probably not being built... IIRC, in version 0.21 the build system was looking for dependencies and enabling features depending on that. This means that if libserial is not available in your build, the serial backend won't be compiled. Hence, adding "DEPENDS += libserialport" to ibiio_%.bbappend might resolve your issue...

    On the other hand if you really want to move to v0.23 you might wanna look at the master version of the recipe and update PV and SRCREV. For SRCREV, AUTOREV just means you'll get always the latest state of the master branch. If you prefer, you can change it and give the git hast for the v0.23 release tag.

    - Nuno Sá

  • Thanks .  Can't make it work right now so temporarily I'm back on 2020.1 meta-adi and v0.23 libiio (will go back to this later).  My goal is still to get the serial/uart backend working

    Right now I'm trying to make serial/UART connection work on my device's libiio/iiod (network backend was already tested to be working).  I tried the following command in my host PC and got the following response:

    $ sudo iio_info -u serial:/dev/ttyUSB0,115200,8n1
    Library version: 0.23 (git tag: 92d6a35)
    Compiled with backends: local xml ip usb serial
    ERROR: sp_blocking_read_next has timedout
    ERROR: READ LINE: -110
    Unable to create IIO context serial:/dev/ttyUSB0,115200,8n1: Connection timed out (110)

    Not sure why it didn't work.  Did I miss anything on the target side?  My host's usb-to-serial adapter (/dev/ttyUSB0) is connected to Zedboard's uart0 (/dev/ttyPS1) and I've already set the latter's baud rate to 115200, just to be able to test it.  I saw somewhere in the forum or some github pages that a command

    $ iiod -s /dev/ttyS2,115200,8n1

    was used (different libiio git branch?), so I did this in the target side (since it's dealing with the IIOD daemon).  But if I do it:

    $ iio_info
    Library version: 0.23 (git tag: 0.23)
    Compiled with backends: local xml ip usb serial
    ...

    $ iiod -s /dev/ttyPS1,115200,8n1
    iiod: invalid option -- 's'

    Not sure what is the hash of my libiio v0.23 here.  The libiio .bbappend recipe says 56f7db743651e02a838aab7bf224978da8661b22 but build files show files of name libiio-src-0.21+git0+c14a0f8b38-r0.cortexa9t2hf_neon so the hash could be c14a0f8b38xxx (not sure if this info is relevant but showing this for completeness of information).

    Is there a proper way of making serial backend work?  I'm obviously missing a lot here.  Thanks for the answers.

  • 0
    •  Analog Employees 
    on Sep 10, 2021 7:23 AM in reply to ubermensch

    Hello,

    When you call iio_info through the UART terminal, does the local context return valid information? If yes, then the IIO framework should be working and you should be able to call iio_info -u serial:/dev/ttyUSB0,115200,8n1 as you did. It is the correct command.

    Make sure that the terminal is not connected to the target when you try the above command. If it is, it might hog the connection.

    Regards,
    Andrei

  • Hello ,

    Yes, if I call the iio_info command in the target through the UART terminal/console, it does return with IIO devices information.  Here's the reply:

    $ iio_info
    Library version: 0.23 (git tag: 0.23)
    Compiled with backends: local xml ip usb serial
    ...

    But the command iio_info -u serial:/dev/ttyUSB0,115200,8n1 indeed fails when called from the host.

    $ sudo iio_info -u serial:/dev/ttyACM0,115200,8n1
    Library version: 0.23 (git tag: 92d6a35)
    Compiled with backends: local xml ip usb serial
    Unable to create IIO context serial:/dev/ttyACM0,115200,8n1: Invalid argument (22)

    $ sudo iio_info -u serial:/dev/ttyUSB0,115200,8n1
    Library version: 0.23 (git tag: 92d6a35)
    Compiled with backends: local xml ip usb serial
    ERROR: sp_blocking_read_next has timedout
    ERROR: READ LINE: -110
    Unable to create IIO context serial:/dev/ttyUSB0,115200,8n1: Connection timed out (110)

    Zedboard's uart0 or its ttyPS1 is connected to my host PC's /dev/ttyUSB0.

    Zedboard's uart1 or its ttyPS0 and port for the console is connected to my host PC's /dev/ttyACM0.

    I'm not sure I understand when you said "Make sure that the terminal is not connected to the target when you try the above command (iio_info -u serial:/dev/ttyUSB0,115200,8n1)".  Do you mean I must not access the terminal or the console while using this iio_info command?  I've already turned off putty or minicom sessions for the target board.  I don't know how the serial backend works - does the serial backend by default uses the /dev/ttyPS0 or terminal port or it can be any of the two UART ports?

  • 0
    •  Analog Employees 
    on Sep 10, 2021 8:19 AM in reply to ubermensch

    Yes, that's what I meant: disconnect any Putty and similar programs from the terminal before trying the command. And try the command on the same port the Putty terminal was working.

    Try only sudo iio_info -u serial:/dev/ttyACM0 (if that is the correct port).

    Regards,
    Andrei