w1 and i2c support: Pin config via kernel command-line.

145 views
Skip to first unread message

biff...@yahoo.co.uk

unread,
Sep 6, 2009, 1:46:56 PM9/6/09
to Bifferboard
I have added these to the 2.6.30.5 kernel patch.

http://sites.google.com/site/bifferboard/Home/s3282-kernel-issues

I've only tested w1: Have managed to get some temperature readings out
of a DS1822-PAR with about 1.9K pull-up resistor (3.3v supply).

regards,
Biff.

Nelson Neves

unread,
Sep 8, 2009, 8:38:03 PM9/8/09
to biffe...@googlegroups.com
Started to test i2c but spent some time re-wiring my breadboard.
I've selected my digital temperature sensor DS1721 for the tests,
since I've already explained how it works in my i2c topic!

Still haven't moved any further, just to know if anyone else is testing it,
to get some feedback on how the tests are going on.

Here is what I've done:

- Compiled OnFlashSystem for kernel 2.6.30.5 and removed 1-wire and spi
support to gain some of space for extra apps. Used the kernel command line:

console=uart,io,0x3f8 i2c-gpio-custom.bus0=0,12,9

1st command is only necessary for BIFFBOOT<=V2 (really need to upgrade this soon).
I've separated the commands with space, didn't thought that comma would work!

It seems to work, during boot I got this:
[    0.948058] i2c-gpio i2c-gpio.0: using pins 12 (SDA) and 9 (SCL)

I have started to read i2c documentation but couldn't get the necessary
concentration to make sense out of it, will need to review it another day.

Have compiled my old C code that I used on the OpenWrt to communicate
with the DS1721 and got it to compile under dietlibc to get some light apps.
Have sent this to bifferboard but it didn't work! OK, really need to get back
to documentation to sort that out!

No tools available (i2cdetect) so will really need to rely on my digital protocol
analyzer.

If someone has some useful tips, please feel free to share !!!

Regards,
Nelson.

Sunspot

unread,
Sep 9, 2009, 4:34:50 AM9/9/09
to Bifferboard
I cheer from the touch line!

i2cget and i2cset are very useful
http://www.sunspot.co.uk/Projects/SWEEX/slug/i2c/LCD03_i2c.html
so I hope you get i2c tools - including i2cdetect - to run.

Go, go, go!

On Sep 9, 1:38 am, Nelson Neves <nelson.s.ne...@gmail.com> wrote:
> Started to test i2c but spent some time re-wiring my breadboard.
> I've selected my digital temperature sensor DS1721 for the tests,
> since I've already explained how it works in my i2c topic!
>
> Still haven't moved any further, just to know if anyone else is testing it,
> to get some feedback on how the tests are going on.
>
> Here is what I've done:
>
> - Compiled OnFlashSystem for kernel 2.6.30.5 and removed 1-wire and spi
> support to gain some of space for extra apps. Used the kernel command line:
>
> *console=uart,io,0x3f8 i2c-gpio-custom.bus0=0,12,9*
>
> 1st command is only necessary for BIFFBOOT<=V2 (really need to upgrade this
> soon).
> I've separated the commands with space, didn't thought that comma would
> work!
>
> It seems to work, during boot I got this:
> *[    0.948058] i2c-gpio i2c-gpio.0: using pins 12 (SDA) and 9 (SCL)*
>
> I have started to read i2c documentation but couldn't get the necessary
> concentration to make sense out of it, will need to review it another day.
>
> Have compiled my old C code that I used on the OpenWrt to communicate
> with the DS1721 and got it to compile under dietlibc to get some light apps.
> Have sent this to bifferboard but it didn't work! OK, really need to get
> back
> to documentation to sort that out!
>
> No tools available (i2cdetect) so will really need to rely on my digital
> protocol
> analyzer.
>
> If someone has some useful tips, please feel free to share !!!
>
> Regards,
> Nelson.
>
> On Sun, Sep 6, 2009 at 6:46 PM, biffe...@yahoo.co.uk
> <biffe...@yahoo.co.uk>wrote:

