question

nebulight avatar image
nebulight asked

Upgrading pi erased settings?

I’m new to the pi and Victron in general but I spent this evening getting my pi touch screen setup for touch, dimming and screen off settings. I got everthing calibrated and working, then on a whim I decided to see if there was a new beta build available and 2.30~40 was available. I installed it and it killed most of my settings (touch, dimming, screen off) and is no longer headless. However it kept some of my settings for dvcc, network and WiFi.


Is this normal behavior when upgrading the pi? Or maybe just with beta releases?


Thanks.

Venus OS
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

7 Answers
wkirby avatar image
wkirby answered ·

Your DVCC, Network, WiFi and settings such as those made from the menus on the device are kept in /data which is not over-written during updates.

Modifications which are made in other partitions will be over-written during updates.
I have just such a problem, I have an additionl VE.Direct port which I need to be map to a specific tty port upon startup. An update destroys my config.

So, what I do is run a startup script from within /data which compares the file I want (which is also on the /data partition) to the configuration file and if it's different then it copies it from /data to overwrite the configuration file with my version.

2 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

nebulight avatar image nebulight commented ·

Does this happen with non-beta releases as well? I would assume so, care to share your script?

0 Likes 0 ·
wkirby avatar image wkirby ♦♦ nebulight commented ·

I'd be happy to share my script. I don't have it with me, I'll have to wait until the next time I go home to get it for you.

Yes, this is true for non-beta too.

0 Likes 0 ·
wkirby avatar image
wkirby answered ·

So, I managed to get hold of my files.
In /data/conf are all the usual settings that were saved, as you pointed out.

In /data there needs to be a file called rc.local
rc.local will get called at startup and then you can run a script like mine.
Also in /data you must keep copies of all of the files that you modified so that they can be copied back from /data if they get overwritten by an update.

My rc.local looks like this:

#!/bin/bash

# /data/vedirect_ports contains a third entry "TTYO5"
# which I use for my third VE.Direct port.
# If the files are different, then the copy in /data is copied to /etc/venus

if diff /data/vedirect_ports /etc/venus/vedirect_ports >/dev/null ;
then
echo "No change"
else
cp /data/vedirect_ports /etc/venus
echo "Copied vedirect_ports to /etc/venus"
fi

3 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

nebulight avatar image nebulight commented ·

Thanks! This is great. Now I just need to go through all the google threads I did yesterday to get this working and make copies of files and place them in a directory.

0 Likes 0 ·
lederhos avatar image lederhos nebulight commented ·

If you find a good thread or two that you can recommend on configuring the touchscreen, please post. Did the same thing as you a few days earlier and spent countless hours sifting back through without success.

0 Likes 0 ·
lederhos avatar image lederhos commented ·

Thanks @WKirby!

0 Likes 0 ·
vk2emp avatar image
vk2emp answered ·

I have had this problem as well. I just found this post (and thus the culprit) that kept deleting my config for my 7" screen. I wrote a little script that sits in the u-boot folder (the boot partition) that handles my setup nicely. It reinstalls the opkg bits and pieces, runs a screen calibration, replaces the start-gui.sh script, renames the headless file to headless.off, and reboots the pi. I will automate it now, so it can check for the existance of the headless.off file, and if exist, exit, else run script at u-boot, using rc.local on each boot. If I turn on the backlight (hardware switch only) and see a touchscreen calibration on the panel, I know its updated.

10 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

nebulight avatar image nebulight commented ·

Care to share the script for the community?

0 Likes 0 ·
vk2emp avatar image vk2emp nebulight commented ·

Sure - for me its a basic check for a modification to the start-gui.sh script in /opt/victronenergy/gui

This script gets placed into /data and alongside goes the modified copy (the one you have changed to support the touch screen) of start-gui.sh


ssh in with root, and cd to /data


type "nano rc.local", and press enter, a nano editor console will appear and paste this into it, excluding the <script></end script>:


<script>


if diff /data/start-gui.sh /opt/victronenergy/gui/start-gui.sh >/dev/null;

then

