Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12606 Discussions

Opencores I2C Core and uClinux Driver

Altera_Forum
Honored Contributor II
2,938 Views

I have added an Altera Avalon SOPC Builder I2C Master component based on the Opencores I2C Host.  

 

http://via.dynalias.org/svn/fpga/cores/i2c_master/trunk/ (http://via.dynalias.org/svn/fpga/cores/i2c_master/trunk/

 

Either download using the web, or use SVN to check out the project.. 

 

I simply created a wrapper for this and the necessary files to drop this component onto the Avalon bus, so I don't take any credit for this core. This will just make it easier for new people not wishing to go through this hassle. 

 

Also, I am working on getting the uClinux driver up and running. There is an Opencores driver already included in 2.6.16.1, so I will just be modifying/testing that and posting the results here. 

 

J
0 Kudos
16 Replies
Altera_Forum
Honored Contributor II
595 Views

The kernel patch for 2.6.16.1 is located here: 

 

http://via.dynalias.org/svn/uclinux/patche..._core/tags/1.0/ (http://via.dynalias.org/svn/uclinux/patches/i2c_core/tags/1.0/

 

This is only a simple modification of the Mictronix driver, so that it compiles with a single core. Credit goes to Microtronix for the core.
0 Kudos
Altera_Forum
Honored Contributor II
595 Views

TO_BE_DONE

0 Kudos
Altera_Forum
Honored Contributor II
595 Views

It is due to kernel version changed to 2.6.17 in uClinux-dist-20060803. 

I will check it tommorow.
0 Kudos
Altera_Forum
Honored Contributor II
595 Views

The include file is missing. 

Updated in the nios2 patch ver 10.
0 Kudos
Altera_Forum
Honored Contributor II
595 Views

Hippo, 

 

Did all that, and still get the following 

 

make: Entering directory `/home/uclinux/uClinux-dist/linux-2.6.x&#39;  CHK     include/nios2_system.h perl -I/home/uclinux/uClinux-dist/linux-2.6.x/arch/nios2nommu/scripts /home/uclinux/uClinux-dist/linux-2.6.x/arch/nios2nommu/scripts/gen_nios2_system.h.pl cpu ddr_sdram ext_flash < /windows/downloaded/std_2C35.ptf > include/nios2_system.h.tmp; if && cmp -s include/nios2_system.h include/nios2_system.h.tmp; then rm -f include/nios2_system.h.tmp; else echo &#39;  UPD     include/nios2_system.h&#39;; mv -f include/nios2_system.h.tmp include/nios2_system.h; fi  CHK     include/linux/version.h  SPLIT   include/linux/autoconf.h -> include/config/*  CHK     include/linux/compile.h  CC      drivers/i2c/i2c-core.o  CC      drivers/i2c/i2c-dev.o  CC      drivers/i2c/algos/i2c-algo-bit.o  CC      drivers/i2c/algos/i2c-algo-oc.o drivers/i2c/algos/i2c-algo-oc.c:51: error: syntax error before string constant drivers/i2c/algos/i2c-algo-oc.c:51: warning: type defaults to `int&#39; in declaration of `MODULE_PARM&#39; drivers/i2c/algos/i2c-algo-oc.c:51: warning: function declaration isn&#39;t a prototype drivers/i2c/algos/i2c-algo-oc.c:51: warning: data definition has no type or storage class drivers/i2c/algos/i2c-algo-oc.c:374: error: unknown field `name&#39; specified in initializer drivers/i2c/algos/i2c-algo-oc.c:374: warning: initialization from incompatible pointer type drivers/i2c/algos/i2c-algo-oc.c:375: error: unknown field `id&#39; specified in initializer drivers/i2c/algos/i2c-algo-oc.c:375: error: `I2C_ALGO_OC&#39; undeclared here (not in a function) drivers/i2c/algos/i2c-algo-oc.c:375: error: initializer element is not constant drivers/i2c/algos/i2c-algo-oc.c:375: error: (near initialization for `oc_algo.smbus_xfer&#39;) drivers/i2c/algos/i2c-algo-oc.c: In function `i2c_oc_add_bus&#39;: drivers/i2c/algos/i2c-algo-oc.c:391: error: structure has no member named `id&#39; drivers/i2c/algos/i2c-algo-oc.c:385: warning: unused variable `oc_adap&#39; make: *** Error 1 make: *** Error 2 make: *** Error 2 make: *** Error 2 make: Leaving directory `/home/uclinux/uClinux-dist/linux-2.6.x&#39; make: *** Error 1 uclinux@colinux:~/uClinux-dist$
0 Kudos
Altera_Forum
Honored Contributor II
595 Views

