Skip to main content
Ozone
Principal
November 20, 2024
Solved

STM32MP157F-DK2, iio_info error

  • November 20, 2024
  • 2 replies
  • 1885 views

Running the iio_info command on a terminal into a STM32MP157F-DK2 (booting from the shipped SD-card) reports some errors:
root@stm32mp1:~# iio_info
Library version: 0.23 (git tag: 92d6a35)
Compiled with backends: local xml ip usb serial
IIO context created with local backend.
Backend version: 0.23 (git tag: 92d6a35)
Backend description string: Linux stm32mp1 5.15.45 #1 SMP PREEMPT Mon Jun 6 06:43:42 UTC 2022 armv7l
IIO context has 2 attributes:
local,kernel: 5.15.45
uri: local:
IIO context has 2 devices:
iio:device0: 48003000.adc:adc@0 (buffer capable)
2 channels found:
...
ERROR: checking for trigger : Input/output error (5)
iio:device1: 48003000.adc:adc@100 (buffer capable)
4 channels found:
...
ERROR: checking for trigger : Input/output error (5)

(Several dozen lines dropped here. And trying to format the output as 'code' throws HTML errors). 

What do these trigger - related errors tell me?

If this is supposed to mean the EIO error (clib errno), i.e. a file read/write error, isn't iio_info supposed to know what are readable/writable files, and what not ?
I suppose it's related to /sys/bus/iio/devices/iio:device<n>/trigger.

I have some difficulties wrapping my head around ST's libiio implementation.

Best answer by PatrickF

Hi,
The examples README.md file mention which DTB is needed to run it.

To avoid selecting at each boot using the serial console, you could also change the default DTD to one of the other LABEL alternatives value by editing the "DEFAULT" value in /boot/mmc0_extlinux/stm32mp157f-dk2_extlinux.conf file.

# Generic Distro Configuration file generated by OpenEmbedded
menu title Select the boot mode
MENU BACKGROUND /splash_portrait.bmp
TIMEOUT 20
DEFAULT OpenSTLinux ==> e.g. change by stm32mp157f-dk2-a7-examples
LABEL OpenSTLinux
 KERNEL /uImage
 FDTDIR /
 INITRD /st-image-resize-initrd
 APPEND root=PARTUUID=e91c4e10-16e6-4c0e-bd0e-77becf4a3582 rootwait rw console=${console},${baudrate}
LABEL stm32mp157f-dk2-a7-examples
 KERNEL /uImage
 FDT /stm32mp157f-dk2-a7-examples.dtb
 INITRD /st-image-resize-initrd
 APPEND root=PARTUUID=e91c4e10-16e6-4c0e-bd0e-77becf4a3582 rootwait rw console=${console},${baudrate}
LABEL stm32mp157f-dk2-m4-examples
 KERNEL /uImage
 FDT /stm32mp157f-dk2-m4-examples.dtb
 INITRD /st-image-resize-initrd
 APPEND root=PARTUUID=e91c4e10-16e6-4c0e-bd0e-77becf4a3582 rootwait rw console=${console},${baudrate}

 

Regards.

2 replies

Ozone
OzoneAuthor
Principal
November 21, 2024

And as a consequence, the examples given in the ST Wiki don't work.

root@stm32mp1:~# iio_readdev -t trigger1 -s 8 -b 8 iio:device0 voltage18
voltage19 | hexdump
Trigger trigger1 not found

root@stm32mp1:~# iio_readdev -t trigger0 -s 8 -b 8 iio:device0 voltage18
voltage19 | hexdump
Trigger trigger0 not found

Or, trying without trigger:

root@stm32mp1:~# iio_readdev -s 8 -b 8 iio:device0 voltage18 voltage19 | hexdump
WARNING: High-speed mode not enabled
Unable to allocate buffer: Invalid argument (22)


May I assume the ADC channels are running in continuous mode, at least when enabled ?

Ozone
OzoneAuthor
Principal
November 25, 2024

I am suprised nobody at ST seems to know. If I'm not mistaken, the iio ADC driver implementation is done by ST employees.
Anyway ...

I wanted to explore a trigger-based approach, which it seems is not implemented.
Reason was, the sysfs-based approach had some issues.
An example I found used the following sequence to cyclically read ADC values :
  fseek (channelfile, 0 , SEEK_SET);
  fgets (string, strsize, channelfile);

In other words, rewinding the "file" to initial position first, and then read a string.
In practice, this always yielded the same result, which didn't seem right.
By trial and error, I came to the following solution:
  fseek (channelfile, 0 , SEEK_SET);
  fgets (string, strsize, channelfile);
  fflush (channelfile);

Although I don't know which implementational detail caused this behavior.
For reference, the example I drew this from is from the Luckfox Pico Mini wikipedia page, found under "peripheral examples".

PatrickF
Technical Moderator
November 25, 2024

Hi @Ozone 

could you try to select choice 2 during boot (not easy to catch I agree)

Select the boot mode
1: OpenSTLinux
2: stm32mp157f-dk2-a7-examples
3: stm32mp157f-dk2-m4-examples
Enter choice: 2
2: stm32mp157f-dk2-a7-examples

 then iio_info seems not giving errors.

Regards.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.NEW ! Sidekick STM32 AI agent, see here
Ozone
OzoneAuthor
Principal
November 26, 2024

I'm going to try that.
To be honest, I used to let the board boot up (from SD) undisturbed until now, and never tried any other boot options.

BTW, I think I had seen respective "examples" folders in /usr/local .

At the moment I'm experimenting with my own user space applications, which work fine so far.

PatrickF
PatrickFBest answer
Technical Moderator
November 26, 2024

Hi,
The examples README.md file mention which DTB is needed to run it.

To avoid selecting at each boot using the serial console, you could also change the default DTD to one of the other LABEL alternatives value by editing the "DEFAULT" value in /boot/mmc0_extlinux/stm32mp157f-dk2_extlinux.conf file.

# Generic Distro Configuration file generated by OpenEmbedded
menu title Select the boot mode
MENU BACKGROUND /splash_portrait.bmp
TIMEOUT 20
DEFAULT OpenSTLinux ==> e.g. change by stm32mp157f-dk2-a7-examples
LABEL OpenSTLinux
 KERNEL /uImage
 FDTDIR /
 INITRD /st-image-resize-initrd
 APPEND root=PARTUUID=e91c4e10-16e6-4c0e-bd0e-77becf4a3582 rootwait rw console=${console},${baudrate}
LABEL stm32mp157f-dk2-a7-examples
 KERNEL /uImage
 FDT /stm32mp157f-dk2-a7-examples.dtb
 INITRD /st-image-resize-initrd
 APPEND root=PARTUUID=e91c4e10-16e6-4c0e-bd0e-77becf4a3582 rootwait rw console=${console},${baudrate}
LABEL stm32mp157f-dk2-m4-examples
 KERNEL /uImage
 FDT /stm32mp157f-dk2-m4-examples.dtb
 INITRD /st-image-resize-initrd
 APPEND root=PARTUUID=e91c4e10-16e6-4c0e-bd0e-77becf4a3582 rootwait rw console=${console},${baudrate}

 

Regards.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.NEW ! Sidekick STM32 AI agent, see here