Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sw][linux][raspi][ioc] Raspberry Pi setup #78

Open
konosubakonoakua opened this issue Aug 3, 2024 · 7 comments
Open

[sw][linux][raspi][ioc] Raspberry Pi setup #78

konosubakonoakua opened this issue Aug 3, 2024 · 7 comments
Assignees

Comments

@konosubakonoakua
Copy link
Owner

konosubakonoakua commented Aug 3, 2024

raspberry-pi-imager

scoop install raspberry-pi-imager

Select board type & os, then flash sd card.

apt mirrors

sudo cp -f /etc/apt/sources.list /etc/apt/sources.list.bak
sudo tee /etc/apt/sources.list << 'EOF'
deb https://mirrors.bfsu.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.bfsu.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.bfsu.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware

# deb-src https://mirrors.bfsu.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.bfsu.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.bfsu.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
EOF
sudo apt update && sudo apt upgrade

samba & tftp

raspi docs samba

sudo apt update
sudo apt install samba samba-common-bin smbclient cifs-utils
cd ~
mkdir shared
chmod 0740 shared
sudo smbpasswd -a rpi
sudo tee -a /etc/samba/smb.conf << 'EOF'
[shared]
    path = /home/rpi/shared
    writable = yes
    browsable = yes
    public = yes
    create mask = 0777
    max connections = 10
EOF
sudo sed -i '/map to guest = bad user/s/^/# /' /etc/samba/smb.conf
sudo systemctl restart smbd
# trouble shoot
rm -rf /var/log/samba/log.smbd
sudo rm -rf /var/lib/samba/registry.tdb

Test setup (TFTP)

Install fzf/zellij/zoxide

Download them from windows side

share-files-with-scp

scp fzf zellij zoxide [email protected]:shared/

Or just use samba on windows side.

Install nvim

sudo apt update
sudo apt install snapd
sudo reboot
sudo snap install snapd
sudo snap install --classic nvim

rc-local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

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

### add your commands here ###

# keep this line
exit 0

uv & python

sudo apt-get install libffi-dev libjpeg-dev zlib1g-dev
curl -LsSf https://astral.sh/uv/install.sh | sh
source ~/.bashrc
uv python list
uv python install cpython-3.13.0+freethreaded-linux-aarch64-gnu
uv python install cpython-3.12.7-linux-aarch64-gnu
uv python install cpython-3.11.10-linux-aarch64-gnu
cat > ~/.config/uv/uv.toml << 'EOF'
index-url = "https://mirrors.bfsu.edu.cn/pypi/web/simple"
EOF

rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
@konosubakonoakua konosubakonoakua self-assigned this Aug 3, 2024
@konosubakonoakua konosubakonoakua changed the title [sw][linux][raspi][ioc] enable ipv4 on raspberrypi 3b with networkmanager [sw][linux][raspi][ioc] Raspberry Pi setup Nov 21, 2024
@konosubakonoakua
Copy link
Owner Author

konosubakonoakua commented Nov 21, 2024

ssh

#123

@konosubakonoakua
Copy link
Owner Author

konosubakonoakua commented Nov 25, 2024

nodejs

use nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

Install nodejs 20 version

nvm install 20
nvm use 20

@konosubakonoakua
Copy link
Owner Author

konosubakonoakua commented Nov 26, 2024

docker

sudo apt-get update
sudo apt-get install ca-certificates curl
case $(uname -a) in
  *ubuntu*) HOST_OS=ubuntu;;
  *Debian*) HOST_OS=debian;;
  *)
    echo "Unsupported system"
    exit 1
    ;;
esac
# Add Docker's official GPG key:
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/${HOST_OS}/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/${HOST_OS} \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo docker run hello-world

@konosubakonoakua
Copy link
Owner Author

konosubakonoakua commented Nov 26, 2024

Network

