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++

i2c bus not work i think ?

Altera_Forum
Honored Contributor II
4,505 Views

I have add the I2C opencores component in SOPC builder, add the logic in quartus and assigned the pins.  

copiled the kernell en filesystem. 

 

i have started the i2cset 

I get this on my console. 

 

uClinux/Nios II Altera Nios II support (C) 2004 Microtronix Datacom Ltd. Built 1 zonelists Kernel command line: root=/dev/mtdblock0 ro PID hash table entries: 128 (order: 7, 2048 bytes) Dentry cache hash table entries: 4096 (order: 2, 16384 bytes) Inode-cache hash table entries: 2048 (order: 1, 8192 bytes) Memory available: 14416k/16384k RAM, 0k/0k ROM (1447k kernel code, 327k data) Mount-cache hash table entries: 512 (order: 0, 4096 bytes) NET: Registered protocol family 16 NIOS serial driver version 0.0 ttyS0 (irq = 4) is a builtin NIOS UART Serial: JTAG UART driver $Revision: 1.3 $ ttyJ0 at MMIO 0x821208b0 (irq = 1) is a jtag_uart RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize smc_probe: 150000 Khz Nios SMSC LAN91C111 Driver (v2.1), (Linux Kernel 2.6) eth0: SMC91C11xFD(rev:1) at 0x82110300 IRQ:6 MEMSIZE:8192b NOWAIT:0 ADDR: 00:07: ed:0d:b1:df smc_probe: 150000 Khz Nios Using anticipatory io scheduler Altera NDK flash (AMD): Found 1 x16 devices at 0x0 in 8-bit bank Amd/Fujitsu Extended Query Table at 0x0040 Altera NDK flash (AMD): CFI does not contain boot bank location. Assuming top. number of CFI chips: 1 cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness. cmdlinepart partition parsing not available RedBoot partition parsing not available Using Altera NDK partition definition Creating 4 MTD partitions on "Altera NDK flash (AMD)": 0x00200000-0x00600000 : "romfs/jffs2" 0x00000000-0x00200000 : "loader/kernel" 0x00600000-0x00700000 : "User configuration" 0x00700000-0x00800000 : "safe configuration" NET: Registered protocol family 2 IP: routing cache hash table of 512 buckets, 4Kbytes TCP: Hash tables configured (established 1024 bind 2048) NET: Registered protocol family 1 NET: Registered protocol family 17 VFS: Mounted root (romfs filesystem) readonly. Freeing unused kernel memory: 48k freed (0x119e000 - 0x11a9000) expand: from=/ramfs.img to=/dev/ram0 expand: from=/ramfs.img to=/dev/ram1 eth0:PHY 100BaseT eth0:PHY Full Duplex /etc/issue              www.microtronix.com               July 2004                   Welcome to Linux on the Nios II Nios2 login: nios Password: # cd # cd bin# i2cset Syntax: i2cset I2CBUS CHIP-ADDRESS DATA-ADDRESS VALUE  MODE is 'b' or 'w' (default b)  I2CBUS is an integer Error: No I2C busses found! Be sure you have done 'modprobe i2c-dev' and also modprobed your i2c bus drivers#  

 

Has someone any suggestions what i can do ??
0 Kudos
9 Replies
Altera_Forum
Honored Contributor II
2,906 Views

can you run i2cdetect and see what it finds? 

 

# i2cdetect Error: No i2c-bus specified! Syntax: i2cdetect I2CBUS  I2CBUS is an integer  With -f, scans all addresses (NOT RECOMMENDED)  With -q, uses only quick write commands for probing (NOT RECOMMENDED)  With -r, uses only read byte commands for probing (NOT RECOMMENDED)  If provided, FIRST and LAST limit the probing range.  i2cdetect -l lists installed busses only  Installed I2C busses:    i2c-0       unknown         Opencores i2c 0    Algorithm unavailable    i2c-1       unknown         Opencores i2c 1    Algorithm unavailable
0 Kudos
Altera_Forum
Honored Contributor II
2,906 Views

I get this 

 

# i2cdetect Error: No i2c-bus specified! Syntax: i2cdetect I2CBUS  I2CBUS is an integer  With -f, scans all addresses (NOT RECOMMENDED)  With -q, uses only quick write commands for probing (NOT RECOMMENDED)  With -r, uses only read byte commands for probing (NOT RECOMMENDED)  If provided, FIRST and LAST limit the probing range.  i2cdetect -l lists installed busses only Error: No I2C busses found! Be sure you have done 'modprobe i2c-dev' and also modprobed your i2c bus drivers#
0 Kudos
Altera_Forum
Honored Contributor II
2,906 Views

Did you enable the i2c support in the kernel? If not,  

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

