I'm trying the Buffer and Hardware Trigger capabilities of the SAMA5D4.
I follow the instructions of http://www.at91.com/linux4sam/bin/view/Linux4SAM/IioAdcDriver.
In Part 1, I enabled the hardware trigger from the linux prompt.
In this post, I'm testing the buffer with the test tool generic_buffer.
Building the Test Tool
generic_buffer is available as c source. There's a number of them available in different versions on the internet, but not all compile for this board (or for my tool chain).
I steered away from examples that use the be16toh function. I got errors when I compiled those.
There are also versions without that function.
I used (without further analysis, just because it was the first hit) kernel-rsbac-source-3.0.2-1mdv-1-1-mdv2011.0.i586.rpm.59587983/usr/src/3.0.2-rsbac-1mdv/drivers/staging/iio/Documentatio…
Use the one from the atmel git: https://raw.githubusercontent.com/linux4sam/linux-at91/master/drivers/staging/iio/Documentation/generic_buffer.c
Run the Test Tool
My first run is with the analog input connected to ground. I'm doing the exercise while writing the blog, so what you see here is exactly as it happens.
As a first step, I load my compiled program
rz -e -b -X generic_buffer chmod +x generic_buffer
and execute the steps documented in part 1:
modprobe at91_adc echo 1 > /sys/bus/iio/devices/iio:device0/scan_elements/in_voltage0_en echo "fc034000.adc-dev0-continuous" > /sys/bus/iio/devices/iio:device0/trigger/current_trigger echo 100 > /sys/bus/iio/devices/iio:device0/buffer/length echo 1 > /sys/bus/iio/devices/iio:device0/buffer/enable
And now the moment suprême: running that binary:
# Don't use at91_adc when working with a 'device tree' linux distro ./generic_buffer -n at91_adc -t fc034000.adc-dev0-continuous -l 2
./generic_buffer -n fc034000.adc -t fc034000.adc-dev0-continuous -l 2
where:
- at91_adc is the IIO driver
- fc034000.adc is the IIO driver
- fc034000.adc-dev0-continuous is the trigger name
- 2 is the buffer lenght (I would expect 100 here because I echo 100 to buffer/length a few lines higher. I'm following the advice of linux4sam here.
And here I fail. Failed to find the at91_adc
My error message is related to the driver. I'm posting a new post on the at91.com forum to see what's wrong.
hold on...
While my post is open on the at91 forum, I'm continuing with investigations.
Here's where the code fails: /* Find the device requested */ dev_num = find_type_by_name(device_name, "device"); if (dev_num < 0) { printf("Failed to find the %s\n", device_name); ret = -ENODEV; goto error_ret; } printf("iio device number being used is %d\n", dev_num);
I'm going to check how find_type_by_name() works, and check in the ii0 folders if I find something obvious... |
update May 22:
Solved. The error was caused by 2 things:
(see element14 question )
1. the source for generic_buffer.c : There's a multitude of versions of that file on the internet.
In the correct one, here's how the device is found:
dev_num = find_type_by_name(device_name, "iio:device");
In the wrong one:
dev_num = find_type_by_name(device_name, "device");
2. With the switch of the Yocto distro to device tree, the name of driver/trigger changed.
This is reflected on http://www.at91.com/linux4sam/bin/view/Linux4SAM/IioAdcDriver
echo "fc034000.adc-dev0-continuous" > /sys/bus/iio/devices/iio:device0/trigger/current_trigger ./generic_buffer -n fc034000.adc -t fc034000.adc-dev0-continuous -l 2 The result: |
Maybe the image that I use (the HDMI demo that peteroakes also uses in his videos) may not have the driver for ADC loaded...
According to at91.com, the driver should be at /lib/modules/3.5.0/kernel/drivers/iio/adc/at91_adc.ko My build is not 3.5.0, but 3.10.0-custom. I get up to lib/modules/3.10.0-custom/kernel/drivers. There is no iio in that folder.
I'l check if there's more info somewhere else... |
In /sys/devices/ahb/ahb:apb/fc034000.adc/modalias , I found a reference to the driver name at91sam9x5-adc But I couldn't load the driver and the generic_buffer tool failed to find that driver too.
I've also downloaded nd installed the latet Poky image available from Sama5d4XplainedMainPage < Linux4SAM < TWiki |
I've done a file find for all .ko files (I'm searching where the adc_91 would b).
find . -print | grep -i '.*[.]ko' > ~/drivers.log
The results are attached to the blog (drivers.log). I couldn't find the adc driver. |