Moode Forum
[split] Maintaining config.txt - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: [split] Maintaining config.txt (/showthread.php?tid=3878)

Pages: 1 2


[split] Maintaining config.txt - adrii - 05-28-2021

Hi Tim

1. I looked at the Raspberry Pi OS setup again and i2c-dev is loaded at boot and included in '/etc/modules' and '/etc/modules-load.d/modules.conf' (I don't think I have changed these lines manually, as I don't use an I2C screen with the machine, but I can't be sure, also Volumio loads the i2c-dev module by default). Enabling/disabling I2C in raspi-config changes the line 'dtparam=i2c_arm=on' to 'dtparam=i2c_arm=off', but the i2c-dev module is still loaded in both cases. In which case it seems that both the i2c-dev module must be specifically loaded and 'dtparam=i2c_arm=on' be set for the /dev/i2c-1 (etc) device entries to be created.

On Moode...
Code:
pi@moode:~ $ sudo modprobe i2c-dev
pi@moode:~ $ ls /dev/i2c*
/dev/i2c-1
pi@moode:~ $ sudo dtparam i2c_arm=off
pi@moode:~ $ ls /dev/i2c*
ls: cannot access '/dev/i2c*': No such file or directory
pi@moode:~ $ sudo dtparam i2c_arm=on
pi@moode:~ $ ls /dev/i2c*
/dev/i2c-1
pi@moode:~ $ sudo rmmod i2c-dev
pi@moode:~ $ ls /dev/i2c*
ls: cannot access '/dev/i2c*': No such file or directory
pi@moode:~ $ sudo modprobe i2c-dev
pi@moode:~ $ ls /dev/i2c*
/dev/i2c-1

2. I thought the /etc/modules file was also overwritten by the the 720 to 721 update, but I could be mistaken.

3. In worker.php, it doesn't look like i2c-dev is loaded by the ALSA loopback configuration (and it wasn't loaded when I tried it), but is loaded for 'Allo Boss 2 DAC', 


Besides the specific details of the I2C configuration on Moode (which are clearer to me now), I am mainly interested in a user's mpd_oled configuration being able to survive a Moode update (as it wasn't previously possible for an mpd_oled user to update Moode because of system customisations). The user has to configure their screen, and this will involve loading modules (for I2C or SPI) and adding settings to '/boot/config.txt'. It would be useful if there was a Moode recommended place for a user to load modules, that won't be overwritten by an update. Also, it would be useful if Moode could support a config.txt include file for user settings that would survive an update ( https://www.raspberrypi.org/documentation/configuration/config-txt/misc.md ), so if the user adds a setting for the i2c bus speed like 'dtparam=i2c_arm_baudrate=800000' to the include file then the setting is still present after the Moode update.

I think those are all my comments. I don't want to hijack the 7.2.1 support thread!

Francesco and bitlab, thank you for the suggestion to use raspi-config. I thought it was something that shouldn't be used on Moode, but I can't find a reference not to use it in the forums! I'll check out if it can make the mpd_oled instructions easier. I think 'dtparam=i2c_arm_baudrate=800000' was commented out in '/boot/config.txt' by the upgrade, and if that is the case this file would still need editing after an upgrade.

Adrian.


RE: Official moOde 7.2.1 support thread - Tim Curtis - 05-28-2021

To summarize:

1. Need i2c-dev loaded at boot time by default
2. Would be helpful to have the "include file" feature for config.txt

Correct?


RE: Official moOde 7.2.1 support thread - adrii - 05-29-2021

Hi Tim

1. Yes, load i2c-dev at boot.

2. Yes, and if the include statement comes last in /boot/config.txt then user settings can override the Moode settings (e.g. to turn I2C off) . However, I notice in testing that raspi-config is adding statements at the end of config.txt, in which case, maybe Moode settings coulld be in a separate file that is included first in config.txt, and everything that follows in config.txt is user settings, and raspi-config changes are then user settings. But, I don't know enough about this to say what the downsides of any approach could be.

My other suggestion was that it would be useful if a user could list modules to load in a file (which could be /etc/modules) and they wouldn't be overwriten by a Moode upgrade, but on further investigation the only module I needed this for was i2c-dev. Unlike with I2C, the SPI module is loaded by the corresponding SPI setting in config.txt