hippo, 

 

In the customise kernel settings --> device driver --> i2c 

 

When I added  

 

i2c algorithms --> Opencores i2c interface 

i2c hardware bus support --> opencores i2c adapter 

 

It gives error when generating the zImage 

 

Pls help.
0 Kudos
Altera_Forum
Honored Contributor II
595 Views

update again, nios2 patch ver 11. 

fixup i2c for DE2.
0 Kudos
Altera_Forum
Honored Contributor II
595 Views

Hippo, 

 

Tried that, still have problems: 

 

 CC      drivers/i2c/algos/i2c-algo-oc.o drivers/i2c/algos/i2c-algo-oc.c:484: error: redefinition of &#39;i2c_debug&#39; drivers/i2c/algos/i2c-algo-oc.c:66: error: previous definition of &#39;i2c_debug&#39; was here drivers/i2c/algos/i2c-algo-oc.c:500: error: redefinition of &#39;i2c_start&#39; drivers/i2c/algos/i2c-algo-oc.c:82: error: previous definition of &#39;i2c_start&#39; was here drivers/i2c/algos/i2c-algo-oc.c:506: error: redefinition of &#39;i2c_repstart&#39; drivers/i2c/algos/i2c-algo-oc.c:88: error: previous definition of &#39;i2c_repstart&#39; was here drivers/i2c/algos/i2c-algo-oc.c:512: error: redefinition of &#39;i2c_stop&#39; drivers/i2c/algos/i2c-algo-oc.c:94: error: previous definition of &#39;i2c_stop&#39; was here drivers/i2c/algos/i2c-algo-oc.c:518: error: redefinition of &#39;wait_for_bb&#39; drivers/i2c/algos/i2c-algo-oc.c:100: error: previous definition of &#39;wait_for_bb&#39; was here drivers/i2c/algos/i2c-algo-oc.c:542: error: redefinition of &#39;try_address&#39; drivers/i2c/algos/i2c-algo-oc.c:124: error: previous definition of &#39;try_address&#39; was here drivers/i2c/algos/i2c-algo-oc.c:564: error: redefinition of &#39;oc_sendbytes&#39; drivers/i2c/algos/i2c-algo-oc.c:146: error: previous definition of &#39;oc_sendbytes&#39; was here drivers/i2c/algos/i2c-algo-oc.c:602: error: redefinition of &#39;oc_readbytes&#39; drivers/i2c/algos/i2c-algo-oc.c:184: error: previous definition of &#39;oc_readbytes&#39; was here drivers/i2c/algos/i2c-algo-oc.c:641: error: redefinition of &#39;oc_doAddress&#39; drivers/i2c/algos/i2c-algo-oc.c:223: error: previous definition of &#39;oc_doAddress&#39; was here drivers/i2c/algos/i2c-algo-oc.c:711: error: redefinition of &#39;oc_xfer&#39; drivers/i2c/algos/i2c-algo-oc.c:293: error: previous definition of &#39;oc_xfer&#39; was here drivers/i2c/algos/i2c-algo-oc.c:785: error: redefinition of &#39;oc_func&#39; drivers/i2c/algos/i2c-algo-oc.c:367: error: previous definition of &#39;oc_func&#39; was here drivers/i2c/algos/i2c-algo-oc.c:792: error: redefinition of &#39;oc_algo&#39; drivers/i2c/algos/i2c-algo-oc.c:374: error: previous definition of &#39;oc_algo&#39; was here drivers/i2c/algos/i2c-algo-oc.c:793: error: unknown field `name&#39; specified in initializer drivers/i2c/algos/i2c-algo-oc.c:793: warning: initialization from incompatible pointer type drivers/i2c/algos/i2c-algo-oc.c:794: error: unknown field `id&#39; specified in initializer drivers/i2c/algos/i2c-algo-oc.c:794: error: `I2C_ALGO_OC&#39; undeclared here (not in a function) drivers/i2c/algos/i2c-algo-oc.c:794: error: initializer element is not constant drivers/i2c/algos/i2c-algo-oc.c:794: error: (near initialization for `oc_algo.smbus_xfer&#39;) drivers/i2c/algos/i2c-algo-oc.c:803: error: redefinition of &#39;i2c_oc_add_bus&#39; drivers/i2c/algos/i2c-algo-oc.c:383: error: previous definition of &#39;i2c_oc_add_bus&#39; was here drivers/i2c/algos/i2c-algo-oc.c: In function `i2c_oc_add_bus&#39;: drivers/i2c/algos/i2c-algo-oc.c:810: error: structure has no member named `id&#39; drivers/i2c/algos/i2c-algo-oc.c:804: warning: unused variable `oc_adap&#39; drivers/i2c/algos/i2c-algo-oc.c: At top level: drivers/i2c/algos/i2c-algo-oc.c:822: error: redefinition of &#39;i2c_oc_del_bus&#39; drivers/i2c/algos/i2c-algo-oc.c:399: error: previous definition of &#39;i2c_oc_del_bus&#39; was here drivers/i2c/algos/i2c-algo-oc.c:827: error: redefinition of &#39;i2c_algo_oc_init&#39; drivers/i2c/algos/i2c-algo-oc.c:404: error: previous definition of &#39;i2c_algo_oc_init&#39; was here drivers/i2c/algos/i2c-algo-oc.c:834: error: redefinition of &#39;i2c_algo_oc_exit&#39; drivers/i2c/algos/i2c-algo-oc.c:411: error: previous definition of &#39;i2c_algo_oc_exit&#39; was here drivers/i2c/algos/i2c-algo-oc.c:838: error: redefinition of &#39;__kstrtab_i2c_oc_add_bus&#39; drivers/i2c/algos/i2c-algo-oc.c:415: error: previous definition of &#39;__kstrtab_i2c_oc_add_bus&#39; was here drivers/i2c/algos/i2c-algo-oc.c:838: error: redefinition of &#39;__ksymtab_i2c_oc_add_bus&#39; drivers/i2c/algos/i2c-algo-oc.c:415: error: previous definition of &#39;__ksymtab_i2c_oc_add_bus&#39; was here drivers/i2c/algos/i2c-algo-oc.c:839: error: redefinition of &#39;__kstrtab_i2c_oc_del_bus&#39; drivers/i2c/algos/i2c-algo-oc.c:416: error: previous definition of &#39;__kstrtab_i2c_oc_del_bus&#39; was here drivers/i2c/algos/i2c-algo-oc.c:839: error: redefinition of &#39;__ksymtab_i2c_oc_del_bus&#39; drivers/i2c/algos/i2c-algo-oc.c:416: error: previous definition of &#39;__ksymtab_i2c_oc_del_bus&#39; was here drivers/i2c/algos/i2c-algo-oc.c:841: error: redefinition of &#39;__initcall_i2c_algo_oc_init&#39; drivers/i2c/algos/i2c-algo-oc.c:418: error: previous definition of &#39;__initcall_i2c_algo_oc_init&#39; was here drivers/i2c/algos/i2c-algo-oc.c:842: error: redefinition of &#39;__exitcall_i2c_algo_oc_exit&#39; drivers/i2c/algos/i2c-algo-oc.c:419: error: previous definition of &#39;__exitcall_i2c_algo_oc_exit&#39; was here make: *** Error 1 make: *** Error 2 make: *** Error 2 make: *** Error 2 make: Leaving directory `/home/uclinux/uClinux-dist/linux-2.6.x&#39; make: *** Error 1 uclinux@colinux:~/uClinux-dist$
