simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Add enable i2c option in raspi-config

Fri May 23, 2014 11:05 pm

Enabling I2C is a bit geeky to do but there are now £10 add-on boards with i2C devices on them.

SO I think it would be a good idea to have an option in raspi-config to enable the I2C bus to amek it easy for non-tech users (like teachers or youngsters) who just want to get on and program the device in Python or Scratch or anything for that matter

There is code in Github from heeed to do this as a basis for the change

https://github.com/heeed/pi2c

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Add enable i2c option in raspi-config

Sat May 24, 2014 3:23 am

Since programming the I2c bus requires that files be created by an editor, editing two files to enable the i2c buses seems trivial.

Put another way the Rpi is supposed to be an educational tool, not a plug and play device.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

tvjon
Posts: 730
Joined: Mon Jan 07, 2013 9:11 am

Re: Add enable i2c option in raspi-config

Sat May 24, 2014 8:42 am

"Put another way the Rpi is supposed to be an educational tool, not a plug and play device."

I've recently had such a discussion with a friend I'm helping in his educational robot development, & who uses Simon's useful Scratch additions (thank you for those).

Said friend wants to make things simpler & simpler, but where do you draw the line? If the students & teachers have reached the stage where they're using I2C, surely they can edit a couple of files?

Without the will to research & learn, it's hard to see how they'll be motivated enough to pursue electronics & computing beyond a curiosity stage.

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Add enable i2c option in raspi-config

Sat May 24, 2014 2:24 pm

Well, I use RaspberryPi as a tool to interface between Scratch and real-world devices so I go out of my way to minimise the geekyness required to get things up and running.

This is because my educational aim is to use it in primaries - not to configure it using cmd line tools.

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Add enable i2c option in raspi-config

Sat May 24, 2014 3:32 pm

simplesi wrote:Well, I use RaspberryPi as a tool to interface between Scratch and real-world devices so I go out of my way to minimise the geekyness required to get things up and running.
Computers are by definition "geeky". To get to the appliance stage or remove all "geekyness" is contrary to the Rpi's primary purpose. If you want plug and play, I recommend a Motorola Droid 2 or better.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Add enable i2c option in raspi-config

Sat May 24, 2014 9:05 pm

Well the Pi;'s purpose is to educate.

At primary level, having to cmd line edit several text files in order to get a LED board working from Scratch is counter productive on the educational front at this age :)

A few other things are configured in raspi-config so the concept has been around for a while.

Now that ready made i2c boards designed purely for educational market are appearing, then I feel there is a need to make it easier to use them (possibly to the point where I2C support is default and editing of text files is needed to go back to current situation)

This requirement is for the benefit of primary teachers/pupils/kids operating at a very basic level.

But you can rest easy as I don't think a single one of my suggestions has ever been acted upon :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
joan
Posts: 14655
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Add enable i2c option in raspi-config

Sat May 24, 2014 9:32 pm

The approach I take is to open the I2C/SPI device. If the open fails I modprobe i2c_dev, i2c_bcm2708, spi_bcm2708 as needed and retry the open. I'm not sure than any editing of files is required at all.

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Add enable i2c option in raspi-config

Sat May 24, 2014 11:01 pm

I modprobe i2c_dev, i2c_bcm2708, spi_bcm2708 as needed
That's maybe even more geeky than editing some files :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
joan
Posts: 14655
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 6:51 am

simplesi wrote:
I modprobe i2c_dev, i2c_bcm2708, spi_bcm2708 as needed
That's maybe even more geeky than editing some files :)

Simon
It's what I do in the next release of pigpio. Get the library you use to do something similar.

User avatar
Cancelor
Posts: 759
Joined: Wed Aug 28, 2013 4:09 pm
Location: UK

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 8:32 am

I think 'working straight out of the box' should be a requirement. i2c, ssh, spi etc

I find it so hard and difficult just to get started that I've lost the will to live before I get to any project.

School classes are short.

The aim is to be educational not de-motivating. People who know can say things like "I modprobe i2c_dev, i2c_bcm2708, spi_bcm2708 as needed" ( sorry to pick on that one ;) ) but for the beginner it just induces a grey haze.

The RPi is supposed to be educational so must start with the ABC's not with the invention of the alphabet or the picking of the lock to get into the library!

Having i2c disabled by default is like setting a deliberate trap to purposely deter people. :evil:
Can't find the thread you want? Try googling : YourSearchHere site:raspberrypi.org

achrn
Posts: 378
Joined: Wed Feb 13, 2013 1:22 pm

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 8:38 am

I'm in agreement with simplesi - I2C has become a fairly standard means to control a lot of hardware, and the enabling of it is a rather higher hurdle than actually using some of that hardware.

Some of the arguments advanced here against the proposal are false, or incoherent in my view. Programming the I2C bus does not require using an editor - it can be controlled from Scratch. The one about pi supposed to be educational so we shouldn't make it easy is competently bogus - that's clearly just a matter of degree. If we extrapolate that argument, then why does Raspbian have any configuration enabled? Why is sound set up, for example? Noobs is obviously completely counter the intentions of pi and should be abolished forthwith - imagine making it easy to install different operating systems when there's a learning opportunity to be had - heresy!

Oh, and I look forward to future versions of Raspbian being source-only - none of this package manager malarky - people can learn to compile from source, and "the Rpi is supposed to be an educational tool, not a plug and play device".

Actually, enabling I2C is NOT a good learning opportunity. It's a do-it-once-and-forget situation. You don't actually learn anything from enabling I2C, except that on Pi to use some hardware you have to blindly jump through some unexplained black-magic hoops before you can get to the point where you might learn something. Can anyone coherently explain the specific learning intention behind forcing I2C to be manually enabled?

In my view, I2C has become sufficiently central to the add-ons ecosystem that it should default to being enabled - just like HDMI is, and sound is.

User avatar
joan
Posts: 14655
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 8:39 am

Cancelor wrote: ...
The aim is to be educational not de-motivating. People who know can say things like "I modprobe i2c_dev, i2c_bcm2708, spi_bcm2708 as needed" ( sorry to pick on that one ;) ) but for the beginner it just induces a grey haze.
...
If we had to tailor every reply to the lowest common denominator very few posts would be written and even fewer would be read.

I'd be disappointed if simplesi didn't understand the post.
Last edited by joan on Sun May 25, 2014 8:50 am, edited 1 time in total.

User avatar
DougieLawson
Posts: 37073
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 8:49 am

How much pain is it to echo "i2c-bcm2708" >> /etc/modules && echo "i2c-dev" >> /etc/modules && reboot as a one shot script?

I'm sure the OP can add that to raspi-config (which is just a shell script) in less than five minutes.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Cancelor
Posts: 759
Joined: Wed Aug 28, 2013 4:09 pm
Location: UK

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 8:50 am

achrn wrote:.....Oh, and I look forward to future versions of Raspbian being source-only.....
you'r going to give 'em source code?!!!!! :twisted: what a learning opportunity missed! :lol:

I'm going to put my other hat on now and help the other side (they need it) ... to make some things 'off' by default is to illustrate that resources are limited in small devices (this is why 256 memory in a model A is good!) and that everything that happens on a computer needs something else 'working under the covers' Maybe it's a teaching opportunity rather than a learning opportunity. ..... I'm not convinced! :twisted:

I still think enabled by default is best, if there is time at the end of the class then disable it to illustrate the point.
Can't find the thread you want? Try googling : YourSearchHere site:raspberrypi.org

User avatar
Cancelor
Posts: 759
Joined: Wed Aug 28, 2013 4:09 pm
Location: UK

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 9:01 am

DougieLawson wrote:How much pain is it to echo "i2c-bcm2708" >> /etc/modules && echo "i2c-dev" >> /etc/modules && reboot as a one shot script?

I'm sure the OP can add that to raspi-config (which is just a shell script) in less than five minutes.
A near infinite amount of pain for someone who has never seen it before.

I don't know how to put across the difficulty and frustration that incredibly small things can cause to a noob.
Can't find the thread you want? Try googling : YourSearchHere site:raspberrypi.org

User avatar
DougieLawson
Posts: 37073
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 9:07 am

The OP isn't a newbie. He's got some sophisticated script in the link from his original post.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 9:18 am

I'm battling for the newbies though :)

What I can do and what a 7 year old/teacher of a 7 year old can do are two separate things - although sometimes the same :)

A lot of wizards here don't comprehend the view of the Pi world from the muggles point of view

We (wizards that is) all know that the I2C can be eanbled by casting a few spells - I'm asking

1. Can it be made a simple request in raspi-config (like quite a few other things are already)

2. Better still - enable it by default nowadays and let the wizards do any probing of mods required to disable it to retrieve the 2 pins for their projects :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
joan
Posts: 14655
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 9:29 am

simplesi wrote:I'm battling for the newbies though :)

What I can do and what a 7 year old/teacher of a 7 year old can do are two separate things - although sometimes the same :)

A lot of wizards here don't comprehend the view of the Pi world from the muggles point of view

We (wizards that is) all know that the I2C can be eanbled by casting a few spells - I'm asking

1. Can it be made a simple request in raspi-config (like quite a few other things are already)

2. Better still - enable it by default nowadays and let the wizards do any probing of mods required to disable it to retrieve the 2 pins for their projects :)

Simon
If you are using I2C/SPI in your lessons or scripts you really ought to make sure that your preparatory scripts load the needed modules.

User avatar
DougieLawson
Posts: 37073
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 9:31 am

I agree with you I2C (and SPI and 1-wire) should all be enabled by default and raspi-config should have an option to disable those.

I have no idea why the foundation haven't fixed that.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 9:39 am

joan wrote: If you are using I2C/SPI in your lessons or scripts you really ought to make sure that your preparatory scripts load the needed modules.
That's exactly what Simon is saying!! The 'preparatory script' has been written - it is at https://github.com/heeed/pi2c

Simon, on behalf of teachers and others who want to use i2c-enabled addons without fuss, suggests that script could be optionally invoked from raspi-config, whose github repo is here - https://github.com/asb/raspi-config

My github and bash skills aren't up to it, but it looks like a simple task to fork raspi-config, manually merge in the pi2c script, and send Alex a pull request? Perhaps no more work than contributing to this thread explaining why it shouldn't be done?

The idea of revisiting the design decision that noone needed spi/i2c and that they should be disabled by default is also a good one.
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

User avatar
joan
Posts: 14655
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 9:40 am

DougieLawson wrote:I agree with you I2C (and SPI and 1-wire) should all be enabled by default and raspi-config should have an option to disable those.

I have no idea why the foundation haven't fixed that.
Possibly because of the damage it might cause to attached devices during boot if gpios are set as outputs rather than inputs.

User avatar
DougieLawson
Posts: 37073
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 9:58 am

joan wrote:
DougieLawson wrote:I agree with you I2C (and SPI and 1-wire) should all be enabled by default and raspi-config should have an option to disable those.

I have no idea why the foundation haven't fixed that.
Possibly because of the damage it might cause to attached devices during boot if gpios are set as outputs rather than inputs.
So it's valid to inconvenience the masses for the sake of some random device that has a serious hardware fault.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 10:01 am

So maybe the best compromise is to 1st introduce it into raspi-config and see how it goes :)
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
GTR2Fan
Posts: 1601
Joined: Sun Feb 23, 2014 9:20 pm
Location: South East UK

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 10:05 am

Why not still have it disabled by default but have an option in raspi-config to enable it, the same as SSH? Wouldn't that keep nearly everyone happy?
Pi2B Mini-PC/Media Centre: ARM=1GHz (+3), Core=500MHz, v3d=500MHz, h264=333MHz, RAM=DDR2-1200 (+6/+4/+4+schmoo). Sandisk Ultra HC-I 32GB microSD card on '50=100' OCed slot (42MB/s read) running Raspbian/KODI16, Seagate 3.5" 1.5TB HDD mass storage.

User avatar
joan
Posts: 14655
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Add enable i2c option in raspi-config

Sun May 25, 2014 10:11 am

DeeJay wrote:
joan wrote: If you are using I2C/SPI in your lessons or scripts you really ought to make sure that your preparatory scripts load the needed modules.
That's exactly what Simon is saying!! The 'preparatory script' has been written - it is at https://github.com/heeed/pi2c

Simon, on behalf of teachers and others who want to use i2c-enabled addons without fuss, suggests that script could be optionally invoked from raspi-config, whose github repo is here - https://github.com/asb/raspi-config

My github and bash skills aren't up to it, but it looks like a simple task to fork raspi-config, manually merge in the pi2c script, and send Alex a pull request? Perhaps no more work than contributing to this thread explaining why it shouldn't be done?

The idea of revisiting the design decision that noone needed spi/i2c and that they should be disabled by default is also a good one.
I didn't realise you needed to do anything about the blacklisting. You don't on my machine. I thought I had a fairly standard set-up.

Code: Select all

mercury:~$ ssh hard
Linux hard 3.12.20+ #685 PREEMPT Fri May 23 18:59:01 BST 2014 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
You have new mail.
Last login: Sun May 25 09:54:55 2014 from mercury.lan
hard ~ $ ls /dev/i2c*
ls: cannot access /dev/i2c*: No such file or directory
hard ~ $ ls /dev/spi*
ls: cannot access /dev/spi*: No such file or directory
hard ~ $ ls /etc/modprobe.d/ 
alsa-base-blacklist.conf  fbdev-blacklist.conf  raspi-blacklist.conf
alsa-base.conf.old        ipv6.conf
hard ~ $ cat /etc/modprobe.d/raspi-blacklist.conf  
# blacklist spi and i2c by default (many users don't need them)

blacklist snd_soc_bcm2708_i2s
blacklist spi_bcm2708
blacklist i2c_bcm2708  
blacklist i2c_dev  
hard ~ $ sudo pigpiod
[sudo] password for joan: 
hard ~ $ pigs i2co 0 0x53 0 # does a modprobe if I2C open fails
0
hard ~ $ pigs spio 1 200000 0 # does a modprobe if SPI open fails
0
hard ~ $ ls /dev/i2c*
/dev/i2c-0  /dev/i2c-1
hard ~ $ ls /dev/spi*
/dev/spidev0.0  /dev/spidev0.1
hard ~ $ 

Return to “General discussion”