From 23e4928015acc91a4507dd3e63b9a490eaf2495b Mon Sep 17 00:00:00 2001 From: Crescendo Fang Date: Sat, 4 Feb 2017 08:53:22 +0700 Subject: [PATCH 1/7] Daemon Installation Script No need to mix up daemon installation and firmware update preparation step. --- code/shell/config_for_pico.sh | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/code/shell/config_for_pico.sh b/code/shell/config_for_pico.sh index 0b17fb2..84890e0 100755 --- a/code/shell/config_for_pico.sh +++ b/code/shell/config_for_pico.sh @@ -18,24 +18,12 @@ pip install psutil echo '--- pip install xmltodict' pip install xmltodict -echo '--- save and edit cmdline.txt' -cp /boot/cmdline.txt /boot/cmdline.txt.save -sed -i 's| console=serial0,115200 console=tty1||' /boot/cmdline.txt - -echo '--- save and edit config.txt' -cp /boot/config.txt /boot/config.txt.save -sed -i 's|#dtparam=i2c_arm=on|dtparam=i2c_arm=on|' /boot/config.txt - - echo '--- adding line to config.txt' -echo -e "\n\ndtparam=pi3-disable-bt\n\n" >> /boot/config.txt +echo -e "\n\ndtoverlay=i2c-rtc,ds1307\n\n" >> /boot/config.txt +echo -e "\n\nenable_uart=1\n\n" >> /boot/config.txt echo '--- adding lines to /etc/modules' -echo -e "\n\ni2c-bcm2708\ni2c-dev\n\n" >> /etc/modules - -echo '--- disabling hciuart' -systemctl disable hciuart +echo -e "\n\ni2c-bcm2708\ni2c-dev\rtc-ds1307\n\n" >> /etc/modules echo '--- all done' exit 0 - From e584f0698d7beace22ad9ed5e014c8da51f78e72 Mon Sep 17 00:00:00 2001 From: Crescendo Fang Date: Sat, 4 Feb 2017 01:54:49 +0000 Subject: [PATCH 2/7] Firmware Update Preparation Script This is the script for firmware update preparation steps. --- code/shell/firmware_update.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 code/shell/firmware_update.sh diff --git a/code/shell/firmware_update.sh b/code/shell/firmware_update.sh new file mode 100644 index 0000000..1a96b64 --- /dev/null +++ b/code/shell/firmware_update.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ `whoami` != 'root' ]; then + echo 'Must be run as root' + exit 1 +fi + +set -e + +echo '--- save and edit cmdline.txt' +cp /boot/cmdline.txt /boot/cmdline.txt.save +sed -i 's| console=ttyAMA0,115200||' /boot/cmdline.txt + +echo '--- adding line to config.txt' +echo -e "\n\ndtparam=pi3-disable-bt\n\n" >> /boot/config.txt + +echo '--- disabling hciuart' +systemctl disable hciuart + +echo '--- disabling serial' +systemctl stop serial-getty@ttyAMA0.service +systemctl disable serial-getty@ttyAMA0.service +systemctl stop serial-getty@ttyS0.service +systemctl disable serial-getty@ttyS0.service + +echo '--- all done' +exit 0 \ No newline at end of file From 3ac60d8ef1f59b4f631e1e104043e1647f7f895b Mon Sep 17 00:00:00 2001 From: Crescendo Fang Date: Sat, 4 Feb 2017 01:57:09 +0000 Subject: [PATCH 3/7] Post-Firmware Update Script This script is for returning the OS to original state and undo all steps in firmware_update.sh. --- code/shell/post_firmware_update.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 code/shell/post_firmware_update.sh diff --git a/code/shell/post_firmware_update.sh b/code/shell/post_firmware_update.sh new file mode 100644 index 0000000..a80e8f0 --- /dev/null +++ b/code/shell/post_firmware_update.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ `whoami` != 'root' ]; then + echo 'Must be run as root' + exit 1 +fi + +set -e + +echo '--- save and edit cmdline.txt' +rm /boot/cmdline.txt +cp /boot/cmdline.txt.save /boot/cmdline.txt + +echo '--- adding line to config.txt' +sed -i 's|dtparam=pi3-disable-bt|#dtparam=pi3-disable-bt|' /boot/config.txt + +echo '--- enabling hciuart' +systemctl enable hciuart + +echo '--- enabling serial' +systemctl start serial-getty@ttyAMA0.service +systemctl enable serial-getty@ttyAMA0.service +systemctl start serial-getty@ttyS0.service +systemctl enable serial-getty@ttyS0.service + +echo '--- all done' +exit 0 \ No newline at end of file From e4b0804e5351934c95dbec4bb7494166061ba91f Mon Sep 17 00:00:00 2001 From: Crescendo Fang Date: Sat, 4 Feb 2017 09:10:14 +0700 Subject: [PATCH 4/7] Rename firmware_update.sh to pre_firmware_update.sh --- code/shell/{firmware_update.sh => pre_firmware_update.sh} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename code/shell/{firmware_update.sh => pre_firmware_update.sh} (98%) diff --git a/code/shell/firmware_update.sh b/code/shell/pre_firmware_update.sh similarity index 98% rename from code/shell/firmware_update.sh rename to code/shell/pre_firmware_update.sh index 1a96b64..e2fe0e0 100644 --- a/code/shell/firmware_update.sh +++ b/code/shell/pre_firmware_update.sh @@ -24,4 +24,4 @@ systemctl stop serial-getty@ttyS0.service systemctl disable serial-getty@ttyS0.service echo '--- all done' -exit 0 \ No newline at end of file +exit 0 From 5957b80a6a5a4962ceb7b607fb0c517f8f742e56 Mon Sep 17 00:00:00 2001 From: Crescendo Fang Date: Sat, 4 Feb 2017 09:39:52 +0700 Subject: [PATCH 5/7] Change in the Fan Speed displaying.... Better to use percentage for fan speed as the original script unable to parse 60% fan speed (0x3c) and throws this error below: UPS PIco FAN Speed....: Traceback (most recent call last): File "./pico_status.py", line 263, in print " ","UPS PIco FAN Speed....:",fan_speed(),"RPM" File "./pico_status.py", line 201, in fan_speed return int (float(data) * 100) ValueError: invalid literal for float(): 3c --- pico_status/pico_status_hv3.0.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/pico_status/pico_status_hv3.0.py b/pico_status/pico_status_hv3.0.py index 9e7be5d..4abfba0 100644 --- a/pico_status/pico_status_hv3.0.py +++ b/pico_status/pico_status_hv3.0.py @@ -155,8 +155,30 @@ def fan_state(): def fan_speed(): time.sleep(0.1) data = i2c.read_word_data(0x6b, 0x12) - data = format(data,"02x") - return (float(data) * 10) + if (data == 0x00): + return "OFF" + elif (data == 0x0a): + return "10%" + elif (data == 0x14): + return "20%" + elif (data == 0x1e): + return "30%" + elif (data == 0x28): + return "40%" + elif (data == 0x32): + return "50%" + elif (data == 0x3c): + return "60%" + elif (data == 0x46): + return "70%" + elif (data == 0x50): + return "80%" + elif (data == 0x5a): + return "90%" + elif (data == 0x64): + return "100%" + else: + return "ERROR" def r232_state(): time.sleep(0.1) @@ -210,9 +232,9 @@ def r232_state(): print " " print " ","PIco FAN Mode.........:",fan_mode() print " ","PIco FAN State........:",fan_state() -print " ","PIco FAN Speed........:",fan_speed(),"RPM" +print " ","PIco FAN Speed........:",fan_speed() print " " print "***********************************" print " Powered by PiCo " print "***********************************" -print " " \ No newline at end of file +print " " From 3d92f41ba3cfbbff5cb6bb751724088af3a651c6 Mon Sep 17 00:00:00 2001 From: Crescendo Fang Date: Sat, 4 Feb 2017 10:51:52 +0700 Subject: [PATCH 6/7] Update config_for_pico.sh --- code/shell/config_for_pico.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/shell/config_for_pico.sh b/code/shell/config_for_pico.sh index 84890e0..b5ab682 100755 --- a/code/shell/config_for_pico.sh +++ b/code/shell/config_for_pico.sh @@ -25,5 +25,8 @@ echo -e "\n\nenable_uart=1\n\n" >> /boot/config.txt echo '--- adding lines to /etc/modules' echo -e "\n\ni2c-bcm2708\ni2c-dev\rtc-ds1307\n\n" >> /etc/modules +echo '--- removing fake-hwclock' +apt-get -y remove fake-hwclock && sudo update-rc.d -f fake-hwclock remove + echo '--- all done' exit 0 From 8be92d4347b5e3b6314d63edb8cc79d4d8e6d8b8 Mon Sep 17 00:00:00 2001 From: Crescendo Fang Date: Sat, 4 Feb 2017 11:45:39 +0700 Subject: [PATCH 7/7] Update config_for_pico.sh include daemon installation... --- code/shell/config_for_pico.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/code/shell/config_for_pico.sh b/code/shell/config_for_pico.sh index b5ab682..73ab4a3 100755 --- a/code/shell/config_for_pico.sh +++ b/code/shell/config_for_pico.sh @@ -18,6 +18,13 @@ pip install psutil echo '--- pip install xmltodict' pip install xmltodict +echo '--- installing & enabling daemon' +cd PiModules/code/python/package +python setup.py install +cd ../upspico/picofssd +python setup.py install +systemctl enable picofssd.service + echo '--- adding line to config.txt' echo -e "\n\ndtoverlay=i2c-rtc,ds1307\n\n" >> /boot/config.txt echo -e "\n\nenable_uart=1\n\n" >> /boot/config.txt