Under the "Linux Kernel Configuration" interface, please goto submenu "Device Drivers" --> "I2C support",  then enable the following items: 

    I2C device interface 

    I2C Algorithms  ---> Opencores I2C interface 

    I2C hardware Bus support ---> Opencores I2C Adapter[/b] 

--- Quote End ---  

 

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

Make sure the following items are in the root filesystem: 

        /dev/i2c/0: character device, major 89, minor 0 

        /dev/i2c/1: character device, major 89, minor 1[/b] 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
2,906 Views

I was forgot to enable the option: 

 

I2C hardware Bus support ---> Opencores I2C Adapter 

 

when i build the kernell now ik get some error&#39;s  

the same in the topic " I2C Build errors, Where to define na_i2c_* variables "  

 

6.x/drivers/i2c/busses/i2c-oc.c:165: error: (near initialization for `oc_hw_0.irq&#39;) /cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/drivers/i2c/busses/i2c-oc.c:170: error: `na_i2c_1&#39; undeclared here (not in a function) /cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/drivers/i2c/busses/i2c-oc.c:170: error: initializer element is not constant /cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/drivers/i2c/busses/i2c-oc.c:170: error: (near initialization for `oc_hw_1.base&#39;) /cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/drivers/i2c/busses/i2c-oc.c:171: error: `na_i2c_1_irq&#39; undeclared here (not in a function) /cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/drivers/i2c/busses/i2c-oc.c:171: error: initializer element is not constant /cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/drivers/i2c/busses/i2c-oc.c:171: error: (near initialization for `oc_hw_1.irq&#39;) make: *** Error 1 make: *** Error 2 make: *** Error 2 make: *** Error 2 make: *** Error 2 make: Leaving directory `/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x&#39; 

 

your anser on that topic is  

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

They are defined in SOPC builder, and exported to Linux through a dynamic generated header file called nios2_system.h[/b] 

--- Quote End ---  

 

 

That file is in the worspace directory of the kernell\build\inlcude 

Must i adjust the file ? 

What must i add or change? 

 

Could you help me whith this ?
0 Kudos
Altera_Forum
Honored Contributor II
2,906 Views

I don&#39;t think you can change that file manually. It is checked (and updated if necessary) according to the system ptf file each time you build the kernel, so your manual changes will be removed.  

 

You need to instantiate the opencores i2c component in SOPC builder.
0 Kudos
Altera_Forum
Honored Contributor II
2,906 Views

I don&#39;t uderstand ?  

 

I just add the component to SOCP builder 

 

http://oege.ie.hva.nl/~koopma59/sopc1.gif (http://oege.ie.hva.nl/~koopma59/sopc1.gif)  

 

 

-> generate -> update the symbol -> assing pins&#39;s -> run compilation -> generate the kernell whit i2c support ? 

than i get the error&#39;s 

 

also i have try to add a "interface to user logic" i2c then add verilog files en so on. But i get the same kernell building error&#39;s
0 Kudos
Altera_Forum
Honored Contributor II
2,906 Views

sorry, it is me who do not understand. The driver assumes there are 2 i2c controllers, (this is bad). Can you go to delete one from the source? It is in file drivers/i2c/busses/i2c-oc.c. Just remove all occurences of oc_xxxx_1 (oc_data_1, oc_ops_1, oc_hw_1, etc) and code accessing them.

0 Kudos
Altera_Forum
Honored Contributor II
2,906 Views

I have got the kernell build whit no error&#39;s.  

 

This i think the solution is: 

 

When i add the component to the system in SOPC builder the name is "opencores_i2c_0"  

i rename it to "i2c_0" in the SOPC builder, the name in the nios2_system.h changes also. You must rerun SOPC an Quartus. 

 

Then i build the kernell en there where only error&#39;s on "i2c_1" and not on "i2c_0". 

I add a second i2c master to SOPC and also rename it to "i2c_1" then the kernell build;s wihout error&#39;s 

 

I don&#39;t have my kit with me so i will upload the kernell tomorrow and see if it is working.  

I it 22:00 hour at The Netherland now  

So it is just a name problem !!! I let you know if it is working tommorow
0 Kudos
Altera_Forum
Honored Contributor II
2,906 Views

It is working !! 

 

# i2cdetect Error: No i2c-bus specified! Syntax: i2cdetect I2CBUS  I2CBUS is an integer  With -f, scans all addresses (NOT RECOMMENDED)  With -q, uses only quick write commands for probing (NOT RECOMMENDED)  With -r, uses only read byte commands for probing (NOT RECOMMENDED)  If provided, FIRST and LAST limit the probing range.  i2cdetect -l lists installed busses only  Installed I2C busses:    i2c-1       unknown         Opencores i2c 1                         Algorith m unavailable    i2c-0       unknown         Opencores i2c 0                         Algorith m unavailable 

 

I get also pulses on the pins that i assginged. 

wehen i run "i2cdetect -f 0" or i2cdetect -f 1"
0 Kudos
Reply