-
Notifications
You must be signed in to change notification settings - Fork 12
Add OV9782 support, optional support for libcamera 0.6+, and add arm64 sysroot JNI build helper #30
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| #!/bin/bash | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you remind me why we should upstream this script, rather than the existing cross build setup? (Which granted only really works in CI or a real Pi)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes local dev much quicker and possible without access to direct hardware. I can swap it out with a full docker container so other environments can build easier or if its not wanted can be removed all together. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do think that the current cross-compiling story kinda sucks/isn't there, so I do see value in having a blessed way to build outside of the pipeline. I'll think a bit harder on it but that broadly makes sense to me |
||
| set -euo pipefail | ||
|
|
||
| repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||
|
|
||
| sysroot_dir="${SYSROOT_DIR:-}" | ||
| if [ -z "${sysroot_dir}" ]; then | ||
| echo "SYSROOT_DIR is required (path to the target rootfs or sysroot)." 1>&2 | ||
| exit 1 | ||
| fi | ||
| sysroot_dir="$(realpath "${sysroot_dir}")" | ||
|
|
||
| docker_image="${DOCKER_IMAGE:-debian:bookworm}" | ||
| docker_platform="${DOCKER_PLATFORM:-linux/arm64}" | ||
| maven_local_repo="${MAVEN_LOCAL_REPO:-${repo_root}/.m2-arm64}" | ||
| cmake_extra_args="${CMAKE_EXTRA_ARGS:-}" | ||
| gradle_extra_args="${GRADLE_EXTRA_ARGS:-}" | ||
| clean_build="${CLEAN_BUILD:-0}" | ||
| sysroot_mode="${SYSROOT_MODE:-libcamera}" | ||
| use_docker="${USE_DOCKER:-1}" | ||
|
|
||
| if [ "${clean_build}" = "1" ]; then | ||
| rm -rf "${repo_root}/cmake_build" || true | ||
| fi | ||
|
|
||
| mkdir -p "${maven_local_repo}" | ||
|
|
||
| if [ "${use_docker}" != "1" ]; then | ||
| export DEBIAN_FRONTEND=noninteractive | ||
| export PKG_CONFIG_SYSROOT_DIR="${sysroot_dir}" | ||
| export PKG_CONFIG_PATH="${sysroot_dir}/usr/lib/aarch64-linux-gnu/pkgconfig:${sysroot_dir}/usr/lib/pkgconfig:${sysroot_dir}/usr/share/pkgconfig:${sysroot_dir}/usr/local/lib/aarch64-linux-gnu/pkgconfig:${sysroot_dir}/usr/local/lib/pkgconfig:/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig" | ||
| if [ -z "${JAVA_HOME:-}" ]; then | ||
| arch="$(dpkg --print-architecture 2>/dev/null || true)" | ||
| if [ "${arch}" = "amd64" ]; then | ||
| export JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64" | ||
| else | ||
| export JAVA_HOME="/usr/lib/jvm/java-17-openjdk-arm64" | ||
| fi | ||
| else | ||
| export JAVA_HOME="${JAVA_HOME}" | ||
| fi | ||
| git config --global --add safe.directory "${repo_root}" | ||
|
|
||
| build_dir="${repo_root}/cmake_build" | ||
| cmake_args=( | ||
| -B "${build_dir}" | ||
| -S "${repo_root}" | ||
| -DOpenGL_GL_PREFERENCE=GLVND | ||
| -DBUILD_CAMERA_MEME=OFF | ||
| ) | ||
| if [ "${sysroot_mode}" = "full" ]; then | ||
| cmake_args+=( | ||
| -DCMAKE_SYSROOT="${sysroot_dir}" | ||
| -DCMAKE_FIND_ROOT_PATH="${sysroot_dir}" | ||
| -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY | ||
| -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY | ||
| -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY | ||
| -DCMAKE_PREFIX_PATH="${sysroot_dir}/usr;${sysroot_dir}/usr/local" | ||
| ) | ||
| else | ||
| cmake_args+=( | ||
| -DCMAKE_LIBRARY_PATH="${sysroot_dir}/usr/lib/aarch64-linux-gnu:${sysroot_dir}/usr/local/lib/aarch64-linux-gnu" | ||
| -DCMAKE_INCLUDE_PATH="${sysroot_dir}/usr/include:${sysroot_dir}/usr/local/include" | ||
| ) | ||
| fi | ||
| cmake "${cmake_args[@]}" ${cmake_extra_args} | ||
| cmake --build "${build_dir}" -j"$(nproc)" | ||
|
|
||
| cd "${repo_root}" | ||
| ./gradlew --no-daemon \ | ||
| -Dmaven.repo.local="${maven_local_repo}" \ | ||
| build publishToMavenLocal \ | ||
| -PArchOverride=linuxarm64 \ | ||
| ${gradle_extra_args} | ||
| exit 0 | ||
| fi | ||
|
|
||
| docker run --rm --platform="${docker_platform}" \ | ||
| -v "${repo_root}:/work" \ | ||
| -v "${sysroot_dir}:/sysroot:ro" \ | ||
| -v "${maven_local_repo}:/work/.m2-arm64" \ | ||
| "${docker_image}" bash -lc " | ||
| set -euo pipefail | ||
| export DEBIAN_FRONTEND=noninteractive | ||
| apt-get update >/dev/null | ||
| apt-get install -y --no-install-recommends \ | ||
| build-essential \ | ||
| ca-certificates \ | ||
| cmake \ | ||
| git \ | ||
| libdrm-dev \ | ||
| libegl1-mesa-dev \ | ||
| libgbm-dev \ | ||
| libgl1-mesa-dev \ | ||
| ninja-build \ | ||
| openjdk-17-jdk \ | ||
| pkg-config >/dev/null | ||
|
|
||
| export PKG_CONFIG_SYSROOT_DIR=/sysroot | ||
| export PKG_CONFIG_PATH=/sysroot/usr/lib/aarch64-linux-gnu/pkgconfig:/sysroot/usr/lib/pkgconfig:/sysroot/usr/share/pkgconfig:/sysroot/usr/local/lib/aarch64-linux-gnu/pkgconfig:/sysroot/usr/local/lib/pkgconfig:/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig | ||
| export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-arm64 | ||
| git config --global --add safe.directory /work | ||
|
|
||
| cmake_args=( | ||
| -B /work/cmake_build | ||
| -S /work | ||
| -DOpenGL_GL_PREFERENCE=GLVND | ||
| -DBUILD_CAMERA_MEME=OFF | ||
| ) | ||
| if [ \"${sysroot_mode}\" = \"full\" ]; then | ||
| cmake_args+=( | ||
| -DCMAKE_SYSROOT=/sysroot | ||
| -DCMAKE_FIND_ROOT_PATH=/sysroot | ||
| -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY | ||
| -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY | ||
| -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY | ||
| -DCMAKE_PREFIX_PATH=/sysroot/usr\\;/sysroot/usr/local | ||
| ) | ||
| else | ||
| cmake_args+=( | ||
| -DCMAKE_LIBRARY_PATH=/sysroot/usr/lib/aarch64-linux-gnu:/sysroot/usr/local/lib/aarch64-linux-gnu | ||
| -DCMAKE_INCLUDE_PATH=/sysroot/usr/include:/sysroot/usr/local/include | ||
| ) | ||
| fi | ||
| cmake \${cmake_args[@]} ${cmake_extra_args} | ||
| cmake --build /work/cmake_build -j\$(nproc) | ||
|
|
||
| cd /work | ||
| ./gradlew --no-daemon \ | ||
| -Dmaven.repo.local=/work/.m2-arm64 \ | ||
| build publishToMavenLocal \ | ||
| -PArchOverride=linuxarm64 \ | ||
| ${gradle_extra_args} | ||
| " | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for 2027+, we should force everyone to use a new libcamera?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the over arching goals are, so I did not want to force 0.6 if there was other issues with other platforms. I would recommend it as 0.6+ is stable now to my knowledge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully this fixes (unofficial) Debian/RPiOS Trixie support again. I don't have the time to check this today, but maybe tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we currently install libcamera 0.5.2 -> https://github.com/PhotonVision/photon-image-modifier/actions/runs/22130709321/job/64030036864?pr=126#step:5:1477
I think @Gold856 was partially through compiling libcamera from source as part of this driver build, which would release us from our dependence on random rpi apt repos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RPiOS Trixie image has libcamera 0.6 preinstalled. While libcamera 0.5 is available, sufficiently removing 0.6 to install 0.5 is nontrivial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I got libcamera 0.6 building completely independently. That's what I want to switch to for 2027. Still trying to work out how to ship the IPA files and stuff.