2

I am using Raspberry Pi3 B with

  • OS: Kali Linux
  • Kernal: 4.1.19-v7
  • RTC: DS3231 Real Time Clock

I configured I2C manually following the instruction here.
Steps I did:

  1. Install the i2c-tools utility

    sudo apt-get install python-smbus
    sudo apt-get install i2c-tools
    
  2. Install Kernel Support

    #Open 
    sudo nano /etc/modules
    #Paste
    i2c-bcm2708 
    i2c-dev
    
  3. Edit config.txt file

    #Open 
    sudo nano /boot/config.txt 
    #Paste 
    dtparam=i2c1=on
    dtparam=i2c_arm=on      
    

After configuration and reboot, I tested it with

sudo i2cdetect -y 1  

but getting the error:

Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory

What is the reason for the error? How could I fix this?
Is it even possible to install RTC on Kali Linux?

  • sudo modprobe i2c-dev – goldilocks Aug 11 '16 at 13:25
  • @goldilocks; I already added i2c-dev in /modules folder. – haccks Aug 11 '16 at 13:37
  • Sorry, missed that. Check it is loaded w/ sudo lsmod | grep i2c. Also check ls -1 /dev | grep i2c. Both of them should output something. The only required config.txt option is dtparam=i2c_arm=on. Also, I would remove i2c-bcm2708 from /etc/modules; technically the Pi 3 SoC uses a "BCM 2710" -- although I dunno if it matters WRT that module, just loading i2c-dev will pull in any required dependencies. If you have done both those things (enabled in config.txt, and i2c-dev is shown loaded with lsmod), you should have a /dev/i2c-1 node or something is wrong. – goldilocks Aug 11 '16 at 13:45
  • sudo lsmod | grep i2c shows the out put i2c_dev 5654 i2c_bcm2708 5020, but ls -1 /dev | grep i2c shows nothing. – haccks Aug 11 '16 at 13:51
  • I checked my 3 and it does use i2c_bcm2708. All I can say is I've been using the I2C bus for years on B/B+/2/3 models and that's all I've ever had to do as far as I can remember. Try powering down, unplug everything from the pins, and reboot. If the module is loaded you should get the dev node and i2cdetect -y 1 should work (but show nothing connected). If not something may be busted. Also double check config.txt to make sure nothing is overridden by multiple entries (and remove dtparam=i2c1=on). – goldilocks Aug 11 '16 at 13:56
2

First, check that the /boot/config.txt you are editing is actually the on the first partition of the SD card. Although it is not technically necessary, Raspbian is set up to mount this partition on /boot automatically, so online tutorials will refer to it that way -- and raspi-config, used in the Adafruit guide, presumes this is the case.

However, if the file doesn't exist it will be created, and if Kali doesn't use the scheme Raspbian does (comments here imply that), this means it will just create a file in the otherwise empty /boot directory, which won't actually be used when the system boots. The Pi makes use of a vfat formatted partition at the beginning of the SD card, where firmware and bootloader must be located (and generally also the kernel). You can set things up the same way by adding the following line to /etc/fstab:

/dev/mmcblk0p1  /boot           vfat    defaults          0       2

Note this will render anything actually in that directory inaccessible (but not delete it) although from the sounds of things there was nothing there to start with.

In any case, the contents of that partition -- /dev/mmcblk0p1 -- should resemble this -- and it must be there or the Pi would not work. That github repo actually doesn't contain a config.txt, but whether or not there's one there on your system, that partition is where you want to apply it. If you mount this before running raspi-config it should work out. If you don't want it in fstab, manually:

mount -t vfat /dev/mmcblk0p1 /boot

Kernal: 4.1.19-v7

This may be an issue. It predates the release of the Pi 3 and may never have been updated for it. Further, there is a Pi 3 specific device tree overlay in /boot and this implies you don't have that either.

You need to replace the contents of the /boot partition referred to above with this and copy the -v7+ modules directory from here into /lib/modules. It must remain named exactly the same.

  • Let me try. Will inform you. – haccks Aug 11 '16 at 14:20
  • I want to confirm that after copying -v7+ to /lib/modules do I need to remove 4.1.19-v7 or leave it as it is? – haccks Aug 11 '16 at 14:39
  • You don't need to remove it, but if everything works out it probably takes up 1-200 MB of space. If you want to keep your old kernel/boot partition then back that up (the whole thing only has ~35MB in it) and leave the modules directory. You can then put everything back as it was if necessary. Unfortunately Kali may require some obscure IP features for certain things (I dunno), so that's not a bad idea. If this works then those things don't, you'll have to compile your own kernel. – goldilocks Aug 11 '16 at 14:59
  • OK. I did the second step but I can see only two files are in my /boot directory cmdline.txt and config.txt. Should I copy all the contents of boot directory of link you provided with the /boot present directory? And I don't want to keep the old kernel unless it is necessary. – haccks Aug 11 '16 at 16:13
  • 1
    Okay, so here's the funny part: config.txt is actually read by the bootloader/firmware/kernel (not sure which, but probably one of the former two) from the first partition, so if you have have been editing a version of that file in your otherwise empty /boot partition, it was not being used. You need to find the one on the actual first partition and edit that to include dtparam=i2c_arm=on. – goldilocks Aug 11 '16 at 17:15
1

The only thing you should need to do is to add the following line to /boot/config.txt

dtoverlay=i2c-rtc,ds3231 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.