0 Kudos
Altera_Forum
Honored Contributor II
595 Views

I think your source is OVER patched. ? 

Did you remove old patchby reverser patch ? 

Check "update the patches" in the UclinuxDist wiki page. 

Now you should remove old uCLinux-dist dir, and reinstall.
0 Kudos
Altera_Forum
Honored Contributor II
595 Views

hippo, i am trying it NOW ... standby.

0 Kudos
Altera_Forum
Honored Contributor II
595 Views

Hippo, 

 

OK. I can confirm, I have compiled the uclinux image w/o problem (w/ oc i2c master). 

 

Now, I need some things to test it. 

 

Can you point me to some apps and code for testing this ? 

 

I assume I have to create a device /dev/i2c-0 in romfs_list ? 

 

I will wire the hardware to some devices I have. Many thanks.
0 Kudos
Altera_Forum
Honored Contributor II
595 Views

 

--- Quote Start ---  

originally posted by albertyong88@Nov 3 2006, 06:30 AM 

hippo, 

 

ok. i can confirm, i have compiled the uclinux image w/o problem (w/ oc i2c master). 

 

now, i need some things to test it. 

 

can you point me to some apps and code for testing this ? 

 

i assume i have to create a device /dev/i2c-0 in romfs_list ? 

 

i will wire the hardware to some devices i have. many thanks. 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=19115) 

