element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum has anyone got a linux kernel driver for mcp79410 rtc  -solved
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 13 replies
  • Subscribers 665 subscribers
  • Views 3858 views
  • Users 0 members are here
  • mcp79410
  • rtc
  • raspberry_pi
  • rtcc
  • raspberrypi
  • kernel
  • linux
Related

has anyone got a linux kernel driver for mcp79410 rtc  -solved

Former Member
Former Member over 12 years ago

I originally ordered a BQ320000DR from farnell to make a rtc module for my raspberrypi. there is a kernel driver for this rtc i2c chip.

unfortunately, the chip still hasn't arrived, and in the mean-time I ordered a MCP79410-I/SN RTCC (i2c).

I can see this on the i2c bus (address 6F) but there doesn't appear to be kernel drivers for this device (mcp7941x series)

If there was another chip which was functionally the same, but with a kernel driver, I could just copy it's driver and change the chip name throughout the code.

 

does anyone know of a i2c chip for which there is kernel support, which is similar to the mcp79410?

 

I have the list of currently supported rtc chips (see drivers/rtc in the kernel source)

 

88pm80x,88pm860x,ab3100,ab8500,at32ap700x,at91rm9200,at91sam9,au1xxx,bfin,bq32k,bq4802,cmos,coh901331,core,da9052,davinci,dev,dm355evm,

ds1216,ds1286,ds1302,ds1305,ds1307,ds1374,ds1390,ds1511,ds1553,ds1672,ds1742,ds3232,ds3234,efi,em3027,ep93xx,fm3130,generic,imxdi,isl12022,

isl1208,jz4740,lib,lpc32xx,ls1x,m41t80,m41t93,m41t94,m48t35,m48t59,m48t86,max6900,max6902,max8925,max8998,mc13xxx,mpc5121,mrst,msm6242,

mv,mxc,nuc900,omap,pcap,pcf2123,pcf50633,pcf8563,pcf8583,pl030,pl031,pm8xxx,proc,ps3,puv3,pxa,r9701,rp5c01,rs5c313,rs5c348,rs5c372,rv3029c2,

rx8025,rx8581,s35390a,s3c,sa1100,sh,spear,starfire,stk17ta8,stmp3xxx,sun4v,sysfs,tegra,test,tile,twl,tx4939,v3020,vr41xx,vt8500,wm831x,wm8350,x1205

 

