SCU OS Setup Raspbian - Geowissenschaften/EXCISS GitHub Wiki

This document describes the setup of the SCU.
The installation process consists of these major steps:

Raspbian version used

Raspbian Stretch Lite
Minimal image based on Debian Stretch
Version: June 2018
Release date: 2018-06-27
Kernel version: 4.14
SHA-256: 3271b244734286d99aeba8fa043b6634cad488d211583814a2018fc14fdca313

Additional packages/software installed

  • ntfs-3g
  • lshw
  • git git-core
  • ImageMagick
  • wiringPi (via git)
  • Python module pyserial via pip

Documentation URLs

Download Raspbian for Raspberry Pi

Installing operating system images - Raspberry Pi Documentation

Special tasks to set up Raspbian


Install Raspbian onto SD card

Find SD card device on Linux PC

Take note of /dev/sd* devices without USB stick:

# df -h | egrep "Filesystem|/dev/sd"
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             477M  101M  352M  23% /boot

Insert USB Stick and find new /dev/sd* devices:

# df -h | egrep "Filesystem|/dev/sd"
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             477M  101M  352M  23% /boot
/dev/sdb1              42M   21M   21M  51% /media/boot
/dev/sdb2             4.4G  4.0G  216M  95% /media/rootfs

# dmesg | grep "logical blocks" | tail -1
sd 18:0:0:0: [sdb] 60367872 512-byte logical blocks: (30.9 GB/28.7 GiB)

$ sudo fdisk -l | grep "Disk /dev/sd"
Disk /dev/sda: 953,9 GiB, 1024209543168 bytes, 2000409264 sectors
Disk /dev/sdb: 298,1 GiB, 320072933376 bytes, 625142448 sectors
Disk /dev/sdc: 58,6 GiB, 62948114432 bytes, 122945536 sectors
Disk /dev/sde: 29,7 GiB, 31914983424 bytes, 62333952 sectors

Unmount any existing file system on the /dev/sd* device selected for Raspbian installation:

# umount /media/${USER}/boot /media/${USER}/rootfs

Install Raspbian from ZIP file onto SD card on Linux PC

# cd ~/Downloads
# ls -l *raspbian*.zip
-rw-r--r--  1 user user 366980542 Jul 21 19:24 2018-06-27-raspbian-stretch-lite.zip

# unzip -p 2018-06-27-raspbian-stretch-lite.zip | sudo dd bs=4M conv=fsync of=/dev/sdb
[sudo] password for user: *****
0+21315 records in
0+21315 records out
1862270976 bytes (1,9 GB, 1,7 GiB) copied, 86,8821 s, 21,4 MB/s

# sync;sync

Verify Installation (skipped)

# sudo dd bs=4M if=/dev/sdb of=from-sd-card.img

# truncate --reference 2018-06-27-raspbian-stretch.img from-sd-card.img

# diff -s from-sd-card.img 2018-06-27-raspbian-stretch.img

# sync;sync

Configure Raspbian on SD card

Mount and customize SD card on Linux PC

Eject and re-insert USB stick, so rootfs and boot are mounted automatically:

# df -h | egrep "Filesystem|media"
Filesystem                 Size  Used Avail Use% Mounted on
/dev/sdd2                  1,7G  945M  622M  61% /media/user/rootfs
/dev/sdd1                   43M   22M   21M  51% /media/user/boot

Enable SSH remote access:

# touch /media/${USER}/boot/ssh

Configure networking (example)

# cd /media/${USER}/rootfs

Modify etc/network/interfaces

# sudo cp -p etc/network/interfaces etc/network/interfaces.SAV
# sudo vi etc/network/interfaces
(...)
source-directory /etc/network/interfaces.d

### EXCISS MLU SCU modifications start ------------------------------

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan2
iface wlan2 inet manual
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

auto lo
iface lo inet loopback

iface HackFFM inet dhcp
iface Home inet dhcp
iface Work inet dhcp

auto eth0
iface eth0 inet static
address 192.168.1.123
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

### EXCISS MLU SCU modifications end   ------------------------------

Modify etc/wpa_supplicant/wpa_supplicant.conf

# sudo cp etc/wpa_supplicant/wpa_supplicant.conf etc/wpa_supplicant/wpa_supplicant.conf.SAV
# sudo vi etc/wpa_supplicant/wpa_supplicant.conf

(...)
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

### EXCISS MLU SCU modifications start ------------------------------

country=DE
ap_scan=2
eapol_version=1

#network={
#    id_str="Unsecured"
#    ssid=""
#    scan_ssid=1
#    mode=0
#    key_mgmt=NONE
#    ppriority=-999
#}

