aoakley
Posts: 66
Joined: Fri May 11, 2012 10:27 pm
Contact: Website

DS3231 I2C RTC and g_ether - cannot use both?

Wed Jan 16, 2019 4:03 pm

Hi, I've got a couple of cheap DS3231 real-time-clock add-ons which work over I2C:

https://www.ebay.co.uk/itm//153061540451

After a considerable amount of trial and error, it would appear that these cannot be used at the same time as the USB gadget g_ether ethernet mode. Does anyone agree / disagree / know why please? Or, ideally, have a solution to make these two things work together?

I'm trying to create the "perfect" headless setup - aren't we all? ;-)

Starting with vanilla Raspbian Lite, the DS3231 RTC works fine with:

Code: Select all

Add the following to /boot/config.txt :
dtoverlay=i2c-rtc,ds3231

Enable I2C:
sudo raspi-config
Interfacing Options
Reboot e.g. shutdown -r now
Test the RTC with sudo hwclock -r
And again, starting with vanilla Raspbian Lite, g_ether works fine with:

Code: Select all

Add modules-load=dwc2,g_ether to /boot/cmdline.txt
Add dtoverlay=dwc2 to /boot/config.txt

However the following attempt to combine both RTC and g_ether does NOT work:
/boot/config.txt: dtoverlay=dwc2,i2c-rtc,ds3231
/boot/cmdline.txt: [...] modules-load=dwc2,g_ether

The result is that g_ether works fine, but:
sudo apt update && sudo apt install -y i2c-tools
sudo i2cdetect -y -1
...returns 68 which indicates that the DS3231 is being detected, but the kernel module is not being loaded (it should show UU if the RTC kernel module had loaded)

sudo hwclock -r shows: hwclock: Cannot access the Hardware Clock via any known method.

uname -r shows: 4.14.71+

I'm not quite sure whether I'm asking for help, asking for an explanation, or typing up some handy hints for someone else, but there you go.

--
Andrew Oakley, Cotswold Jam cotswoldjam.org
Next event Sat 2 March 2019, Cheltenham

ericcooper
Posts: 123
Joined: Sat Apr 08, 2017 6:23 pm

Re: DS3231 I2C RTC and g_ether - cannot use both?

Wed Jan 16, 2019 5:01 pm

I would try more permutations.
On my Pi Zeros, I have multiple dtoverlay lines in config.txt:

Code: Select all


# Enable USB driver
dtoverlay=dwc2

# Enable i2c real-time clock
dtoverlay=i2c-rtc,m41t62,wakeup-source

# Enable i2c accelerometer
dtoverlay=i2c-st-accel,lis3dh

# Enable i2c ADC
dtoverlay=ads1015,cha_enable,cha_cfg=4,chb_enable,chb_cfg=5
Maybe something similar will help? Also, I'd try just one of the modules in the modules-load parameter, and try loading the other after boot to see what errors if any are reported.

aoakley
Posts: 66
Joined: Fri May 11, 2012 10:27 pm
Contact: Website

Re: DS3231 I2C RTC and g_ether - cannot use both?

Thu Jan 17, 2019 10:56 am

Eric, could you post your /boot/cmdline.txt too please?
Andrew Oakley - Cotswold Raspberry Jam, Gloucestershire - http://www.cotswoldjam.org

ericcooper
Posts: 123
Joined: Sat Apr 08, 2017 6:23 pm

Re: DS3231 I2C RTC and g_ether - cannot use both?

Thu Jan 17, 2019 4:54 pm

Code: Select all

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_serial

Return to “Interfacing (DSI, CSI, I2C, etc.)”