echo "no software update detected, exiting"

else

opkg-update

opkg install qt4-embedded-plugin-mousedriver-tslib

opkg install tslib-calibrate

opkg install tslib-conf

opkg install tslib-tests

TSLIB_PLUGINDIR=/usr/lib/ts ts_calibrate

rm /opt/victronenergy/gui/start-gui.sh

cp /data/start-gui.sh /opt/victronenergy/gui/start-gui.sh

mv /etc/venus/headless /etc/venus/headless.off

reboot

fi


<end script>


Save the script by pressing CTRL+O then enter, then exit the nano console with CTRL+X

place a copy of your modified start-gui.sh into the /data folder as well. Its located at "/opt/victronenergy/gui". As each setup is different, you should use yours, as touchscreen drivers differ between setups. You may also need to modify the driver install lines starting with the opkg install qt4... line


Make your rc.local script executable with


"chmod +x rc.local"


then test it, with "./rc.local"


If no update has occured the first echo statemant is shown, and the script aborts, letting the pi continues to boot without changes, if the changes have occured, the script runs through, and your screen will be in calibration mode. Once you finish calibration, the pi will restart and gui will be restored.


My script started out as "fixthiss##t.sh" in the u-boot folder, but once I discovered the joys of rc.local, and the persistent data folder, I moved it to there along with its trigger, start-gui.sh, and then added the if, then, else and fi, to automate it.


Enjoy


0 Likes 0 ·
Show more comments
mihair avatar image
mihair answered ·

For me is a little bit more complicated as I have a canbus BMS and a can interface which does not keep config after upgrade.

Here is the script, maybe help someone ...


#!/bin/bash

if diff /data/backup_custom_files/canbus_ports /etc/venus/canbus_ports > /home/root/post_upgrade.txt 2>&1 ;

then

echo "No change"

else

echo "can0" > /etc/venus/canbus_ports

