Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DietPi-Config | Fix I2C baudrate handling on RPi #2967

Merged
merged 7 commits into from
Jul 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ v6.26
(XX/08/19)

Bug Fixes:
- DietPi-Config | Resolved an issue on RPi where I2C baudrate was not applied correctly, thus selection was ineffective. Many thanks to @flashspys for reporting this issue: https://github.com/MichaIng/DietPi/issues/2966
- DietPi-Software | Gitea: Resolved an issue where install fails on ARMv7 systems. Many thanks to @maschiw for reporting this issue: https://github.com/MichaIng/DietPi/issues/2959

As always, many smaller code performance and stability improvements, visual and spelling fixes have been done, too much to list all of them here. Check out all code changes of this release on GitHub: https://github.com/MichaIng/DietPi/pull/XXXX
Expand Down
4 changes: 2 additions & 2 deletions config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ dtparam=audio=off
#-------I²C-------------
dtparam=i2c_arm=off
dtparam=i2c1=off
i2c_arm_baudrate=100000
#dtparam=i2c_arm_baudrate=100000

#-------SPI-------------
dtparam=spi=off

#-------Serial/UART-----
# NB: Enabled for 1st run only, if you want to keep this setting, please set CONFIG_SERIAL_CONSOLE_ENABLE=1 in /DietPi/dietpi.txt.
# NB: "enable_uart=1" will forcefully set "core_freq=250" unless "force_turbo=1" is set as well.
# NB: "enable_uart=1" will forcefully set "core_freq=250" on WiFi/BT-capable RPi models, unless "force_turbo=1" is set as well.
enable_uart=1

#-------Overclock-------
Expand Down
14 changes: 7 additions & 7 deletions dietpi/dietpi-config
Original file line number Diff line number Diff line change
Expand Up @@ -1404,27 +1404,27 @@ NB: You now need to run "apt update" or "G_AGUP" once after each reboot, before
if (( $G_HW_MODEL < 10 )); then

# I2C state
local rpi_i2c_enabled=$(grep -c -m1 '^[[:blank:]]*dtparam=i2c_arm=on' /DietPi/config.txt)
local rpi_i2c_enabled=$(grep -cm1 '^[[:blank:]]*dtparam=i2c_arm=on' /DietPi/config.txt)
local rpi_i2c_text='Off'
(( $rpi_i2c_enabled )) && rpi_i2c_text='On'
G_WHIP_MENU_ARRAY+=('I2C state' ": [$rpi_i2c_text]")

# I2C baudrate
local rpi_i2cbaudrate_hz=$(grep -m1 '^[[:blank:]]*i2c_arm_baudrate=' /DietPi/config.txt | sed 's/^[^=]*=//')
local rpi_i2cbaudrate_hz=$(grep -m1 '^[[:blank:]]*dtparam=i2c_arm_baudrate=' /DietPi/config.txt | sed 's/^.*=//')
# - Allow commented/non-existent entry, using default value: https://github.com/raspberrypi/firmware/blob/d69aadedb7c146ba5d3b0b45a661e5669a9141c4/boot/overlays/README#L115-L116
rpi_i2cbaudrate_hz="$(( ${rpi_i2cbaudrate_hz:-100000} / 1000 )) kHz"
G_WHIP_MENU_ARRAY+=('I2C frequency' ": [$rpi_i2cbaudrate_hz]")

# USB max current
local usb_max_current_enabled=$(grep -c -m1 '^[[:blank:]]*max_usb_current=1' /DietPi/config.txt)
local usb_max_current_enabled=$(grep -cm1 '^[[:blank:]]*max_usb_current=1' /DietPi/config.txt)
local rpi_usbmaxcurrent_text='Off'
(( $usb_max_current_enabled )) && rpi_usbmaxcurrent_text='On'
G_WHIP_MENU_ARRAY+=('Max USB current' ": [$rpi_usbmaxcurrent_text]")

# USB boot option: RPi3 only and not required for RPi3+: https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md
if [[ $G_HW_MODEL == 3 && $G_HW_MODEL_DESCRIPTION != *'+'* ]]; then

local rpi3_usb_boot_bit_enabled=$(vcgencmd otp_dump | grep -m1 -ci '17:3020000a')
local rpi3_usb_boot_bit_enabled=$(vcgencmd otp_dump | grep -cm1 '17:3020000a')
local rpi3_usb_boot_bit_enabled_text='Off'
(( $rpi3_usb_boot_bit_enabled )) && rpi3_usb_boot_bit_enabled_text='On'
G_WHIP_MENU_ARRAY+=('USB boot support' ": [$rpi3_usb_boot_bit_enabled_text]")
Expand Down Expand Up @@ -1544,7 +1544,7 @@ Please choose whether your device have an active RTC or requires "fake-hwclock":
if G_WHIP_YESNO "Current setting: $rpi_usbmaxcurrent_text (1.2AMP)\nWould you like to disable this setting?
\nOnce Disabled:\n - Max USB current will be limited to 0.6AMP.\n - Shared by all USB ports."; then