network={
    id_str="HackFFM"
    ssid="HACKFFM.DE"
    psk="*****"
    scan_ssid=1
    proto=RSN
    key_mgmt=WPA-PSK
    priority=1
}

network={
    id_str="Home"
    ssid="HomeWiFi"
    psk="Password"
    scan_ssid=1
    proto=RSN
    key_mgmt=WPA-PSK
    priority=2
}

network={
    id_str="Work"
    ssid="WorkWiFi"
    psk="Password"
    scan_ssid=1
    proto=RSN
    key_mgmt=WPA-PSK
    priority=3
}

### EXCISS MLU SCU modifications end   ------------------------------

Change the hostname

# cd /media/${USER}/rootfs

# cat etc/hostname
raspberrypi

# sudo cp etc/hostname etc/hostname.SAV
# sudo vi etc/hostname
exciss-space

# grep raspberrypi etc/hosts
127.0.1.1	raspberrypi

# sudo cp etc/hosts etc/hosts.SAV
# sudo vi etc/hosts
127.0.1.1	exciss-space # raspberrypi

Eject USB stick on Linux PC

# cd
# sync;sync
# umount /media/${USER}/boot /media/${USER}/rootfs

Configure Raspberry Pi

Connect from PC to Raspberry Pi via ssh

# ssh pi@exciss-space
The authenticity of host 'exciss-space (2001:16b8:28ae:a200:ba27:ebff:fe7c:e638)' can't be established.
ECDSA key fingerprint is SHA256:94SXNn3VdWeltwkALqbAAXbnNNvr/LshwhTbTzju++Y.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'exciss-space,2001:16b8:28ae:a200:ba27:ebff:fe7c:e638' (ECDSA) to the list of known hosts.
pi@exciss-space's password: raspberry
Linux exciss-space 4.14.50-v7+ #1122 SMP Tue Jun 19 12:26:26 BST 2018 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

Verify IP addresses currently in use:

# ifconfig -a | grep "inet "
        inet 192.168.1.123  netmask 255.255.255.0  broadcast 192.168.1.255
        inet 127.0.0.1  netmask 255.0.0.0
        inet 10.0.0.138  netmask 255.255.0.0  broadcast 10.0.255.255

Change OS password

# sudo passwd pi
Enter new UNIX password: *****
Retype new UNIX password: *****
passwd: password updated successfully

Update Raspbian to latest version

# sudo apt-get -qy update

# sudo apt-get -qy dist-upgrade

Install additional packages

Install NTFS-3G driver package

# sudo apt-get -qy install ntfs-3g

Install WiringPi via git

WiringPi is needed for system status reports (gpio).

# sudo apt-get -qy install git git-core

# cd
# git clone git://git.drogon.net/wiringPi
# cd wiringPi && ./build

Test WiringPi gpio tool:

# gpio readall
 +-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 |   IN | 1 |  3 || 4  |   |      | 5v      |     |     |
 |   3 |   9 |   SCL.1 |   IN | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 0 | IN   | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 1 | IN   | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 1 | IN   | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 1 | IN   | CE1     | 11  | 7   |
 |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
 |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
 |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |
 |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |
 |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
 |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+

NB: Updates to wiringPi (skipped - note for later)

# sudo apt-get update && sudo apt-get upgrade
# cd ${HOME}/wiringPi
# git pull origin
# ./build

NB: Install WiringPi "Plan B" (skipped - documented for scripting setup process)
WiringPi Plan B: Download top "snapshot" with wget from:

    2018-03-14 Gordon Henderson  update for the v3+ master 2.46  commit|commitdiff|tree|snapshot

WiringPi Plan B: Unpack and compile WiringPi source (skipped):

    # tar xfz wiringPi-98bcb20.tar.gz
    # cd wiringPi-98bcb20
    # ./build

Install ImageMagick

ImageMagick is needed for reading JPEG EXIF data (format).

# sudo apt-get -qy install imagemagick

Install lshw tool

lshw is needed for system status reports.

# sudo apt-get -qy install lshw

Install Python module pyserial via pip

pyserial is needed for MCU-SCU serial communication.

# sudo apt-get -qy install python-pip
# sudo pip install pyserial

NB: Python pyserial module alternative installation (skipped):

# python -m pip install pyserial

Expand rootfs (skipped)

Skip expand-rootfs (automatic with latest Raspbian)

# sudo raspi-config --expand-rootfs

Check root file system (/) is about the size of the SD card:

# df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       235G  1.4G  224G   1% /

Disable Raspbian services

