johannesthoma / linux-hc-sro4

The HC-SRO4 is an ultrasonic distance sensor to be attached on 2 5V GPIO pins. This driver uses the interrupt logic of the GPIO driver to measure the distance in a non-blocking, precise and load-independend way. Unlike user land measurement methods you can even compile a linux kernel while doing measurements without getting weird results.
GNU General Public License v2.0
26 stars 17 forks source link

IIO interface #1

Open barbieri opened 8 years ago

barbieri commented 8 years ago

Hi,

in a forum you mention IIO interface, did you get to do it?

johannesthoma commented 8 years ago

Hi not yet, I will keep you updated on that.

johannesthoma commented 8 years ago

The driver is fully functional it's just that the interface will change. The reason is that I want to contribute it to Linux mainline and that's what they suggested (see posts on kernelnewbies).

barbieri commented 8 years ago

I know that :)

I'm a huge supporter of the IIO. I'm the engineering manager of two projects targeting IoT:

They complement each other and pushes IIO as the sensor interface, then yesterday we got such sensor for a demo and noticed it was lacking the driver, Google shows your github :) at the same time we got a request for proximity sensor! See:

Then once you have it converted, let me know so we include a back port to kernel 4.4 we use now. We can also help with development and testing.

johannesthoma commented 8 years ago

Thanks for letting me know. That actually boosts the priority of finishing it soon. I am currently in a project until May 10 and then I will port the driver to IIO. I will get back to you as soon I am finished.

johannesthoma commented 8 years ago

Please note that currently the driver just supports HC-SRO4 since this is all I have, however it could be extended to support other sensors as well.

johannesthoma commented 8 years ago

Hi, I've created a branch iio where I work on IIO support for the driver. It is work in progress but it works for me (c). If you or one of your colleagues would give it a try that would help me a lot.

Please see the shell scripts setup.sh and test.sh for how to use the new interface. Looking forward to hear you, please message me with comments and bug reports.

Thanks,

barbieri commented 8 years ago

@yongli3 can you look into this driver?

yongli3 commented 8 years ago

@johannesthoma l tested the kernel module using Ostro OS, Since Ostro is using kernel 4.4, there are several changes, the build failed fatal error: linux/iio/sw_trigger.h: No such file or directory, Using Kernel 4.6, build is okay. When I execute the mkdir sensor0 command, I received the below error message(I did not connect the real sensor). Could you let me know if you are using a raspberry pi boards for the module test? which kernel version are you using?

