question

nebulight avatar image

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
10 |3000 characters needed characters left characters exceeded

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 Share
10 |3000 characters needed characters left characters exceeded

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

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

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.

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 Share
10 |3000 characters needed characters left characters exceeded

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

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.

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.

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

Share
10 |3000 characters needed characters left characters exceeded

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


Share
10 |3000 characters needed characters left characters exceeded

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

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


Share
10 |3000 characters needed characters left characters exceeded

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 Share
10 |3000 characters needed characters left characters exceeded

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

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

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 Share
10 |3000 characters needed characters left characters exceeded

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

Care to share the script for the community?

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


This is a jem, I just tried this. Working perfect.

I'm no amazing scripter - we have WKirby to thank for the diff parser, without that I would have probably settled for running my script each time the pi rebooted, resulting in a screen calibration at each boot which would become annoying. Thankfully, WKirby came to the rescue and now a calibration is only needed when an update occurs. Since its only a few seconds to touch the 5 points on the screen, I was too lazy to go looking for where the TS libraries store the calibration data and backing it up to /data ;)

Thats awesome thank you. how would you get it to add to files too? as I have to add files for adc and relays and edit the gpio list.

i'm no programmer but im happy to have a go if ive got some direction lol

basically everything you already have plus-

edit the config file

add an overlay into overlays folder mcp3008-overlay.dtb

Install dbus-adc file into /opt/victronenergy/

run these commands

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/service/log/run

touch /var/log/dbus-adc

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

add the relaystate updated files to

/opt/victronenergy/dbus-systemcalc-py/delegates

My Question is I suppose lo,

do I just add these commands to the script and where do I put the folders/files?

Thanks

Mark

I've got a new test bench setup, and I've got some odd behavior. I've stripped out all the touch screen settings as it appears that version 2.42 has the native drivers and touch screen calibration for the pi screen. I've got an ADC for tank monitor so I'm making the directories and copying the files there. I then copy over the backlight and slider for the touch screen and configure the settings required for the ADC. I then install the module for the hardware clock and make the unit boot the GUI with the headless off.

The script runs successfully, but will not go headless. To make things worse, I lose all connection to the Pi. I can't log into the web interface and I get:

Remote console

Failed to connect. Make sure to enable Remote
Console for LAN, and reboot the device.

I can no longer SSH into the device either. Not sure what I did that would cause this to break. Web interface won't load and can't SSH so I'm basically stuck imaging the card and starting over. I've done this about 6 times now. Odd thing is I don't get any errors when I run the script manually, it's only after it's rebooted when I can't login or access the gui or ssh.

I plug in a keyboard and I trip to run ./start-gui.sh an dI get Permission denied. I try bash start-gui.sh and it starts up. THEN I can access the web interface and SSH in. I haven't modified the start-gui.sh, but I've changed the third line from:


echo "*** Starting gui***"

to

echo "*** Starting gui Modified***"


Not sure where my issue is

Here is my rc.local script:


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

then

echo "NO SOFTWARE UPDATE FOUND"

else

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

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

mkdir /opt/victronenergy/dbus-adc/

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

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

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/backlight_device /etc/venus/backlight_device

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

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

opkg install kernel-module-rtc-ds1307

echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device

hwclock -s

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

reboot

fi

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

Ok, so testing this on 2.60~4 , Mine appears to no be updating packages and re-installing things. However, it does appear to copy the start-gui.sh over properly. Anyone else?

I'm still using a touch screen, I found I had to add a few steps. You need to manually copy the pointercal file. easy as

cp /etc/pointercal /data/pointercal

You could also consider adding in ts_calibrate and calibrate on every update.


Then I added setting the display blank and backlight devices. I'm still testing everything.



```

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

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/start-gui.sh /opt/victronenergy/gui/start-gui.sh

cp /data/pointercal /etc/pointercal

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


reboot

fi

```

I've stopped using the start-gui as it seems to not run after I copy it back. I forgot to update my thread, but I just created a random file in a location that I know will get over written, then just copy it back with my rc.local.

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