Epics@GSI Webhome

Epics Installation At Raspberry Pi From Scratch

Detailed Table of Content

Installing Raspbian/Debian image

see e.g. https://www.raspberrypi.org/documentation/installation/installing-images/

    Download Image, Write Image, First Boot, Login

    1. Consult e.g. http://elinux.org/RPi_SD_cards#Working_.2F_Non-working_SD_cards to not purchase wrong SD cards.
    2. Download Image
    3. Write Image to the SD card
    4. Plug SD card into the Raspberry PI
    5. Connect Monitor via HDMI and Keyboard/Mouse
    6. Power on
    7. STRETCH image already ends up at the Desktop GUI logged in as user pi

    For registration purposes extract the SERIAL number and the type of RASPI

      Serial number

      ( e.g. q.v. https://developer-blog.net/raspberry-pi-seriennummer-ausgeben/ )
      cat /proc/cpuinfo | grep Serial | cut -d' ' -f2

      Hardware type, origin

      ( e.g. q.v. https://elinux.org/RPi_HardwareHistory )
      cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}' | sed 's/^1000//'



Configurations

    before connecting to GSI LAN ...

      GSI specific network settings

        IP6 permanent off
        (q.v. https://www.raspberrypi.org/forums/viewtopic.php?t=138899#p1140972 )
        • Add ipv6.disable=1 to /boot/cmdline.txt.
        • don't load ipv6 module at all



    reboot and connect network ...

    • connect network and
    • sudo reboot

    raspi-config

    1. raspi-config - Raspberry Pi Software Configuration Tool, current settings
      1. To start raspi-config:
        a. console based
        1. open a terminal, either by
          • mouse click, or
          • CTRL-ALT-F2
            • login, if necessary : pi/raspberry
        2. sudo raspi-config
        b. GUI based
        via the system menu → "raspi-config"
      2. If connected to the internet, then update
        • Update
      3. Localisation Options
        1. Timezone: Change TimezoneEuropeBerlin
        2. Keyboard Layout, (if needed)
          1. Change Keyboard Layout
            1. Generic 105-key (Intl) PC__→ __Other, (if not English) → GermanGerman
            2. Key to function as AltGr: Right Alt (AltGr)
            3. Compose key: No compose key
            4. Use Control+Alt+Backspace to terminate X server: <No>
      4. Change User Password (pi)
        pw.png
      5. Boot Options
        1. Desktop / CLIConsole Autologin
        2. Wait for Network at Boot<No>
          • requires some action on network (re)connection → dhcpd hooks
      6. Interfacing Options
        • SSHEnable

    %FOR{"_var_" start="0" stop="2" step="1"}% %NEXT{"v"}%

      1. <Finish>reboot<Yes>


    Image ("1st config" ) - optional Saving and Resizing the current Image


      Cleaning

        ssh_
        • delete and regenerate global keys

        ([ -f /var/log/regen_ssh_keys.log ] && sudo rm /var/log/regen_ssh_keys.log || : ; ) && 
                          sudo rm /etc/ssh/ssh_host* && 
                          sudo ssh-keygen -A
                         

        • check ~/.ssh/authorized_keys
          • optionally delete it :
            [ -f ~/.ssh/authorized_keys ] && rm ~/.ssh/authorized_keys
        • check ~/.ssh/known_hosts
          • optionally delete it :
            [ -f ~/.ssh/known_hosts ] && rm ~/.ssh/known_hosts

        clear logs
        • Before creating the next image,
          • Remove zipped files,
            clear all logs:, and
            history
            sudo su -c '(find /var/log -name "*.gz" -delete && for item in $(find /var/log/ -type f | grep -v git-daemon | grep -E -v '\.1$' ); do sudo cat /dev/null > $item;  done && history -c )'
               
            history -c

      1. Power off:
        sudo poweroff
      2. Remove SD card and save the current image.

      Shrinking the Image

      • Think of Resizing
        • Why? : Since the complete size of the SD is stored as image, and sizes of SD cards vary, a resize - at least a few MB is recommended.

        PiShrink
        1. Take out the SD card and copy the whole image (via WinDiskImager or better tools) to a linux box
        2. download piShrink


        other methods


      Current (resized) image files

        Distribution link parent directorySorted ascending comment
        Jessie
        2015 !
        Stretch
         



    more configurations, tools, installs

    1. Reinsert SD-Card, if removed, and power on
    2. login as user pi

    Aptitude based Install Packages

      ( <a style="font-size:smaller" href="/edit/Epics/EpicsInstallationAtRaspberryPiFromScratchAptitudeInstalls">edit</a> )

      Detailed

        1. Update & Safe-Upgrade
          sudo aptitude update
          sudo aptitude -y safe-upgrade
          • takes ~1h or more
        ncurses
        sudo aptitude -y install ncurses-bin ncurses-dev libncurses-dev libncurses5
        readline
        sudo aptitude -y install libreadline-dev
        tecla
        sudo aptitude -y install libtecla-dev
        htop
        sudo aptitude -y install htop
        (m)locate
        sudo aptitude -y install locate mlocate
        tmux
        sudo aptitude -y install tmux
        procServ & telnet
        sudo aptitude -y install procserv telnet
        vim
        sudo aptitude -y install vim
        git
        sudo aptitude -y install vim-fugitive qgit python-git gitk git-all
        ntpdate
        sudo aptitude -y install ntpdate
        re2c
        sudo aptitude -y install re2c
        __pcre
        sudo aptitude -y install libpcre3-dev libpcre++-dev
        WiringPi
        sudo aptitude -y install wiringpi
        picocom / microcom
        sudo aptitude -y install picocom microcom
        ca-certificates
        sudo aptitude -y install ca-certificates
        python-dev python.gpio
        sudo aptitude -y install python-setuptools ipython python-dev python-gpiozero
        postgres client &amp server
        sudo aptitude -y install postgresql-all postgresql-autodoc postgresql-client postgresql-client-common postgresql-doc pgadmin3 pgadmin3-data phppgadmin
        tightvncserver
        sudo aptitude -y install tightvncserver
        i2c-tools
        sudo aptitude -y install i2c-tools
        7z
        sudo aptitude -y install p7zip-full
        avr
        sudo aptitude -y install avr-libc avrdude avrp binutils-avr gcc-avr gdb-avr simulavr avarice
        munin_node
        sudo aptitude -y install munin-node lm-sensors munin-plugins-extra
        ntp
        sudo aptitude -y install ntp
        1. Finally update & Safe-Upgrade & autoclean
          sudo aptitude update &&
          sudo aptitude -y safe-upgrade &&
          sudo aptitude -y autoclean


      Compact

        sudo aptitude update  &&  
        sudo aptitude -y safe-upgrade  &&  
        sudo aptitude -y install ncurses-bin ncurses-dev &&  
        sudo aptitude -y install libncurses-dev libncurses5 &&  
        sudo aptitude -y install libtecla-dev libreadline-dev  &&  
        sudo aptitude -y install htop   &&  
        sudo aptitude -y install locate mlocate    &&  
        sudo aptitude -y install tmux procserv  &&  
        sudo aptitude -y install telnet  &&  
        sudo aptitude -y install vim  vim-fugitive  &&  
        sudo aptitude -y install qgit python-git gitk git-all   &&  
        sudo aptitude -y install ntpdate  &&  
        sudo aptitude -y install re2c libpcre3-dev libpcre++-dev  &&  
        sudo aptitude -y install wiringpi  &&  
        sudo aptitude -y install picocom microcom  &&  
        sudo aptitude -y install ca-certificates  &&  
        sudo aptitude -y install python-setuptools ipython python-dev python-gpiozero  &&  
        sudo aptitude -y install postgresql-all postgresql-autodoc postgresql-client postgresql-client-common postgresql-doc pgadmin3 pgadmin3-data phppgadmin   &&  
        sudo aptitude -y install tightvncserver  &&  
        sudo aptitude -y install i2c-tools && 
        sudo aptitude -y install p7zip-full &&  
        sudo aptitude -y install avr-libc avrdude avrp binutils-avr gcc-avr gdb-avr simulavr avarice &&  
        sudo aptitude -y install munin-node lm-sensors munin-plugins-extra && 
        sudo aptitude -y install ntp &&
        sudo aptitude update  &&  
        sudo aptitude -y safe-upgrade && 
        sudo aptitude -y autoclean
           



    Image ("Packages")

      Cleaning

        ssh_
        • delete and regenerate global keys

        ([ -f /var/log/regen_ssh_keys.log ] && sudo rm /var/log/regen_ssh_keys.log || : ; ) && 
                          sudo rm /etc/ssh/ssh_host* && 
                          sudo ssh-keygen -A
                         

        • check ~/.ssh/authorized_keys
          • optionally delete it :
            [ -f ~/.ssh/authorized_keys ] && rm ~/.ssh/authorized_keys
        • check ~/.ssh/known_hosts
          • optionally delete it :
            [ -f ~/.ssh/known_hosts ] && rm ~/.ssh/known_hosts

        clear logs
        • Before creating the next image,
          • Remove zipped files,
            clear all logs:, and
            history
            sudo su -c '(find /var/log -name "*.gz" -delete && for item in $(find /var/log/ -type f | grep -v git-daemon | grep -E -v '\.1$' ); do sudo cat /dev/null > $item;  done && history -c )'
               
            history -c

      1. Power off:
        sudo poweroff
      2. Remove SD card and save the current image.

      Shrinking the Image

      • Think of Resizing
        • Why? : Since the complete size of the SD is stored as image, and sizes of SD cards vary, a resize - at least a few MB is recommended.

        PiShrink
        1. Take out the SD card and copy the whole image (via WinDiskImager or better tools) to a linux box
        2. download piShrink


        other methods


      Image location

        Distribution link parent directory comment
        Jessie
         
        Stretch
         


    Others

      printf 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", SYMLINK+="$env{ID_SERIAL}", GROUP="users", MODE="0666"\n 
                    SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ENV{ID_SERIAL}=="FTDI_FT232R_USB_UART_A100*", RUN+="/usr/bin/stty -F/dev/$kernel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke 115200 "\n 
                    SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ENV{ID_SERIAL}=="FTDI_FT232R_USB_UART_A801*", RUN+="/usr/bin/stty -F/dev/$kernel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke 115200 "\n' > /tmp/99-serial-permissions.rules && 
            sudo chown root:root /tmp/99-serial-permissions.rules && 
            sudo mv /tmp/99-serial-permissions.rules /etc/udev/rules.d/
          

      update hostname on network connect via dhclient-exit-hook

      ... see the details at: dhclient - dynamic hostname

      Provided you have root privileges this can be achieved by creating a script file hostname created in /etc/dhcp/dhclient-exit-hooks.d/ (on Debian), which is sourced by dhclient after having updated/received its DHCP informations.

      #!/bin/sh
         # Filename:     /etc/dhcp/dhclient-exit-hooks.d/hostname
         # Purpose:      Used by dhclient-script to set the hostname of the system
         #               to match the DNS information for the host as provided by
         #               DHCP.
         #
            
         # Do not update hostname for virtual machine IP assignments
         if [ "$interface" != "eth0" ] && [ "$interface" != "eth1" ] && [ "$interface" != "wlan0" ]
         then
                 return
         fi
            
         if [ "$reason" != BOUND ] && [ "$reason" != RENEW ] && [ "$reason" != REBIND ] && [ "$reason" != REBOOT ]
         then
            return
         fi
         
         echo dhclient-exit-hooks.d/hostname: Dynamic IP address = $new_ip_address
         hostname=$(a=$(host $new_ip_address) || { false; } && { echo -n $a | cut -d ' ' -f 5 | cut -d "." -f 1; true; }) || unset hostname &&
         echo ${hostname?} > /etc/hostname &&
         hostname $hostname &&
         export HOSTNAME=$hostname &&
         echo dhclient-exit-hooks.d/hostname: Dynamic Hostname = $hostname
      

      Applying those code lines: %FOREACH{"file" in="/etc/dhcp/dhclient-exit-hooks.d/hostname"}%
      sudo curl -s https://wiki.gsi.de/pub/Epics/TipsLinuxDhclientDynamicHostname/_etc_dhcp_dhclient-exit-hooks.d_hostname -o $file && 
        sudo dos2unix $file && 
        sudo chmod a+r $file
      
      %NEXT{"file"}%


      ntp.conf / systemd-timesyncd

      For either ntp or systemd-timesyncd, deactivate the other and
      • adjust timeservers at /etc/ntp.conf to German de.pool.ntp.org
      • add (local) timeservers to /etc/ntp.conf, e.g.
        • local network servers server 192.168.100.50 iburst
        • site server server timeserver1.gsi.de iburst
        • not recommeded, german main time server server ptbtime1.ptb.de iburst


        systemd-timesyncd
          sudo apt-get purge ntp
          systemctl restart systemd-timesyncd.service
          sudo timedatectl set-ntp true

          set NTP timeservers at /etc/systemd/timesyncd.conf
            add space seperated list of time servers:
            • timeserver 192.168.100.50 timeserver1.gsi.de de.pool.ntp.org ptbtime1.ptb.de
            sudo nano /etc/systemd/timesyncd.conf

            sudo systemctl restart systemd-timesyncd.service
            sudo timedatectl set-ntp true



        ntp
        sudo systemctl stop systemd-timesyncd
        sudo systemctl disable systemd-timesyncd
          adjust timeservers at /etc/ntp.conf to German de.pool.ntp.org
          sudo perl -pi.bak -e 's/^(server [0123])\..*?\.pool\.ntp\.org/\1.de.pool.ntp.org/g' /etc/ntp.conf

          add (local) timeservers to /etc/ntp.conf
          e.g.
          • local network servers server 192.168.100.50 iburst
          • site server server timeserver1.gsi.de iburst
          • not recommeded, german main time server server ptbtime1.ptb.de iburst


      force update of time on network (re)connect via dhclient-exit-hook

      ... see the details at: dhclient - forced time update

      Provided you have root privileges this can be achieved by creating a script file ntp_force_update created in /etc/dhcp/dhclient-exit-hooks.d/ (on Debian), which is sourced by dhclient after having updated/received its DHCP informations.

      #!/bin/sh
         # Filename:     /etc/dhcp/dhclient-exit-hooks.d/ntp_force_update
         # Purpose:      Used by dhclient-script to set the time of the system
         #
             
         # Do not update hostname for virtual machine IP assignments
         if [ "$interface" != "eth0" ] && [ "$interface" != "eth1" ] && [ "$interface" != "wlan0" ]
         then
                 return
         fi
             
         if [ "$reason" != BOUND ] && [ "$reason" != RENEW ] && [ "$reason" != REBIND ] && [ "$reason" != REBOOT ]
         then
            return
         fi
           
         service ntp status >/dev/null 2>&1 && 
         (
           sleep 5 && 
           service ntp stop && 
           ntpd -qg ; 
           service ntp start; 
           touch /tmp/force_update
         ) &
         
          systemctl status systemd-timesyncd.service >/dev/null 2>&1 && 
         (
           sleep 5 && 
           systemctl status systemd-timesyncd.service stop && 
           timedatectl ; 
           systemctl status systemd-timesyncd.service start; 
           touch /tmp/force_update
         ) &
      Applying those code lines: %FOREACH{"file" in="/etc/dhcp/dhclient-exit-hooks.d/ntp_force_update"}%
      sudo curl -s https://wiki.gsi.de/pub/Epics/TipsLinuxDhclientForceTimeUpdate/_etc_dhcp_dhclient-exit-hooks.d_ntp_force_update -o $file && 
        sudo dos2unix $file && 
        sudo chmod a+r $file
      
      %NEXT{"file"}%


      docker

      If you would like to use Docker as a non-root user, you should now consider
      adding your user to the "docker" group with something like:
      
        sudo usermod -aG docker your-user
      
      Remember that you will have to log out and back in for this to take effect!
      
      WARNING: Adding a user to the "docker" group will grant the ability to run
               containers which can be used to obtain root privileges on the
               docker host.
               Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
               for more information.
      
      

      bash_completion

      • edit /etc/bash.bashrc and uncomment bash_completion section
        sudo vi /etc/bash.bashrc

      optional topics

      ([ -f /var/log/regen_ssh_keys.log ] && sudo rm /var/log/regen_ssh_keys.log || : ; ) && 
                        sudo rm /etc/ssh/ssh_host* && 
                        sudo ssh-keygen -A
                       

        • ssh-key-copy
      • .bashrc / .profile


    1-wire support module

    Image ("Packages + 'Others'")


      Cleaning

        ssh_
        • delete and regenerate global keys

        ([ -f /var/log/regen_ssh_keys.log ] && sudo rm /var/log/regen_ssh_keys.log || : ; ) && 
                          sudo rm /etc/ssh/ssh_host* && 
                          sudo ssh-keygen -A
                         

        • check ~/.ssh/authorized_keys
          • optionally delete it :
            [ -f ~/.ssh/authorized_keys ] && rm ~/.ssh/authorized_keys
        • check ~/.ssh/known_hosts
          • optionally delete it :
            [ -f ~/.ssh/known_hosts ] && rm ~/.ssh/known_hosts

        clear logs
        • Before creating the next image,
          • Remove zipped files,
            clear all logs:, and
            history
            sudo su -c '(find /var/log -name "*.gz" -delete && for item in $(find /var/log/ -type f | grep -v git-daemon | grep -E -v '\.1$' ); do sudo cat /dev/null > $item;  done && history -c )'
               
            history -c

      1. Power off:
        sudo poweroff
      2. Remove SD card and save the current image.

      Shrinking the Image

      • Think of Resizing
        • Why? : Since the complete size of the SD is stored as image, and sizes of SD cards vary, a resize - at least a few MB is recommended.

        PiShrink
        1. Take out the SD card and copy the whole image (via WinDiskImager or better tools) to a linux box
        2. download piShrink


        other methods


      Current (resized) image files

        Distribution link parent directory comment
        Jessie
        2016 !
        Stretch
        ---
        ---
        skipped


    EPICS

      Users

      • adduser epics:
        sudo adduser epics
        • epics/r p i - c t r l
        • epics, add to groups, amongst other, become "sudoer"
          (
            myGROUPS="adm dialout cdrom sudo audio video plugdev games users input netdev spi"; 
            for group in $myGROUPS; 
            do 
               sudo adduser epics $group; 
            done; 
            unset myGROUPS;
          ) 
          
      • set epics's sudoer actions
        1. open visudo to change sudoer settings: visudo
        2. add this line at the end of the file, close to pi's settings: epics ALL=(ALL) NOPASSWD: ALL


      Directory

      mkdir -p ~epics/EPICS/{EPICS-3.15.3,bin,programs}


      . epics

      sudo ln -s ~/EPICS/bin/epics /usr/local/bin/epics


      Base

      • readline -> EPICS CONFIG

      Extensions


      Modules

      StreamDevice, Asyn, stats, sscan

    Notizen

    Options:

    Firmware update

    First, no since read this:
    https://www.raspberrypi.org/documentation/raspbian/updating.md

    But if you want the upmost, experimental Firmware
    http://raspberrypiguide.de/howtos/raspberry-pi-firmware-update/

    Kernel building

    First, no since read this:
    https://www.raspberrypi.org/documentation/raspbian/updating.md
    optionally
    https://www.raspberrypi.org/documentation/linux/kernel/building.md

    U-Boot

    http://elinux.org/RPi_U-Boot

    Device Tree


    -- PeterZumbruch - 2018-05-02
    -- PeterZumbruch - 2020-11-09
Topic revision: r52 - 2020-11-09, PeterZumbruch
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding GSI Wiki? Send feedback | Legal notice | Privacy Policy (german)