[ 9021.869336] ------------[ cut here ]------------ [ 9021.874846] WARNING: CPU: 0 PID: 980 at /home/yongli/ostro-os/build/tmp-glibc/work-shared/intel-corei7-64/kernel-source/include/linux/kref.h:46 config_item_get+0x4d/0x60 [configfs] [ 9021.893427] Modules linked in: hc_sro4(O) industrialio_sw_trigger industrialio_configfs configfs 8021q xt_connmark iptable_nat nf_nat_ipv4 nf_nat iptable_mangle intel_soc_dts_iosf intel_powerclamp coretemp efivars i2c_designware_platform i2c_i801 snd_hda_codec_hdmi i2c_designware_core snd_hda_intel snd_hda_codec snd_hda_core mei_txe mei dw_dmac dw_dmac_core snd_soc_sst_acpi snd_soc_sst_match spi_pxa2xx_platform pwm_lpss_platform pwm_lpss nf_conntrack_ipv4 nf_defrag_ipv4 nf_conntrack_ipv6 nf_defrag_ipv6 xt_tcpudp uio xt_conntrack nf_conntrack iptable_filter iwlwifi cfg80211 iio_trig_sysfs industrialio ip6table_filter ip6_tables efivarfs ip_tables x_tables [ 9021.959259] CPU: 0 PID: 980 Comm: mkdir Tainted: G O 4.6.0-yocto-standard #1 [ 9021.968423] Hardware name: Circuitco Minnowboard Max B3 PLATFORM/MinnowBoard MAX, BIOS MNW2MAX1.X64.0082.R02.1507271125 07/27/2015 [ 9021.981574] 0000000000000286 00000000f03f2eb4 ffff880076e6bdc0 ffffffff92e2b01d [ 9021.989874] 0000000000000000 0000000000000000 ffff880076e6be00 ffffffff92a7d01b [ 9021.998181] 0000002e00000018 ffff880076dce890 ffff880076dce890 ffff880077483560 [ 9022.006491] Call Trace: [ 9022.009239] [] dump_stack+0x4f/0x72 [ 9022.014997] [] __warn+0xcb/0xf0 [ 9022.020364] [] warn_slowpath_null+0x1d/0x20 [ 9022.026903] [] config_item_get+0x4d/0x60 [configfs] [ 9022.034216] [] link_obj+0x42/0x50 [configfs] [ 9022.040849] [] link_group+0x19/0x70 [configfs] [ 9022.047676] [] configfs_mkdir+0x18f/0x400 [configfs] [ 9022.055088] [] vfs_mkdir+0x9f/0xf0 [ 9022.060746] [] SyS_mkdir+0x7a/0xe0 [ 9022.066405] [] entry_SYSCALL_64_fastpath+0x13/0x8f [ 9022.073652] ---[ end trace 904865d6762673c2 ]--- [ 9022.078849] BUG: unable to handle kernel paging request at ffffffffffffffb8 [ 9022.086661] IP: [] link_obj+0xc/0x50 [configfs] [ 9022.093496] PGD 13807067 PUD 13809067 PMD 0 [ 9022.098296] Oops: 0002 [#1] PREEMPT SMP [ 9022.102704] Modules linked in: hc_sro4(O) industrialio_sw_trigger industrialio_configfs configfs 8021q xt_connmark iptable_nat nf_nat_ipv4 nf_nat iptable_mangle intel_soc_dts_iosf intel_powerclamp coretemp efivars i2c_designware_platform i2c_i801 snd_hda_codec_hdmi i2c_designware_core snd_hda_intel snd_hda_codec snd_hda_core mei_txe mei dw_dmac dw_dmac_core snd_soc_sst_acpi snd_soc_sst_match spi_pxa2xx_platform pwm_lpss_platform pwm_lpss nf_conntrack_ipv4 nf_defrag_ipv4 nf_conntrack_ipv6 nf_defrag_ipv6 xt_tcpudp uio xt_conntrack nf_conntrack iptable_filter iwlwifi cfg80211 iio_trig_sysfs industrialio ip6table_filter ip6_tables efivarfs ip_tables x_tables [ 9022.167835] CPU: 0 PID: 980 Comm: mkdir Tainted: G W O 4.6.0-yocto-standard #1 [ 9022.176996] Hardware name: Circuitco Minnowboard Max B3 PLATFORM/MinnowBoard MAX, BIOS MNW2MAX1.X64.0082.R02.1507271125 07/27/2015 [ 9022.190146] task: ffff880071010000 ti: ffff880076e68000 task.ti: ffff880076e68000 [ 9022.198530] RIP: 0010:[] [] link_obj+0xc/0x50 [configfs] [ 9022.208084] RSP: 0018:ffff880076e6be18 EFLAGS: 00010286 [ 9022.214031] RAX: 0000000000000000 RBX: ffff880076dce890 RCX: 0000000000000001 [ 9022.222022] RDX: 0000000000000000 RSI: ffffffffffffff88 RDI: ffff880076dce890 [ 9022.230012] RBP: ffff880076e6be18 R08: 0000000000000000 R09: 0000000000000000 [ 9022.238003] R10: ffff880076dce8ac R11: ffffffff93aad72d R12: ffffffffffffff88 [ 9022.245994] R13: ffff880076dce8f8 R14: ffff880079ae1d80 R15: ffff880076dce890 [ 9022.253985] FS: 00007f549e1f9700(0000) GS:ffff880078200000(0000) knlGS:0000000000000000 [ 9022.263049] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 9022.269482] CR2: ffffffffffffffb8 CR3: 00000000775d1000 CR4: 00000000001006f0 [ 9022.277472] Stack: [ 9022.279721] ffff880076e6be40 ffffffffc03c6a29 ffffffffffffff88 ffff880076dce890 [ 9022.288013] ffff880076dce8f8 ffff880076e6be68 ffffffffc03c6a55 ffff8800727eda80 [ 9022.296304] ffff880076e5cd10 ffff880077483560 ffff880076e6bec0 ffffffffc03c7dcf [ 9022.304595] Call Trace: [ 9022.307338] [] link_group+0x19/0x70 [configfs] [ 9022.314167] [] link_group+0x45/0x70 [configfs] [ 9022.320995] [] configfs_mkdir+0x18f/0x400 [configfs] [ 9022.328405] [] vfs_mkdir+0x9f/0xf0 [ 9022.334063] [] SyS_mkdir+0x7a/0xe0 [ 9022.339722] [] entry_SYSCALL_64_fastpath+0x13/0x8f [ 9022.346934] Code: 4c 89 ee e8 17 fc ff ff 48 8b 73 48 41 89 c6 eb 87 0f 1f 40 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 55 48 85 ff 48 89 e5 <48> 89 7e 30 53 48 89 f3 74 2f e8 05 28 00 00 48 89 43 38 48 8b [ 9022.368444] RIP [] link_obj+0xc/0x50 [configfs] [ 9022.375374] RSP [ 9022.379279] CR2: ffffffffffffffb8 [ 9022.382984] ---[ end trace 904865d6762673c3 ]---