cp -pr /data/backup_custom_files/can-bus-bms/service/* /opt/victronenergy/can-bus-bms/service/ >> /home/root/post_upgrade.txt 2>&1

cp -pr /data/backup_custom_files/dbus-motordrive/service/* /opt/victronenergy/dbus-motordrive/service >> /home/root/post_upgrade.txt 2>&1

cp -pr /data/backup_custom_files/dbus-valence/service/* /opt/victronenergy/dbus-valence/service >> /home/root/post_upgrade.txt 2>&1

cp -pr /data/backup_custom_files/vecan-dbus/service/* /opt/victronenergy/vecan-dbus/service >> /home/root/post_upgrade.txt 2>&1

cp -pr /data/backup_custom_files/mqtt-n2k/service/* /opt/victronenergy/mqtt-n2k/service >> /home/root/post_upgrade.txt 2>&1

ln -s /opt/victronenergy/can-bus-bms/service /service/can-bus-bms.can0 >> /home/root/post_upgrade.txt 2>&1

ln -s /opt/victronenergy/dbus-motordrive/service /service/dbus-motordrive.can0 >> /home/root/post_upgrade.txt 2>&1

ln -s /opt/victronenergy/dbus-valence/service /service/dbus-valence.can0 >> /home/root/post_upgrade.txt 2>&1

ln -s /opt/victronenergy/vecan-dbus/service /service/vecan-dbus.can0 >> /home/root/post_upgrade.txt 2>&1

ln -s /opt/victronenergy/mqtt-n2k/service /service/mqtt-n2k.can0 >> /home/root/post_upgrade.txt 2>&1

opkg update >> /home/root/post_upgrade.txt 2>&1

opkg install qt4-embedded-plugin-mousedriver-tslib >> /home/root/post_upgrade.txt 2>&1

opkg install tslib-calibrate >> /home/root/post_upgrade.txt 2>&1

opkg install tslib-conf >> /home/root/post_upgrade.txt 2>&1

opkg install tslib-tests >> /home/root/post_upgrade.txt 2>&1

cp -pr /data/backup_custom_files/ts.conf /etc/ts.conf >> /home/root/post_upgrade.txt 2>&1

cp -pr /data/backup_custom_files/pointercal /etc/pointercal >> /home/root/post_upgrade.txt 2>&1

cp -pr /data/backup_custom_files/start-gui.sh /opt/victronenergy/gui/start-gui.sh >> /home/root/post_upgrade.txt 2>&1

opkg install kernel-module-rpi-backlight >> /home/root/post_upgrade.txt 2>&1

echo "/sys/class/backlight/rpi_backlight" > /etc/venus/backlight_device

echo "/sys/class/backlight/rpi_backlight/bl_power" > /etc/venus/blank_display_device

mv /etc/venus/headless /etc/venus/headless.off >> /home/root/post_upgrade.txt 2>&1

echo "Copied back all custom files"

fi

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Mark avatar image
Mark answered ·

Hi All

Firstly id like to say thank you to everyone and my code/script below is hash up of different lines from lots of other peoples ones and a few lines ive added. so credit to lots of people thanks.

ok so..... I cant seem to get this to work?? first time it just went into a reboot loop, second time it just stopped at first splash screen (same as fresh image install), Third try it comes up with touch cal' screen but then reboots and starts looping cal'screen?

can any one please help and point me in the right direction? what i'm missing or what ive done wrong?

Thanks Mark

This is my rc.local

#The script exists in /data

#open an ssh to the device, and change directory to /data.

# cd /data

#then create a script called rc.local with nano

# nano rc.local

#fill the file with all the commands you need to make the system the way you like it then CTRL+O to save it then CTRL+X to exit

#then make the script executable.

# chmod 755 rc.local

#Any modified files will need to be also located in /data

#here is my version of the rc.local contents between the #####

#ive added a file called fw to /opt/victronenergy/gui/

####

if diff /data/backup/fw /opt/victronenergy/gui/fw >/dev/null;

then


echo "no software update detected, exiting"

else

opkg-update

opkg install qt4-embedded-plugin-mousedriver-tslib

opkg install tslib-calibrate

opkg install tslib-conf

opkg install tslib-tests

TSLIB_PLUGINDIR=/usr/lib/ts ts_calibrate

TSLIB_FBDEVICE=/dev/fb0

TSLIB_TSDEVICE=/dev/input/touchscreen0

TSLIB_CALIBFILE=/etc/pointercal

TSLIB_CONFFILE=/etc/ts.conf

TSLIB_PLUGINDIR=/usr/lib/ts

rm /opt/victronenergy/gui/start-gui.sh

rm /etc/pointercal

echo '/sys/class/backlight/rpi_backlight/bl_power' >/etc/venus/blank_display_device

echo '/sys/class/backlight/rpi_backlight' >/etc/venus/backlight_device

cp /data/Backup/start-gui.sh /opt/victronenergy/gui/start-gui.sh

cp /data/Backup/pointercal /etc/pointercal

chmod 755 /opt/victronenergy/gui/start-gui.sh

opkg install kernel-module-rpi-backlight

cp /data/Backup/blank_display_device /etc/venus/blank_display_device

cp /data/Backup/backlight_device /etc/venus/backlight_device

cp /data/Backup/gpio_list /etc/venus/gpio_list

cp /data/Backup/relaystate.py /opt/victronenergy/dbus-systemcalc-py/delegates/relaystate.py

cp /data/Backup/relaystate.pyc /opt/victronenergy/dbus-systemcalc-py/delegates/relaystate.pyc

mkdir /opt/victronenergy/dbus-adc/

mkdir /opt/victronenergy/dbus-adc/sevice/

mkdir /opt/victronenergy/dbus-adc/service/log/

cp /data/Backup/dbus-adc/log/run /opt/victronenergy/dbus-adc/log/run

cp /data/Backup/dbus-adc/service/log/run /opt/victronenergy/dbus-adc/service/log/run

cp /data/Backup/dbus-adc/service/run /opt/victronenergy/dbus-adc/service/run

cp /data/Backup/dbus-adc/dbus-adc /opt/victronenergy/dbus-adc/dbus-adc

cp /data/Backup/dbus-adc/start-adc.sh /opt/victronenergy/dbus-adc/start-adc.sh

cp /data/Backup/dbus-adc/dbus-adc.conf /etc/venus/dbus-adc.conf

opkg install kernel-module-mcp320x

chmod 755 /opt/victronenergy/dbus-adc/start-adc.sh

chmod 755 /opt/victronenergy/dbus-adc/dbus-adc

chmod 755 /opt/victronenergy/dbus-adc/service/run

chmod 755 /opt/victronenergy/dbus-adc/log/run

touch /var/log/dbus-adc

ln -s /opt/victronenergy/dbus-adc/service /service/dbus-adc

cp /data/Backup/overview-generator.png /opt/victronenergy/themes/ccgx/images/overview-generator.png

cp /data/Backup/splash.png /opt/victronenergy/gui/splash.png

cp /data/Backup/fw /opt/victronenergy/gui/fw

cp /data/Backup/OverviewGenerator.qml /opt/victronenergy/gui/qml/OverviewGenerator.qml

cp /data/Backup/PageGenerator.qml /opt/victronenergy/gui/qml/PageGenerator.qml

cp /data/Backup/PageMain.qml /opt/victronenergy/gui/qml/PageMain.qml

cp /data/Backup/PageSettingsGeneral.qml /opt/victronenergy/gui/qml/PageSettingsGeneral.qml

cp /data/Backup/PageTankSensor.qml /opt/victronenergy/gui/qml/PageTankSensor.qml

cp /data/Backup/PageTankSetup.qml /opt/victronenergy/gui/qml/PageTankSetup.qml

cp /data/Backup/PageTemperatureSensor.qml /opt/victronenergy/gui/qml/PageTemperatureSensor.qml

cp /data/Backup/PageTemperatureSensorSetup.qml /opt/victronenergy/gui/qml/PageTemperatureSensorSetup.qml

cp /data/Backup/TileTank.qml /opt/victronenergy/gui/qml/TileTank.qml

mv /etc/venus/headless /etc/venus/headless.off

reboot

fi


#####

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Mark avatar image Mark commented ·

sorry forgot to mention im running v260-9 and trying to up date to v260-19 via online update on RPI3B+ with official raspberry 7" screen. all the page copy is due to renaming items in the page.

Thanks

0 Likes 0 ·
Rob Duthie avatar image
Rob Duthie answered ·

Hi All

Re the latest script for the raspi, i have tested the latest version it reloads every thing now, all analog inputs, switching relays up to 6x now can be used ( have tested 8x) but over lapped the canbus control, canbus, display control and timers all functions, only a screen calibration to do on start up and auto reboots and you are away, The super user function is still there just enter a pass word only required if you want to log back on with WinSCP or Bitvise SSH etc

So all the opkg software updates as well are updated and installed

The VE can functions, the normal canbus functions OK with the Pylon tech and BYD lithium batteries etc.

Note: For this to work correctly you must have all the files & folders required to be saved in the data folder for the back up to work.

Tested script attached.

The commented out commands are for custom tiles settings only if required, (Mark Mevan from the UK) these are his custom tiles etc.

Enjoy

Rob D

NZ

Update Script Rob Duthie Test Ver.txt


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

neoneddy avatar image
neoneddy answered ·

I made some edits to it to keep it simple for simpler installs.


Also here are the copy commands you need to do before the script will work properly.

cp /opt/victronenergy/gui/start-gui.sh /data/start-gui.sh

cp /etc/venus/backlight_device /data/backlight_device

cp /etc/venus/blank_display_device /data/blank_display_device

cp /etc/pointercal /data/pointercal


One addition is the pointercal data, copy that out and then replace it. If the position of the screen never changes and the screen never changes, no need to re run it.

update-script-himmelberger-bus-edits.txt


1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

silicastormthai avatar image silicastormthai commented ·

Awesome thanks so much Shawn for making this entry, worked perfectly smooth while following your step-by-step process on YouTube.

https://youtu.be/UXskvldEmiw


0 Likes 0 ·

Related Resources