Skip to content

Commit

Permalink
fixed: white/black screen on first boot after firmware update
Browse files Browse the repository at this point in the history
  • Loading branch information
kwindrem committed Dec 8, 2023
1 parent 3f44de0 commit 9877ffc
Show file tree
Hide file tree
Showing 17 changed files with 302 additions and 1,080 deletions.
255 changes: 142 additions & 113 deletions CommonResources

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions DbusSettingsResources
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ source "/data/SetupHelper/LogHandler"

updateDbusStringSetting ()
{
# don't do any work if install has already failed
if $installFailed; then
return
fi

dbus-send --system --print-reply=literal --dest=com.victronenergy.settings "$1"\
com.victronenergy.BusItem.GetValue &> /dev/null
if (( $? != 0 )); then
Expand All @@ -58,6 +63,11 @@ updateDbusStringSetting ()

updateDbusIntSetting ()
{
# don't do any work if install has already failed
if $installFailed; then
return
fi

dbus-send --system --print-reply=literal --dest=com.victronenergy.settings "$1"\
com.victronenergy.BusItem.GetValue &> /dev/null
if (( $? != 0 )); then
Expand All @@ -71,6 +81,11 @@ updateDbusIntSetting ()

updateDbusRealSetting ()
{
# don't do any work if install has already failed
if $installFailed; then
return
fi

dbus-send --system --print-reply=literal --dest=com.victronenergy.settings "$1"\
com.victronenergy.BusItem.GetValue &> /dev/null
if (( $? != 0 )); then
Expand Down Expand Up @@ -105,6 +120,11 @@ removeDbusSettings ()

setSetting ()
{
# don't do any work if install has already failed
if $installFailed; then
return
fi

dbus -y com.victronenergy.settings $2 SetValue $1 &> /dev/null
}

Expand All @@ -125,6 +145,11 @@ setSetting ()

moveSetting ()
{
# don't do any work if install has already failed
if $installFailed; then
return
fi

local setupOption="$1"
local oldDbusPath=$2
local newDbusPath=$3
Expand Down
22 changes: 22 additions & 0 deletions EssentialResources
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ EXIT_OPTIONS_NOT_SET=251
EXIT_RUN_AGAIN=250
EXIT_ROOT_FULL=249
EXIT_DATA_FULL=248
EXIT_NO_GUI_V1=247
# old variables - keep for compatibility
exitReboot=$EXIT_REBOOT
exitSuccess=$EXIT_SUCCESS
Expand Down Expand Up @@ -138,4 +139,25 @@ function versionStringToNumber ()
versionNumber=$number
}

# restart the GUI service
# begining at about v3.20~18, changes were made to accommodate the gui-v2
# and these changes require different handling of a GUI service restart
#
# this is in EssentialResorces because it is used in reinstallMods and ServiceResources is overkill there

restartGuiService ()
{
# start-gui is the new service which supports gui-v2
# that service will start gui-v2 if selected in Settings or run the older gui if not
if [ -e "/service/start-gui" ]; then
svc -t "/service/start-gui"
# gui is the older service that runs GUI v1
elif [ -e "/service/gui" ]; then
svc -t "/service/gui"
fi
}





6 changes: 6 additions & 0 deletions FileSets/MbDisplayPackageVersion.qml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ MbItem {
return qsTr ( " no file set for " + osVersion )
else if (incompatibleReason == 'CMDLINE' && installedVersion.item.value == "")
return qsTr ( " must install from command line" )
else if (incompatibleReason == 'ROOT_FULL')
return qsTr ( " no space on root partition" )
else if (incompatibleReason == 'DATA_FULL')
return qsTr ( " no space on /data partition" )
else if (incompatibleReason == 'GUI_V1_MISSING')
return qsTr ( " GUI v1 not installed" )
else
return ""
}
Expand Down
2 changes: 2 additions & 0 deletions FileSets/PageSettingsPackageEdit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ MbPage {
return qsTr ( "no room on root partition" )
else if (incompatibleReason == 'DATA_FULL')
return qsTr ( "no room on data partition" )
else if (incompatibleReason == 'GUI_V1_MISSING')
return qsTr ( "GUI v1\nnot installed" )
else
return qsTr ("incompatible ???" ) // compatible for unknown reason
}
Expand Down
77 changes: 56 additions & 21 deletions PackageManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
EXIT_RUN_AGAIN = 250
EXIT_ROOT_FULL = 249
EXIT_DATA_FULL = 248
EXIT_NO_GUI_V1 = 247

EXIT_ERROR = 255 # generic error
# install states only
Expand All @@ -153,6 +154,7 @@
# nanopi Multi/Easy Solar GX
# raspberrypi2 Raspberry Pi 2/3
# raspberrypi4 Raspberry Pi 4
# ekrano Ekrano GX
#
# /ActionNeeded informs GUI if further action is needed following a manual operation
# the operator has the option to defer reboots and GUI restarts (by choosing "Later)
Expand Down Expand Up @@ -1166,7 +1168,7 @@ def __init__(self):
'autoInstall': [ '/Settings/PackageManager/AutoInstall', 0, 0, 0 ],
}
self.DbusSettings = SettingsDevice(bus=dbus.SystemBus(), supportedSettings=settingsList,
timeout = 10, eventCallback=None )
timeout = 30, eventCallback=None )

self.DbusService = VeDbusService ('com.victronenergy.packageManager', bus = dbus.SystemBus())
self.DbusService.add_mandatory_paths (
Expand Down Expand Up @@ -2174,7 +2176,7 @@ def run (self):
command = ""
# do initial refreshes quickly
if fastRefresh:
delay = 2.0
delay = 0.5
# otherwise scan one version every 10 minutes
else:
delay = 600.0
Expand Down Expand Up @@ -2733,6 +2735,12 @@ def InstallPackage ( self, packageName=None, source=None , direction='install' )
where=sendStatusTo, logLevel=ERROR )
if source == 'GUI':
DbusIf.SetGuiEditAction ( 'ERROR' )
elif returnCode == EXIT_NO_GUI_V1:
package.SetIncompatible ('GUI_V1_MISSING')
DbusIf.UpdateStatus ( message=packageName + " GUI v1 not installed",
where=sendStatusTo, logLevel=ERROR )
if source == 'GUI':
DbusIf.SetGuiEditAction ( 'ERROR' )
# unknown error
elif returnCode != 0:
DbusIf.UpdateStatus ( message=packageName + " " + direction + " unknown error " + str (returnCode),
Expand Down Expand Up @@ -3426,26 +3434,44 @@ def mainLoop():
currentDownloadMode = DbusIf.GetAutoDownloadMode ()
autoInstall = DbusIf.GetAutoInstall ()

# UpdateGitHubVersion is responsible for fetching GitHub versions
# so we can update the download mode
# skip all package processing until the update is complete
# check to see if reinstallMods is running
# to prevent conflicts with it's installs and those done here
proc = subprocess.Popen ( "pgrep reinstallMods", shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE )
proc.wait()
stdout, stderr = proc.communicate ()
# convert from binary to string
stdout = stdout.decode ().strip ()
if stdout == "":
waitForReinstall = False
else:
waitForReinstall = True

# setup status messages
if currentDownloadMode == AUTO_DOWNLOADS_OFF:
if autoInstall:
idleMessage = "checking for installs"
else:
idleMessage = ""
idleMessage = ""
actionMessage = ""
statusMessage = ""
# no updates has highest prioroity
if currentDownloadMode == AUTO_DOWNLOADS_OFF and not autoInstall:
idleMessage = ""
# hold-off of processing has next highest priority
elif WaitForGitHubVersions:
idleMessage = "refreshing GitHub version information"
elif waitForReinstall:
idleMessage = "waiting for boot reinstall to complete"
# finally, set idleMessage based on download and install states
elif currentDownloadMode != AUTO_DOWNLOADS_OFF and autoInstall:
idleMessage = "checking for downloads and installs"
elif currentDownloadMode == AUTO_DOWNLOADS_OFF and autoInstall:
idleMessage = "checking for installs"
elif currentDownloadMode != AUTO_DOWNLOADS_OFF and not autoInstall:
idleMessage = "checking for downloads"

# hold off all package processing until the GitHub versions have been updated
# and reinstallMods has finished reinstalling packages after Venus OS update
if waitForReinstall or WaitForGitHubVersions:
PackageScanComplete = False
PackageIndex = 0 # make sure new scan starts at beginning
else:
idleMessage = "checking for downloads"
if autoInstall:
idleMessage += " and installs"
actionMessage = ""
statusMessage = ""

# after a complete scan, change modes if appropirate
if PackageScanComplete:
Expand All @@ -3462,7 +3488,7 @@ def mainLoop():
PackageIndex = 0
PackageScanComplete = False
UpdateGitHubVersion.GitHubVersionQueue.put ('REFRESH')
downloadDelay = 10.0
downloadDelay = 2.0

PackageClass.AddStoredPackages ()

Expand All @@ -3479,11 +3505,12 @@ def mainLoop():
PackageIndex = 0
PackageScanComplete = False

# hold off other processing until Git Hub version refresh is complete
# hold off other processing until boot package reinstall and Git Hub version refresh is complete
# this insures download checks are based on up to date Git Hub versions
# installs are also held off to prevent install of older version,
# then another install of the more recent version
if not WaitForGitHubVersions:
# waiting for reinstallMods to finish prevents conflicts between these two processes
if not waitForReinstall and not WaitForGitHubVersions:
package = PackageClass.PackageList [PackageIndex]
packageName = package.PackageName
PackageIndex += 1
Expand Down Expand Up @@ -3582,7 +3609,13 @@ def mainLoop():
logging.warning ("restarting GUI")
statusMessage = "restarting GUI ..."
try:
proc = subprocess.Popen ( [ 'svc', '-t', '/service/gui' ] )
# with gui-v2 present, GUI v1 runs from start-gui service not gui service
if os.path.exists ('/service/start-gui'):
proc = subprocess.Popen ( [ 'svc', '-t', '/service/start-gui' ] )
elif os.path.exists ('/service/gui'):
proc = subprocess.Popen ( [ 'svc', '-t', '/service/gui' ] )
else:
logging.critical ("GUI restart failed")
except:
logging.critical ("GUI restart failed")
GuiRestart = False
Expand Down Expand Up @@ -3687,7 +3720,7 @@ def main():
PackageIndex = 0
noActionCount = 0
LastAutoDownloadTime = 0.0
WaitForGitHubVersions = False
WaitForGitHubVersions = True # hold off package processing until first GitHub version refresh pass
downloadDelay = 600.0

# set logging level to include info level entries
Expand Down Expand Up @@ -3755,6 +3788,8 @@ def main():
Platform = "Raspberry Pi 2/3"
elif machine == "raspberrypi4":
Platform = "Raspberry Pi 4"
elif machine == "ekrano":
Platform = "Ekrano GX"
else:
Platform = machine
file.close()
Expand Down
5 changes: 5 additions & 0 deletions ServiceResources
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ removeService ()

installService ()
{
# don't do any work if install has already failed
if $installFailed; then
return
fi

local serviceName=""
if (( $# >= 1 )); then
serviceName=$1
Expand Down
2 changes: 1 addition & 1 deletion blindInstall/SetupHelperVersion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v5.15
v5.16
5 changes: 5 additions & 0 deletions changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v5.16:
fixed: white/black screen on first boot after firmware update
incorporate changes for GUI v1 and gui-v2 selection,
mainly to prevent package install if GUI v1 is needed and missing

v5.15:
fixed: PackageManager isn't in menus after v5.14 install
updateFileSets: fixed: NO_REPLACEMENT in existing file sets that should link to other sets
Expand Down
56 changes: 30 additions & 26 deletions reinstallMods
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# some setup scripts access dbus Settings which are not up early in the boot process
# therefore, this script is run as a background task and waits for dbus Settings
#
# Refer to the ReadMe for more details

setupHelperDir="/data/SetupHelper"
source "$setupHelperDir/EssentialResources"
Expand All @@ -25,7 +24,7 @@ logMessage "reinstallMods starting"
# and call each script
rebootNeeded=false
guiRestartNeeded=false
settingsAlive=false
okToInstall=false

while read -u 9 line ; do
# ignore blank and comment lines
Expand All @@ -34,6 +33,11 @@ while read -u 9 line ; do
command=$(awk '{print var $1}' <<< $line)
scriptDir=$(dirname $command)
packageName=$(basename $scriptDir)
if [ ! -f $command ] ; then
logMessage "Error: $packageName setup script not found - skipping reinstall"
continue
fi

packageVersionFile="$scriptDir/version"
installedVersionFile="$installedVersionPrefix$packageName"
doReinstall=false
Expand All @@ -54,40 +58,40 @@ while read -u 9 line ; do
fi

if $doReinstall ; then
if [ -f $command ] ; then
fullCommand=$(echo "$command reinstall auto deferReboot deferGuiRestart")
# wait until dbus settings are active before calling setup script
while ! $settingsAlive ; do
if [ $(dbus -y | grep -c "com.victronenergy.settings") == 0 ]; then
logMessage "waiting for dBus settings"
else
settingsAlive=true
fi
# wait until dbus settings and GUI are active before calling setup script
# this is done before first reinstall so PackageManager isn't held off if there are no reinstalls
while ! $okToInstall ; do
if [ $(dbus -y | grep -c "com.victronenergy.settings") == 0 ]; then
logMessage "waiting for dBus settings"
sleep 2
done

$fullCommand
returnCode=$?
if (( $returnCode == $EXIT_REBOOT )) ; then
logMessage "$packageName reinstall requested reboot"
rebootNeeded=true
elif (( $returnCode == $EXIT_RESTART_GUI )) ; then
logMessage "$packageName reinstall requested GUI restart"
guiRestartNeeded=true
else
okToInstall=true
fi
else
logMessage "Error: $packageName setup script not found"
done

# run setup script
fullCommand=$(echo "$command reinstall auto deferReboot deferGuiRestart")
$fullCommand
returnCode=$?
if (( $returnCode == $EXIT_REBOOT )) ; then
logMessage "$packageName reinstall requested reboot"
rebootNeeded=true
elif (( $returnCode == $EXIT_RESTART_GUI )) ; then
logMessage "$packageName reinstall requested GUI restart"
guiRestartNeeded=true
fi
fi
fi
done 9< "$reinstallScriptsList"

# reboot now if any script reboots were indicated
logMessage "reinstallMods complete"

# reboot or restart GUI now if any script reboots were indicated
if $rebootNeeded ; then
logMessage "rebooting ..."
reboot
elif $guiRestartNeeded ; then
logMessage "restarting GUI"
svc -t /service/gui
restartGuiService
fi
logMessage "reinstallMods complete"

Loading

0 comments on commit 9877ffc

Please sign in to comment.