Jump to content


Photo

w1-gpio OneWire Kernel module


  • Please log in to reply
19 replies to this topic

#1 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:15 PM

Hi all,

is it possible to include wire, w1-gpio and 1-therm modules in the next kernel releases?

I am trying to follow this tutorial to add support for OneWire devices and it requires adding those modules.
http://webshed.org/w...pberryPI_DS1820

Thanks


  • ABiossetle likes this

#2 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:15 PM

You should be able to make it work using the approach shown in this post:

http://learn.linkspr...t11-on-pcduino/



#3 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:15 PM

Hi jim,

thanks for the link, but unfortunately that article is not what I need. That article show how to use a NTC thermistor with Arduino code. I need to connected OneWire devices, in the operating system level.

I can re-compile the kernel with w1-gpio and 1-therm module, but that wouldn't help other people with the same problem. OneWire devices are quite popular in the Arduino world, thus it is likely they will become popular amongst PCDuino users.



#4 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:15 PM

I would also be interested in this.

Right now I have no alternative to read the DS18B20 - but to convert the OneWire (for Arduino) to run on pcDuino3 ... which I'm working on. However, it feels like Arduino, you abuse macros to go one step higher than ASM. But with the w1-gpio it would be much more interesting to forget about the protocol ..

I had a short look at the kernel module, but I have to:
a) build the kernel first (I do run pcDuino3 now from a 32Gb class 10 sdcard, but if there's an error somewhere ....)
B) build the module (either inside or outside the kernel source)
c) figure out if it works correctly with the way GPIO pins are configured on pcDuino3 and redo the whole thing in case errors, reconfigurations, etc, are required (since I'm not familiar with the board yet).

Thus, it would be a very welcomed addition smiley.gif

Later Edit:

Checking the source code from here: https://github.com/p...drivers/Kconfig it seems that the patch does reference both the gpio as well as the w1 
 

Code: [Select]

...
source "drivers/gpio/Kconfig"
source "drivers/w1/Kconfig"
...



#5 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:15 PM

I would like this as well 



#6 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:15 PM

wow Write driver to kernel? Raspberry did and I thought raspberry just write 1wire protocol to the driver , and it has used one gpio that you can't change one wire port to another...

Use a .h which you can find them from arduino to solve this case is more flexible



#7 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:16 PM

wow Write driver to kernel? Raspberry did and I thought raspberry just write 1wire protocol to the driver , and it has used one gpio that you can't change one wire port to another...

Use a .h which you can find them from arduino to solve this case is more flexible
 


Can you expand on that how would you go about it?



#8 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:16 PM

buster7,
I also got confused with 'MorningTZH' comment. I think what he meant to say by "use a .h" is to write a OneWire client in C, then call it from your code in whatever language you use. 

That is what I ended up doing as a proof of concept and it works. I've compiled the Arduino OneWire library, then I call it from Java. However, maintaining the bridge is very troublesome and adding the 1-wire module to the kernel is a much better solution, that will also help many other users.



#9 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:16 PM

buster7,
I also got confused with 'MorningTZH' comment. I think what he meant to say by "use a .h" is to write a OneWire client in C, then call it from your code in whatever language you use. 

That is what I ended up doing as a proof of concept and it works. I've compiled the Arduino OneWire library, then I call it from Java. However, maintaining the bridge is very troublesome and adding the 1-wire module to the kernel is a much better solution, that will also help many other users.
 

Hi fsamir 
how did you go about compiling the library and what was the resulting file ? I'm using gambas and i can use shared libraries lib.so files is that what you ended up with I'm not familiar with java 



#10 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:16 PM

buster7,

I've followed this link to convert a sketch into executable C on pcduino:
 http://electronhobbi...etch-on-pcduino

The code itself is very simple and simply uses the Arduino OneWire library to query temperature. I will post it once I get back home. 

Regarding running it, any programming language can call native code or run a process. I am pretty sure gambas too.



#11 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:16 PM

Hi,

I think you must also change the config of the gpio-pin in the fex file. Did you try whats mentioned here:
http://linux-sunxi.org/1-Wire

This is just a guess, didn't try it myself.

 

buster7,

I've followed this link to convert a sketch into executable C on pcduino:
 http://electronhobbi...etch-on-pcduino

The code itself is very simple and simply uses the Arduino OneWire library to query temperature. I will post it once I get back home. 

Regarding running it, any programming language can call native code or run a process. I am pretty sure gambas too.


#12 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:16 PM

Hi kang.yang,

OneWire isn't provided in the Ubuntu image (that is my request in the first post), so it isn't possible to configure it according to the link. That is an nice reference on how to configure it, nevertheless.



#13 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:16 PM

I confirm, I don't have the w1 kernel module on my pcDuino3 either and I would like to avoid having to build the kernel myself (since it is not clear yet what I have to do to get the hardware lib into the new kernel - or at least, if I could just build the kernel without the hardware lib).

It would be very easy then, instead relying on the OneWire library for Arduino ..



#14 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:16 PM

Alternatively, while the a newUbuntu image with the kernel module isn't release, we can try to install SunXi according to the link below:
http://archlinuxarm....lwinner/pcduino

I am assuming SunXi has the OneWire kernel module installed by default because there are instructions on how to configure it at:  http://linux-sunxi.org/1-Wire

I will give it a try tonight.



#15 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:17 PM

where is script.fex file ?



#16 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:17 PM

Try:

Code: [Select]

sudo find / -name script.fex
I've run it on Ubuntu and it doesn't exists, most likely because the 1-wire kernel module isn't installed.



#17 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:17 PM

where is script.fex file ?
 

i think this is in the source code for the kernel and  i think you edit it before compiling the kernel ?



#18 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:17 PM

his guy  will publish the code in the weekend and post a link here on the forum on the programming part.

 http://pcduino.com/f...msg6738#msg6738
 

where is script.fex file ?
 

i think this is in the source code for the kernel and  i think you edit it before compiling the kernel ?


#19 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:17 PM

even if he post his code, it is a workaround and not an ideal solution. The 1-wire protocol does support many more sensors, other than the temperature one and many people use it with Arduinos.
It would be  simpler and more elegant solution if the PCduino team could provide an Ubuntu image with the 1-wire kernel module. As administrators I think you guys should push on that direction.



#20 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 12 February 2015 - 09:17 PM

w1-gpio is the same workaround ... it does bit-banging itself (no hardware timer involved) and uses msleep to do the sampling delays required by the One Wire protocol. However, msleep has the same problem as usleep - it guarantees the minimum time, but it can delay more - which sometimes breaks the one wire protocol tight timings. You will get from time to time incorrect CRC values or no response from the bus.

You can search for msleep call here: http://lxr.free-elec...sters/w1-gpio.c

It should be in the kernel just in case, since then you can use python / java etc directly - what I'm saying it is still a workaround.
Timings work properly in case of Arduino / Atmel since there's no board power management kicking in when you don't expect it, no other higher priority kernel stuff that could interrupt your thread and break the timings sad.gif






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users