2022-09-14 04:49 AM
I am asking this question after using the the Developer package of the STM32 Echosystem in orfer to recompile the kernel drivers of the ADC to activate the ADC, how ever i can't figure out how to modify the device tree. i was trying to get this example "3.3 How to perform multiple ADC conversions in triggered buffer mode using libiio
" provided by st to work (https://wiki.st.com/stm32mpu/wiki/How_to_use_the_IIO_user_space_interface)
how ever when i reach this example to test it doesn't work since i don't have the trigger0 showing up after using the iio_info command
$ iio_readdev -t trigger0 -s 8 -b 8 iio:device0 voltage0 voltage1 | hexdump
in that case my question is how to get this example working by changing the device tree and the developement echosystem's method ?
this is my device tree configuration
&adc {
vdd-supply = <&vdd>;
vdda-supply = <&vdda>;
vref-supply = <&vdda>;
status = "okay";
adc1: adc@0 {
st,min-sample-time-nsecs = <5000>;
st,adc-channels = <0 1>;
status = "okay";
};
adc2: adc@100 {
status = "okay";
};
adc_temp: temp {
status = "okay";
};
};
Solved! Go to Solution.
2022-09-15 02:52 AM
Hello @iheb,
I think you missed the information bubble in chapter 3.1.
Regarding to your configuration that does not work, I think that your timer@6 that is supposed to be used with your failing command is not activated.
Please try to enable it, this is the timer located in stm32mp151.dtsi file:
timers6: timer@40004000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "st,stm32-timers";
reg = <0x40004000 0x400>;
clocks = <&rcc TIM6_K>;
clock-names = "int";
dmas = <&dmamux1 69 0x400 0x80000001>;
dma-names = "up";
status = "okay";
timer@5 {
compatible = "st,stm32h7-timer-trigger";
reg = <5>;
status = "okay";
};
};
I modified it directly in the dtsi file to show you, but the clean method is to override the status property in your dts file (More than that, modify it here will not work because the node is overwritten in another DT file). If it is well activated, you will be able to see it in /sys/bus/iio/devices directory. Then, your commands from chaper 3.1 / 3.2 should not fail anymore (except lsiio that is not present on board by default).
Hope it will help to solve your issue.
Kind regards,
Erwan.
2022-09-14 08:53 AM
Hello @iheb ,
In the same article as you mentioned, did you well follow all the chapter 3 (3.1 and 3.2) ?
What is the output of the command lsiio | grep tim ?
In chapter 3.2, did you well assigned the tim6_trgo to your ADC (command echo "tim6_trgo" > trigger/current_trigger)
Please double check these different points and make me a feedback if you still have troubles, and at which step.
Kind regards,
Erwan.
2022-09-15 01:31 AM
Hello Erwan,
Thank you for your assistance,
The command
board# lsiio | grep tim
outputs
-sh: lsiio: not found
when i attempt to assign the "tim6_trgo" to the adc i get an error, since i have the same timers when executing iio_info i receive the following output
Library version: 0.15 (git tag: 6ecff5d)
Compiled with backends: local xml ip usb
IIO context created with local backend.
Backend version: 0.15 (git tag: 6ecff5d)
Backend description string: Linux osd32mp1-brk 5.10.10 #1 SMP PREEMPT Sat Jan 23 15:04:06 UTC 2021 armv7l
IIO context has 1 attributes:
local,kernel: 5.10.10
IIO context has 1 devices:
iio:device0: 48003000.adc:adc@0 (buffer capable)
2 channels found:
voltage0: (input, index: 0, format: le:U16/16>>0)
3 channel-specific attributes found:
attr 0: raw value: 886
attr 1: offset value: 0
attr 2: scale value: 0.044250488
voltage1: (input, index: 1, format: le:U16/16>>0)
3 channel-specific attributes found:
attr 0: raw value: 795
attr 1: offset value: 0
attr 2: scale value: 0.044250488
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: watermark value: 1
attr 1: data_available value: 0
1 debug attributes found:
debug attr 0: direct_reg_access value: 0x100A
To hear form you soon
Thank you
Iheb
2022-09-15 02:52 AM
Hello @iheb,
I think you missed the information bubble in chapter 3.1.
Regarding to your configuration that does not work, I think that your timer@6 that is supposed to be used with your failing command is not activated.
Please try to enable it, this is the timer located in stm32mp151.dtsi file:
timers6: timer@40004000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "st,stm32-timers";
reg = <0x40004000 0x400>;
clocks = <&rcc TIM6_K>;
clock-names = "int";
dmas = <&dmamux1 69 0x400 0x80000001>;
dma-names = "up";
status = "okay";
timer@5 {
compatible = "st,stm32h7-timer-trigger";
reg = <5>;
status = "okay";
};
};
I modified it directly in the dtsi file to show you, but the clean method is to override the status property in your dts file (More than that, modify it here will not work because the node is overwritten in another DT file). If it is well activated, you will be able to see it in /sys/bus/iio/devices directory. Then, your commands from chaper 3.1 / 3.2 should not fail anymore (except lsiio that is not present on board by default).
Hope it will help to solve your issue.
Kind regards,
Erwan.
2022-09-15 08:04 AM
hello @Erwan SZYMANSKI
I'm unable to Assign tim7_trgo trigger to ADC, however, I was able to activate the timers and now the iio_info shows the following data.
Library version: 0.15 (git tag: 6ecff5d)
Compiled with backends: local xml ip usb
IIO context created with local backend.
Backend version: 0.15 (git tag: 6ecff5d)
Backend description string: Linux osd32mp1-brk 5.4.31 #7 SMP PREEMPT Thu Sep 15 16:30:06 CEST 2022 armv7l
IIO context has 1 attributes:
local,kernel: 5.4.31
IIO context has 3 devices:
iio:device1: 48003000.adc:adc@100 (buffer capable)
2 channels found:
voltage0: (input, index: 0, format: le:U16/16>>0)
3 channel-specific attributes found:
attr 0: raw value: 1129
attr 1: offset value: 0
attr 2: scale value: 0.044250488
voltage1: (input, index: 1, format: le:U16/16>>0)
3 channel-specific attributes found:
attr 0: raw value: 967
attr 1: offset value: 0
attr 2: scale value: 0.044250488
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: watermark value: 1
attr 1: data_available value: 0
1 debug attributes found:
debug attr 0: direct_reg_access value: 0x100A
iio:device0: 48003000.adc:adc@0 (buffer capable)
2 channels found:
voltage0: (input, index: 0, format: le:U16/16>>0)
3 channel-specific attributes found:
attr 0: raw value: 227
attr 1: offset value: 0
attr 2: scale value: 0.044250488
voltage1: (input, index: 1, format: le:U16/16>>0)
3 channel-specific attributes found:
attr 0: raw value: 434
attr 1: offset value: 0
attr 2: scale value: 0.044250488
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: watermark value: 1
attr 1: data_available value: 0
1 debug attributes found:
debug attr 0: direct_reg_access value: 0x100A
trigger0: tim7_trgo
0 channels found:
3 device-specific attributes found:
attr 0: sampling_frequency value: 0
attr 1: master_mode value: reset
attr 2: master_mode_available value: reset enable update compare_pulse OC1REF OC2REF OC3REF OC4REF
how ever when I execute this command
board# echo "tim7_trgo" > trigger/current_trigger
I receive the following error:
sh: write error: Invalid argument
and if I use for example tim6_trgo as an argument that would yield nothing but when I cat the value of the file it seems to be empty.
therefore I'm still unable to finish the example
the dts file :
...
&timers4 {
status = "okay";
/* spare dmas for other usage */
/delete-property/dmas;
/delete-property/dma-names;
pwm4: pwm {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&pwm4_pins_mx>;
pinctrl-1 = <&pwm4_sleep_pins_mx>;
status = "okay";
};
};
&timers7 {
status = "okay";
/* spare dmas for other usage */
/delete-property/dmas;
/delete-property/dma-names;
};
&timers6 {
status = "okay";
/* spare dmas for other usage */
/delete-property/dmas;
/delete-property/dma-names;
};
&timers8 {
status = "okay";
/* spare dmas for other usage */
/delete-property/dmas;
/delete-property/dma-names;
pwm8: pwm {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&pwm8_pins_mx>;
pinctrl-1 = <&pwm8_sleep_pins_mx>;
status = "okay";
};
};
...
Thank you
Iheb
2022-09-15 08:43 AM
@iheb ,
My bad I shared the wrong node, like you said it was timer6 and not timer7.
On which OSTL version are you ? The 4.0 ?
Regards,
Erwan.
2022-09-16 03:15 AM
@iheb ,
What I device you is to do the following steps:
In your device tree, add the following part:
/* Test ADC purpose */
&timers5 {
status = "okay";
};
&timers6 {
status = "okay";
};
&adc {
status = "okay";
};
&adc1 {
status = "okay";
st,adc-channels = <0 1>;
};
Then, after compilation and deployment, do the following steps on your board shell.
Board$> cd /sys/bus/iio/devices
Board$> ls
You should see something like this in output:
iio:device0 iio:device1 iio:device2 trigger0 trigger1 trigger2 trigger3 trigger4 trigger5 trigger6
Now look at your different device/name to find adc@0 and tim6_trgo:
Board$> cat */name
My output:
40003000.timer:timer@4
48003000.adc:adc@0
48003000.adc:adc@100
tim5_trgo
tim5_ch1
tim5_ch2
tim5_ch3
tim5_ch4
tim6_trgo
tim7_trgo
In my case, I see that adc@0 is iio:device1 and tim6_trgo is trigger5.
Now,
Board$> cd trigger5
Board$> echo 10 > sampling_frequency
Board$> cd ..
Board$> cd iio:device1
Board$> echo 1 > scan_elements/in_voltage0_en
Board$> echo 1 > scan_elements/in_voltage1_en
Board$> echo "tim6_trgo" > trigger/current_trigger
Board$> echo 1 > buffer/enable
Now if I do the multiple ADC conversions command:
Board$> iio_readdev -t trigger5 -s 8 -b 8 iio:device1 voltage0 voltage1 | hexdump
My output:
WARNING: High-speed mode not enabled
0000000 ffff 749e ffff 8660 ffff 8ae9 ffff 8e2c
0000010 ffff 8e30 ffff 8e42 ffff 8eb5 ffff 8f1a
0000020
Can you check these different steps ?
Kind regards,
Erwan.
2022-09-16 07:36 AM
@Erwan SZYMANSKI i am using stm32mp1-openstlinux-5-4-dunfell-mp1-20-06-24
2022-09-19 02:41 AM
Hello @Erwan SZYMANSKI ,
I have followed the exact same steps, it works now i was able to fully follow the tutorial steps by only activating the timers6 on the DTSI file, if I try to activate it on the DTS file it wouldn't work at this point I'm sure it's something to do with me not being able to correctly use the DTS file.
Thank you so much for your help
Iheb
2022-09-19 02:44 AM
Hi @iheb ,
Glad to see that you solved your issue.
Have a nice day,
Erwan.