enable ipv4 on raspberrypi 3b with networkmanager (without raspi offical os)

  • use nmtui-edit to modify Wired Connection 1 located @ system-connections/Wired\ connection\ 1.nmconnection

    rpi@<hidden>:/etc/NetworkManager $ sudo cat system-connections/Wired\ connection\ 1.nmconnection 
    
    [connection]
    id=Wired connection 1
    uuid=<hidden>
    type=ethernet
    autoconnect-priority=-999
    interface-name=<hidden>
    
    [ethernet]
    
    [ipv4]
    address1=100.100.100.100/8,100.100.100.254
    may-fail=false
    method=manual
    
    [ipv6]
    addr-gen-mode=default
    method=disabled
    
    [proxy]
    
  • but how to automatically disable ipv6 when flashing os into sdcard?

    rpi@<hidden>:/etc/NetworkManager/system-connections $ sudo cat preconfigured.nmconnection 
    [connection]
    id=preconfigured
    uuid=<hidden>
    type=wifi
    [wifi]
    mode=infrastructure
    ssid=rfhjj
    hidden=false
    [ipv4]
    method=auto
    [ipv6]
    addr-gen-mode=default
    method=auto
    [proxy]
    [wifi-security]
    key-mgmt=wpa-psk
    psk=<hidden>
  • how to make mdns working

    • We need setup ipv4 first, use nmtui-edit then disable then enable connection by nmtui
    • https://wiki.archlinux.org/title/Avahi
    • In case you want to change mdns domain & host: sudo vi /etc/avahi/avahi-daemon.conf
      [server]
      host-name=<your host name>
      domain-name=local
      #browse-domains=0pointer.de, zeroconf.org
      use-ipv4=yes
      use-ipv6=no
      allow-interfaces=eth0
      #deny-interfaces=eth1
      #check-response-ttl=no
      #use-iff-running=no
      #enable-dbus=yes
      #disallow-other-stacks=no
      #allow-point-to-point=no
      #cache-entries-max=4096
      #clients-max=4096
      #objects-per-client-max=1024
      #entries-per-entry-group-max=32
      ratelimit-interval-usec=1000000
      ratelimit-burst=1000

@konosubakonoakua konosubakonoakua pinned this issue Nov 27, 2024
@konosubakonoakua
Copy link
Owner Author

konosubakonoakua commented Nov 27, 2024

epics on raspi

sudo apt -y install git net-tools build-essential re2c libnet-dev libpcap-dev libusb-1.0-0-dev
mkdir $HOME/EPICS
cd $HOME/EPICS
##git clone --recursive https://github.com/epics-base/epics-base.git
wget https://epics.anl.gov/download/base/base-7.0.8.1.tar.gz
tar xf base-7.0.8.1.tar.gz && ln -s base-7.0.8.1 epics-base
cd epics-base
make -j2 # rpi4b
~/EPICS/bin/linux-aarch64/caget

[!IMPORTANT]
You need to set PYEPICS_LIBCA to load the correct libca.so on rpi
Refer to: pyepics issue 238

cat >> ~/.bashrc << 'EOF'

export PYEPICS_LIBCA=$HOME/EPICS/epics-base/lib/linux-aarch64/libca.so

EOF

pythonsoftioc on raspi

# because it will install 7.0.7.99.0.2 which will not work with latest softioc
uv pip install epicscorelibs==7.0.7.99.1.1
uv pip install softioc

Then try with this test.

pcaspy on raspi

sudo apt install -y swig
mkdir ~/EPICS/support
cd ~/EPICS/support
wget https://github.com/epics-modules/pcas/archive/refs/tags/v4.13.3.tar.gz
mv v4.13.3.tar.gz pcas-4.13.13.tar.gz
tar xvzf pcas-4.13.3.tar.gz && rm pcas-4.13.3.tar.gz
cd ./pcas-4.13.3
cat > configure/RELEASE.local << EOF
EPICS_BASE = ${EPICS_BASE}
EOF
make -j4
cat >> ~/.bashrc << EOF
export PCAS=~/EPICS/support/pcas-4.13.3
EOF
source ~/.bashrc
uv pip install pcaspy

If encountered with: ImportError: libca.so.4.14.3: cannot open shared object file: No such file or directory, Check version first:

caget -V
ldd ~/.virtualenvs/ioc/lib/python3.12/site-packages/pcaspy/_cas.cpython-312-aarch64-linux-gnu.so

If epics version not matched with pcas build, then use ln -s to make softlinks for shared libs.

cd $EPICS_BASE/lib/linux-aarch64/
ln -s libca.so.4.14.4 libca.so.4.14.3
ln -s libCom.so.3.23.1 libCom.so.3.23.0

@konosubakonoakua
Copy link
Owner Author

konosubakonoakua commented Nov 27, 2024

gpio libs

pinout

https://pinout.xyz/

uv pip install adafruit-blinka gpiozero smbus smbus2 smbus3 spidev pyserial lgpio

@konosubakonoakua
Copy link
Owner Author

serial port monitoring

sudo apt install tio
tio -a latest --exclude-drivers=!(cp210x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant