mainsail-crew / MainsailOS

This Raspberry Pi distribution for managing Klipper 3D printers with Mainsail provides all you need.
https://docs.mainsail.xyz/setup/mainsail-os
GNU General Public License v3.0
546 stars 262 forks source link

fix: load `i2c-dev` modules #217

Closed ashthespy closed 1 year ago

ashthespy commented 1 year ago

This PR adds to #196 with the required bits to enable i2c by default.

Fixes: #216

You might also just want to use raspi-config's undocumented noint mode directly from the chroot script? And then use some sed magic to add the comments from #196 to config.txt.

KwadFan commented 1 year ago

Hey @ashthespy ,

First of all thank you for your contribution! Unfortunatly, your patch does not work as intended. The build test failed. Bildschirmfoto_2023-04-08_13-14-04

Please create this file using the unpack function. If you are interessted in doing it via raspi-config nonint I would prefer that method.

As soon the build is successful and we tested the resulting image, we will merge your fix and asap release a new version.

Regards Kwad

ashthespy commented 1 year ago

Have switched to raspi-config nonint, which should be more future/backwards friendly. It may just need a sudo, will know after the CI runs :-)

KwadFan commented 1 year ago

So, build was successful but didnt work for me. image

I had to activate it in raspi-config to get it work.

ashthespy commented 1 year ago

Will have a look, need to set up a build environment first..

KwadFan commented 1 year ago

Will have a look, need to set up a build environment first..

This is quite simple. Enable actions in your develop repo, then it should build an Image for debugging in your PR Branch, if it fails to start automaticly, you could force it to run via workflow_dispatch

ashthespy commented 1 year ago

Yeah, looks like using raspi-config won't work, will got back to enabling the module directly.

Enabling i2c-dev
+ echo -e -n '\e[0m'
+ raspi-config nonint do_i2c 0
mount: /config/device-tree: mount point does not exist.
* Failed to mount configfs - 2
modprobe: FATAL: Module i2c-dev not found in directory /lib/modules/5.15.0-1035-azure
ashthespy commented 1 year ago

That should now work.

pi@mainsailos:~ $ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

i2c-dev
bcm2835-v4l2

pi@mainsailos:~ $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Sorry for the multiple attempts, it took a while to get up to speed with the workflow here :-)

Not sure how you feel, but it might be smart to include i2c-tools as part of the default packages?

KwadFan commented 1 year ago

Good point, would you mind to extend your PR?

ashthespy commented 1 year ago

Done 👍

KwadFan commented 1 year ago

A test of @meteyou went very well, so, will test that also, but think we can merge it soon.

KwadFan commented 1 year ago

My test went also well, so LGTM!