sed -i '/max_usb_current=/c\max_usb_current=0' /DietPi/config.txt
G_CONFIG_INJECT 'max_usb_current=' 'max_usb_current=0' /DietPi/config.txt
REBOOT_REQUIRED=1

fi
Expand All @@ -1555,7 +1555,7 @@ Please choose whether your device have an active RTC or requires "fake-hwclock":
if G_WHIP_YESNO "Current setting: $rpi_usbmaxcurrent_text (0.6AMP)\nWould you like to enable this setting?
\nOnce Enabled:\n - Max USB current will be set to 1.2AMP.\n - Shared by all USB ports."; then

sed -i '/max_usb_current=/c\max_usb_current=1' /DietPi/config.txt
G_CONFIG_INJECT 'max_usb_current=' 'max_usb_current=1' /DietPi/config.txt
REBOOT_REQUIRED=1

fi
Expand All @@ -1581,7 +1581,7 @@ Please choose whether your device have an active RTC or requires "fake-hwclock":
G_WHIP_DEFAULT_ITEM=${rpi_i2cbaudrate_hz% kHz}
if G_WHIP_INPUTBOX 'Please enter the required I2C baudrate frequency (kHz).' && G_CHECK_VALIDINT "$G_WHIP_RETURNED_VALUE" 0; then

/DietPi/dietpi/func/dietpi-set_hardware i2c "$G_WHIP_RETURNED_VALUE"
/DietPi/dietpi/func/dietpi-set_hardware i2c $G_WHIP_RETURNED_VALUE
REBOOT_REQUIRED=1

fi
Expand Down
4 changes: 2 additions & 2 deletions dietpi/func/dietpi-globals
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@

# DietPi Versions/Branch
G_DIETPI_VERSION_CORE=${G_DIETPI_VERSION_CORE:-6}
G_DIETPI_VERSION_SUB=${G_DIETPI_VERSION_SUB:-25}
G_DIETPI_VERSION_RC=${G_DIETPI_VERSION_RC:-3}
G_DIETPI_VERSION_SUB=${G_DIETPI_VERSION_SUB:-26}
G_DIETPI_VERSION_RC=${G_DIETPI_VERSION_RC:-0}
G_GITBRANCH=${G_GITBRANCH:-master}
G_GITOWNER=${G_GITOWNER:-MichaIng}
[[ -f '/DietPi/dietpi/.version' && $(</DietPi/dietpi/.version) == '#!/bin/bash'* ]] && . /DietPi/dietpi/.version
Expand Down
13 changes: 8 additions & 5 deletions dietpi/func/dietpi-set_hardware
Original file line number Diff line number Diff line change
Expand Up @@ -1068,19 +1068,22 @@ _EOF_

elif [[ $INPUT_DEVICE_VALUE == 'disable' ]]; then

# Kernel modules
sed -i '/^[[:blank:]]*i2c-bcm2708/d' /etc/modules
sed -i '/^[[:blank:]]*i2c-dev/d' /etc/modules

# config.txt
G_CONFIG_INJECT 'dtparam=i2c_arm=' 'dtparam=i2c_arm=off' $FP_RPI_CONFIG
G_CONFIG_INJECT 'dtparam=i2c1=' 'dtparam=i2c1=off' $FP_RPI_CONFIG
G_CONFIG_INJECT 'i2c_arm_baudrate=' 'i2c_arm_baudrate=100000' $FP_RPI_CONFIG
G_CONFIG_INJECT 'dtparam=i2c_arm_baudrate=' 'dtparam=i2c_arm_baudrate=100000' $FP_RPI_CONFIG

# Set baudrate (khz) | valid int
# Set baudrate (kHz) | valid int
elif disable_error=1 G_CHECK_VALIDINT "$INPUT_DEVICE_VALUE" 2 10000000; then

G_CONFIG_INJECT 'i2c_arm_baudrate=' "i2c_arm_baudrate=$(( $INPUT_DEVICE_VALUE * 1000 ))" $FP_RPI_CONFIG
G_CONFIG_INJECT 'dtparam=i2c_arm_baudrate=' "dtparam=i2c_arm_baudrate=$(( $INPUT_DEVICE_VALUE * 1000 ))" $FP_RPI_CONFIG

# inform user
INPUT_DEVICE_VALUE+='Khz'
# Inform user
INPUT_DEVICE_VALUE+=' kHz'

else

Expand Down
7 changes: 7 additions & 0 deletions dietpi/patch_file
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,13 @@ A backup will be created to "/etc/mympd/mympd.conf.bak_DDMMYYY_N" from where you
fi
#-------------------------------------------------------------------------------

elif (( $G_DIETPI_VERSION_SUB == 25 )); then

#-------------------------------------------------------------------------------
# RPi: Remove invalid I2C baudrate entries from dietpi.txt. Do no apply any value to preserve current system state (default): https://github.com/MichaIng/DietPi/issues/2966
(( $G_HW_MODEL < 10 )) && sed -i '/^[[:blank:]]*i2c_arm_baudrate=/d' /DietPi/dietpi.txt
#-------------------------------------------------------------------------------

fi

#-------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions dietpi/server_version-6
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
6
25
3
26
0