bifferos

unread,
Sep 9, 2009, 5:06:07 AM9/9/09
to Bifferboard
You could start with getting i2c-detect working, rather than your own
program.

By the way: I have just uploaded a new biffinitrd tarball, which uses
hush instead of ash, and job control now works, unfortunately ls -l
doesn't for some reason. This should allow you to use the standard
kernel config of mine, and fit more of your stuff on flash.

On Sep 9, 1:38 am, Nelson Neves <nelson.s.ne...@gmail.com> wrote:
> Started to test i2c but spent some time re-wiring my breadboard.
> I've selected my digital temperature sensor DS1721 for the tests,
> since I've already explained how it works in my i2c topic!
>
> Still haven't moved any further, just to know if anyone else is testing it,
> to get some feedback on how the tests are going on.
>
> Here is what I've done:
>
> - Compiled OnFlashSystem for kernel 2.6.30.5 and removed 1-wire and spi
> support to gain some of space for extra apps. Used the kernel command line:
>
> *console=uart,io,0x3f8 i2c-gpio-custom.bus0=0,12,9*
>
> 1st command is only necessary for BIFFBOOT<=V2 (really need to upgrade this
> soon).
> I've separated the commands with space, didn't thought that comma would
> work!
>
> It seems to work, during boot I got this:
> *[    0.948058] i2c-gpio i2c-gpio.0: using pins 12 (SDA) and 9 (SCL)*
>
> I have started to read i2c documentation but couldn't get the necessary
> concentration to make sense out of it, will need to review it another day.
>
> Have compiled my old C code that I used on the OpenWrt to communicate
> with the DS1721 and got it to compile under dietlibc to get some light apps.
> Have sent this to bifferboard but it didn't work! OK, really need to get
> back
> to documentation to sort that out!
>
> No tools available (i2cdetect) so will really need to rely on my digital
> protocol
> analyzer.
>
> If someone has some useful tips, please feel free to share !!!
>
> Regards,
> Nelson.
>
> On Sun, Sep 6, 2009 at 6:46 PM, biffe...@yahoo.co.uk
> <biffe...@yahoo.co.uk>wrote:

Nelson Neves

unread,
Sep 9, 2009, 9:06:13 AM9/9/09
to biffe...@googlegroups.com
i2c-detect is part of the lm-sensors project
http://www.lm-sensors.org/wiki/I2CTools

I'll have a look into it, will probablly need some help from the Linux gurus,
don't really know if its possible to get this tools compiled and get it passed
through dietlibc to get a very small exe!

I saw a new biffinitrd yesterday, version 5, I had just updated to version 4
and since I was trying i2c stuff dind't had time to try it out. Thanks for the
tip, will get new version 5 into my stuff right away!

Thanks,
Nelson.

bifferos

unread,
Sep 9, 2009, 9:13:37 AM9/9/09
to Bifferboard
On Sep 9, 2:06 pm, Nelson Neves <nelson.s.ne...@gmail.com> wrote:
> i2c-detect is part of the lm-sensors projecthttp://www.lm-sensors.org/wiki/I2CTools
>
> I'll have a look into it, will probablly need some help from the Linux
> gurus,
> don't really know if its possible to get this tools compiled and get it
> passed
> through dietlibc to get a very small exe!

You could always just compile it static, and wget the file across to
your board, just to check it's working. You don't have to use
dietlibc yet. If you can't enum. the devices on the bus, then nothing
else will work, so it's certainly worth testing that first.

Nelson Neves

unread,
Sep 9, 2009, 9:22:20 AM9/9/09
to biffe...@googlegroups.com
OK, that's really a good point! Will stick to that! Thanks!

ps: I'm having windowze software development training at the moment, so may brain
is getting fried! The just hope that linux get it back again! Lol.