--- quote end ---  

 

--- Quote End ---  

 

Look in, linux-2.6.x/Documentation/i2c .
0 Kudos
Altera_Forum
Honored Contributor II
595 Views

Hippo, 

 

I tried to include lm_sensors (which includes i2ctools) in menuconfig, but it got error. 

 

Please help 

 

make: Entering directory `/home/uclinux/uClinux-dist/lib/sysfsutils&#39; rm -rf build mkdir build (cd build; sh ../configure --host=nios2-linux-uclibc --build=i686-pc-linux-gnu --target=nios2-linux-uclibc ) checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for nios2-linux-uclibc-strip... nios2-linux-uclibc-strip checking build system type... i686-pc-linux-gnu checking host system type... Invalid configuration `nios2-linux-uclibc&#39;: machine `nios2-linux&#39; not recognized configure: error: /bin/sh ../config.sub nios2-linux-uclibc failed make: *** Error 1 make: Leaving directory `/home/uclinux/uClinux-dist/lib/sysfsutils&#39; make: *** Error 2 make: Leaving directory `/home/uclinux/uClinux-dist/lib&#39; make: *** Error 2 make: Leaving directory `/home/uclinux/uClinux-dist/lib&#39; make: *** Error 1 uclinux@colinux:~/uClinux-dist$
0 Kudos
Altera_Forum
Honored Contributor II
595 Views

You should create a new topic for a new question. 

If the thread got too long, it is difficult to read by others.
0 Kudos
Altera_Forum
Honored Contributor II
595 Views

hey 

 

i tried to download the link from i2c master in the first post, but link does not match... could u pls update the link ?
0 Kudos
Altera_Forum
Honored Contributor II
595 Views

You may use software pio driver instead of hardware, see i2c-gpio in the wiki, and ver 32 of uClinux-dist patches. 

http://nioswiki.jot.com/wikihome/operatingsystems/video (http://nioswiki.jot.com/wikihome/operatingsystems/video)
0 Kudos
Reply