# service --status-all | grep "\[ + \]"
 [ + ]  alsa-utils
 [ + ]  avahi-daemon
 [ + ]  bluetooth
 [ + ]  cron
 [ + ]  dbus
 [ + ]  dphys-swapfile
 [ + ]  fake-hwclock
 [ + ]  kmod
 [ + ]  networking
 [ + ]  procps
 [ + ]  raspi-config
 [ + ]  rsyslog
 [ + ]  ssh
 [ + ]  triggerhappy
 [ + ]  udev

# systemctl list-unit-files | grep enabled
[email protected]                        enabled
avahi-daemon.service                   enabled
bluetooth.service                      enabled
bthelper.service                       enabled
console-setup.service                  enabled
cron.service                           enabled
dbus-org.bluez.service                 enabled
dbus-org.freedesktop.Avahi.service     enabled
dhcpcd.service                         enabled
dhcpcd5.service                        enabled
fake-hwclock.service                   enabled
[email protected]                         enabled
hciuart.service                        enabled
keyboard-setup.service                 enabled
networking.service                     enabled
raspberrypi-net-mods.service           enabled
rpi-display-backlight.service          enabled
rsync.service                          enabled
rsyslog.service                        enabled
ssh.service                            enabled
sshswitch.service                      enabled
syslog.service                         enabled
systemd-timesyncd.service              enabled
triggerhappy.service                   enabled
wifi-country.service                   enabled
avahi-daemon.socket                    enabled
triggerhappy.socket                    enabled
nfs-client.target                      enabled
remote-fs.target                       enabled
apt-daily-upgrade.timer                enabled
apt-daily.timer                        enabled

# sudo timedatectl set-ntp false
# sudo update-rc.d networking disable

# sudo systemctl stop alsa-utils
# sudo systemctl mask alsa-utils
# sudo systemctl stop apt-daily-upgrade.timer
# sudo systemctl mask apt-daily-upgrade.timer
# sudo systemctl stop apt-daily.timer
# sudo systemctl mask apt-daily.timer
# sudo systemctl stop avahi-daemon.socket
# sudo systemctl mask avahi-daemon.socket
# sudo systemctl stop avahi-daemon
# sudo systemctl mask avahi-daemon
# sudo systemctl stop bluetooth.service
# sudo systemctl mask bluetooth.service
### sudo systemctl stop bthelper.service
### sudo systemctl mask bthelper.service
### sudo systemctl stop networking
### sudo systemctl mask networking
# sudo systemctl stop nfs-client.target
# sudo systemctl mask nfs-client.target
# sudo systemctl stop remote-fs.target
# sudo systemctl mask remote-fs.target
# sudo systemctl stop rpi-display-backlight.service
# sudo systemctl mask rpi-display-backlight.service
# sudo systemctl stop systemd-timesyncd
# sudo systemctl mask systemd-timesyncd
# sudo systemctl stop triggerhappy.socket
# sudo systemctl mask triggerhappy.socket
# sudo systemctl stop triggerhappy.service
# sudo systemctl mask triggerhappy.service

# sudo systemctl daemon-reload

# service --status-all | grep "\[ + \]"
 [ + ]  alsa-utils
 [ + ]  cron
 [ + ]  dbus
 [ + ]  dphys-swapfile
 [ + ]  fake-hwclock
 [ + ]  kmod
 [ + ]  procps
 [ + ]  raspi-config
 [ + ]  rsyslog
 [ + ]  ssh
 [ + ]  udev

# systemctl list-unit-files | grep enabled
[email protected]                        enabled  
console-setup.service                  enabled  
cron.service                           enabled  
dhcpcd.service                         enabled  
dhcpcd5.service                        enabled  
fake-hwclock.service                   enabled  
[email protected]                         enabled  
hciuart.service                        enabled  
keyboard-setup.service                 enabled  
raspberrypi-net-mods.service           enabled  
rsync.service                          enabled  
rsyslog.service                        enabled  
ssh.service                            enabled  
sshswitch.service                      enabled  
syslog.service                         enabled  
wifi-country.service                   enabled  

# sudo timedatectl
      Local time: Sun 2017-07-23 04:47:04 UTC
  Universal time: Sun 2017-07-23 04:47:04 UTC
        RTC time: n/a
       Time zone: Etc/UTC (UTC, +0000)
 Network time on: no
NTP synchronized: no
 RTC in local TZ: no

Enable serial UART ttyAMA0 on Raspberry Pi Zero W

Modify /boot/config.txt:

# sudo cp /boot/config.txt /boot/config.txt.SAV
# sudo vi /boot/config.txt