thanks

  • Sign in to reply
  • Cancel
  • Former Member
    Former Member over 12 years ago

    Hi Tim!

     

    You want the ds1307 driver, however it sort of depends which kernel you're running, the patch to add the mcp7941x series isn't in the 3.1.9+ kernel that's default in most of the current distros.  If you're ok with patching your kernel and re-compling it then you can find the patch here: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=43fcb81550f7a16be192b19c77a379c9b27b1585 but be aware that it may not apply cleanly to the older kernel depending on what other changes there were.

     

    However the patch did make it into 3.2, so if you don't want to mess with kernel compiling then have a look at Chris Boots kernel http://www.bootc.net/projects/raspberry-pi-kernel/

     

    I'd also suggest asking Raspberry Pi questions over in the Raspberry Pi section http://www.element14.com/community/groups/raspberry-pi?ICID=technologies_rpi_menubar. There's a fair number of us over there willing to help, but we're not necessarily going to see stuff here in the Experts section.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    thanks very much selsinork.

    My next challenge will be to get the 3.1.9 kernel source for my current armedslack install on my raspberrypi, as the source is not at kernel.org anymore;

    or, find out the config with special raspberrypi blobs and patches and see if I can get the 3.6rc1 kernel built instead. I'll post in the raspberry pi section in future, but there still seams to be a problem with posts dissapearing entirely on all the forums here at element14/farnell

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.1.9.tar.gz still seems to be there..

     

    'official' 3.1.9 kernel source for the Pi is available here https://github.com/raspberrypi/linux and this will include all the necessary drivers.

     

    You're unlikely to get 3.6rc1 working, there are too many missing pieces and there's a lot of changes to arm code between 3.1.9 and 3.6 making forward porting it far from simple..

    That said, if you're a wizard kernel developer then you should go look at  https://github.com/lp0/linux Simon Arlott and Chris Boot have done a bunch of work in this direction. You'll need this too https://github.com/raspberrypi/linux/wiki/Device-Tree-port and you probably want to sign up to the mailing list http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel

     

    It appears that either an admin moved the thread into the Raspberry Pi area, or it magically disappeared only to turn up in the right place on it's own image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    well I'm not a wizard kernel developer, I've compiled a few custom kernels for pc's but that's about it. Thanks for the pointer to the 3.1.9 kernel source. I should have hunted further on the site. I'l get that downloaded and see I can get the rtc module happy.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    just an update. I tried the patch on the kernel and it didn't like it, so I manually put in the changes roughly comparing them with the 3.6rc1. with modifying the include/linux/vermagic.h I can get the module to compile, but when I try insmod rtc-ds1307.ko it complains of an "-1 unknown symbol in module". the joys :-(

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • fustini
    fustini over 12 years ago in reply to Former Member

    What version of the kernel were you modifying for those changes in 3.6rc1?  The Foundation's 3.1.9+?

     

    (btw, in case it's any help, I wrote this document awhile back http://www.element14.com/community/docs/DOC-44948/l/compiling-linux-kernel-staging-driver-modules)


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to fustini

    yes, the 3.1.9+ one from github/raspberrypi/linux, although it looks like it may now have moved up a subversion - see https://github.com/raspberrypi/linux/blob/rpi-3.2.27/Makefile

    I'll have a look at your kernel (cross) compiling guide drew, and try that. I think part of the problem is that my slackware distribution was using the 3.1.9 kernel, but still had 2.6.38.4 source present as well. (in /usr/src). I used david (spencer's) kernel+installer from http://www.daves-collective.co.uk/raspi/images/raspi-slack-installer_01Aug12.img.xz

     

    since this post slackware 14.0 (and armedslack 14.0 ) has come out. this updates the source framework to 3.4.11

    hopefully dave will update his kernel installer/package for slackware from the 3.1.9 version to a 3.2.x or higher, as I belive that is required to add the rtc device to the kernel using the method posted http://www.element14.com/community/groups/raspberry-pi/blog/2012/07/19/what-time-is-it-adding-a-rtc-to-the-raspberry-pi-via-i2c 

    I am looking forward to testing the little module I made to see if it works!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to fustini

    I've just updated to the 3.6.1 kernel,(with slackware 14.0) and have been able to compile the rtc-ds1703 kernel module.

    I can install it with modprobe, but don't know how to tell the module that the device is at 0x6f on the i2c-0 port (ie. mcp79410) instead of 0x68 (ds1307) .

    i have /dev/i2c-0 and /dev/i2c-1 and if i do a i2cdetect 0 -y it shows the device at 0x6f

    i have tried

    echo mcp7941x 0x6f > /sys/class/i2c-adapter/i2c-0/new_device

    but I just get "no such file or directory" which is not a suprise as /sys/class/i2c-adapter does not exist. /sys/class/i2c-dev does, but substituting (ie using echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/new_device  ) still complains with error

    -bash /sys/class/i2c-dev/i2c-0/new_device: No such file or directory

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    modprobe rtc-ds1307

    echo mcp7941x 0x6f > /sys/bus/i2c/devices/i2c-0/new_device

     

    works for me on a slightly older kernel.. I've not checked 3.6.1 (why can't they stick to mainline ?) but if /sys/class/i2c-adapter doesn't exist, it's possible you're missing some other stuff. Do you have i2c-dev compiled in or loaded as a module ?

     

    Based on my older kernel it appears you'd want to use /sys/class/i2c-dev/i2c-0/device/new_device if you use that path.

     

    Have you read Documentation/i2c/instantiating-devices in the kernel tree ?   There's a couple of ways in there to get the device configured, my personal choice is to use platform data (i.e. method 1) which also lets you configure the kernel to automatically set the clock on boot.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    you hit the nail on the head, thanks. I just had a thought last night to look for "new_device" anywhere in the /sys/class/i2c-dev path and came up with the same location.

    so, once the rtc module is loaded with modprobe i2c:mcp7941x  (or insmod rtc_ds1307   )

     

    echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device

     

    creates the /dev/rtc0 device, and after a bit of prodding*, hwclock -w set the time on the rtc, and hwclock -s can now be used in /etc/rc.d/rc.local to set the system time from the rtc (and hwclock -r shows the rtc time and date)

    *(to explain the prodding. initially after running above, I got ioctl errors when running hwclock. I then did

    cat /dev/rtc0

      (and ctl-c ), and that seemed to fix the problem. I could then set the rtc with hwclock -w   .the proper behaviour was preserved after a cold restart of the raspberrypi  )

     

    Info for other armedslack raspberrypi users

    you need to recompile the kernel and add rtc support. specifically

    CONFIG_RTC_LIB=y

    CONFIG_RTC_CLASS=y

    CONFIG_RTC_HCTOSYS=y

    CONFIG_RTC_HCTOSYS_DEVICE="rtc0"

    CONFIG_RTC_INTF_SYSFS=y

    CONFIG_RTC_INTF_PROC=y

    CONFIG_RTC_INTF_DEV=y

     

    CONFIG_RTC_DRV_DS1307=m

    I used the the kernel, modules and kernel source from http://ponce.cc/slackware/slackwarearm-14.0/raspi-slackbuild-3.6.y/  (thanks to ponce) as a starting point.

     

    then compile and install i2c-tools from slackbuilds.org (sbopkg). this gives the i2c-dev module, so you can "talk" to i2c bus and provides the i2cdetect and i2cdump and similar tools for

    probing the i2c busses.

     

    my /etc/rc.d/rc.local includes the following lines at the bottom

    modprobe i2c-dev

    modprobe i2c:mcp7941x

    echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device

    hwclock -s

    Now I know my rtc gadget works, I'll have to find somewhere to post the circuit layouts for folks so they can make their own. The mcp79410 is quite a bit cheaper than the ds1307 and happens to run at 3.3v so you don't need any 5v-3.3v 2way buffering on the i2c bus. It also has battery backup function.

     

    thanks again for your assistance selsinork et-al

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube