2024-11-20 09:01 AM
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.
Solved! Go to Solution.
2024-11-26 12:38 AM
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.
2024-11-21 01:19 AM
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 ?
2024-11-25 04:29 AM
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".
2024-11-25 09:59 AM
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.
2024-11-25 10:17 PM
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.
2024-11-26 12:38 AM
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.
2024-11-26 03:01 AM
That would be easy, and doesn't require a serial console to stop the boot process ...
Which I have not set up yet. I just added a static IP configuration, and login via ethernet / ssh.
I'm going to try ASAP, and report back here.
2024-11-26 09:04 AM
Well, at least better ...
I haven't kept the full command output from the first post, to be honest.
Having switched to "stm32mp157f-dk2-a7-examples", I get this output from iio_info. (This time the full output, just to be complete):
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:
voltage18: (input, index: 0, format: le:U16/16>>0)
5 channel-specific attributes found:
attr 0: offset value: 0
attr 1: oversampling_ratio value: 0
attr 2: oversampling_ratio_available value: 1 2 4 8 16 32 64 128 256 512 1024
attr 3: raw value: 10822
attr 4: scale value: 0.038146972
voltage19: (input, index: 1, format: le:U16/16>>0)
5 channel-specific attributes found:
attr 0: offset value: 0
attr 1: oversampling_ratio value: 0
attr 2: oversampling_ratio_available value: 1 2 4 8 16 32 64 128 256 512 1024
attr 3: raw value: 0
attr 4: scale value: 0.038146972
2 device-specific attributes found:
attr 0: trigger_polarity value: rising-edge
attr 1: trigger_polarity_available value: rising-edge falling-edge both-edges
2 buffer-specific attributes found:
attr 0: data_available value: 0
attr 1: watermark value: 1
7 debug attributes found:
debug attr 0: lincalfact6 value: 502
debug attr 1: lincalfact5 value: 516407794
debug attr 2: lincalfact4 value: 535292415
debug attr 3: lincalfact3 value: 533194225
debug attr 4: lincalfact2 value: 517467641
debug attr 5: lincalfact1 value: 534246910
debug attr 6: direct_reg_access value: 0x100A
ERROR: checking for trigger : Input/output error (5)
iio:device1: 48003000.adc:adc@100 (buffer capable)
4 channels found:
voltage13: (input, index: 0, format: le:U16/16>>0)
5 channel-specific attributes found:
attr 0: input value: 2471
attr 1: offset value: 0
attr 2: oversampling_ratio value: 0
attr 3: oversampling_ratio_available value: 1 2 4 8 16 32 64 128 256 512 1024
attr 4: scale value: 0.038146972
voltage14: (input, index: 1, format: le:U16/16>>0)
5 channel-specific attributes found:
attr 0: offset value: 0
attr 1: oversampling_ratio value: 0
attr 2: oversampling_ratio_available value: 1 2 4 8 16 32 64 128 256 512 1024
attr 3: raw value: 35534
attr 4: scale value: 0.038146972
voltage18: (input, index: 2, format: le:U16/16>>0)
5 channel-specific attributes found:
attr 0: offset value: 0
attr 1: oversampling_ratio value: 0
attr 2: oversampling_ratio_available value: 1 2 4 8 16 32 64 128 256 512 1024
attr 3: raw value: 10735
attr 4: scale value: 0.038146972
voltage19: (input, index: 3, format: le:U16/16>>0)
5 channel-specific attributes found:
attr 0: offset value: 0
attr 1: oversampling_ratio value: 0
attr 2: oversampling_ratio_available value: 1 2 4 8 16 32 64 128 256 512 1024
attr 3: raw value: 168
attr 4: scale value: 0.038146972
2 device-specific attributes found:
attr 0: trigger_polarity value: rising-edge
attr 1: trigger_polarity_available value: rising-edge falling-edge both-edges
2 buffer-specific attributes found:
attr 0: data_available value: 0
attr 1: watermark value: 1
7 debug attributes found:
debug attr 0: lincalfact6 value: 509
debug attr 1: lincalfact5 value: 516401652
debug attr 2: lincalfact4 value: 521662976
debug attr 3: lincalfact3 value: 535300581
debug attr 4: lincalfact2 value: 513265148
debug attr 5: lincalfact1 value: 535296511
debug attr 6: direct_reg_access value: 0x100A
ERROR: checking for trigger : Input/output error (5)
root@stm32mp1:~#
Here the output for channel 0 again as screenshot, with nicer formatting:
While the "input/output error (5)" seems to persist, there are trigger attributes listed now which haven't been there before.
Which is fine for me right now, so I will mark this thread as "solved". Perhaps I come back to this topic later.
Thanks !