Topic: openembedded and i2c

I followed the instructions posted here https://github.com/clearwater/chumby-oe to build openembedded Linux for my Chumby Hacker Board but that didn't result in any packages for the software development kit. After adding a 'make --continue world' option to the Makefile I was able to obtain all the packages that seemed to be needed to compile C programs on the CHB.

However the i2c motion sensor examples from the Adafruit website didn't seem to work, although it all worked fine using the original image that came with the CHB. After a bit of reading I determined that the mma7455 wasn't being initialised. Issuing the command "/usr/bin/i2c 58 wb 22 1" to put it in measurement mode fixed that.

Another difference that I noticed was that the i2c initialisation script /etc/init.d/i2c didn't work and produced the errors:

FATAL: Module i2c_pxa not found.
FATAL: Module i2c_dev not found.

According to the kernel config file used by the CHB openembedded recipe the i2c modules are supposed to be compiled into the kernel rather than installed as modules so I figure that this doesn't matter.

I'm wondering if there are some other packages in the openembedded version that I missed and that should have been installed to avoid these problems. Can anyone recommend a list of all the openembedded packages that should be built and installed to get the best out of the CHB? It would be good to not have to do an entire "make world" to get a workable development kit. Attempting to compile just a few packages at a time only seemed to result in missing dependency errors, but compiling everything takes a very long time.

2 (edited by guyc 2012-03-18 20:34:48)

Re: openembedded and i2c

I think the process of building an image for development would be something like this:

  • copy meta-chumby/recipes/images/chumby-starter-image.bb to a new recipe file, maybe chumby-dev-image.bb

  • modify the new recipe file to add task-native-sdk to the IMAGE_INSTALL list.

  • modify the Makefile to change the CHUMBY_IMAGE definition to chumby-dev-image

I hate to give untested advice, so I've created a dev-image branch on the github repo with those changes:
    https://github.com/clearwater/chumby-oe … 4d1d8b1891
I'm running a build now.  Once any issues are ironed out I'll merge that back into the main branch.
Probably makes sense to make this the new default build target too.

Re: openembedded and i2c

The chumby-dev-image builds correctly as described in the previous post.  When it is complete there seems to be a missing soft link to a critical gcc library.  I'll track that down later, but for now here's how the missing link exhibits and how it is fixed:

# gcc -o i2c i2c.c 
/usr/lib/gcc/arm-angstrom-linux-gnueabi/4.5.3/../../../../arm-angstrom-linux-gnueabi/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
# ln -s /lib/libgcc_s.so.1 /lib/libgcc_s.so
# gcc -o i2c i2c.c 
#

With this link in place, both i2c.c and mma7455.c from the adafruit page compile and run.

Your command to enter measurement mode seems to use a different syntax than the adafruit-supplied i2c tool.  Are you using a different i2c tool?  Regardless, using the tool on the page linked above, the following command works to set register 22 (0x16) to value 1 which puts the accelerometer in measurement mode.

# ./i2c w 58 22 1
Set register 16: 1 (1)

Having done that, the mma7455 tool shows varying x,y,z values when you run it and move the CHB.

# ./mma7455
X = -1  Y = -3  Z = 17
X = -1  Y = -3  Z = 17
X = -1  Y = -4  Z = 17
X = -1  Y = -4  Z = 17
...

FWIW I'm using a slightly later kernel version than the chumby-oe tools, but I don't think that affects anything here.

The new dev image recipe is now the default for https://github.com/clearwater/chumby-oe so you can just "git pull" to update the chumby-oe code and rebuild.

Re: openembedded and i2c

guyc wrote:

Your command to enter measurement mode seems to use a different syntax than the adafruit-supplied i2c tool.  Are you using a different i2c tool?
...
The new dev image recipe is now the default for https://github.com/clearwater/chumby-oe so you can just "git pull" to update the chumby-oe code and rebuild.

There are i2c and i2c-tools packages in openembedded which provide many more features than the twiddler.c example so I opted to install and use those instead. Probably should have mentioned that in my earlier post, but well spotted.

I'm trying the new default build now. Thanks for updating the repository with the modifications.

Re: openembedded and i2c

Oh cool, that sounds useful.   We should bake those i2c packages into the dev image too. 

I've just built and tested with i2c-tools-3.0.3-r0 but I didn't initially appreciate that i2c is a separate package.  Rebuilding now with i2c-1.0-r3, and I've also add ldd to help diagnose dynamic linking problems with the compiler.  Once I finish a validation test I will commit these changes to repository.

Re: openembedded and i2c

Your updated recipe worked fine here. I've just been digging around to see what else needs to be installed. I believe that installing the package libgcc-dev solves the missing link problem that you encountered above. It doesn't actually create the link that you created but instead installs the text file /usr/lib/libgcc_s.so which contains the following:

/* GNU ld script
   Use the shared library, but some functions are only in
   the static library.  */
GROUP ( libgcc_s.so.1 libgcc.a )

I have a hunch that that represents a more robust solution. wink

7 (edited by guyc 2012-03-19 21:13:32)

Re: openembedded and i2c

Ahh fantastic, that's the key I was looking for!  Agreed, much better than the link hack.  And fascinating - I did not know you could create a scripted .so.

That package, and the i2c packages have now been added to the chumby-dev-image recipe.