- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a few questions about I2C interfaces on Nios II on Linux with MMU.
I found this thread http://www.alteraforum.com/forum/showthread.php?t=18441 (though forum search for "i2c" or "I2C" doesn't find it). It is a bit fragmented, and difficult to follow. I have a Microtronix i2c interface. Should the OpenCores drivers work with this? I defined I2C_0_BASE, I2C_0_IRQ based on my custom_fpga.h I2C_0_FREQ is being a bit trickier. I assumed it should be the i2c bus speed; however, I discovered that it seems to hang the system at boot if I don't define it as the system clock speed (85 MHz for me).Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you need I²C Master or Slave ?
AFAIK, there is a (not bit banging) open core I²C design. I'm not sure if same is already available for the Avalon bus and if there is a current Kernel driver in place. Do you think the Microtronix design offer advantages ? -Michael- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need the I2C to talk to an RTC chip, an M41T0.
I assume that means the I2C on the FPGA is the master, and the RTC is the slave. I have no idea if the Microtronix design has advantages over the OpenCores design. It is what the hardware guys put in the design.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With the RTC chip, of course the NIOS is the I²C Master.
For accessing just an RTC Chip, a bit banging I²C driver (no I²C-specific hardware) should work fine. Such a driver is standard in the Linux distribution. If the hardware guys decided to use a piece of hardware they of course will be able to tell you where to find the appropriate (and not outdated) driver. Microtronix usually do provide Linux drivers for their IP Cores. -Michael- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You will need to check the hardware. The hardware decides which driver to use.
I guess the microtronix one is opencore i2c. You have to make sure the component names match the config.c. The m41t00 uses the ds1307 driver. You will need to make sure the i2c address matches the config.c. Please refer to the wiki, http://www.nioswiki.com/operatingsystems/uclinux/video - Hippo- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've mapped the I2C component name from custom_fpga.h to the one used in config.c., with# defines in nios.h.
My custom_fpga.h does not have a frequency for the I2C. I tried a few differet vaues. When I use the CPU clock speed (85 MHz), it doesn't hang. When I start up, the I2C seems to be initializing correctly. It does not, however, recognize the RTC chip. I have selected the ds1307 driver. It does probe for the RTC. The RTC is an M41T0, not an M41T00. This makes it quite difficult to google anything on the chip.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please check your data sheet or user guide of the i2c daughter board to find out the exact part number.
What is the result of i2cdetect? Please note that you must match the i2c board info with the bus number, i2c address and i2c part in config.c, - Hippo- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have verified: M41T0.
Here is the relevant output from boot:i2c /dev entries driver
rtc-ds1307: probe of 0-0068 failed with error -5
i2c-0: I2C OpenCores Bus Adapter, MMIO = 0x2120C00, irq = 9
i2c-0: Using 85000kHz clock source
And when I run i2cdetect: /# i2cdetect 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? y
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
I have verified in the part data sheet that the device address is 0x68. I finally got my hands on the Microtronix driver, but it is in a full linux distribution, for nios2nommu. I'm working on getting the relevant pieces transfered into the MMU build.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think there are problems in your i2c setup from the i2cdetect output. I would suggest changing the interface to gpio because it is simple and easy to debug.
http://www.nioswiki.com/gpio - Hippo- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not quite ready to give up on the Microtronix I2C yet.
I think I have the Microtronix I2C driver compiled in, but it seems to have no connection to /dev/i2c-0 (so i2cdetect fails). Microtronix sent me their entire Linux distribution. (I think it is uClinux, as there is nios2nommu). I've copied over what I think are the relevant I2C files:- drivers/i2c/algos/i2c-algo-mtx.c
- drivers/i2c/algos/i2c-mtx.h
- drivers/i2c/busses/i2c-mtx.c
- include/linux/i2c-algo-mtx.h
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, I cannot help. I gave up i2c oc early and made gpio instead. It might be easier to modify the sopc design than fighting with a vendor driver. I cannot see the point to spend time on a simple i2c rtc interface.
- Hippo- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
> Microtronix sent me their entire Linux distribution.
What Kernel Version does same use ? The only Microtronix Linux I saw up till now was based on a very old Kernel Version that uses a quite different driver interface. To work with the community, you would need to use the community distribution and if you want to use the Microtronix IP-Core supposedly you would need to port the driver to thr new Kernel interface. -Michael- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried to find the kernel version today. Didn't see any sign of it. Any suggestions on where I should look?
I did notice that the files were dated May '07. at the latest. I did see some differences in the driver structure. I've asked the hardware guys about putting in the OpenCores I2C. If that fails, I'll be asking them for a bit-banging interface.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
> the files were dated May '07. at the latest.
That is what I feared :( > If that fails, I'll be asking them for a bit-banging interface. That would be very easy for them as it's a simple Bit I/O port. -Michael- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, I had them switch to the OpenCores I2C interface.
I pointed them at both http://www.opencores.org/project,i2c and http://www.niosforum.com/pages/project_details.php?p_id=111&t_id=18 as sources for the design. I compiled the kernel with I2C_0_FREQ defined as 400000 (400 kHz), and the ds1307 Real Time Clock support. The I2C initialized, and the RTC was read. I have not tried to write to the RTC, but the OpenCores I2C interface and driver seem to work just fine.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great !
Thanks for letting us know. :) -Michael
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page