Code:
pi@moode:~ $ lsmod | grep spidev
pi@moode:~ $ ls /dev/spi*
ls: cannot access '/dev/spi*': No such file or directory
pi@moode:~ $ sudo dtparam spi=on
pi@moode:~ $ lsmod | grep spidev
spidev                 20480  0
pi@moode:~ $ ls /dev/spi*
/dev/spidev0.0  /dev/spidev0.1

Similarly, my radio project uses the ti_ads1015 module, but this is loaded by a setting in config.txt.

Adrian.


RE: Official moOde 7.2.1 support thread - Tim Curtis - 05-29-2021

I'm a bit confused on #2. What is raspi-config being used for?


RE: Official moOde 7.2.1 support thread - adrii - 05-29-2021

Hi Tim

raspi-config is being used to enable/re-enable I2C on Moode. It also might be used to enable SPI, which would append a line to the end of /boot/config.txt.

Adrian.


RE: Official moOde 7.2.1 support thread - Tim Curtis - 05-29-2021

Below is i2c section of raspi-config script. It looks like its doing the following:

1. Adding "dtparam=i2c_arm=on" to /boot/config.txt
2. Adding "i2c-dev' to /etc/modules
3. Manually loading i2c-dev module via "modprobe i2c-dev"

moOde already includes "dtparam=i2c_arm=on" in /boot/config.txt so if I add "i2c-dev' to /etc/modules" as the default it will get loaded automatically at boot by Linux. 

There wouldn't be a need to use raspi-config at this point correct?
What is SPI used for?

Code:
do_i2c() {
 DEFAULT=--defaultno
 if [ $(get_i2c) -eq 0 ]; then
   DEFAULT=
 fi
 if [ "$INTERACTIVE" = True ]; then
   whiptail --yesno "Would you like the ARM I2C interface to be enabled?" $DEFAULT 20 60 2
   RET=$?
 else
   RET=$1
 fi
 if [ $RET -eq 0 ]; then
   SETTING=on
   STATUS=enabled
 elif [ $RET -eq 1 ]; then
   SETTING=off
   STATUS=disabled
 else
   return $RET
 fi

 set_config_var dtparam=i2c_arm $SETTING $CONFIG &&
 if ! [ -e $BLACKLIST ]; then
   touch $BLACKLIST
 fi
 sed $BLACKLIST -i -e "s/^\(blacklist[[:space:]]*i2c[-_]bcm2708\)/#\1/"
 sed /etc/modules -i -e "s/^#[[:space:]]*\(i2c[-_]dev\)/\1/"
 if ! grep -q "^i2c[-_]dev" /etc/modules; then
   printf "i2c-dev\n" >> /etc/modules
 fi
 dtparam i2c_arm=$SETTING
 modprobe i2c-dev

 if [ "$INTERACTIVE" = True ]; then
   whiptail --msgbox "The ARM I2C interface is $STATUS" 20 60 1
 fi
}



RE: Official moOde 7.2.1 support thread - TheOldPresbyope - 05-29-2021

(05-29-2021, 01:18 PM)adrii Wrote: Hi Tim

raspi-config is being used to enable/re-enable I2C on Moode. It also might be used to enable SPI, which would append a line to the end of /boot/config.txt.

Adrian.

Wish I had time to concentrate on moOde stuff...but I don't if I want to preserve domestic tranquility Rolleyes

raspi-config is a 2900-line shell script and the I2C and SPI subroutines (ca lines 850-935) are only several percent of it. Seems like some economy is possible here.

Regards,
Kent


RE: Official moOde 7.2.1 support thread - adrii - 05-29-2021

Hi Tim

Some screens use SPI.

If you load i2c-dev with the current /boot/config.txt then I2C should be available through the normal devices and there is no reason to run raspi-config, but other I2C settings might be needed in /boot/config.txt, e.g. for bus speed.

Adrian.


RE: Official moOde 7.2.1 support thread - Tim Curtis - 05-29-2021

Ok that explains it. I'll test the include feature of config.txt. You recommend placing it first rather than last correct?


RE: Official moOde 7.2.1 support thread - adrii - 05-29-2021

Hi Tim

In config.txt, if user settings come after Moode settings then they can override them. It seems like the options are:
  • put user settings in a separate file and include it last in config.txt, but then raspi-config changes (which I imagine will occur even if unnecessary) might be added both before and after the include statement
  • put Moode settings in a separate file and include it first in config.txt, then any settings in config.txt are user settings (including changes made by raspi-config) and always come after Moode settings.
The second option seems better from the point of view that it ensure that user settings come after Moode settings. However, there may be other aspects to consider, and I don't know all the details of the config system.

Adrian.