Finally. Patches for continuous sampling got accepted in IIO.
http://thread.gmane.org/gmane.linux.kernel.input/32024
All the hard work paid of in the end. Achievement unlocked.
:)
A hiccup n warning here n there mentioned by the autobuild scripts. but no biggy. sending a couple of cleanup patches in a jiffy
http://thread.gmane.org/gmane.linux.kernel.iio/9638
Now for rebasing stuff for koen's trees. A long blogpost describing how to get the driver to work from userspace. The trigger stuff on the blog is redundant and misleading now. I'll put a note in the start of those posts pointing to the new one when its done..
Thanks for pushing this through to the end on the IIO group.
ReplyDeleteLooking forward to hearing about the new userspace wrap-up!
That could take a while since I'm a bit busy these days.
DeleteIn short, its the same as the generic_buffer.c. But remove the trigger checks.
Similar to the sample application provided at the end of
http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver%27s_Guide
Although, the driver now doesn't have those limitations and conforms to IIO spec.
I've been trying with the patch from http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver%27s_Guide removing the triggers as well as the previous patch from Craig for the iio_utils.h; however, I am getting a Read Size = 0 and its not recording any data from the buffer.
ReplyDeleteMy thinking is its not being triggered to write to the buffer somehow but there is no error thrown. I know there are not triggers anymore, so where is it told to write to the buffer?
When you write 1 in the buffer/enable file, the ADC starts sampling..
DeleteWhen I try to do: echo 1 > /sys/bus/iio/devices/iio:device0/buffer/enable
DeleteI get: bash: echo: write error: Invalid argument
I was able to set a length for the buffer and am sure the tiadc driver is enabled. Also, I thought it might be because a trigger is not active, but the 'new' code does not use triggers I thought.
I did this anyway: echo 1 > /sys/bus/iio/devices/iio_sysfs_trigger/add_trigger
and it still returns that invalid argument error, I can write '0' to enable but that does me no good.
Running: cat /sys/bus/iio/devices/trigger0/name
Returns:
er0/name
sysfstrig1
I've been trying to troubleshoot using http://ez.analog.com/message/52587 but have had no luck.
Have you enabled the ADC channels?
DeleteAlso, which driver/kernel are you using?
I have run: 'echo BB-ADC > /sys/devices/bone_capemgr.*/slots' to enable ADC
DeleteI'm using the 'tiadc' driver.
Kernel: 'Linux arm 3.8.13-bone28 #1 SMP Mon Sep 16 01:49:45 CDT 2013 armv7l GNU/Linux' its a version of Debian
Sorry for the really long delay in getting back to you.
DeleteMy work is mostly for 3.11..
I didn't down port it to 3.8.
did you manage to get the ADC working?
This comment has been removed by the author.
DeleteGreetings Zubair
DeleteFirst, thanks for the effort on AM335x_ADC_Driver. As you already realised, it is quite a useful function that you created. It could be an important solution for many people, with much greater impact if you would made an effort to explain how to use it for dummies. May be in a style: "Guide for continuos ADC for dummies". It has been a while since the last time I had to recompile the kernel, may be 10 years, and the only thing I remember it was a lengthy, painful process. Now I need to provide an easy example for students and I suspect this process wont be easy.
I am creating a simple application for beaglebone black where I need fast sampling from ADC to be able to use it a s PID controller. The physics
behind are solved, however I am having troubles with sampling rate. The code below gives me no more than 1000 samples per second, at best. Before I deep myself in your world of iio-subsystem and kernel drivers what real sampling frequency could I achieve using continuous ADC reading? Are you still planning to make a guide for mortals who do not recompile kernel often?
Thank you in advance for the done effort and future advice.
code:
const char AIN_DEV[] = "/sys/devices/ocp.2/helper.14/AIN0";
int main() {
int fd = open(AIN_DEV, O_RDONLY);
// Get current time from the clock, using microseconds resolution
time_t end = time(NULL) + 1;
int i = 0;
while (time(NULL) < (end + 1))
{
char buffer[1024];
int ret = read(fd, buffer, sizeof(buffer));
if (ret != -1)
{
buffer[ret] = '\0';
//printf("%d\n", ret);
//printf("%s\n", buffer);
lseek(fd, 0, 0);
}
i++;
}
std::cout << "have done: " << i <<" reads" << std::endl;
close(fd);
return 0;
}
This comment has been removed by the author.
ReplyDeleteHi Zubair,
ReplyDeleteFirst of all congratulations for the good work. Could you provide me some info on how to put this new driver to work? As far as I understand I'm going to have to compile a new kernel (which? from your git repository?) and disable the trigger checks in generic_buffer.c, is this correct? Is there any additional step I should be aware of?
Best regards,
Tiago C.
Hi Tiago,
DeleteThank-you
I am a bit out of touch. But if I remember correctly, you should be able to use continuous sampling if you compile this https://github.com/beagleboard/kernel/tree/3.11.
And yes. Removing trigger checks in generic_buffer.c is the way to go. Ping me if you get stuck on any issue.
Cheers
Zubair
Hi again Zubair,
ReplyDeleteSome updates:
1) Compiled kernel 3.11;
2) When trying to enable the ADC in slots this was the result:
root@beaglebone:~# echo BB-ADC > /sys/devices/bone_capemgr.*/slots
[ 159.910544] of_resolve: Could not find symbol 'ocp'
[ 159.915789] bone-capemgr bone_capemgr.5: slot #8: Failed to resolve tree
-sh: echo: write error: Invalid argument
root@beaglebone:~# dmesg -c
[ 159.910013] bone-capemgr bone_capemgr.5: part_number 'BB-ADC', version 'N/A'
[ 159.910093] bone-capemgr bone_capemgr.5: slot #8: generic override
[ 159.910121] bone-capemgr bone_capemgr.5: bone: Using override eeprom data at slot 8
[ 159.910151] bone-capemgr bone_capemgr.5: slot #8: 'Override Board Name,00A0,Override Manuf,BB-ADC'
[ 159.910310] bone-capemgr bone_capemgr.5: slot #8: Requesting part number/version based 'BB-ADC-00A0.dtbo
[ 159.910341] bone-capemgr bone_capemgr.5: slot #8: Requesting firmware 'BB-ADC-00A0.dtbo' for board-name 'Override Board Name', version '00A0'
[ 159.910381] bone-capemgr bone_capemgr.5: slot #8: dtbo 'BB-ADC-00A0.dtbo' loaded; converting to live tree
[ 159.910544] of_resolve: Could not find symbol 'ocp'
[ 159.915789] bone-capemgr bone_capemgr.5: slot #8: Failed to resolve tree
To help debugging this, I also include my dtb file (in dts format) here:
http://pastebin.com/cBwLcYJj
Any clue about this? I think I'm very close now...
Thank you!
Tiago
I am not sure if the slots feature was fixed in that kernel. What I would do was directly enable the ADC using the dts file..
DeleteHi Zubair,
DeleteGot it to work. I mean, sort of...I can only get it to work with a maximum of 4 channels. If I try to enable more, the values get all mixed up (i'm testing this with AC signals). Have you ever seen this behaviour?
Thanks again,
Tiago
Hi Tiago,
DeleteGlad to know you got it working.
To be honest, I haven't checked so thoroughly enabling so many channels.
Can I see the dts code enabling the ADC?
Thanks
Zubair
I'd like to reproduce your errors and see if I can debug this. I thought the code was scalable..
DeleteZubair
DeleteHere's the tscadc from am33xx.dtsi:
tscadc: tscadc@44e0d000 {
compatible = "ti,am3359-tscadc";
reg = <0x44e0d000 0x1000>;
interrupt-parent = <&intc>;
interrupts = <16>;
ti,hwmods = "adc_tsc";
status = "okay";
tsc {
compatible = "ti,am3359-tsc";
};
am335x_adc: adc {
#io-channel-cells = <1>;
compatible = "ti,am3359-adc";
ti,adc-channels = <0 1 2 3 4 5 6 7>;
};
};
By the way...
DeleteThank you for your great work =)
Hi again Zubair.
DeleteIntroductions first, João is a friend of mine, also involved in this work. The credit of enabling the ADC is his.
What we are doing now is using the ADC to read 6 AC signals. This is done by disabling any reference to the trigger in the file original “generic_buffer.c”. Also applied the changes in “iio_utils.h”. Lets keep in touch with this. Thank you!
Tiago P.
Nice work. Ping if you need any help. :).
DeleteI didn't find the time to rework genericbuffer.c properly. And used the same method. Just disable trigger. What changes did you make to iio-utils?
Zubair
Hi Zubair,
ReplyDeleteThe changes were those described by Craig Markwardt in is comment from 8 October 2013 01:11
"
I'm not a member of iio mailing list, nor do I know where iio_utils.h came from other than your sample code. I posted a commit here which resolves the problem:
https://github.com/CBGoodBuddy/adc-iio-continuous-sampling-userspace/commit/280d5243a31d35a7282dd0575a615107289976f0"
Thanks,
Tiago
I see.
DeleteThanks,
Zubair
Hi All,
DeleteZubair has sent this upstream to linux-iio which is great. I've applied Craig's patch and attributed the authorship to him. Unfortunately right now I don't have an email address for him.
If Craig (or anyone else if they think he won't mind!) could send me an email to jic23@kernel.org I'll get that fixed up before sending a pull request to my upstream.
For reference the patch is:
https://git.kernel.org/cgit/linux/kernel/git/jic23/iio.git/commit/?h=fixes-togreg&id=66c65d90db1004356281db6ead988e2e38ba9e37
and once the 3.13 kernel is out this will go to Greg KH's staging tree and on to Linus as a fix for 3.14-rc1.
Thanks,
Jonathan
Hi Jonathan,
DeleteI've forwarded this message to Craig's original comment on another post. That should send him an email about it..
Thanks,
Zubair
Hi Zubair,
DeleteI implement a net protocol for linux. What should I do or what's the process to add features to mainline?
There's a zilion streams and repositories on the net, I just don't know where to start and/or to whom talk to, just to guide me to prepare the code for kernel.
Thanks.
João Taveira
Hi Joao,
DeleteA good place to start is http://kernelnewbies.org/FAQ
Watch this http://www.youtube.com/watch?v=L2SED6sewRw
Its a bit old. But still useful and comprehensive.
Unfortunately I didn't see an email. I replied today to Jonathan.
DeleteHi Zubair,
ReplyDeleteI have been having difficulty trying to enable ADC subsystem, to use it with PRU, in kernel 3.12. The dmesg returns "could not find symbol ocp". I know I have to change the .dts file, target = <&tscadc> instead, but I am still very confused with it. I got it working on 3.8, however, it would be nice to get it working in 3.12. Could you please help me with it. Thank you.
Nhan Nguyen
Hi Nhan,
DeleteCheck patch.sh in your kernel folder. If i remember 3.12 doesn't add the tscadc patches by default..
Hope that helps.
Zubair
This comment has been removed by the author.
ReplyDeleteHi Zubair,
ReplyDeletewhen i am trying to enable adc i am getting below error. can you please help me to fix this
-bash: /sys/bus/iio/devices/iio:device0/scan_elements/in_voltage7_en: No such file or directory
Hi,
DeleteThis work is quite old now and the file name/location might be different if you are using a modern beaglebone black image.
try running the following commands
find /sys | grep iio
find /sys | grep adc
find /sys | grep voltage
They will search for any files names iio/adc/voltage and might show which file to read.
Hello everybody.
ReplyDeleteI really like you post.
I would like to share page collection with you!
if you want to play game online casino please click on this post comment.Thank you.
gclub casino
golden slot casino
gclub
That should send him an email about it..
ReplyDeleteplaystar slots
gold slots