From fa587c0f5aa0015e19d351f69e07e4ea4c1c84f2 2017-01-23 22:23:54 From: drtyhlpr Date: 2017-01-23 22:23:54 Subject: [PATCH] Added: I2C and SPI interface support --- diff --git a/README.md b/README.md index 5ab0071..137493a 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,12 @@ Set the IP address for the second NTP server. ##### `ENABLE_CONSOLE`=true Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2/3. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system. +##### `ENABLE_I2C`=false +Enable I2C interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](http://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins. + +##### `ENABLE_SPI`=false +Enable SPI interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](http://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins. + ##### `ENABLE_IPV6`=true Enable IPv6 support. The network interface configuration is managed via systemd-networkd. diff --git a/bootstrap.d/13-kernel.sh b/bootstrap.d/13-kernel.sh index ddfed3d..ada4691 100644 --- a/bootstrap.d/13-kernel.sh +++ b/bootstrap.d/13-kernel.sh @@ -257,6 +257,22 @@ if [ "$ENABLE_SOUND" = true ] ; then sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${R}/lib/modules-load.d/rpi2.conf" fi +# Enable I2C interface +if [ "$ENABLE_I2C" = true ] ; then + echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt" + sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${R}/lib/modules-load.d/rpi2.conf" + sed -i "s/^# i2c-dev/i2c-dev/" "${R}/lib/modules-load.d/rpi2.conf" +fi + +# Enable SPI interface +if [ "$ENABLE_SPI" = true ] ; then + echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt" + echo "spi-bcm2708" >> "${R}/lib/modules-load.d/rpi2.conf" + if [ "$RPI_MODEL" = 3 ] ; then + sed -i "s/spi-bcm2708/spi-bcm2835/" "${R}/lib/modules-load.d/rpi2.conf" + fi +fi + # Install kernel modules blacklist mkdir -p "${ETC_DIR}/modprobe.d/" install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" diff --git a/rpi23-gen-image.sh b/rpi23-gen-image.sh index 4f3ab6f..6a891cb 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -112,6 +112,8 @@ APT_SERVER=${APT_SERVER:="ftp.debian.org"} # Feature settings ENABLE_CONSOLE=${ENABLE_CONSOLE:=true} +ENABLE_I2C=${ENABLE_I2C:=false} +ENABLE_SPI=${ENABLE_SPI:=false} ENABLE_IPV6=${ENABLE_IPV6:=true} ENABLE_SSHD=${ENABLE_SSHD:=true} ENABLE_NONFREE=${ENABLE_NONFREE:=false}