Nelson Neves

unread,
Sep 9, 2009, 10:57:37 AM9/9/09
to biffe...@googlegroups.com
I think I got i2c-tools statically compiled, if anyone wants to try it or just double check if it's ok:

1) get source code:
svn checkout http://lm-sensors.org/svn/i2c-tools/trunk i2c-tools

> cd i2c-tools
> cd tools

Edit Module.mk
under # Programs add -static just after $(CC) $(LDFLAGS) for all 4 apps (i2cdetect, i2cdump, i2cset, i2cget)

cd ..
make clean; make;

And that's it! Testing dynamic library dependencies:
ldd ./tools/i2cdetect

Seems OK, also apps jump from 20Kb to 600Kb! Will need to test this tonight!

Fingers crossed! Let just hope that this helps!

Regards,
Nelson.

bifferos

unread,
Sep 9, 2009, 11:06:13 AM9/9/09
to Bifferboard

But in any case, when dietlibc works it's not rocket science, when it
doesn't, it can be tricky to figure out what to do. Wait until you
see it fail before you start worrying! :-)

Looks like you'll have no problems:

wget http://dl.lm-sensors.org/i2c-tools/releases/i2c-tools-3.0.2.tar.bz2
tar xf i2tools-3.0.2.tar.bz2
cd i2ctools-3.0.2
make CC="diet gcc -nostdinc"
ls -l tools/i2cdetect
-rwxr-xr-x 1 wrt users 29428 2009-09-09 16:11 tools/i2cdetect

... took me all of about 3 minutes. Longer to write this email :-).

Good luck,
Biff.

On Sep 9, 2:22 pm, Nelson Neves <nelson.s.ne...@gmail.com> wrote:
> OK, that's really a good point! Will stick to that! Thanks!
>
> ps: I'm having windowze software development training at the moment, so may
> brain
> is getting fried! The just hope that linux get it back again! Lol.
>

bifferos

unread,
Sep 9, 2009, 11:09:03 AM9/9/09
to Bifferboard
Just uploaded my versions, in case it helps.
http://sites.google.com/site/bifferboard/Home/howto/faster-route-to-kernel--initrd

On Sep 9, 4:06 pm, bifferos <biffe...@yahoo.co.uk> wrote:
> But in any case, when dietlibc works it's not rocket science, when it
> doesn't, it can be tricky to figure out what to do.  Wait until you
> see it fail before you start worrying! :-)
>
> Looks like you'll have no problems:
>
> wgethttp://dl.lm-sensors.org/i2c-tools/releases/i2c-tools-3.0.2.tar.bz2

Nelson Neves

unread,
Sep 9, 2009, 11:53:25 AM9/9/09
to biffe...@googlegroups.com
Thanks Biff, I was trying to get there but had to go back to trainning :P.

3 minutes, oh yeah, one day I'll get there! Ahahahah!

Regards,
Nelson.

Nelson Neves

unread,
Sep 9, 2009, 2:35:02 PM9/9/09
to biffe...@googlegroups.com
i2c-tools are running (not meaning that they are OK, still need to test it right).

running i2cdetect I found my 1st problem:

/ # i2cdetect -y 0
Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directory

listing /dev content:
/dev # ls
ram
ptmx
null
tty2
tty3
tty0
console
tty5
tty4
tty1
ttyS0

I had the idea the i2c-gpio-custom would create such device file ... hum, well it's something!

Regards,
Nelson.

bifferos

unread,
Sep 9, 2009, 2:58:53 PM9/9/09
to Bifferboard
On Sep 9, 7:35 pm, Nelson Neves <nelson.s.ne...@gmail.com> wrote:
> i2c-tools are running (not meaning that they are OK, still need to test it
> right).
>
> running i2cdetect I found my 1st problem:
>
> / # i2cdetect -y 0
> Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or
> directory
>
> listing /dev content:
> /dev # ls
> ram
> ptmx
> null
> tty2
> tty3
> tty0
> console
> tty5
> tty4
> tty1
> ttyS0
>
> I had the idea the i2c-gpio-custom would create such device file ... hum,
> well it's something!