johannesthoma commented 8 years ago

Hi,

Thanks for your bug report. I am using a raspberry Pi 1: kernel version is:

Linux camRaspi 4.6.0+ #15 Mon May 23 15:38:09 CEST 2016 armv6l GNU/Linux

from the raspberry kernel at:

https://github.com/raspberrypi/linux.git

Can you point me to the git repo of the kernel you are using? Then I will be able to reproduce the error.

Best,

PS: Sorry for the delay, I've expected to get an eMail from github when something is going on on the issue.

johannesthoma commented 8 years ago

Please note that there is a newer version of the driver in the iio branch, but this probably won't fix the issue.

yongli3 commented 8 years ago

@johannesthoma Thanks for your update! I am using the linux-yocto-dev: git://git.yoctoproject.org/linux-yocto-dev. I have a Pi 3 board, let me test it using it too.

johannesthoma commented 8 years ago

@yongli3: Thanks for the info, I will try to reproduce the error using your kernel version.

johannesthoma commented 8 years ago

@yongli3: I just tried to reproduce the error with the most up-to-date yocto kernel, unfortunately without success. The git hash of the kernel I've used is

248edfa0de0fce4f4e88a8d9a0ccc326ac532fa9

Which one did you use?

Note that with this kernel there is an issue with gpio_to_desc() - it just doesn't work with numbers on the Raspberry. This may be an issue in the device tree GPIO descriptors (echo 23 > /sys/class/gpio/export doesn't work as well).

Note also that I've just posted the driver to linux-iio kernel mailing list and just wait for responses.

yongli3 commented 8 years ago

Thanks @johannesthoma. When you tested the linux-yocto-dev kernel, did you connected the hardware?

Since the linux-yocto-dev is changing, let me re-test it using 248edfa0de0fce4f4e88a8d9a0ccc326ac532fa9

johannesthoma commented 8 years ago

@yongli3 yes I connected the hardware, however this should not make any difference since at device creation time the hardware is not accessed.

Just because I am curious: which time zone are you in?

yongli3 commented 8 years ago

@johannesthoma Since it is not hardware related, let me test it using my Pi3 and Minnowmax boards. I am in Shanghai China, GMT+8