-
-
Notifications
You must be signed in to change notification settings - Fork 623
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
Raspberry Pi Zero 2 W Support? #2108
Comments
@mcrosson, thank you for creating an issue. Yes, I'd be happy to see your notes. I don't mind if they're dense. I really appreciate it. |
reply to @nicomiguelinothe below is everything ive found related to the raspberry pi zero 2 w. a lot of the changes will likely need adjusting if incorporated into the main anthias project. you're welcome to borrow/use/etc anything from the below. i hope the below has enough clarity to be useful but if not, i can provide any additional detail as desired. overview of issuethe anthias installer hangs and sometimes crashes when run on a raspberry pi zero 2 w -- its essentially 'impossible' to install anthias on a pi zero 2 w without changes to the anthias install procedure. i managed to find fixes that allow anthias to be installed on a pi zero 2 w. these fixes are fully documented below. i also found additional items that should be addressed for better pi zero 2 w support. these items are also documented below. some of these may also be applicable to other raspberry pi setups. i don't know how the maintainers may want to proceed and have placed my notes here for reference. hopefully they will allow for another person to put together patch(es) based on my notes that meet the requirements for inclusion in the project. environment / hardware
related github issues (probably)critical / must read before continuingthe below will allow anthias to be installed on a pi zero 2 w with an sd card. HOWEVER: IT WILL NOT RUN PROPERLY POST INSTALL post install, anthias will cause load average spikes over 40 and will generally Not Work at all. anthias requires a storage setup thats fast enough to keep pace with the containers. the containers perform heavy disk io and will make the setup wholly unusable on the pi zero 2 w. i have tested multiple sd cards and usb-otg disks, all fail to run the anthias services post-install. i cannot underscore this point enough: anthias will not run from an sd card or usb-otg properly on the pi zero 2 w based on my testing. fundamental fixes for installerswapswap is required for the install to work correctly. the current installer removes keeping ive included a work around / fix below. docker pulldocker tries to download and extract images in parallel which causes high load averages and lock ups. setting the ive included a work around / fix below. additional concerns (and fixes) beyond the installerthese items are mainly related to running anthias. the below will make anthias seem to start but in reality it will ultimately fail to run due to heavy disk io which causes load average spikes. the below changes mitigate this to an extend but to not fully solve the problem. note: ive left the system running overnight and it still had failed to start the anthias containers. the below mitigates problems running anthias but does not fully solve them.
steps to reproduce / install procedure usedimportant considerations
procedurethe below procedure will allow anthias to be installed on a raspberry pi zero 2 w board. this process includes installer adjustments and general tweaks.
patchesinstall patch (for usb disk install)filename: diff --git a/ansible/roles/network/tasks/main.yml b/ansible/roles/network/tasks/main.yml
index 4b50c71d..42e438cd 100644
--- a/ansible/roles/network/tasks/main.yml
+++ b/ansible/roles/network/tasks/main.yml
@@ -20,8 +20,8 @@
- name: Enable network systemd services
ansible.builtin.systemd:
name: "{{ item }}"
- state: started
- enabled: true
+ state: stopped
+ enabled: false
with_items: "{{ network_systemd_units }}"
- name: Disable network manager
diff --git a/ansible/roles/screenly/tasks/main.yml b/ansible/roles/screenly/tasks/main.yml
index 8c87dc7e..396b7967 100644
--- a/ansible/roles/screenly/tasks/main.yml
+++ b/ansible/roles/screenly/tasks/main.yml
@@ -101,7 +101,7 @@
- name: Enable screenly systemd services
ansible.builtin.systemd:
name: "{{ item }}"
- state: started
+ state: stopped
enabled: true
with_items: "{{ screenly_systemd_units }}"
diff --git a/ansible/roles/system/tasks/main.yml b/ansible/roles/system/tasks/main.yml
index 7434f162..b229b4a4 100644
--- a/ansible/roles/system/tasks/main.yml
+++ b/ansible/roles/system/tasks/main.yml
@@ -231,7 +231,6 @@
- name: Remove deprecated apt dependencies
ansible.builtin.apt:
name:
- - dphys-swapfile
- lightdm
- lightdm-gtk-greeter
- matchbox
@@ -377,11 +376,3 @@
mode: "0644"
owner: root
group: root
-
-- name: Disable swap
- ansible.builtin.command: /sbin/swapoff --all removes=/var/swap
-
-- name: Remove swapfile from disk
- ansible.builtin.file:
- path: /var/swap
- state: absent
diff --git a/bin/install.sh b/bin/install.sh
index 2e860cc5..7b470871 100755
--- a/bin/install.sh
+++ b/bin/install.sh
@@ -184,9 +184,6 @@ function install_ansible() {
function run_ansible_playbook() {
display_section "Run the Anthias Ansible Playbook"
- sudo -u ${USER} ${SUDO_ARGS[@]} ansible localhost \
- -m git \
- -a "repo=$REPOSITORY dest=${ANTHIAS_REPO_DIR} version=${BRANCH} force=yes"
cd ${ANTHIAS_REPO_DIR}/ansible
if [ "$ARCHITECTURE" == "x86_64" ]; then
@@ -200,10 +197,6 @@ function run_ansible_playbook() {
function upgrade_docker_containers() {
display_section "Initialize/Upgrade Docker Containers"
- wget -q \
- "$GITHUB_RAW_URL/master/bin/upgrade_containers.sh" \
- -O "$UPGRADE_SCRIPT_PATH"
-
sudo -u ${USER} \
DOCKER_TAG="${DOCKER_TAG}" \
"${UPGRADE_SCRIPT_PATH}"
@@ -212,6 +205,8 @@ function upgrade_docker_containers() {
function cleanup() {
display_section "Clean Up Unused Packages and Files"
+ sudo -E docker compose -f /home/${USER}/screenly/docker-compose.yml down
+
sudo apt-get autoclean
sudo apt-get clean
sudo docker system prune -f
diff --git a/bin/upgrade_containers.sh b/bin/upgrade_containers.sh
index 94103502..38309fbb 100755
--- a/bin/upgrade_containers.sh
+++ b/bin/upgrade_containers.sh
@@ -6,8 +6,8 @@
Export various environment variables
export MY_IP=$(ip -4 route get 8.8.8.8 | awk {'print $7'} | tr -d '\n')
TOTAL_MEMORY_KB=$(grep MemTotal /proc/meminfo | awk {'print $2'})
-export VIEWER_MEMORY_LIMIT_KB=$(echo "$TOTAL_MEMORY_KB" \* 0.8 | bc)
-export SHM_SIZE_KB="$(echo "$TOTAL_MEMORY_KB" \* 0.3 | bc | cut -d'.' -f1)"
+export VIEWER_MEMORY_LIMIT_KB=$(echo "$TOTAL_MEMORY_KB" \* 0.6 | bc)
+export SHM_SIZE_KB="$(echo "$TOTAL_MEMORY_KB" \* 0.25 | bc | cut -d'.' -f1)"
export GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
@@ -26,7 +26,7 @@ elif grep -qF "Raspberry Pi 2" /proc/device-tree/model; then
export DEVICE_TYPE="pi2"
else
If all else fail, assume pi1
- export DEVICE_TYPE="pi1"
+ export DEVICE_TYPE="pi3"
fi
if [[ -n $(docker ps | grep srly-ose) ]]; then
diff --git a/docker-compose.yml.tmpl b/docker-compose.yml.tmpl
index 6bfdd7e6..df0780ee 100644
--- a/docker-compose.yml.tmpl
+++ b/docker-compose.yml.tmpl
@@ -1,30 +1,21 @@
vim: ft=yaml.docker-compose
services:
- anthias-wifi-connect:
- image: screenly/anthias-wifi-connect:${DOCKER_TAG}-${DEVICE_TYPE}
- build:
- context: .
- dockerfile: docker/Dockerfile.wifi-connect
- depends_on:
- - anthias-viewer
- environment:
- PORTAL_LISTENING_PORT: 8000
- CHECK_CONN_FREQ: 10
- PORTAL_SSID: 'Anthias WiFi Connect'
- DBUS_SYSTEM_BUS_ADDRESS: 'unix:path=/run/dbus/system_bus_socket'
- network_mode: host
- privileged: true
- volumes:
- - type: bind
- source: /run/dbus/system_bus_socket
- target: /run/dbus/system_bus_socket
-
anthias-server:
image: screenly/anthias-server:${DOCKER_TAG}-${DEVICE_TYPE}
build:
context: .
dockerfile: docker/Dockerfile.server
+ cpus: "0.25"
+ cpuset: "1"
+ blkio_config:
+ weight: 300
+ device_read_bps:
+ - path: /dev/mmcblk0
+ rate: '5mb'
+ device_write_bps:
+ - path: /dev/mmcblk0
+ rate: '1024k'
environment:
- MY_IP=${MY_IP}
- HOST_USER=${USER}
@@ -50,6 +41,16 @@ services:
build:
context: .
dockerfile: docker/Dockerfile.viewer
+ cpus: "0.5"
+ cpuset: "1"
+ blkio_config:
+ weight: 300
+ device_read_bps:
+ - path: /dev/mmcblk0
+ rate: '5mb'
+ device_write_bps:
+ - path: /dev/mmcblk0
+ rate: '1024k'
mem_limit: ${VIEWER_MEMORY_LIMIT_KB}k
depends_on:
- anthias-server
@@ -77,6 +78,16 @@ services:
build:
context: .
dockerfile: docker/Dockerfile.websocket
+ cpus: "0.25"
+ cpuset: "1"
+ blkio_config:
+ weight: 300
+ device_read_bps:
+ - path: /dev/mmcblk0
+ rate: '5mb'
+ device_write_bps:
+ - path: /dev/mmcblk0
+ rate: '1024k'
depends_on:
- anthias-server
environment:
@@ -95,6 +106,16 @@ services:
build:
context: .
dockerfile: docker/Dockerfile.celery
+ cpus: "0.25"
+ cpuset: "1"
+ blkio_config:
+ weight: 300
+ device_read_bps:
+ - path: /dev/mmcblk0
+ rate: '5mb'
+ device_write_bps:
+ - path: /dev/mmcblk0
+ rate: '1024k'
depends_on:
- anthias-server
- redis
@@ -119,6 +140,16 @@ services:
build:
context: .
dockerfile: docker/Dockerfile.redis
+ cpus: "0.25"
+ cpuset: "1"
+ blkio_config:
+ weight: 300
+ device_read_bps:
+ - path: /dev/mmcblk0
+ rate: '5mb'
+ device_write_bps:
+ - path: /dev/mmcblk0
+ rate: '1024k'
ports:
- 127.0.0.1:6379:6379
restart: always
@@ -130,6 +161,16 @@ services:
build:
context: .
dockerfile: docker/Dockerfile.nginx
+ cpus: "0.25"
+ cpuset: "1"
+ blkio_config:
+ weight: 300
+ device_read_bps:
+ - path: /dev/mmcblk0
+ rate: '5mb'
+ device_write_bps:
+ - path: /dev/mmcblk0
+ rate: '1024k'
ports:
- 80:80
environment: docker patchfilename: diff --git a/ansible/roles/system/tasks/main.yml b/ansible/roles/system/tasks/main.yml
index b229b4a4..fa5a1b52 100644
--- a/ansible/roles/system/tasks/main.yml
+++ b/ansible/roles/system/tasks/main.yml
@@ -245,60 +245,6 @@
- xserver-xorg
state: absent
-- name: Make sure distro package of Docker is absent
- ansible.builtin.apt:
- name:
- - docker
- - docker-engine
- - docker.io
- - containerd
- - runc
- - docker-compose
- state: absent
-
-- name: Add Docker apt key (x86)
- ansible.builtin.apt_key:
- url: https://download.docker.com/linux/debian/gpg
- state: present
- when: ansible_architecture == "x86_64"
-
-- name: Add Docker apt key (Raspberry Pi)
- ansible.builtin.apt_key:
- url: https://download.docker.com/linux/raspbian/gpg
- state: present
- when: |
- ansible_architecture == "aarch64" or
- ansible_architecture == "armv7l" or
- ansible_architecture == "armv6l"
-
-- name: Get Debian name
- ansible.builtin.command: lsb_release -cs
- register: debian_name
- changed_when: false
-
-- name: Set architecture
- ansible.builtin.set_fact:
- architecture: "{{ 'amd64' if ansible_architecture == 'x86_64' else 'armhf' }}"
-
-- name: Add Docker repo
- ansible.builtin.lineinfile:
- path: /etc/apt/sources.list.d/docker.list
- create: true
- line: "deb [arch={{ architecture }}] https://download.docker.com/linux/debian {{ debian_name.stdout }} stable"
- state: present
- owner: root
- group: root
- mode: "0644"
-
-- name: Install Docker
- ansible.builtin.apt:
- name:
- - docker-ce:{{ architecture }}
- - docker-ce-cli:{{ architecture }}
- - docker-compose-plugin:{{ architecture }}
- update_cache: true
- install_recommends: false
-
- name: Add user to Docker group (all platforms)
ansible.builtin.user:
name: "{{ lookup('env', 'USER') }}" additional noteworthy items / discoveries
|
@mcrosson, thank you so much! I'll spend a fair bit of time looking into those details. I'll let you know if I created a pull request based from the patches that you've provided. |
@mcrosson take note that as an option, you can also create a pull request if you'd prefer. (We appreciate open-source contributions from users.) I'll just drop comments and suggest changes if needed. |
I'll definitely keep this in mind in the future. I think some of the above would make sense 'in general' but until I get hands on additional test hardware, I think it's wise to not post any of the above as PR's myself. |
Sounds good. I'll have a Pi Zero 2 W on-hand for testing/info gathering. Just let me know if you need anything more from me. I'll also keep an eye on this ticket so I don't miss any additional comments or feedback. |
@mcrosson, will take note of that. For now, I'll test the patches based off the notes, and then create PR. Thanks! |
@mcrosson, I created a PR from your patches. Let me know if I missed anything from the patches. Some of them were rejected, so I have to |
the only thing i see missing is i believe its part of the uninstall step where some raspberry pi specific services are removed / cleaned up |
I just realized you could probably set the restart policy on all the containers to Those two adjustments should prevent the containers from auto-starting on boot so if the board crashes during testing you can simply remove power to turn off the board and then cold boot to resume where you left off. |
Overview of the Issue
Are there any plans to officially support the Raspberry Pi Zero 2 W?
Reproduction Steps / Why I Ask
I ask about official support because I've been experimenting with running Anthias on the Pi Zero 2 W and I keep running into horrific disk io contention issues. An overview of my progress is below.
I was able to sort the installer problems I found and was able to get the install to run to completion within 45-60 minutes on average. However, during container start up the disk io contention makes the Pi Zero 2 W unusable. I noticed something similar on my pi4 deployment: whenever the containers start, they use up all the disk io, cause the load average to spike over 15-20 and the system becomes unusable. On the pi4 the heavy disk io eventually settles and the load average drops within a 10 minutes usually but these two things can be very problematic during startup on the pi4.
On the Pi Zero 2... I've yet to find a way to constrain the intense disk io the containers cause during startup to allow Anthias to actually run. I'm seeing load averages as high as 60 when starting the containers without tuning and with some significant tuning I'm seeing load averages over 30. In either scenario the system becomes unusable very quickly. Additionally, the system will eventually throw a kernel error saying a task is hung. Once this happens, the Pi Zero 2 W is effectively crashed and unusable. The server and viewer containers seem to cause the biggest problems for disk io contention in my experiments.
From what I can figure out, the containers would need to be started sequentially and not in parallel and/or tuned to be less aggressive on disk io during startup. Without the disk io contention addressed, I don't see how the Pi Zero 2 W could be supported.
I can provide my notes if desired but they are dense and very long with a pair of patches that make some significant changes to the setup process and docker-compose template. Please let me know if you'd like this additional detail.
Environment
The text was updated successfully, but these errors were encountered: