From faf6f19fefe3a6a15284442070b95f04fed512f2 Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 17 Dec 2023 21:20:49 -0500 Subject: [PATCH 01/10] Build with docker sysroot lol --- .github/workflows/main.yml | 21 ++++++++++++++++++++- CMakeLists.txt | 2 +- Dockerfile | 3 +++ README.md | 12 ++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 51a42d42..e6f27a9b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,7 @@ jobs: apt-get update apt-get install -y libopencv-dev libegl1-mesa-dev libcamera-dev cmake build-essential libdrm-dev libgbm-dev default-jdk openjdk-17-jdk cmake -B build-pi -DCMAKE_BUILD_TYPE=Release - cmake --build build-pi -j 4 + cmake --build build-pi -- -j - run: find . @@ -54,3 +54,22 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build-chroot: + runs-on: ubuntu-latest + container: + image: mcm001/photon-libcamera-builder-entry:latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v3 + - run: | + find . + uname -a + cat /etc/os-release + bash -c "cmake -B build-pi -DCMAKE_BUILD_TYPE=Release && cmake --build build-pi -- -j" + - uses: actions/upload-artifact@master + with: + name: libcamera-driver + path: build-pi/*.so diff --git a/CMakeLists.txt b/CMakeLists.txt index 73a38f34..9ca75cf9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.25.1) +cmake_minimum_required(VERSION 3.15) project(libcamera_meme) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..b866ac7f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM photon-libcamera-builder + +ENTRYPOINT ["/bin/bash", "/opt/start_chroot.sh"] \ No newline at end of file diff --git a/README.md b/README.md index 793c7629..07804ab8 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,15 @@ This should spit out the shared library into the build directory. Compile with `g++ -std=c++17 -o eglinfo eglinfo.c headless_opengl.cpp -lEGL -lGLESv2 -lgbm`, and then run with `./eglinfo` +## Chroot stuff + +Using our docker image and run with --privileged + +docker run -it --privileged --mount type=bind,source="$(pwd)",target=/opt/photon_sysroot_v2023.4.2/opt/photon-libcamera-gl-driver photon-libcamera-builder:latest +/opt/photon_sysroot_v2023.4.2/opt/photon-libcamera-gl-driver/start_chroot.sh + +Or + +docker run -it --privileged --mount type=bind,source="$(pwd)",target=/opt/photon_sysroot_v2023.4.2/opt/photon-libcamera-gl-driver photon-libcamera-builder-entry:latest + +# git clone ${{ github.repositoryUrl }} && cd "$(basename "$_" .git)" \ No newline at end of file From 9e2a73f521e0a2959bd2f409a1c47ac0ea137267 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 18 Dec 2023 09:06:15 -0500 Subject: [PATCH 02/10] whoops --- .github/workflows/main.yml | 10 +--------- .gitignore | 2 ++ Dockerfile | 6 +++--- README.md | 6 +++++- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e6f27a9b..7c73afa7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,18 +57,10 @@ jobs: build-chroot: runs-on: ubuntu-latest - container: - image: mcm001/photon-libcamera-builder-entry:latest - defaults: - run: - shell: bash steps: - uses: actions/checkout@v3 - run: | - find . - uname -a - cat /etc/os-release - bash -c "cmake -B build-pi -DCMAKE_BUILD_TYPE=Release && cmake --build build-pi -- -j" + docker run --mount type=bind,source=$(pwd),target=/opt/photon_sysroot/work mcm001/photon-libcamera-builder-entry:latest chroot /opt/photon_sysroot && bash -c 'uname -a && cat /etc/os-release && cd /work && cmake -B build-pi -DCMAKE_BUILD_TYPE=Release && cmake --build build-pi -- -j' - uses: actions/upload-artifact@master with: name: libcamera-driver diff --git a/.gitignore b/.gitignore index e48269c9..8b0f9739 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .idea/ .vscode build +build-pi .cache/ compile_commands.json +photon_sysroot \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index b866ac7f..31a2812a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,3 @@ -FROM photon-libcamera-builder - -ENTRYPOINT ["/bin/bash", "/opt/start_chroot.sh"] \ No newline at end of file +FROM ubuntu:22.04 +RUN apt-get update && apt-get install -y qemu qemu-user-static binfmt-support libopencv-dev libegl1-mesa-dev libcamera-dev cmake build-essential libdrm-dev libgbm-dev default-jdk openjdk-17-jdk && apt-get clean +COPY photon_sysroot /opt/photon_sysroot diff --git a/README.md b/README.md index 07804ab8..90b55bc6 100644 --- a/README.md +++ b/README.md @@ -41,4 +41,8 @@ Or docker run -it --privileged --mount type=bind,source="$(pwd)",target=/opt/photon_sysroot_v2023.4.2/opt/photon-libcamera-gl-driver photon-libcamera-builder-entry:latest -# git clone ${{ github.repositoryUrl }} && cd "$(basename "$_" .git)" \ No newline at end of file +# git clone ${{ github.repositoryUrl }} && cd "$(basename "$_" .git)" + + +rm -rf /var/lib/apt/lists/* +locale-gen --purge POSTIX && echo 'Success!' From d43bbd8811d9cfbb9f69c712707560f873ac6b36 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 18 Dec 2023 09:08:13 -0500 Subject: [PATCH 03/10] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7c73afa7..cc0f7684 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -60,7 +60,7 @@ jobs: steps: - uses: actions/checkout@v3 - run: | - docker run --mount type=bind,source=$(pwd),target=/opt/photon_sysroot/work mcm001/photon-libcamera-builder-entry:latest chroot /opt/photon_sysroot && bash -c 'uname -a && cat /etc/os-release && cd /work && cmake -B build-pi -DCMAKE_BUILD_TYPE=Release && cmake --build build-pi -- -j' + docker run --mount type=bind,source=$(pwd),target=/opt/photon_sysroot/work mcm001/photon-libcamera-builder-entry:latest chroot /opt/photon_sysroot bash -c 'uname -a && cat /etc/os-release && cd /work && cmake -B build-pi -DCMAKE_BUILD_TYPE=Release && cmake --build build-pi -- -j' - uses: actions/upload-artifact@master with: name: libcamera-driver From e8efe10d6f28a713e62f22cf428eb9b30cea571d Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 18 Dec 2023 09:09:01 -0500 Subject: [PATCH 04/10] Update main.yml --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cc0f7684..c70a2c17 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -60,6 +60,7 @@ jobs: steps: - uses: actions/checkout@v3 - run: | + sudo apt-get update && sudo apt-get install -y qemu qemu-user-static binfmt-support docker run --mount type=bind,source=$(pwd),target=/opt/photon_sysroot/work mcm001/photon-libcamera-builder-entry:latest chroot /opt/photon_sysroot bash -c 'uname -a && cat /etc/os-release && cd /work && cmake -B build-pi -DCMAKE_BUILD_TYPE=Release && cmake --build build-pi -- -j' - uses: actions/upload-artifact@master with: From 2fe8ee3872b8bb12a2bf5bfc9e38ffd3484b7003 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 18 Dec 2023 09:28:15 -0500 Subject: [PATCH 05/10] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c70a2c17..e8397935 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v3 - uses: pguyot/arm-runner-action@v2 with: - base_image: raspios_lite_arm64:latest + base_image: raspi_4_bookworm:20230612 cpu: cortex-a7 image_additional_mb: 1500 bind_mount_repository: true From a53bae8e77f6a285c0c63479345ba7585b987740 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 18 Dec 2023 09:32:11 -0500 Subject: [PATCH 06/10] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e8397935..69f769f2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: pguyot/arm-runner-action@v2 + - uses: pguyot/arm-runner-action@HEAD with: base_image: raspi_4_bookworm:20230612 cpu: cortex-a7 From 7ef9225bb76050fad4e51dd9f01f07f35a3210a6 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 19 Dec 2023 08:02:23 -0500 Subject: [PATCH 07/10] Update main.yml --- .github/workflows/main.yml | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 69f769f2..5b2acd6c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,12 +13,37 @@ jobs: steps: - uses: actions/checkout@v3 + + # From https://github.com/pguyot/arm-runner-action/blob/main/.github/workflows/test-cache.yml + - uses: actions/cache@v3 + id: cache + with: + path: $RUNNER_TEMP/photon_libcam_builder.img + key: ${{ hashFiles('**/test-cache.yml') }}-${{ hashFiles('**/*.sh') }} + - uses: pguyot/arm-runner-action@HEAD + id: install_deps + if: steps.cache.outputs.cache-hit != 'true' + with: + # we don't want to optimize as it's two-stage + optimize_image: no + image_additional_mb: 1500 + base_image: https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2023-12-11/2023-12-11-raspios-bookworm-arm64-lite.img.xz + commands: | + apt-get update + apt-get install -y libopencv-dev libegl1-mesa-dev libcamera-dev cmake build-essential libdrm-dev libgbm-dev default-jdk openjdk-17-jdk + + - name: Move and rename image with dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: | + mv ${{ steps.install_deps.outputs.image }} $RUNNER_TEMP/photon_libcam_builder.img + - uses: pguyot/arm-runner-action@HEAD with: - base_image: raspi_4_bookworm:20230612 + base_image: file://$RUNNER_TEMP/test_cache.img cpu: cortex-a7 image_additional_mb: 1500 bind_mount_repository: true + # Update again anyways to pull down the latest libcamera et al commands: | apt-get update apt-get install -y libopencv-dev libegl1-mesa-dev libcamera-dev cmake build-essential libdrm-dev libgbm-dev default-jdk openjdk-17-jdk From aa3ec80815b25e607a586219d35117cafd2ecbb0 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 19 Dec 2023 08:09:13 -0500 Subject: [PATCH 08/10] ope --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5b2acd6c..56f3f86c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,7 +39,7 @@ jobs: - uses: pguyot/arm-runner-action@HEAD with: - base_image: file://$RUNNER_TEMP/test_cache.img + base_image: file://$RUNNER_TEMP/photon_libcam_builder.img cpu: cortex-a7 image_additional_mb: 1500 bind_mount_repository: true From 42e85e03c7ebdddc7f7f5af750c8a0c943511d49 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 19 Dec 2023 08:11:04 -0500 Subject: [PATCH 09/10] asdf --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 56f3f86c..02adf006 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ jobs: id: cache with: path: $RUNNER_TEMP/photon_libcam_builder.img - key: ${{ hashFiles('**/test-cache.yml') }}-${{ hashFiles('**/*.sh') }} + key: ${{ hashFiles('**/*.yml') }} - uses: pguyot/arm-runner-action@HEAD id: install_deps if: steps.cache.outputs.cache-hit != 'true' From ab510756c56f06d6dc0600a2c1ca09b2b238b54d Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 19 Dec 2023 08:18:53 -0500 Subject: [PATCH 10/10] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 02adf006..54be796f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -89,5 +89,5 @@ jobs: docker run --mount type=bind,source=$(pwd),target=/opt/photon_sysroot/work mcm001/photon-libcamera-builder-entry:latest chroot /opt/photon_sysroot bash -c 'uname -a && cat /etc/os-release && cd /work && cmake -B build-pi -DCMAKE_BUILD_TYPE=Release && cmake --build build-pi -- -j' - uses: actions/upload-artifact@master with: - name: libcamera-driver + name: libcamera-driver-chroot path: build-pi/*.so