(...)
### -----------------------------------------------------------------
### EXCISS MLU SCU modifications start ------------------------------
### -----------------------------------------------------------------

# Enable audio (loads snd_bcm2835) - DISABLED
dtparam=audio=off

# Enable UART (for serial communication SCU-MCU)
enable_uart=1

# Disable Bluetooth (to free up UART)
dtoverlay=pi3-disable-bt

# Enable RasPi camera
start_x=1
gpu_mem=128

### EXCISS MLU SCU modifications end   ------------------------------

Modify /boot/cmdline.txt:
Remove console=serial0,* | console=ttyAMA0,* | kgdboc=serial0,* | kgdboc=ttyAMA0,*

# sudo cp /boot/cmdline.txt /boot/cmdline.txt.SAV
# sudo vi /boot/cmdline.txt

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

# diff /boot/cmdline.txt.SAV /boot/cmdline.txt | egrep "^<|^>"
< dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=ba4cd4a4-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
> dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

Make Raspbian more robust

Modify /etc/fstab:
Disable automatic 'fsck' at boot time by changing the sixth (last) field of /boot and / in /etc/fstab to 0.

# sudo cp /etc/fstab /etc/fstab.SAV
# sudo vi /etc/fstab

# diff /etc/fstab.SAV /etc/fstab | egrep "^<|^>" | sort -rk3
< PARTUUID=ba4cd4a4-01  /boot           vfat    defaults          0       2
> PARTUUID=ba4cd4a4-01  /boot           vfat    defaults          0       0
< PARTUUID=ba4cd4a4-02  /               ext4    defaults,noatime  0       1
> PARTUUID=ba4cd4a4-02  /               ext4    defaults,noatime  0       0

May be obsolete now that this is the default, but can not hurt to tune the / file system:

# sudo tune2fs -c -1 -i 0 /dev/mmcblk0p2
tune2fs 1.43.4 (31-Jan-2017)
Setting maximal mount count to -1
Setting interval between checks to 0 seconds

Disable cron jobs:
Add 'exit' and a blank line at the start of these scripts, then rename them to '.DISABLED'.

# sudo vi /etc/cron.hourly/fake-hwclock
# sudo mv /etc/cron.hourly/fake-hwclock /etc/cron.hourly/fake-hwclock.DISABLED

# sudo vi /etc/cron.daily/man-db
# sudo mv /etc/cron.daily/man-db /etc/cron.daily/man-db.DISABLED

# sudo vi /etc/cron.weekly/man-db
# sudo mv /etc/cron.weekly/man-db /etc/cron.weekly/man-db.DISABLED

# head -1 /etc/cron.hourly/fake-hwclock.DISABLED /etc/cron.daily/man-db.DISABLED /etc/cron.weekly/man-db.DISABLED
==> /etc/cron.hourly/fake-hwclock.DISABLED <==
exit
==> /etc/cron.daily/man-db.DISABLED <==
exit
==> /etc/cron.weekly/man-db.DISABLED <==
exit

Verify 'fsck.repair=yes' is in /boot/cmdline.txt:

# cat /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

Reboot Raspberry Pi

# sudo shutdown -Fr now

Prepare SCU environment

Logon to Raspberry Pi as user 'pi'

Enable auto-start of SCU environment at boot time

Modify /etc/rc.local:

# sudo cp /etc/rc.local /etc/rc.local.SAV
# sudo vi /etc/rc.local

(...)
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

### -----------------------------------------------------------------
### EXCISS MLU SCU modifications start ------------------------------
### -----------------------------------------------------------------
/opt/MLU/SCU/bin/SCU_boot
### EXCISS MLU SCU modifications end   ------------------------------

exit 0

Customize profile of user 'pi'

Modify file ${HOME}/.profile:

# cd
# cp .profile .profile.SAV
# vi .profile

(...)
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

### -----------------------------------------------------------------
### EXCISS MLU SCU modifications start ------------------------------
### -----------------------------------------------------------------

export SCU_HOME="/opt/MLU/SCU"
export PATH="${SCU_HOME}/bin:${SCU_HOME}/lib:${PATH}"

# set -o vi

alias la="ls -la"
alias ll="ls -l"
alias h="fc -l"

alias e="cd ${SCU_HOME}"
alias log="cd ${SCU_HOME}/log"

alias UART="${SCU_HOME}/lib/lib_MCU_message f_MCU_send " # send any command to MCU
alias rom="${SCU_HOME}/lib/lib_MCU_message f_MCU_send rom" # signal boot ok + operation mode
alias etk="${SCU_HOME}/lib/lib_MCU_message f_MCU_send etk32767" # keepalive 546m = 9,1h
alias wps="${SCU_HOME}/lib/lib_MCU_message f_MCU_send wps1" # power science on (1)