Yeah - I thought so too. But didn't you get this working with OpenWrt
once before? You can create these device files with mknod so long as
you know what minor/major device number to use.

> Regards,
> Nelson.
>

Nelson Neves

unread,
Sep 9, 2009, 6:29:08 PM9/9/09
to biffe...@googlegroups.com
Yeah - I thought so too.  But didn't you get this working with OpenWrt
once before?  You can create these device files with mknod so long as
you know what minor/major device number to use.

This device files have to be created befor module i2c-gpio-custom is created right?
If so, where should I do this?

In OpenWrt it was all working, just needed to load module!

Found some sites that used this:
mknod i2c-0 c 89 0
mknod i2c0 c 89 0
mknod i2c-1 c 89 1
mknod i2c1 c 89 1
not really sure if this should be the right configuration, should only require i2c-0 and/or i2c0 (I think).
I tried to create it after booting, the files are created but when running i2cdetect -y 0:
Error: Could not open file `/dev/i2c-0': No such device or address
but it's there (probably no linked to module).

That is just my idea, I'm a bit of my knowledge, just speculating and trying to get it right!

Nelson Neves

unread,
Sep 9, 2009, 6:45:10 PM9/9/09
to biffe...@googlegroups.com
ps: forgot to mention the source: http://openwrt.pbworks.com/I2C

Regards,
Nelson.

Nelson Neves

unread,
Sep 9, 2009, 8:07:25 PM9/9/09
to biffe...@googlegroups.com
/dev # i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --                        
/dev #

That my friend it's my DS1721 (digital temperature sensor) responding to the scan ! Oh yeah!

Here is what I've done, still need some more test to check if all of this is necessary or not:

- while configuring the kernel activated option:
[*] Device Driver -> I2C Support -> I2C device interface

- after booting:
> cd /dev
> mknod /dev/i2c-0 c 89 0

Tomorrow will make some more test to get this cleared!

Regards,
Nelson.

bifferos

unread,
Sep 9, 2009, 8:26:55 PM9/9/09
to Bifferboard
That's cool! We got that far with the old i2c code, but a promising
start anyway. I will add the i2c dev interface in the next kernel
config I post.

Nelson Neves

unread,
Sep 10, 2009, 7:03:13 PM9/10/09
to biffe...@googlegroups.com
Wohoooo, hurray, It's working!!!

OK, after cooling down - it's still working!

See it for your self:

/ # i2cdetect -y 0

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --                        
/ # ds1721
usage: ds1721 [I2C_address]/ # ds1721 72
I2Cdev[72] -> AccessConfig=ac, 12Bits=c, AutoMode=51
/ # ds1721_read 72
Result 31, 208

-> Spraying some Freeze over it !!!

/ # ds1721_read 72
Result 15, 192
/ # ds1721_read 72
Result 18, 224
/ # ds1721_read 72
Result 20, 176
/ # ds1721_read 72
Result 21, 144
/ # ds1721_read 72
Result 22, 0
/ # ds1721_read 72
Result 22, 176
/ # ds1721_read 72
Result 23, 64
/ # ds1721_read 72
Result 23, 176
/ # ds1721_read 72
Result 28, 0
/ # ds1721_read 72
Result 30, 112
/ # ds1721_read 72
Result 30, 160
/ # ds1721_read 72
...


Damn, it is hot over here!

OK, still need to test with some other devices at the same time, but I'm a bit busy at the moment, will also let some fun for others to :P

I'll post my C code and the compiled applications next to i2c-tools, here:
http://sites.google.com/site/bifferboard/Home/howto/faster-route-to-kernel--initrd

ds1721 - will configure sensor - sets sensor in auto-update buffer mode (only required once for every boot
ds1721_read - requests temperature from sensor buffer

To compile this you will also require to install dietlibc. Extract files with tar zxvf and then compile it with make.

Once again, thanks Biff for all your effort!

Regards,
Nelson.

Nelson Neves

unread,
Sep 10, 2009, 7:27:45 PM9/10/09
to biffe...@googlegroups.com
Source code attached here: http://sites.google.com/site/bifferboard/Home/howto/faster-route-to-kernel--initrd/i2cdevices.tar.gz?attredirects=0

Compiled applications are inside tar.gz file.

Forgot to mention earlier, DS1721 chips is found by i2cdetect at 0x48 address, meaning that decimal value = 72. When using the compiled app. will use the decimal value!

This code is not optimized, the main purpose was for tests only. Use it at your own risc! To adapt it you will need to study your chip because they all differ from each other! Datasheets are your best friends :) !

Regards,
Nelson.


Jonathan Roozing

unread,
Sep 11, 2009, 8:15:25 AM9/11/09
to biffe...@googlegroups.com
Hi,

It's good to see this progress.
What about the spi driver?
I'll need this in the near future.

Regards,
MRX



--- On Fri, 9/11/09, Nelson Neves <nelson....@gmail.com> wrote:

Nelson Neves

unread,
Sep 11, 2009, 8:30:53 AM9/11/09
to biffe...@googlegroups.com
Hi Jonathan,

Haven't tested SPI, but it's a very simple protocol, just needs to shit-register data synchronized with clock, if there is some problem (that I don't think it would have) you can always emulate it from your code!

Nevertheless , whenever I have some free time I can test it with real hardware! Now I just want to make sure that i2c is running with no problems!

Again, if someone else can give it a run would be nice! If you don't have the hardware, you can always ask for free samples ;)

There are some nice notes here to adjust Voltage level from 3.3VDC to 5VDC (i2c lines from GPIO are 3.3VDC and normally the chip/sensors runt at 5VDC - I get the 5VDC from the Bifferboard power supply and the 3.3VCD from GPIO pin):
http://www.sunspot.co.uk/Projects/SWEEX/i2c_notes.html

Regards,
Nelson.

bifferos

unread,
Sep 11, 2009, 8:31:54 AM9/11/09
to Bifferboard
SPI-over-GPIO is working AFAIK. Which device are you talking about?

On Sep 11, 1:15 pm, Jonathan Roozing <jrooz...@yahoo.com> wrote:
> Hi,
>
> It's good to see this progress.
> What about the spi driver?
> I'll need this in the near future.
>
> Regards,
> MRX
>
> --- On Fri, 9/11/09, Nelson Neves <nelson.s.ne...@gmail.com> wrote:

Jonathan Roozing

unread,
Sep 13, 2009, 7:49:34 AM9/13/09
to biffe...@googlegroups.com
Thanks for the reply's.

Somehow i had in mind that there were problems with spi too, so i didn't even try. Sorry about that. I want to use a VS1002. Now wireless is working
and i can play audio when it is decoded on my server (i use this all the time now) im quite convinced that i can turn the board into an mp3 player.
i first had the sta013 in mind, but i want the project to be available for everyboddy, this means no difficult soldering. So i found this: http://futurlec.com/Mini_MP3.shtml It looks very promising for a nice price. I dont have this board yet, but this will be my next project.


Greetz.


--- On Fri, 9/11/09, bifferos <biff...@yahoo.co.uk> wrote:

Nelson Neves

unread,
Sep 13, 2009, 11:47:36 AM9/13/09
to biffe...@googlegroups.com
Very nice project, something that can be used for other applications (having bifferboard to have voice debugging messages).

Don't want to get into a negative vibe, but I advise you to run some speed tests to check the max speed of the SPI bus!

If you are not in a hurry I can run some tests with this in a couple of weeks, will be busy testing some new stuff from Biff ;)

Regards,
Nelson.
Reply all
Reply to author
Forward
0 new messages