From 478a8cd29d0393e9fd2d9e133b184ec04c1d0245 Mon Sep 17 00:00:00 2001 From: Vincent STRAGIER Date: Sun, 13 Feb 2022 23:36:20 +0100 Subject: [PATCH 1/7] Update OS --- .github/workflows/build-image.yml | 34 +++++++++++++++---- .../naturewatchcamera/start_chroot_script | 15 +++----- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 559a5dc..491e283 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -3,11 +3,13 @@ on: [push, pull_request] jobs: build: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Install Dependencies - run: sudo apt-get update && sudo apt install coreutils p7zip-full qemu-user-static + run: | + sudo apt-get update + sudo apt-get install coreutils p7zip-full qemu-user-static - name: Checkout CustomPiOS uses: actions/checkout@v2 @@ -28,19 +30,37 @@ jobs: node-version: 12.x - name: Build React frontend - run: pushd repository/naturewatch_camera_server/static/client && npm i -y && npm run build && popd + run: | + pushd repository/naturewatch_camera_server/static/client + npm i -y + npm run build + popd - name: Download Raspbian Image - run: cd repository/os/image && wget -q -c --trust-server-names 'https://downloads.raspberrypi.org/raspbian_lite_latest' + run: | + cd repository/os/image + wget -q -c --trust-server-names 'https://downloads.raspberrypi.org/raspios_lite_armhf_latest' - name: Update CustomPiOS Paths - run: cd repository/os && ../../CustomPiOS/src/update-custompios-paths + run: | + cd repository/os + ../../CustomPiOS/src/update-custompios-paths - name: Copy NaturewatchCameraServer to CustomPiOS directory - run: cp -r repository /tmp/NaturewatchCameraServer && rm -rf /tmp/NaturewatchCameraServer/os && rm -rf /tmp/NaturewatchCameraServer/naturewatch_camera_server/static/client/node_modules && mv /tmp/NaturewatchCameraServer repository/os/modules/naturewatchcamera/filesystem/home/pi/NaturewatchCameraServer && ls repository/os/modules/naturewatchcamera/filesystem/home/pi/NaturewatchCameraServer + run: | + cp -r repository /tmp/NaturewatchCameraServer + rm -rf /tmp/NaturewatchCameraServer/os + rm -rf /tmp/NaturewatchCameraServer/naturewatch_camera_server/static/client/node_modules + mv /tmp/NaturewatchCameraServer repository/os/modules/naturewatchcamera/filesystem/home/pi/NaturewatchCameraServer + ls repository/os/modules/naturewatchcamera/filesystem/home/pi/NaturewatchCameraServer - name: Build Image - run: export BASE_IMAGE_ENLARGEROOT=2000 && export AUTO_HOTSPOT_NAME=MyNaturewatch && export AUTO_HOTSPOT_PASSWORD=badgersandfoxes && sudo modprobe loop && cd repository/os && sudo bash -x ./build_dist + run: | + export BASE_IMAGE_ENLARGEROOT=2000 + export AUTO_HOTSPOT_NAME=MyNaturewatch + export AUTO_HOTSPOT_PASSWORD=badgersandfoxes + sudo modprobe loop && cd repository/os + sudo bash -x ./build_dist - name: Copy Output run: cp ${{ github.workspace }}/repository/os/workspace/*-raspbian-buster-lite.img mynaturewatch-camera.img diff --git a/os/modules/naturewatchcamera/start_chroot_script b/os/modules/naturewatchcamera/start_chroot_script index 6983749..e94515f 100644 --- a/os/modules/naturewatchcamera/start_chroot_script +++ b/os/modules/naturewatchcamera/start_chroot_script @@ -35,17 +35,12 @@ echo "$NATUREWATCHCAMERA_VAR" libxvidcore-dev libx264-dev libgtk2.0-dev libgtk-3-dev \ libatlas-base-dev libblas-dev libeigen{2,3}-dev liblapack-dev \ gfortran \ - python2.7-dev python3-dev python-pip python3-pip python python3 - apt-get install -y libilmbase23 - apt-get install -y libopenexr-dev - apt-get install -y libgstreamer1.0-dev - apt install -y gpac - pip2 install -U pip - pip3 install -U pip - pip2 install numpy - pip3 install numpy + python3-dev python3-pip python python3 + apt-get install -y libilmbase25 libopenexr-dev libgstreamer1.0-dev + apt-get install -y gpac + echo "Installing OpenCV" -pip3 install opencv-python-headless +pip3 install -U pip numpy opencv-python-headless pushd /home/pi pushd NaturewatchCameraServer From f9ce78fdead96562923cf4a80bb19a27559068e2 Mon Sep 17 00:00:00 2001 From: Vincent STRAGIER Date: Sun, 13 Feb 2022 23:39:32 +0100 Subject: [PATCH 2/7] Add manual trigger for the build action --- .github/workflows/build-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 491e283..32ad144 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -1,5 +1,5 @@ name: Build Image -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] jobs: build: From 1f1e7fedb71b616326e3cd5bbaf9078c6adddbf4 Mon Sep 17 00:00:00 2001 From: Vincent STRAGIER Date: Mon, 14 Feb 2022 00:16:51 +0100 Subject: [PATCH 3/7] Correct image suffix. --- .github/workflows/build-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 32ad144..c6c6c67 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -63,7 +63,7 @@ jobs: sudo bash -x ./build_dist - name: Copy Output - run: cp ${{ github.workspace }}/repository/os/workspace/*-raspbian-buster-lite.img mynaturewatch-camera.img + run: cp ${{ github.workspace }}/repository/os/workspace/*lite.img mynaturewatch-camera.img - name: Zip Output run: gzip mynaturewatch-camera.img From 04163a13ec3b18ee875440eb3264b9c35696f127 Mon Sep 17 00:00:00 2001 From: Vincent STRAGIER Date: Mon, 14 Feb 2022 00:51:38 +0100 Subject: [PATCH 4/7] Fix issue with missing [...]/vcgencmd --- naturewatch_camera_server/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/naturewatch_camera_server/__main__.py b/naturewatch_camera_server/__main__.py index 8a0accc..85818d5 100755 --- a/naturewatch_camera_server/__main__.py +++ b/naturewatch_camera_server/__main__.py @@ -13,7 +13,7 @@ class CameraNotFoundException(Exception): def is_camera_enabled(): # inspired by https://stackoverflow.com/questions/58250817/raspberry-pi-camera-module-check-if-connected#comment102874971_58250817 - vcgencmd_result = subprocess.run(['/opt/vc/bin/vcgencmd', 'get_camera'], stdout=subprocess.PIPE) + vcgencmd_result = subprocess.run(['vcgencmd', 'get_camera'], stdout=subprocess.PIPE) result_text = vcgencmd_result.stdout.decode('utf-8').strip() properties = dict(pair.split('=') for pair in result_text.split(' ')) return properties['supported'] == '1' From 713076b9d6166bf014dffad27f9cd415c60b3611 Mon Sep 17 00:00:00 2001 From: Mike Vanis Date: Tue, 15 Feb 2022 11:58:48 +0000 Subject: [PATCH 5/7] enable legacy camera drivers --- os/modules/naturewatchcamera/start_chroot_script | 3 +++ 1 file changed, 3 insertions(+) diff --git a/os/modules/naturewatchcamera/start_chroot_script b/os/modules/naturewatchcamera/start_chroot_script index e94515f..aba01a4 100644 --- a/os/modules/naturewatchcamera/start_chroot_script +++ b/os/modules/naturewatchcamera/start_chroot_script @@ -39,6 +39,9 @@ echo "$NATUREWATCHCAMERA_VAR" apt-get install -y libilmbase25 libopenexr-dev libgstreamer1.0-dev apt-get install -y gpac +echo "Enabling legacy camera support for Pi Zero W 2" +raspi-config nonint do_legacy + echo "Installing OpenCV" pip3 install -U pip numpy opencv-python-headless From 29182c8d4c92f9e518b5c506bea779d22047f22c Mon Sep 17 00:00:00 2001 From: Mike Vanis Date: Tue, 15 Feb 2022 12:16:08 +0000 Subject: [PATCH 6/7] provide option for raspi-config legacy camera --- os/modules/naturewatchcamera/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/modules/naturewatchcamera/start_chroot_script b/os/modules/naturewatchcamera/start_chroot_script index aba01a4..0689910 100644 --- a/os/modules/naturewatchcamera/start_chroot_script +++ b/os/modules/naturewatchcamera/start_chroot_script @@ -40,7 +40,7 @@ echo "$NATUREWATCHCAMERA_VAR" apt-get install -y gpac echo "Enabling legacy camera support for Pi Zero W 2" -raspi-config nonint do_legacy +raspi-config nonint do_legacy 1 echo "Installing OpenCV" pip3 install -U pip numpy opencv-python-headless From 3bab545e3000e927aa21a94ab799837fa6dfe469 Mon Sep 17 00:00:00 2001 From: Mike Vanis Date: Tue, 15 Feb 2022 14:48:46 +0000 Subject: [PATCH 7/7] enable legacy camera in a different way --- os/modules/naturewatchcamera/start_chroot_script | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/os/modules/naturewatchcamera/start_chroot_script b/os/modules/naturewatchcamera/start_chroot_script index 0689910..8f46513 100644 --- a/os/modules/naturewatchcamera/start_chroot_script +++ b/os/modules/naturewatchcamera/start_chroot_script @@ -40,7 +40,8 @@ echo "$NATUREWATCHCAMERA_VAR" apt-get install -y gpac echo "Enabling legacy camera support for Pi Zero W 2" -raspi-config nonint do_legacy 1 +raspi-config nonint do_camera 1 +echo "start_x=1" >> /boot/config.txt echo "Installing OpenCV" pip3 install -U pip numpy opencv-python-headless