alias Restart="${SCU_HOME}/lib/lib_MCU_message f_MCU_send SCU_Wakeup 5 && ${SCU_HOME}/lib/lib_MCU_message f_MCU_send SCU_Keepalive 1"

### EXCISS MLU SCU modifications end   ------------------------------

Load profile of user 'pi' (or re-login instead):

# . ./.profile

Create SCU directory structure

Manually set up diretory structures in ${SCU_HOME}.
Note: Run "SCU_setup" to do this automatically later.

Directory structure created here:

SCU_HOME="/opt/MLU/SCU"

	bin
	data
	etc
	lib
	log
	mnt
	profiles
	tmp
	update
	USB_A
	USB_B
	USB_X
		TO_GROUND
		TO_SPACE
			updates
# sudo mkdir -p ${SCU_HOME}
# sudo chown -R pi:pi /opt/MLU
# e # cd ${SCU_HOME}
# mkdir -p USB_A USB_B USB_X/TO_SPACE/updates USB_X/TO_GROUND
# mkdir bin data etc lib log mnt profiles tmp update
# chmod -R 0775 /opt/MLU

# find ${CSU_HOME} -ls
   126510      4 drwxrwxr-x  14 pi       pi           4096 Jul 21 18:49 .
   126521      4 drwxrwxr-x   2 pi       pi           4096 Jul 21 18:49 ./update
   126519      4 drwxrwxr-x   2 pi       pi           4096 Jul 21 18:49 ./profiles
   126518      4 drwxrwxr-x   2 pi       pi           4096 Jul 21 18:49 ./mnt
   126514      4 drwxrwxr-x   2 pi       pi           4096 Jul 21 18:49 ./data
   130225      4 drwxrwxr-x   2 pi       pi           4096 Jul 21 18:49 ./USB_B
   126520      4 drwxrwxr-x   2 pi       pi           4096 Jul 21 18:49 ./tmp
   130232      4 drwxrwxr-x   4 pi       pi           4096 Jul 21 18:49 ./USB_X
   130233      4 drwxrwxr-x   3 pi       pi           4096 Jul 21 18:49 ./USB_X/TO_SPACE
   130234      4 drwxrwxr-x   2 pi       pi           4096 Jul 21 18:49 ./USB_X/TO_SPACE/updates
   130235      4 drwxrwxr-x   2 pi       pi           4096 Jul 21 18:49 ./USB_X/TO_GROUND
   126515      4 drwxrwxr-x   2 pi       pi           4096 Jul 21 18:49 ./etc
   126513      4 drwxrwxr-x   2 pi       pi           4096 Jul 21 18:49 ./bin
   126516      4 drwxrwxr-x   2 pi       pi           4096 Jul 21 18:49 ./lib
   126522      4 drwxrwxr-x   2 pi       pi           4096 Jul 21 18:49 ./USB_A
   126517      4 drwxrwxr-x   2 pi       pi           4096 Jul 21 18:49 ./log

EXCISS - Initially provided binaries

This is the minimal file set to enable GPIO shutdown.

SCU_HOME="/opt/MLU/SCU"

  • etc/SCU_env
  • bin/PI_shutdown_IO
  • bin/SCU_boot
  • lib/lib_SCU_base
# chmod +x bin/* lib/*

Backup and clone RPi SD cards

Load SD card in reader on Linux PC and find the device by size (here 16GB):

# sudo fdisk -l | egrep "Disk /dev/sd"
Disk /dev/sda: 953.9 GiB, 1024209543168 bytes, 2000409264 sectors
Disk /dev/sdb: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Disk /dev/sdc: 14.7 GiB, 15720251392 bytes, 30703616 sectors

Create backup file of whole SD card with 'dd':

# sudo dd bs=4M if=/dev/sdc | gzip > $(date +%Y%m%d)_$(hostname -s).img.gz
3748+0 records in
3748+0 records out
15720251392 bytes (16 GB, 15 GiB) copied, 770.988 s, 20.4 MB/s

Check progress of 'dd' process:

# sudo pkill -USR1 -x dd
849+0 records in
848+0 records out
3556769792 bytes (3.6 GB, 3.3 GiB) copied, 265.619 s, 13.4 MB/s

Restore SD card from backup file:

# sudo gzip -dc *_*.img.gz | sudo dd bs=4M of=/dev/sdc
0+273471 records in
0+273471 records out
15720251392 bytes (16 GB, 15 GiB) copied, 1314.48 s, 12.0 MB/s