2

I used: sudo raspi-config to select the I2C option but it got into the config.txt file appended to the previous line. I since fixed that, but want to know what I did wrong or is it a bug?

  • Sounds like a bug. Can you duplicate the bug? i.e. from a known /boot/config.txt can you run raspi-config and get the same result? If so it is certainly worth reporting. – joan Nov 17 '15 at 9:31
1

Here's what the current version of raspi-config does (it's in the do_i2c()) function:

sed $CONFIG -i -r -e "s/^((device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?)(=[^,]*)?/\1=$SETTING/"
if ! grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?=[^,]*" $CONFIG; then
  printf "dtparam=i2c_arm=$SETTING\n" >> $CONFIG
fi

The sed command will change the line if it begins with device_tree_param or dtparam then = then something ending with i2c= or i2c_arm=.

The grep line then checks for the same thing and if it's not there, adds it. Don't ask me why this isn't an if/else; efficiency is not a real concern here anyway.

So note that won't change or count a line that's been commented out.

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.