diff --git a/Dockerfile b/Dockerfile index e133a5c502..cba0b8b8d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG BASE_IMAGE=debian:bullseye +ARG BASE_IMAGE=debian:bookworm FROM ${BASE_IMAGE} ENV DEBIAN_FRONTEND noninteractive @@ -10,7 +10,7 @@ RUN apt-get -y update && \ libarchive-tools libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc\ binfmt-support ca-certificates qemu-utils kpartx fdisk gpg pigz\ crossbuild-essential-arm64 \ - build-essential cmake python3 python3-distutils python3-jinja2 ant sudo openjdk-17-jdk \ + build-essential cmake ninja-build protobuf-compiler python3 python3-distutils python3-jinja2 ant sudo openjdk-17-jdk \ && rm -rf /var/lib/apt/lists/* COPY . /pi-gen/ diff --git a/README.md b/README.md index 992b8c65c5..7163db993e 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,11 @@ The following environment variables are supported: The release version to build images against. Valid values are jessie, stretch buster, bullseye, and testing. + * `PI_GEN_RELEASE` (Default: `Raspberry Pi reference`) + + The release name to use in `/etc/issue.txt`. The default should only be used + for official Raspberry Pi builds. + * `USE_QCOW2` **EXPERIMENTAL** (Default: `0` ) Instead of using traditional way of building the rootfs of every stage in @@ -87,7 +92,7 @@ The following environment variables are supported: that the network block device is not disconnected correctly after the Docker process has ended abnormally. In that case see [Disconnect an image if something went wrong](#Disconnect-an-image-if-something-went-wrong) -* `RELEASE` (Default: bullseye) +* `RELEASE` (Default: bookworm) The release version to build images against. Valid values are any supported Debian release. However, since different releases will have different sets of @@ -204,9 +209,9 @@ The following environment variables are supported: stays activated. `FIRST_USER_PASS` must be set for this to work. Please be aware of the implied security risk of defining a default username and password for your devices. - * `WPA_ESSID`, `WPA_PASSWORD` and `WPA_COUNTRY` (Default: unset) + * `WPA_COUNTRY` (Default: unset) - If these are set, they are use to configure `wpa_supplicant.conf`, so that the Raspberry Pi can automatically connect to a wireless network on first boot. If `WPA_ESSID` is set and `WPA_PASSWORD` is unset an unprotected wireless network will be configured. If set, `WPA_PASSWORD` must be between 8 and 63 characters. `WPA_COUNTRY` is a 2-letter ISO/IEC 3166 country Code, i.e. `GB` + Sets the default WLAN regulatory domain and unblocks WLAN interfaces. This should be a 2-letter ISO/IEC 3166 country Code, i.e. `GB` * `ENABLE_SSH` (Default: `1`) @@ -527,7 +532,7 @@ To resolve this, ensure that the following files are available (install them if ``` /lib/modules/$(uname -r)/kernel/fs/binfmt_misc.ko -/usr/bin/qemu-arm-static +/usr/bin/qemu-aarch64-static ``` You may also need to load the module by hand - run `modprobe binfmt_misc`. diff --git a/build-docker.sh b/build-docker.sh index 62ac5e656d..05d7da1add 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -1,13 +1,20 @@ -#!/bin/bash -eu +#!/usr/bin/env bash +# Note: Avoid usage of arrays as MacOS users have an older version of bash (v3.x) which does not supports arrays +set -eu -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)" BUILD_OPTS="$*" -DOCKER="docker" +# Allow user to override docker command +DOCKER=${DOCKER:-docker} -if ! ${DOCKER} ps >/dev/null 2>&1; then - DOCKER="sudo docker" +# Ensure that default docker command is not set up in rootless mode +if \ + ! ${DOCKER} ps >/dev/null 2>&1 || \ + ${DOCKER} info 2>/dev/null | grep -q rootless \ +; then + DOCKER="sudo ${DOCKER}" fi if ! ${DOCKER} ps >/dev/null; then echo "error connecting to docker:" @@ -88,49 +95,84 @@ fi # Modify original build-options to allow config file to be mounted in the docker container BUILD_OPTS="$(echo "${BUILD_OPTS:-}" | sed -E 's@\-c\s?([^ ]+)@-c /config@')" -${DOCKER} build --build-arg BASE_IMAGE=debian:bullseye -t pi-gen "${DIR}" +${DOCKER} build --build-arg BASE_IMAGE=debian:bookworm -t pi-gen "${DIR}" if [ "${CONTAINER_EXISTS}" != "" ]; then - trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}_cont' SIGINT SIGTERM - time ${DOCKER} run --rm --privileged \ - --cap-add=ALL \ - -v /dev:/dev \ - -v /lib/modules:/lib/modules \ - ${PIGEN_DOCKER_OPTS} \ - --volume "${CONFIG_FILE}":/config:ro \ - -e "GIT_HASH=${GIT_HASH}" \ - --volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \ - -e IMG_NAME="${IMG_NAME}"\ - -e IMG_VERSION="${IMG_VERSION}"\ - pi-gen \ - bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && - # binfmt_misc is sometimes not mounted with debian bullseye image - (mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc || true) && - cd /pi-gen; ./build.sh ${BUILD_OPTS} && - rsync -av work/*/build.log deploy/" & - wait "$!" + DOCKER_CMDLINE_NAME="${CONTAINER_NAME}_cont" + DOCKER_CMDLINE_PRE="--rm" + DOCKER_CMDLINE_POST="--volumes-from=${CONTAINER_NAME}" else - trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}' SIGINT SIGTERM - time ${DOCKER} run --name "${CONTAINER_NAME}" --privileged \ - --cap-add=ALL \ - -v /dev:/dev \ - -v /lib/modules:/lib/modules \ - ${PIGEN_DOCKER_OPTS} \ - --volume "${CONFIG_FILE}":/config:ro \ - -e "GIT_HASH=${GIT_HASH}" \ - -e IMG_NAME="${IMG_NAME}"\ - -e IMG_VERSION="${IMG_VERSION}"\ - pi-gen \ - bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && - # binfmt_misc is sometimes not mounted with debian bullseye image - (mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc || true) && - cd /pi-gen; ./build.sh ${BUILD_OPTS} && - rsync -av work/*/build.log deploy/" & - wait "$!" + DOCKER_CMDLINE_NAME="${CONTAINER_NAME}" + DOCKER_CMDLINE_PRE="" + DOCKER_CMDLINE_POST="" fi +# Check if binfmt_misc is required +binfmt_misc_required=1 +case $(uname -m) in + aarch64) + binfmt_misc_required=0 + ;; + arm*) + binfmt_misc_required=0 + ;; +esac + +# Check if qemu-aarch64-static and /proc/sys/fs/binfmt_misc are present +if [[ "${binfmt_misc_required}" == "1" ]]; then + if ! qemu_arm=$(which qemu-aarch64-static) ; then + echo "qemu-aarch64-static not found (please install qemu-user-static)" + exit 1 + fi + if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then + echo "binfmt_misc required but not mounted, trying to mount it..." + if ! mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc ; then + echo "mounting binfmt_misc failed" + exit 1 + fi + echo "binfmt_misc mounted" + fi + if ! grep -q "^interpreter ${qemu_arm}" /proc/sys/fs/binfmt_misc/qemu-aarch64* ; then + # Register qemu-aarch64 for binfmt_misc + reg="echo ':qemu-aarch64-rpi:M::"\ +"\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:"\ +"\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:"\ +"${qemu_arm}:F' > /proc/sys/fs/binfmt_misc/register" + echo "Registering qemu-aarch64 for binfmt_misc..." + sudo bash -c "${reg}" 2>/dev/null || true + fi +fi + +trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${DOCKER_CMDLINE_NAME}' SIGINT SIGTERM +time ${DOCKER} run \ + $DOCKER_CMDLINE_PRE \ + --name "${DOCKER_CMDLINE_NAME}" \ + --privileged \ + --cap-add=ALL \ + -v /dev:/dev \ + -v /lib/modules:/lib/modules \ + ${PIGEN_DOCKER_OPTS} \ + --volume "${CONFIG_FILE}":/config:ro \ + -e "GIT_HASH=${GIT_HASH}" \ + -e IMG_VERSION="${IMG_VERSION}"\ + $DOCKER_CMDLINE_POST \ + pi-gen \ + bash -e -o pipefail -c " + dpkg-reconfigure qemu-user-static && + # binfmt_misc is sometimes not mounted with debian bullseye image + (mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc || true) && + cd /pi-gen; ./build.sh ${BUILD_OPTS} && + rsync -av work/*/build.log deploy/ + " & + wait "$!" + +# Ensure that deploy/ is always owned by calling user echo "copying results from deploy/" -${DOCKER} cp "${CONTAINER_NAME}":/pi-gen/deploy . +${DOCKER} cp "${CONTAINER_NAME}":/pi-gen/deploy - | tar -xf - + +echo "copying log from container ${CONTAINER_NAME} to deploy/" +${DOCKER} logs --timestamps "${CONTAINER_NAME}" &>deploy/build-docker.log + ls -lah deploy # cleanup diff --git a/build.sh b/build.sh index 490dd6dd49..e7e568e61b 100755 --- a/build.sh +++ b/build.sh @@ -194,6 +194,7 @@ trap term EXIT INT TERM export PI_GEN=${PI_GEN:-pi-gen} export PI_GEN_REPO=${PI_GEN_REPO:-https://github.com/RPi-Distro/pi-gen} +export PI_GEN_RELEASE=${PI_GEN_RELEASE:-Raspberry Pi reference} if [ -z "${IMG_NAME}" ]; then echo "IMG_NAME not set" 1>&2 @@ -229,9 +230,7 @@ export TARGET_HOSTNAME=${TARGET_HOSTNAME:-raspberrypi} export FIRST_USER_NAME=${FIRST_USER_NAME:-pi} export FIRST_USER_PASS export DISABLE_FIRST_BOOT_USER_RENAME=${DISABLE_FIRST_BOOT_USER_RENAME:-0} -export RELEASE=${RELEASE:-bullseye} # Don't forget to update stage0/prerun.sh -export WPA_ESSID -export WPA_PASSWORD +export RELEASE=${RELEASE:-bookworm} # Don't forget to update stage0/prerun.sh export WPA_COUNTRY export ENABLE_SSH="${ENABLE_SSH:-1}" export PUBKEY_ONLY_SSH="${PUBKEY_ONLY_SSH:-0}" diff --git a/config b/config index d2f0dcd9cc..9f3b09f5ee 100644 --- a/config +++ b/config @@ -1,3 +1,4 @@ +PI_GEN_RELEASE=WPILibPi IMG_NAME='WPILibPi_64' TARGET_HOSTNAME=wpilibpi FIRST_USER_PASS=raspberry diff --git a/deps/tools/configServer/src/Application.h b/deps/tools/configServer/src/Application.h index c438d14181..6d999abaf8 100644 --- a/deps/tools/configServer/src/Application.h +++ b/deps/tools/configServer/src/Application.h @@ -11,10 +11,7 @@ #include #include - -namespace wpi { -class json; -} // namespace wpi +#include class UploadHelper; diff --git a/deps/tools/configServer/src/NetworkSettings.cpp b/deps/tools/configServer/src/NetworkSettings.cpp index 5c5e355fdb..00d1527c02 100644 --- a/deps/tools/configServer/src/NetworkSettings.cpp +++ b/deps/tools/configServer/src/NetworkSettings.cpp @@ -6,6 +6,7 @@ #include +#include #include #include @@ -56,8 +57,8 @@ bool NetmaskToCidr(std::string_view netmask, unsigned int* cidr) { in_addr addr; if (wpi::uv::NameToAddr(netmask, &addr) != 0) return false; uint32_t hostAddr = ntohl(addr.s_addr); - auto leadingOnes = wpi::countLeadingOnes(hostAddr); - auto trailingZeros = wpi::countTrailingZeros(hostAddr); + auto leadingOnes = std::countl_one(hostAddr); + auto trailingZeros = std::countr_zero(hostAddr); if (leadingOnes + trailingZeros != 32) return false; *cidr = leadingOnes; return true; @@ -123,19 +124,19 @@ static std::string BuildDhcpcdSetting( break; case NetworkSettings::kStatic: fmt::print(os, "interface {}\n", iface); - fmt::print(os, "static ip_address={}/{}\n", addressOut, cidr); + fmt::print(os, "static ip_address={}/{}\n", addressOut.str(), cidr); if (!gatewayOut.empty()) - fmt::print(os, "static routers={}\n", gatewayOut); + fmt::print(os, "static routers={}\n", gatewayOut.str()); if (!dnsOut.empty()) - fmt::print(os, "static domain_name_servers={}\n", dnsOut); + fmt::print(os, "static domain_name_servers={}\n", dnsOut.str()); break; case NetworkSettings::kDhcpStatic: fmt::print(os, "profile static_{}\n", iface); - fmt::print(os, "static ip_address={}/{}\n", addressOut, cidr); + fmt::print(os, "static ip_address={}/{}\n", addressOut.str(), cidr); if (!gatewayOut.empty()) - fmt::print(os, "static routers={}\n", gatewayOut); + fmt::print(os, "static routers={}\n", gatewayOut.str()); if (!dnsOut.empty()) - fmt::print(os, "static domain_name_servers={}\n", dnsOut); + fmt::print(os, "static domain_name_servers={}\n", dnsOut.str()); fmt::print(os, "interface {}\n", iface); fmt::print(os, "fallback static_{}\n", iface); break; diff --git a/deps/tools/configServer/src/NetworkSettings.h b/deps/tools/configServer/src/NetworkSettings.h index d9794dec12..1eb40591de 100644 --- a/deps/tools/configServer/src/NetworkSettings.h +++ b/deps/tools/configServer/src/NetworkSettings.h @@ -10,12 +10,9 @@ #include #include +#include #include -namespace wpi { -class json; -} // namespace wpi - class NetworkSettings { struct private_init {}; diff --git a/deps/tools/configServer/src/RomiStatus.cpp b/deps/tools/configServer/src/RomiStatus.cpp index df1f037123..6ceed71b5e 100644 --- a/deps/tools/configServer/src/RomiStatus.cpp +++ b/deps/tools/configServer/src/RomiStatus.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -237,9 +238,10 @@ wpi::json RomiStatus::ReadRomiConfigFile( std::function onFail) { // Read config file std::error_code ec; - wpi::raw_fd_istream is(ROMI_JSON, ec); + std::unique_ptr fileBuffer = + wpi::MemoryBuffer::GetFile(ROMI_JSON, ec); - if (ec) { + if (fileBuffer == nullptr || ec) { onFail("Could not read romi config file"); fmt::print(stderr, "could not read {}\n", ROMI_JSON); return wpi::json(); @@ -247,7 +249,7 @@ wpi::json RomiStatus::ReadRomiConfigFile( wpi::json j; try { - j = wpi::json::parse(is); + j = wpi::json::parse(fileBuffer->GetCharBuffer()); } catch(const wpi::json::parse_error& e) { onFail("Parse error in config file"); fmt::print(stderr, "Parse error in {}: byte {}: {}\n", ROMI_JSON, e.byte, diff --git a/deps/tools/configServer/src/RomiStatus.h b/deps/tools/configServer/src/RomiStatus.h index cfc56fe5a2..c976825db2 100644 --- a/deps/tools/configServer/src/RomiStatus.h +++ b/deps/tools/configServer/src/RomiStatus.h @@ -12,15 +12,12 @@ #include #include +#include #include -namespace wpi { -class json; - -namespace uv { +namespace wpi::uv { class Buffer; -} // namespace uv -} // namespace wpi +} // namespace wpi::uv class RomiStatus { struct private_init {}; diff --git a/deps/tools/configServer/src/SystemStatus.h b/deps/tools/configServer/src/SystemStatus.h index 8a8540f93d..3b356b43c8 100644 --- a/deps/tools/configServer/src/SystemStatus.h +++ b/deps/tools/configServer/src/SystemStatus.h @@ -8,13 +8,10 @@ #include #include +#include #include "DataHistory.h" -namespace wpi { -class json; -} // namespace wpi - class SystemStatus { struct private_init {}; diff --git a/deps/tools/configServer/src/VisionSettings.cpp b/deps/tools/configServer/src/VisionSettings.cpp index 05f398d7de..66d0d10ee1 100644 --- a/deps/tools/configServer/src/VisionSettings.cpp +++ b/deps/tools/configServer/src/VisionSettings.cpp @@ -5,6 +5,7 @@ #include "VisionSettings.h" #include +#include #include #include #include @@ -41,15 +42,17 @@ void VisionSettings::UpdateStatus() { status(GetStatusJson()); } wpi::json VisionSettings::GetStatusJson() { std::error_code ec; - wpi::raw_fd_istream is(FRC_JSON, ec); - if (ec) { + std::unique_ptr fileBuffer = + wpi::MemoryBuffer::GetFile(FRC_JSON, ec); + + if (fileBuffer == nullptr || ec) { fmt::print(stderr, "could not read {}\n", FRC_JSON); return wpi::json(); } try { wpi::json j = {{"type", "visionSettings"}, - {"settings", wpi::json::parse(is)}}; + {"settings", wpi::json::parse(fileBuffer->GetCharBuffer())}}; return j; } catch (wpi::json::exception& e) { fmt::print(stderr, "could not parse {}\n", FRC_JSON); diff --git a/deps/tools/configServer/src/VisionSettings.h b/deps/tools/configServer/src/VisionSettings.h index a2acf6ea4a..1a21d89342 100644 --- a/deps/tools/configServer/src/VisionSettings.h +++ b/deps/tools/configServer/src/VisionSettings.h @@ -10,10 +10,7 @@ #include #include - -namespace wpi { -class json; -} // namespace wpi +#include class VisionSettings { struct private_init {}; diff --git a/deps/tools/configServer/src/VisionStatus.h b/deps/tools/configServer/src/VisionStatus.h index 07736f0027..ba5638a9ed 100644 --- a/deps/tools/configServer/src/VisionStatus.h +++ b/deps/tools/configServer/src/VisionStatus.h @@ -12,15 +12,12 @@ #include #include +#include #include -namespace wpi { -class json; - -namespace uv { +namespace wpi::uv { class Buffer; -} // namespace uv -} // namespace wpi +} // namespace wpi::uv class VisionStatus { struct private_init {}; diff --git a/deps/tools/configServer/src/main.cpp b/deps/tools/configServer/src/main.cpp index 34a12f1bb3..ac39715d1f 100644 --- a/deps/tools/configServer/src/main.cpp +++ b/deps/tools/configServer/src/main.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -129,7 +130,8 @@ int main(int argc, char* argv[]) { // Header is 2 byte len, 1 byte type, 4 byte timestamp, 2 byte // sequence num - uint32_t ts = wpi::FloatToBits((wpi::Now() - startTime) * 1.0e-6); + uint32_t ts = + wpi::bit_cast((wpi::Now() - startTime) * 1.0e-6f); uint16_t pktlen = len + 1 + 4 + 2; const uint8_t contents[] = {static_cast((pktlen >> 8) & 0xff), diff --git a/deps/tools/multiCameraServer/src/multiCameraServer.cpp b/deps/tools/multiCameraServer/src/multiCameraServer.cpp index b1ace5373f..70c0ccccef 100644 --- a/deps/tools/multiCameraServer/src/multiCameraServer.cpp +++ b/deps/tools/multiCameraServer/src/multiCameraServer.cpp @@ -10,9 +10,9 @@ #include #include +#include #include #include -#include #include "cameraserver/CameraServer.h" @@ -152,8 +152,9 @@ bool ReadSwitchedCameraConfig(const wpi::json& config) { bool ReadConfig() { // open config file std::error_code ec; - wpi::raw_fd_istream is(configFile, ec); - if (ec) { + std::unique_ptr fileBuffer = + wpi::MemoryBuffer::GetFile(configFile, ec); + if (fileBuffer == nullptr || ec) { fmt::print(stderr, "could not open '{}': {}", configFile, ec.message()); return false; } @@ -161,7 +162,7 @@ bool ReadConfig() { // parse file wpi::json j; try { - j = wpi::json::parse(is); + j = wpi::json::parse(fileBuffer->GetCharBuffer()); } catch (const wpi::json::parse_error& e) { ParseError("byte {}: {}", e.byte, e.what()); return false; @@ -288,7 +289,7 @@ int main(int argc, char* argv[]) { // start cameras // work around wpilibsuite/allwpilib#5055 - frc::CameraServer::SetSize(frc::CameraServer::kSize160x120); + frc::CameraServer::RemoveCamera("unused"); for (const auto& config : cameraConfigs) cameras.emplace_back(StartCamera(config)); diff --git a/export-image/02-set-sources/01-run.sh b/export-image/02-set-sources/01-run.sh index 5f512099b3..6d5049613c 100755 --- a/export-image/02-set-sources/01-run.sh +++ b/export-image/02-set-sources/01-run.sh @@ -4,6 +4,6 @@ rm -f "${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache" find "${ROOTFS_DIR}/var/lib/apt/lists/" -type f -delete on_chroot << EOF apt-get update -apt-get -y dist-upgrade +apt-get -y dist-upgrade --auto-remove --purge apt-get clean EOF diff --git a/export-image/03-network/01-run.sh b/export-image/03-network/01-run.sh index 2e0cc7af73..4b1338ec87 100755 --- a/export-image/03-network/01-run.sh +++ b/export-image/03-network/01-run.sh @@ -10,9 +10,9 @@ ln -s /tmp/dhcpcd.resolv.conf /etc/resolv.conf #sed -i -e 's/\/run\//\/var\/run\//' /etc/systemd/system/dhcpcd5.service -cp /etc/dhcpcd.conf /boot/ -chown -f 0:0 /boot/dhcpcd.conf -ln -sf /boot/dhcpcd.conf /etc/dhcpcd.conf +#cp /etc/dhcpcd.conf /boot/ +#chown -f 0:0 /boot/dhcpcd.conf +#ln -sf /boot/dhcpcd.conf /etc/dhcpcd.conf cp /etc/wpa_supplicant/wpa_supplicant.conf /boot/wpa_supplicant_wpilibpi.conf chown -f 0:0 /boot/wpa_supplicant_wpilibpi.conf diff --git a/export-image/04-set-partuuid/00-run.sh b/export-image/04-set-partuuid/00-run.sh index 16e1b158ef..2694295c3c 100755 --- a/export-image/04-set-partuuid/00-run.sh +++ b/export-image/04-set-partuuid/00-run.sh @@ -12,7 +12,6 @@ if [ "${NO_PRERUN_QCOW2}" = "0" ]; then sed -i "s/BOOTDEV/PARTUUID=${BOOT_PARTUUID}/" "${ROOTFS_DIR}/etc/fstab" sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${ROOTFS_DIR}/etc/fstab" - sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${ROOTFS_DIR}/boot/cmdline.txt" - + sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${ROOTFS_DIR}/boot/firmware/cmdline.txt" fi diff --git a/export-image/05-finalise/01-run.sh b/export-image/05-finalise/01-run.sh index f2d900940e..87ede120fa 100755 --- a/export-image/05-finalise/01-run.sh +++ b/export-image/05-finalise/01-run.sh @@ -7,7 +7,10 @@ EXAMPLE_DIR="${STAGE_WORK_DIR}/examples" mkdir -p "${EXAMPLE_DIR}" cp -p "${ROOTFS_DIR}"/home/${FIRST_USER_NAME}/zips/* "${EXAMPLE_DIR}/" +sed -i 's/^update_initramfs=.*/update_initramfs=all/' "${ROOTFS_DIR}/etc/initramfs-tools/update-initramfs.conf" + on_chroot << EOF +update-initramfs -u if [ -x /etc/init.d/fake-hwclock ]; then /etc/init.d/fake-hwclock stop fi @@ -57,7 +60,11 @@ rm -f "${ROOTFS_DIR}/root/.vnc/private.key" rm -f "${ROOTFS_DIR}/etc/vnc/updateid" update_issue "$(basename "${EXPORT_DIR}")" -install -m 644 "${ROOTFS_DIR}/etc/rpi-issue" "${ROOTFS_DIR}/boot/issue.txt" +install -m 644 "${ROOTFS_DIR}/etc/rpi-issue" "${ROOTFS_DIR}/boot/firmware/issue.txt" +if ! [ -L "${ROOTFS_DIR}/boot/issue.txt" ]; then + ln -s firmware/issue.txt "${ROOTFS_DIR}/boot/issue.txt" +fi + cp "$ROOTFS_DIR/etc/rpi-issue" "$INFO_FILE" diff --git a/export-image/prerun.sh b/export-image/prerun.sh index c3412c255f..a5f94e93ac 100755 --- a/export-image/prerun.sh +++ b/export-image/prerun.sh @@ -10,8 +10,8 @@ if [ "${NO_PRERUN_QCOW2}" = "0" ]; then rm -rf "${ROOTFS_DIR}" mkdir -p "${ROOTFS_DIR}" - BOOT_SIZE="$((256 * 1024 * 1024))" - ROOT_SIZE=$(du --apparent-size -s "${EXPORT_ROOTFS_DIR}" --exclude var/cache/apt/archives --exclude boot --block-size=1 | cut -f 1) + BOOT_SIZE="$((512 * 1024 * 1024))" + ROOT_SIZE=$(du --apparent-size -s "${EXPORT_ROOTFS_DIR}" --exclude var/cache/apt/archives --exclude boot/firmware --block-size=1 | cut -f 1) # All partition sizes and starts will be aligned to this size ALIGN="$((4 * 1024 * 1024))" @@ -35,7 +35,7 @@ if [ "${NO_PRERUN_QCOW2}" = "0" ]; then echo "Creating loop device..." cnt=0 - until LOOP_DEV="$(losetup --show --find --partscan "$IMG_FILE")"; do + until ensure_next_loopdev && LOOP_DEV="$(losetup --show --find --partscan "$IMG_FILE")"; do if [ $cnt -lt 5 ]; then cnt=$((cnt + 1)) echo "Error in losetup. Retrying..." @@ -55,13 +55,13 @@ if [ "${NO_PRERUN_QCOW2}" = "0" ]; then ROOT_FEATURES="^$FEATURE,$ROOT_FEATURES" fi done - mkdosfs -n boot -F 32 -s 4 -v "$BOOT_DEV" > /dev/null + mkdosfs -n bootfs -F 32 -s 4 -v "$BOOT_DEV" > /dev/null mkfs.ext4 -L rootfs -O "$ROOT_FEATURES" "$ROOT_DEV" > /dev/null mount -v "$ROOT_DEV" "${ROOTFS_DIR}" -t ext4 - mkdir -p "${ROOTFS_DIR}/boot" - mount -v "$BOOT_DEV" "${ROOTFS_DIR}/boot" -t vfat + mkdir -p "${ROOTFS_DIR}/boot/firmware" + mount -v "$BOOT_DEV" "${ROOTFS_DIR}/boot/firmware" -t vfat - rsync -aHAXx --exclude /var/cache/apt/archives --exclude /boot "${EXPORT_ROOTFS_DIR}/" "${ROOTFS_DIR}/" - rsync -rtx "${EXPORT_ROOTFS_DIR}/boot/" "${ROOTFS_DIR}/boot/" + rsync -aHAXx --exclude /var/cache/apt/archives --exclude /boot/firmware "${EXPORT_ROOTFS_DIR}/" "${ROOTFS_DIR}/" + rsync -rtx "${EXPORT_ROOTFS_DIR}/boot/firmware/" "${ROOTFS_DIR}/boot/firmware/" fi diff --git a/scripts/common b/scripts/common index cda27abf77..b71ec35720 100644 --- a/scripts/common +++ b/scripts/common @@ -87,11 +87,27 @@ on_chroot() { mount --bind /sys "${ROOTFS_DIR}/sys" fi + if ! mount | grep -q "$(realpath "${ROOTFS_DIR}"/run)"; then + mount -t tmpfs tmpfs "${ROOTFS_DIR}/run" + fi + + if ! mount | grep -q "$(realpath "${ROOTFS_DIR}"/tmp)"; then + mount -t tmpfs tmpfs "${ROOTFS_DIR}/tmp" + fi + capsh $CAPSH_ARG "--chroot=${ROOTFS_DIR}/" -- -e "$@" } export -f on_chroot update_issue() { - echo -e "${IMG_NAME} ${IMG_VERSION} built on ${IMG_DATE}\nGenerated using ${PI_GEN}, ${PI_GEN_REPO}, ${GIT_HASH}, ${1}" > "${ROOTFS_DIR}/etc/rpi-issue" + echo -e "${PI_GEN_RELEASE} ${IMG_VERSION} built on ${IMG_DATE}\nGenerated using ${PI_GEN}, ${PI_GEN_REPO}, ${GIT_HASH}, ${1}" > "${ROOTFS_DIR}/etc/rpi-issue" } export -f update_issue + +ensure_next_loopdev() { + local loopdev + loopdev="$(losetup -f)" + loopmaj="$(echo "$loopdev" | sed -E 's/.*[^0-9]*?([0-9]+)$/\1/')" + [[ -b "$loopdev" ]] || mknod "$loopdev" b 7 "$loopmaj" +} +export -f ensure_next_loopdev diff --git a/stage0/00-configure-apt/00-run.sh b/stage0/00-configure-apt/00-run.sh index 96e6be38dd..c962c35762 100755 --- a/stage0/00-configure-apt/00-run.sh +++ b/stage0/00-configure-apt/00-run.sh @@ -12,7 +12,8 @@ else rm -f "${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache" fi -cat files/raspberrypi.gpg.key | gpg --dearmor > "${ROOTFS_DIR}/etc/apt/trusted.gpg.d/raspberrypi-archive-stable.gpg" +cat files/raspberrypi.gpg.key | gpg --dearmor > "${STAGE_WORK_DIR}/raspberrypi-archive-stable.gpg" +install -m 644 "${STAGE_WORK_DIR}/raspberrypi-archive-stable.gpg" "${ROOTFS_DIR}/etc/apt/trusted.gpg.d/" on_chroot << EOF dpkg --add-architecture armhf apt-get update diff --git a/stage0/00-configure-apt/files/raspi.list b/stage0/00-configure-apt/files/raspi.list index 41c5a70755..5f889b16a8 100644 --- a/stage0/00-configure-apt/files/raspi.list +++ b/stage0/00-configure-apt/files/raspi.list @@ -1,3 +1,3 @@ -deb http://archive.raspberrypi.org/debian/ RELEASE main +deb http://archive.raspberrypi.com/debian/ RELEASE main # Uncomment line below then 'apt-get update' to enable 'apt-get source' -#deb-src http://archive.raspberrypi.org/debian/ RELEASE main +#deb-src http://archive.raspberrypi.com/debian/ RELEASE main diff --git a/stage0/00-configure-apt/files/sources.list b/stage0/00-configure-apt/files/sources.list index 51290f6806..13697cec09 100644 --- a/stage0/00-configure-apt/files/sources.list +++ b/stage0/00-configure-apt/files/sources.list @@ -1,7 +1,7 @@ -deb http://deb.debian.org/debian RELEASE main contrib non-free -deb http://security.debian.org/debian-security RELEASE-security main contrib non-free -deb http://deb.debian.org/debian RELEASE-updates main contrib non-free +deb http://deb.debian.org/debian RELEASE main contrib non-free non-free-firmware +deb http://deb.debian.org/debian-security/ RELEASE-security main contrib non-free non-free-firmware +deb http://deb.debian.org/debian RELEASE-updates main contrib non-free non-free-firmware # Uncomment deb-src lines below then 'apt-get update' to enable 'apt-get source' -#deb-src http://deb.debian.org/debian RELEASE main contrib non-free -#deb-src http://security.debian.org/debian-security RELEASE-security main contrib non-free -#deb-src http://deb.debian.org/debian RELEASE-updates main contrib non-free +#deb-src http://deb.debian.org/debian RELEASE main contrib non-free non-free-firmware +#deb-src http://deb.debian.org/debian-security/ RELEASE-security main contrib non-free non-free-firmware +#deb-src http://deb.debian.org/debian RELEASE-updates main contrib non-free non-free-firmware diff --git a/stage0/02-firmware/01-packages b/stage0/02-firmware/01-packages index b166aa8dff..a1c3135105 100644 --- a/stage0/02-firmware/01-packages +++ b/stage0/02-firmware/01-packages @@ -1,2 +1,6 @@ -raspberrypi-bootloader -raspberrypi-kernel +initramfs-tools +raspi-firmware +linux-image-rpi-v8 +linux-image-rpi-2712 +linux-headers-rpi-v8 +linux-headers-rpi-2712 diff --git a/stage0/02-firmware/02-run.sh b/stage0/02-firmware/02-run.sh new file mode 100755 index 0000000000..0b2bca9625 --- /dev/null +++ b/stage0/02-firmware/02-run.sh @@ -0,0 +1,3 @@ +#!/bin/bash -e + +sed -i 's/^update_initramfs=.*/update_initramfs=no/' "${ROOTFS_DIR}/etc/initramfs-tools/update-initramfs.conf" diff --git a/stage0/prerun.sh b/stage0/prerun.sh index e4f85f192a..da6f50abea 100755 --- a/stage0/prerun.sh +++ b/stage0/prerun.sh @@ -1,6 +1,6 @@ #!/bin/bash -e -if [ "$RELEASE" != "bullseye" ]; then +if [ "$RELEASE" != "bookworm" ]; then echo "WARNING: RELEASE does not match the intended option for this branch." echo " Please check the relevant README.md section." fi diff --git a/stage1/00-boot-files/00-run.sh b/stage1/00-boot-files/00-run.sh index bc61397d9d..ddb0f5b22b 100755 --- a/stage1/00-boot-files/00-run.sh +++ b/stage1/00-boot-files/00-run.sh @@ -1,4 +1,17 @@ #!/bin/bash -e -install -m 644 files/cmdline.txt "${ROOTFS_DIR}/boot/" -install -m 644 files/config.txt "${ROOTFS_DIR}/boot/" +mkdir -p "${ROOTFS_DIR}/boot/firmware" + +if ! [ -L "${ROOTFS_DIR}/boot/overlays" ]; then + ln -s firmware/overlays "${ROOTFS_DIR}/boot/overlays" +fi + +install -m 644 files/cmdline.txt "${ROOTFS_DIR}/boot/firmware/" +if ! [ -L "${ROOTFS_DIR}/boot/cmdline.txt" ]; then + ln -s firmware/cmdline.txt "${ROOTFS_DIR}/boot/cmdline.txt" +fi + +install -m 644 files/config.txt "${ROOTFS_DIR}/boot/firmware/" +if ! [ -L "${ROOTFS_DIR}/boot/config.txt" ]; then + ln -s firmware/config.txt "${ROOTFS_DIR}/boot/config.txt" +fi diff --git a/stage1/00-boot-files/files/config.txt b/stage1/00-boot-files/files/config.txt index 7e3f252973..b8d7317d8b 100644 --- a/stage1/00-boot-files/files/config.txt +++ b/stage1/00-boot-files/files/config.txt @@ -1,53 +1,14 @@ # For more options and information see -# http://rpf.io/configtxt +# http://rptl.io/configtxt # Some settings may impact device functionality. See link above for details -# uncomment if you get no picture on HDMI for a default "safe" mode -#hdmi_safe=1 - -# uncomment the following to adjust overscan. Use positive numbers if console -# goes off screen, and negative if there is too much border -#overscan_left=16 -#overscan_right=16 -#overscan_top=16 -#overscan_bottom=16 - -# uncomment to force a console size. By default it will be display's size minus -# overscan. -#framebuffer_width=1280 -#framebuffer_height=720 - -# uncomment if hdmi display is not detected and composite is being output -#hdmi_force_hotplug=1 - -# uncomment to force a specific HDMI mode (this will force VGA) -#hdmi_group=1 -#hdmi_mode=1 - -# uncomment to force a HDMI mode rather than DVI. This can make audio work in -# DMT (computer monitor) modes -#hdmi_drive=2 - -# uncomment to increase signal to HDMI, if you have interference, blanking, or -# no display -#config_hdmi_boost=4 - -# uncomment for composite PAL -#sdtv_mode=2 - -#uncomment to overclock the arm. 700 MHz is the default. -#arm_freq=800 - # Uncomment some or all of these to enable the optional hardware interfaces #dtparam=i2c_arm=on #dtparam=i2s=on #dtparam=spi=on -# Uncomment this to enable infrared communication. -#dtoverlay=gpio-ir,gpio_pin=17 -#dtoverlay=gpio-ir-tx,gpio_pin=18 - -# Additional overlays and parameters are documented /boot/overlays/README +# Additional overlays and parameters are documented +# /boot/firmware/overlays/README # Enable audio (loads snd_bcm2835) dtparam=audio=on @@ -74,16 +35,26 @@ camera_auto_detect=1 # Automatically load overlays for detected DSI displays display_auto_detect=1 +# Automatically load initramfs files, if found +auto_initramfs=1 + # Enable DRM VC4 V3D driver dtoverlay=vc4-kms-v3d max_framebuffers=2 +# Don't have the firmware create an initial video= setting in cmdline.txt. +# Use the kernel's default instead. +disable_fw_kms_setup=1 + # Run in 64-bit mode arm_64bit=1 # Disable compensation for displays with overscan disable_overscan=1 +# Run as fast as firmware / board allows +arm_boost=1 + [cm4] # Enable host mode on the 2711 built-in XHCI USB controller. # This line should be removed if the legacy DWC2 controller is required @@ -92,8 +63,3 @@ otg_mode=1 [all] -[pi4] -# Run as fast as firmware / board allows -arm_boost=1 - -[all] diff --git a/stage1/01-sys-tweaks/files/fstab b/stage1/01-sys-tweaks/files/fstab index 198add3d36..a0b209ef36 100644 --- a/stage1/01-sys-tweaks/files/fstab +++ b/stage1/01-sys-tweaks/files/fstab @@ -1,5 +1,5 @@ proc /proc proc defaults 0 0 -BOOTDEV /boot vfat defaults 0 2 +BOOTDEV /boot/firmware vfat defaults 0 2 ROOTDEV / ext4 defaults,noatime 0 1 tmpfs /tmp tmpfs nosuid,nodev 0 0 tmpfs /var/log tmpfs nosuid,nodev 0 0 diff --git a/stage1/03-install-packages/00-packages b/stage1/03-install-packages/00-packages index 99e043c370..2e864f6f8c 100644 --- a/stage1/03-install-packages/00-packages +++ b/stage1/03-install-packages/00-packages @@ -1,2 +1,2 @@ -libraspberrypi-bin libraspberrypi0 raspi-config ca-certificates +ca-certificates systemd-timesyncd diff --git a/stage2/01-sys-tweaks/00-packages b/stage2/01-sys-tweaks/00-packages index a3cac3893b..90e88b1d6f 100644 --- a/stage2/01-sys-tweaks/00-packages +++ b/stage2/01-sys-tweaks/00-packages @@ -3,18 +3,22 @@ ntp daemontools daemontools-run build-essential gdb busybox-syslogd -ssh less fbset sudo psmisc strace ed ncdu crda +ssh less fbset sudo psmisc strace ed ncdu console-setup keyboard-configuration debconf-utils parted build-essential manpages-dev bash-completion gdb pkg-config python-is-python3 +v4l-utils gdbserver -python3-numpy libopenblas-base -python3-rpi.gpio v4l-utils +python3-numpy libopenblas-dev +gpiod python3-libgpiod python3-gpiozero +pigpio python3-pigpio raspi-gpio python3-rpi.gpio +python3-spidev +python3-smbus2 avahi-daemon lua5.1 luajit -hardlink ca-certificates curl +ca-certificates curl fake-hwclock usbutils dosfstools dphys-swapfile @@ -27,15 +31,14 @@ libmtp-runtime htop policykit-1 ssh-import-id -rng-tools ethtool ntfs-3g pciutils rpi-eeprom -raspinfo -python3-picamera +raspi-utils udisks2 unzip zip p7zip-full file kms++-utils openjdk-17-jdk +python3-venv diff --git a/stage2/01-sys-tweaks/00-packages-nr b/stage2/01-sys-tweaks/00-packages-nr index 453ada8be2..6bdb60069e 100644 --- a/stage2/01-sys-tweaks/00-packages-nr +++ b/stage2/01-sys-tweaks/00-packages-nr @@ -1,4 +1,3 @@ cifs-utils libcamera-apps-lite mkvtoolnix -python3-picamera2 diff --git a/stage2/01-sys-tweaks/00-patches/07-resize-init.diff b/stage2/01-sys-tweaks/00-patches/07-resize-init.diff index dfc01d4950..e508a9f525 100644 --- a/stage2/01-sys-tweaks/00-patches/07-resize-init.diff +++ b/stage2/01-sys-tweaks/00-patches/07-resize-init.diff @@ -1,5 +1,5 @@ ---- stage2.orig/rootfs/boot/cmdline.txt -+++ stage2/rootfs/boot/cmdline.txt +--- stage2.orig/rootfs/boot/firmware/cmdline.txt ++++ stage2/rootfs/boot/firmware/cmdline.txt @@ -1 +1 @@ -console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 fsck.repair=yes rootwait +console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 fsck.repair=yes rootwait quiet init=/usr/lib/raspberrypi-sys-mods/firstboot diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh index e0c4b717e1..f96b74b45e 100755 --- a/stage2/01-sys-tweaks/01-run.sh +++ b/stage2/01-sys-tweaks/01-run.sh @@ -34,17 +34,17 @@ ln -s /run /var/run ln -s /tmp /var/spool ln -s /tmp /var/lock sed -i -e 's/d \/var\/spool/#d \/var\/spool/' /usr/lib/tmpfiles.d/var.conf -sed -i -e 's/\/var\/lib\/ntp/\/var\/tmp/' /etc/ntp.conf EOF +#sed -i -e 's/\/var\/lib\/ntp/\/var\/tmp/' /etc/ntp.conf cat files/bash.bashrc >> "${ROOTFS_DIR}/etc/bash.bashrc" cat files/bash.logout >> "${ROOTFS_DIR}/etc/bash.bash_logout" +#systemctl disable nfs-common +#systemctl disable rpcbind on_chroot << EOF systemctl disable hwclock.sh -systemctl disable nfs-common -systemctl disable rpcbind if [ "${ENABLE_SSH}" == "1" ]; then systemctl enable ssh else diff --git a/stage3/01-sys-tweaks/00-packages b/stage3/01-sys-tweaks/00-packages index 77170e2e12..030c5f217d 100644 --- a/stage3/01-sys-tweaks/00-packages +++ b/stage3/01-sys-tweaks/00-packages @@ -1,20 +1,22 @@ cmake -libpython3.9-minimal -libpython3.9-dev -python3.9-minimal -python3.9-dev +libprotobuf-dev +libpython3.11-minimal +libpython3.11-dev +ninja-build +protobuf-compiler +python3.11-minimal +python3.11-dev python3-distutils python3-jinja2 python3-numpy python3-pip -python3-pycoral libedgetpu1-std libedgetpu-dev libtbb-dev -libtbb2 +libtbbmalloc2 +libssh-dev libusb-1.0-0-dev libz-dev swig pigpio -python-pigpio python3-pigpio diff --git a/stage3/01-sys-tweaks/00-packages-nr b/stage3/01-sys-tweaks/00-packages-nr index ebe1830774..1bc22fa8db 100644 --- a/stage3/01-sys-tweaks/00-packages-nr +++ b/stage3/01-sys-tweaks/00-packages-nr @@ -1,4 +1,4 @@ libopenblas-dev liblapacke-dev -libavcodec-dev libavformat-dev libswscale-dev libavresample-dev +libavcodec-dev libavformat-dev libswscale-dev libgtk-3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev diff --git a/stage3/01-sys-tweaks/01-run.sh b/stage3/01-sys-tweaks/01-run.sh index 54d49b904f..c1d7430ff0 100755 --- a/stage3/01-sys-tweaks/01-run.sh +++ b/stage3/01-sys-tweaks/01-run.sh @@ -42,13 +42,13 @@ pushd ${DOWNLOAD_DIR} # opencv sources wget -nc -nv \ - https://github.com/opencv/opencv/archive/4.6.0.tar.gz -wget -nc -nv -O contrib-4.6.0.tar.gz \ - https://github.com/opencv/opencv_contrib/archive/4.6.0.tar.gz + https://github.com/opencv/opencv/archive/4.8.0.tar.gz +wget -nc -nv -O contrib-4.8.0.tar.gz \ + https://github.com/opencv/opencv_contrib/archive/4.8.0.tar.gz # allwpilib wget -nc -nv -O allwpilib.tar.gz \ - https://github.com/wpilibsuite/allwpilib/archive/v2023.4.1.tar.gz + https://github.com/wpilibsuite/allwpilib/archive/v2024.3.1.tar.gz ## robotpy-build #wget -nc -nv -O robotpy-build.tar.gz \ @@ -88,10 +88,10 @@ install -v -d ${EXTRACT_DIR} pushd ${EXTRACT_DIR} # opencv -rm -rf opencv-4.6.0 -tar xzf "${DOWNLOAD_DIR}/4.6.0.tar.gz" -tar xzf "${DOWNLOAD_DIR}/contrib-4.6.0.tar.gz" -pushd opencv-4.6.0 +rm -rf opencv-4.8.0 +tar xzf "${DOWNLOAD_DIR}/4.8.0.tar.gz" +tar xzf "${DOWNLOAD_DIR}/contrib-4.8.0.tar.gz" +pushd opencv-4.8.0 sed -i -e 's/javac sourcepath/javac target="1.8" source="1.8" sourcepath/' modules/java/jar/build.xml.in # disable extraneous data warnings; these are common with USB cameras sed -i -e '/JWRN_EXTRANEOUS_DATA/d' 3rdparty/libjpeg/jdmarker.c @@ -105,35 +105,6 @@ mv allwpilib-* allwpilib pushd allwpilib popd -# robotpy-build -#tar xzf "${DOWNLOAD_DIR}/robotpy-build.tar.gz" -#mv robotpy-build-* robotpy-build - -# pybind11 -#tar xzf "${DOWNLOAD_DIR}/pybind11.tar.gz" -#rmdir robotpy-build/robotpy_build/pybind11 -#mv pybind11-* robotpy-build/robotpy_build/pybind11 - -# robotpy-wpiutil -#tar xzf "${DOWNLOAD_DIR}/robotpy-wpiutil.tar.gz" -#mv robotpy-wpiutil-* robotpy-wpiutil -#echo "__version__ = '2023.1.1.0'" > robotpy-wpiutil/wpiutil/version.py - -# robotpy-wpinet -#tar xzf "${DOWNLOAD_DIR}/robotpy-wpinet.tar.gz" -#mv robotpy-wpinet-* robotpy-wpinet -#echo "__version__ = '2023.1.1.0'" > robotpy-wpinet/wpinet/version.py - -# pyntcore -#tar xzf "${DOWNLOAD_DIR}/pyntcore.tar.gz" -#mv pyntcore-* pyntcore -#echo "__version__ = '2023.1.1.0'" > pyntcore/ntcore/version.py - -# robotpy-cscore -#tar xzf "${DOWNLOAD_DIR}/robotpy-cscore.tar.gz" -#mv robotpy-cscore-* robotpy-cscore -#echo "__version__ = '2023.1.1.0'" > robotpy-cscore/cscore/version.py - # pixy2 tar xzf "${DOWNLOAD_DIR}/pixy2.tar.gz" rm -rf pixy2 @@ -164,34 +135,34 @@ build_opencv () { rm -rf $1 mkdir -p $1 pushd $1 - cmake "${EXTRACT_DIR}/opencv-4.6.0" \ + cmake "${EXTRACT_DIR}/opencv-4.8.0" \ + -G Ninja \ -DWITH_FFMPEG=OFF \ -DBUILD_JPEG=ON \ -DBUILD_TIFF=ON \ -DBUILD_TESTS=OFF \ - -DPython_ADDITIONAL_VERSIONS=3.9 \ + -DPython_ADDITIONAL_VERSIONS=3.11 \ -DBUILD_JAVA=$3 \ -DENABLE_CXX11=ON \ -DBUILD_SHARED_LIBS=$3 \ -DCMAKE_BUILD_TYPE=$2 \ -DCMAKE_DEBUG_POSTFIX=d \ - -DCMAKE_TOOLCHAIN_FILE=${ROOTFS_DIR}/usr/src/opencv-4.6.0/platforms/linux/aarch64-gnu.toolchain.cmake \ + -DCMAKE_TOOLCHAIN_FILE=${ROOTFS_DIR}/usr/src/opencv-4.8.0/platforms/linux/aarch64-gnu.toolchain.cmake \ -DARM_LINUX_SYSROOT=${ROOTFS_DIR} \ -DCMAKE_SYSROOT=${ROOTFS_DIR} \ - -DCMAKE_MAKE_PROGRAM=make \ -DENABLE_NEON=ON \ -DWITH_TBB=$3 \ -DBUILD_opencv_python3=$3 \ - -DPYTHON3_INCLUDE_PATH=${ROOTFS_DIR}/usr/include/python3.9 \ - -DPYTHON3_NUMPY_INCLUDE_DIRS=${ROOTFS_DIR}/usr/include/python3.9/numpy \ + -DPYTHON3_INCLUDE_PATH=${ROOTFS_DIR}/usr/include/python3.11 \ + -DPYTHON3_NUMPY_INCLUDE_DIRS=${ROOTFS_DIR}/usr/include/python3.11/numpy \ -DOPENCV_EXTRA_FLAGS_DEBUG=-Og \ -DOPENCV_GENERATE_PKGCONFIG=ON \ -DCMAKE_MODULE_PATH=${SUB_STAGE_DIR}/files \ -DCMAKE_INSTALL_PREFIX=/usr/local/frc$4 \ - -DOPENCV_EXTRA_MODULES_PATH=${EXTRACT_DIR}/opencv_contrib-4.6.0/modules/aruco \ + -DOPENCV_EXTRA_MODULES_PATH=${EXTRACT_DIR}/opencv_contrib-4.8.0/modules/aruco \ || exit 1 - make -j${NCPU} || exit 1 - make DESTDIR=${ROOTFS_DIR} install || exit 1 + ninja || exit 1 + env DESTDIR=${ROOTFS_DIR} ninja install || exit 1 popd } @@ -200,19 +171,19 @@ build_opencv build/opencv-build Release ON "" || exit 1 build_opencv build/opencv-static Release OFF "-static" || exit 1 # fix up java install -cp -p ${ROOTFS_DIR}/usr/local/frc/share/java/opencv4/libopencv_java460*.so "${ROOTFS_DIR}/usr/local/frc/lib/" +cp -p ${ROOTFS_DIR}/usr/local/frc/share/java/opencv4/libopencv_java480*.so "${ROOTFS_DIR}/usr/local/frc/lib/" mkdir -p "${ROOTFS_DIR}/usr/local/frc/java" -cp -p "${ROOTFS_DIR}/usr/local/frc/share/java/opencv4/opencv-460.jar" "${ROOTFS_DIR}/usr/local/frc/java/" +cp -p "${ROOTFS_DIR}/usr/local/frc/share/java/opencv4/opencv-480.jar" "${ROOTFS_DIR}/usr/local/frc/java/" # the opencv build names the python .so with the build platform name # instead of the target platform, so rename it -pushd "${ROOTFS_DIR}/usr/local/frc/lib/python3.9/site-packages/cv2/python-3.9" -mv cv2.cpython-39-*-gnu.so cv2.cpython-39-aarch64-linux-gnu.so -mv cv2d.cpython-39-*-gnu.so cv2d.cpython-39-aarch64-linux-gnu.so +pushd "${ROOTFS_DIR}/usr/local/frc/lib/python3.11/dist-packages/cv2/python-3.11" +mv cv2.cpython-311-*-gnu.so cv2.cpython-311-aarch64-linux-gnu.so +mv cv2d.cpython-311-*-gnu.so cv2d.cpython-311-aarch64-linux-gnu.so popd -# link python package to site-packages -ln -sf /usr/local/frc/lib/python3.9/site-packages/cv2 "${ROOTFS_DIR}/usr/local/lib/python3.9/dist-packages/cv2" +# link python package to dist-packages +ln -sf /usr/local/frc/lib/python3.11/dist-packages/cv2 "${ROOTFS_DIR}/usr/local/lib/python3.11/dist-packages/cv2" # # Build wpiutil, cscore, ntcore, cameraserver @@ -223,22 +194,24 @@ build_wpilib () { mkdir -p $1 pushd $1 cmake "${EXTRACT_DIR}/allwpilib" \ + -G Ninja \ -DWITH_GUI=OFF \ -DWITH_TESTS=OFF \ -DWITH_SIMULATION_MODULES=OFF \ - -DWPILIB_TARGET_WARNINGS=-Wno-deprecated-declarations \ + -DWPILIB_TARGET_WARNINGS=-Wno-maybe-uninitialized \ -DCMAKE_BUILD_TYPE=$2 \ - -DCMAKE_TOOLCHAIN_FILE=${ROOTFS_DIR}/usr/src/opencv-4.6.0/platforms/linux/aarch64-gnu.toolchain.cmake \ + -DCMAKE_TOOLCHAIN_FILE=${ROOTFS_DIR}/usr/src/opencv-4.8.0/platforms/linux/aarch64-gnu.toolchain.cmake \ -DARM_LINUX_SYSROOT=${ROOTFS_DIR} \ -DCMAKE_SYSROOT=${ROOTFS_DIR} \ -DCMAKE_MODULE_PATH=${SUB_STAGE_DIR}/files \ - -DOPENCV_JAR_FILE=`ls ${ROOTFS_DIR}/usr/local/frc/java/opencv-460.jar` \ - -DOPENCV_JNI_FILE=`ls ${ROOTFS_DIR}/usr/local/frc/lib/libopencv_java460.so` \ + -DOPENCV_JAR_FILE=`ls ${ROOTFS_DIR}/usr/local/frc/java/opencv-480.jar` \ + -DOPENCV_JNI_FILE=`ls ${ROOTFS_DIR}/usr/local/frc/lib/libopencv_java480.so` \ -DOpenCV_DIR=${ROOTFS_DIR}/usr/local/frc/share/opencv4 \ -DTHREADS_PTHREAD_ARG=-pthread \ -DCMAKE_INSTALL_PREFIX=/usr/local/frc \ || exit 1 - make -j${NCPU} || exit 1 + ninja || exit 1 + env DESTDIR=${ROOTFS_DIR} ninja install || exit 1 popd } @@ -251,12 +224,13 @@ build_static_wpilib() { mkdir -p $1 pushd $1 cmake "${EXTRACT_DIR}/allwpilib" \ + -G Ninja \ -DWITH_GUI=OFF \ -DWITH_TESTS=OFF \ -DWITH_SIMULATION_MODULES=OFF \ - -DWPILIB_TARGET_WARNINGS=-Wno-deprecated-declarations \ + -DWPILIB_TARGET_WARNINGS=-Wno-maybe-uninitialized \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_TOOLCHAIN_FILE=${ROOTFS_DIR}/usr/src/opencv-4.6.0/platforms/linux/aarch64-gnu.toolchain.cmake \ + -DCMAKE_TOOLCHAIN_FILE=${ROOTFS_DIR}/usr/src/opencv-4.8.0/platforms/linux/aarch64-gnu.toolchain.cmake \ -DARM_LINUX_SYSROOT=${ROOTFS_DIR} \ -DCMAKE_MODULE_PATH=${SUB_STAGE_DIR}/files \ -DOpenCV_DIR=${ROOTFS_DIR}/usr/local/frc/share/OpenCV \ @@ -265,87 +239,19 @@ build_static_wpilib() { -DTHREADS_PTHREAD_ARG=-pthread \ -DCMAKE_INSTALL_PREFIX=/usr/local/frc-static \ || exit 1 - make -j${NCPU} || exit 1 + ninja || exit 1 + env DESTDIR=${ROOTFS_DIR} ninja install || exit 1 popd } build_static_wpilib build/allwpilib-static || exit 1 -# manually install, since cmake install is a bit weirdly set up -install -v -d "${ROOTFS_DIR}/usr/local/frc/bin" -install -v -d "${ROOTFS_DIR}/usr/local/frc/include" -install -v -d "${ROOTFS_DIR}/usr/local/frc/java" -install -v -d "${ROOTFS_DIR}/usr/local/frc/lib" -install -v -d "${ROOTFS_DIR}/usr/local/frc-static/lib" - -# built libs -sh -c 'cd build/allwpilib-build/lib && tar cf - lib*' | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/lib && tar xf -" -sh -c 'cd build/allwpilib-build-debug/lib && tar cf - lib*' | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/lib && tar xf -" -sh -c 'cd build/allwpilib-static/lib && tar cf - lib*' | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc-static/lib && tar xf -" - -# built headers -sh -c 'cd build/allwpilib-build/hal/gen && tar cf - .' | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c 'cd build/allwpilib-build/ntcore/generated/main/native/include && tar cf - .' | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" - -# built jars -sh -c 'cd build/allwpilib-build/jar && tar cf - *.jar' | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/java && tar xf -" - -# headers -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpiutil/src/main/native/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpiutil/src/main/native/thirdparty/fmtlib/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpiutil/src/main/native/thirdparty/ghc/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpiutil/src/main/native/thirdparty/json/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpiutil/src/main/native/thirdparty/llvm/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpiutil/src/main/native/thirdparty/memory/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpiutil/src/main/native/thirdparty/mpack/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpiutil/src/main/native/thirdparty/sigslot/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpinet/src/main/native/thirdparty/libuv/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpinet/src/main/native/thirdparty/tcpsockets/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpinet/src/main/native/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/cscore/src/main/native/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/ntcore/src/main/native/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/cameraserver/src/main/native/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/hal/src/main/native/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpimath/src/main/native/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpimath/src/main/native/thirdparty/drake/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpimath/src/main/native/thirdparty/eigen/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpimath/src/main/native/thirdparty/gcem/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/apriltag/src/main/native/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" -sh -c "cd ${EXTRACT_DIR}/allwpilib/wpilibc/src/main/native/include && tar cf - ." | \ - sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" - # executables (use static build to ensure they don't break) sh -c 'cd build/allwpilib-static/bin && tar cf - cscore_* netconsoleTee*' | \ sh -c "cd ${ROOTFS_DIR}/usr/local/frc/bin && tar xf -" # pkgconfig files install -v -d "${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig" -install -m 644 ${SUB_STAGE_DIR}/files/pkgconfig/* "${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig" +install -m 644 ${SUB_STAGE_DIR}/files/pkgconfig/*.pc "${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig" install -v -d "${ROOTFS_DIR}/usr/local/frc-static/lib/pkgconfig" for f in ${SUB_STAGE_DIR}/files/pkgconfig/*.pc; do install -m 644 $f "${ROOTFS_DIR}/usr/local/frc-static/lib/pkgconfig" @@ -359,164 +265,23 @@ ln -sf ../frc/include "${ROOTFS_DIR}/usr/local/frc-static/include" rm -rf "${ROOTFS_DIR}/usr/local/frc-static/python" # fix up frc-static opencv pkgconfig Libs.private -sed -i -e 's, -L/pi-gen[^ ]*,,g' "${ROOTFS_DIR}/usr/local/frc-static/lib/pkgconfig/opencv.pc" +sed -i -e 's, -L/pi-gen[^ ]*,,g' "${ROOTFS_DIR}/usr/local/frc-static/lib/pkgconfig/opencv4.pc" popd +ROBOTPY_REPO=https://frcmaven.wpi.edu/api/download/wpilib-python-release-2024 +ROBOTPY_VERSION=2024.3.1.0 +ROBOTPY_ARCH=aarch64 + on_chroot << EOF -pip3 install https://www.tortall.net/~robotpy/wheels/2023/raspbian/robotpy_wpiutil-2023.4.1.0-cp39-cp39-linux_aarch64.whl -pip3 install https://www.tortall.net/~robotpy/wheels/2023/raspbian/robotpy_wpinet-2023.4.1.0-cp39-cp39-linux_aarch64.whl -pip3 install https://www.tortall.net/~robotpy/wheels/2023/raspbian/pyntcore-2023.4.1.1-cp39-cp39-linux_aarch64.whl -pip3 install https://www.tortall.net/~robotpy/wheels/2023/raspbian/robotpy_cscore-2023.4.1.0-cp39-cp39-linux_aarch64.whl -pip3 install https://www.tortall.net/~robotpy/wheels/2023/raspbian/robotpy_wpimath-2023.4.1.0-cp39-cp39-linux_aarch64.whl -pip3 install https://www.tortall.net/~robotpy/wheels/2023/raspbian/robotpy_apriltag-2023.4.1.0-cp39-cp39-linux_aarch64.whl +pip3 install --break-system-packages ${ROBOTPY_REPO}/robotpy-wpiutil/${ROBOTPY_VERSION}/robotpy_wpiutil-${ROBOTPY_VERSION}-cp311-cp311-linux_${ROBOTPY_ARCH}.whl +pip3 install --break-system-packages ${ROBOTPY_REPO}/robotpy-wpinet/${ROBOTPY_VERSION}/robotpy_wpinet-${ROBOTPY_VERSION}-cp311-cp311-linux_${ROBOTPY_ARCH}.whl +pip3 install --break-system-packages ${ROBOTPY_REPO}/pyntcore/${ROBOTPY_VERSION}/pyntcore-${ROBOTPY_VERSION}-cp311-cp311-linux_${ROBOTPY_ARCH}.whl +pip3 install --break-system-packages ${ROBOTPY_REPO}/robotpy-cscore/${ROBOTPY_VERSION}/robotpy_cscore-${ROBOTPY_VERSION}-cp311-cp311-linux_${ROBOTPY_ARCH}.whl +pip3 install --break-system-packages ${ROBOTPY_REPO}/robotpy-wpimath/${ROBOTPY_VERSION}/robotpy_wpimath-${ROBOTPY_VERSION}-cp311-cp311-linux_${ROBOTPY_ARCH}.whl +pip3 install --break-system-packages ${ROBOTPY_REPO}/robotpy-apriltag/${ROBOTPY_VERSION}/robotpy_apriltag-${ROBOTPY_VERSION}-cp311-cp311-linux_${ROBOTPY_ARCH}.whl EOF - -### We install wheels instead of using this, but keeping it because it *almost* works -# -## these builds arepretty cpu-intensive, so we don't want to build it in a chroot, -## and setup.py doesn't support cross-builds, so build it manually -#pip3 install robotpy-build==2023.0.0 -# -## -## Build robotpy-wpiutil -## -#pushd ${EXTRACT_DIR}/robotpy-wpiutil -# -## install Python sources -#sh -c 'tar cf - wpiutil' | \ -# sh -c "cd ${ROOTFS_DIR}/usr/local/lib/python3.9/dist-packages && tar xf -" -# -## install blank _init_wpiutil.py -#touch "${ROOTFS_DIR}/usr/local/lib/python3.9/dist-packages/wpiutil/_init_wpiutil.py" -# -## generate sources -#python3 setup.py build_gen -# -## build module -#aarch64-linux-gnu-g++ \ -# --sysroot=${ROOTFS_DIR} \ -# -g -O -Wall -fvisibility=hidden -shared -fPIC -std=c++20 \ -# -o "${ROOTFS_DIR}/usr/local/lib/python3.9/dist-packages/_wpiutil.cpython-39-aarch64-linux-gnu.so" \ -# -I build/temp.*/gensrc/* \ -# -I../robotpy-build/robotpy_build/include \ -# -I../robotpy-build/robotpy_build/pybind11/include \ -# -Iwpiutil/src/type_casters \ -# -Iwpiutil/rpy-include \ -# `env PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR}:${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig pkg-config --cflags python3 wpiutil` \ -# wpiutil/src/main.cpp \ -# wpiutil/src/safethread_gil.cpp \ -# wpiutil/src/stacktracehook.cpp \ -# build/temp.*/gensrc/*/*.cpp \ -# `env PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR}:${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig pkg-config --libs wpiutil` \ -# || exit 1 -# -#popd -# -#pip3 install robotpy-wpiutil==2023.1.1.0 -# -## -## Build robotpy-wpinet -## -#pushd ${EXTRACT_DIR}/robotpy-wpinet -# -## install Python sources -#sh -c 'tar cf - wpinet' | \ -# sh -c "cd ${ROOTFS_DIR}/usr/local/lib/python3.9/dist-packages && tar xf -" -# -## install blank _init_wpinet.py -#touch "${ROOTFS_DIR}/usr/local/lib/python3.9/dist-packages/wpinet/_init_wpinet.py" -# -## generate sources -#python3 setup.py build_gen -# -## build module -#aarch64-linux-gnu-g++ \ -# --sysroot=${ROOTFS_DIR} \ -# -g -O -Wall -fvisibility=hidden -shared -fPIC -std=c++20 \ -# -o "${ROOTFS_DIR}/usr/local/lib/python3.9/dist-packages/_wpinet.cpython-39-aarch64-linux-gnu.so" \ -# -I build/temp.*/gensrc/* \ -# -I../robotpy-build/robotpy_build/include \ -# -I../robotpy-build/robotpy_build/pybind11/include \ -# `env PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR}:${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig pkg-config --cflags python3 wpinet wpiutil` \ -# wpinet/src/main.cpp \ -# build/temp.*/gensrc/*/*.cpp \ -# `env PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR}:${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig pkg-config --libs wpinet wpiutil` \ -# || exit 1 -# -#popd -# -#pip3 install robotpy-wpinet==2023.1.1.0 -# -## -## Build pyntcore -## -#pushd ${EXTRACT_DIR}/pyntcore -# -## install Python sources -#sh -c 'tar cf - ntcore' | \ -# sh -c "cd ${ROOTFS_DIR}/usr/local/lib/python3.9/dist-packages && tar xf -" -# -## install blank _init_ntcore.py -#touch "${ROOTFS_DIR}/usr/local/lib/python3.9/dist-packages/cscore/_init_ntcore.py" -# -## generate sources -#python3 setup.py build_gen -# -## build module -#aarch64-linux-gnu-g++ \ -# --sysroot=${ROOTFS_DIR} \ -# -g -O -Wall -fvisibility=hidden -shared -fPIC -std=c++20 \ -# -o "${ROOTFS_DIR}/usr/local/lib/python3.9/dist-packages/_cscore.cpython-39-aarch64-linux-gnu.so" \ -# -I build/temp.*/gensrc/* \ -# -I../robotpy-build/robotpy_build/include \ -# -I../robotpy-build/robotpy_build/pybind11/include \ -# `env PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR}:${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig pkg-config --cflags python3 ntcore wpiutil` \ -# ntcore/src/ntcore.cpp \ -# ntcore/src/nt_instance.cpp \ -# ntcore/src/py2value.cpp \ -# ntcore/src/pyentry.cpp \ -# build/temp.*/gensrc/*/*.cpp \ -# `env PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR}:${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig pkg-config --libs ntcore wpiutil` \ -# || exit 1 -# -#popd -# -#pip3 install pyntcore==2023.1.1.0 -# -## -## Build robotpy-cscore -## -#pushd ${EXTRACT_DIR}/robotpy-cscore -# -## install Python sources -#sh -c 'tar cf - cscore' | \ -# sh -c "cd ${ROOTFS_DIR}/usr/local/lib/python3.9/dist-packages && tar xf -" -# -## install blank _init_cscore.py -#touch "${ROOTFS_DIR}/usr/local/lib/python3.9/dist-packages/cscore/_init_cscore.py" -# -## generate sources -#python3 setup.py build_gen -# -## build module -#aarch64-linux-gnu-g++ \ -# --sysroot=${ROOTFS_DIR} \ -# -g -O -Wall -fvisibility=hidden -shared -fPIC -std=c++20 \ -# -o "${ROOTFS_DIR}/usr/local/lib/python3.9/dist-packages/_cscore.cpython-39-aarch64-linux-gnu.so" \ -# -I build/temp.*/gensrc/* \ -# -I../robotpy-build/robotpy_build/include \ -# -I../robotpy-build/robotpy_build/pybind11/include \ -# `env PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR}:${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig pkg-config --cflags python3 cameraserver cscore wpiutil` \ -# cscore/src/main.cpp \ -# cscore/cvnp/cvnp.cpp \ -# cscore/cvnp/cvnp_synonyms.cpp \ -# `env PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR}:${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig pkg-config --libs cameraserver cscore wpiutil` \ -# || exit 1 -# -#popd - # # Build pixy2 # @@ -528,8 +293,8 @@ popd EOF install -m 644 "${EXTRACT_DIR}/pixy2/build/libpixyusb2/libpixy2.a" "${ROOTFS_DIR}/usr/local/frc/lib/" -install -m 644 "${EXTRACT_DIR}/pixy2/build/python_demos/pixy.py" "${ROOTFS_DIR}/usr/local/lib/python3.9/site-packages/" -install -m 755 ${EXTRACT_DIR}/pixy2/build/python_demos/_pixy.*.so "${ROOTFS_DIR}/usr/local/lib/python3.9/site-packages/" +install -m 644 "${EXTRACT_DIR}/pixy2/build/python_demos/pixy.py" "${ROOTFS_DIR}/usr/local/lib/python3.11/dist-packages/" +install -m 755 ${EXTRACT_DIR}/pixy2/build/python_demos/_pixy.*.so "${ROOTFS_DIR}/usr/local/lib/python3.11/dist-packages/" rm -rf "${EXTRACT_DIR}/pixy2/build" # diff --git a/stage3/01-sys-tweaks/files/pkgconfig/apriltag.pc b/stage3/01-sys-tweaks/files/pkgconfig/apriltag.pc index 65b3967b40..b4461afbbc 100644 --- a/stage3/01-sys-tweaks/files/pkgconfig/apriltag.pc +++ b/stage3/01-sys-tweaks/files/pkgconfig/apriltag.pc @@ -2,12 +2,12 @@ prefix=/usr/local/frc exec_prefix=${prefix} -includedir=${prefix}/include +includedir=${prefix}/include/apriltag libdir=${exec_prefix}/lib Name: apriltag Description: WPILib Robotics Library AprilTags -Version: 2023.1.1 +Version: 2024.1.1 Requires: wpimath wpiutil Libs: -L${libdir} -lapriltag Libs.private: -lpthread diff --git a/stage3/01-sys-tweaks/files/pkgconfig/cameraserver.pc b/stage3/01-sys-tweaks/files/pkgconfig/cameraserver.pc index 245b35da8c..64c7d2fff7 100644 --- a/stage3/01-sys-tweaks/files/pkgconfig/cameraserver.pc +++ b/stage3/01-sys-tweaks/files/pkgconfig/cameraserver.pc @@ -2,12 +2,12 @@ prefix=/usr/local/frc exec_prefix=${prefix} -includedir=${prefix}/include +includedir=${prefix}/include/cameraserver libdir=${exec_prefix}/lib Name: cameraserver Description: WPILib Robotics Library CameraServer -Version: 2023.1.1 +Version: 2024.1.1 Requires: cscore wpiutil Requires.private: ntcore Libs: -L${libdir} -lcameraserver diff --git a/stage3/01-sys-tweaks/files/pkgconfig/cscore.pc b/stage3/01-sys-tweaks/files/pkgconfig/cscore.pc index e3d9f8e5e3..c9d7aaed0d 100644 --- a/stage3/01-sys-tweaks/files/pkgconfig/cscore.pc +++ b/stage3/01-sys-tweaks/files/pkgconfig/cscore.pc @@ -2,12 +2,12 @@ prefix=/usr/local/frc exec_prefix=${prefix} -includedir=${prefix}/include +includedir=${prefix}/include/cscore libdir=${exec_prefix}/lib Name: cscore Description: WPILib Robotics Library CameraServer Core -Version: 2023.1.1 +Version: 2024.1.1 Requires: wpiutil opencv4 Requires.private: wpinet Libs: -L${libdir} -lcscore diff --git a/stage3/01-sys-tweaks/files/pkgconfig/ntcore.pc b/stage3/01-sys-tweaks/files/pkgconfig/ntcore.pc index c3da5c47de..d12ec26312 100644 --- a/stage3/01-sys-tweaks/files/pkgconfig/ntcore.pc +++ b/stage3/01-sys-tweaks/files/pkgconfig/ntcore.pc @@ -2,12 +2,12 @@ prefix=/usr/local/frc exec_prefix=${prefix} -includedir=${prefix}/include +includedir=${prefix}/include/ntcore libdir=${exec_prefix}/lib Name: ntcore Description: WPILib Robotics Library NetworkTables -Version: 2023.1.1 +Version: 2024.1.1 Requires: wpiutil Requires.private: wpinet Libs: -L${libdir} -lntcore diff --git a/stage3/01-sys-tweaks/files/pkgconfig/wpilibc.pc b/stage3/01-sys-tweaks/files/pkgconfig/wpilibc.pc index bb97c9cf1f..e477a4489f 100644 --- a/stage3/01-sys-tweaks/files/pkgconfig/wpilibc.pc +++ b/stage3/01-sys-tweaks/files/pkgconfig/wpilibc.pc @@ -2,12 +2,12 @@ prefix=/usr/local/frc exec_prefix=${prefix} -includedir=${prefix}/include +includedir=${prefix}/include/wpilibc libdir=${exec_prefix}/lib Name: wpilibc Description: WPILib Robotics Library -Version: 2023.1.1 +Version: 2024.1.1 Requires: apriltag cameraserver ntcore cscore wpimath wpinet wpiutil Libs: -L${libdir} -lwpilibc -lwpiHal Cflags: -I${includedir} diff --git a/stage3/01-sys-tweaks/files/pkgconfig/wpimath.pc b/stage3/01-sys-tweaks/files/pkgconfig/wpimath.pc index 21eba35381..6edcee8737 100644 --- a/stage3/01-sys-tweaks/files/pkgconfig/wpimath.pc +++ b/stage3/01-sys-tweaks/files/pkgconfig/wpimath.pc @@ -2,12 +2,12 @@ prefix=/usr/local/frc exec_prefix=${prefix} -includedir=${prefix}/include +includedir=${prefix}/include/wpimath libdir=${exec_prefix}/lib Name: wpimath Description: WPILib Robotics Library Math -Version: 2023.1.1 +Version: 2024.1.1 Requires: wpiutil Libs: -L${libdir} -lwpimath Cflags: -I${includedir} diff --git a/stage3/01-sys-tweaks/files/pkgconfig/wpinet.pc b/stage3/01-sys-tweaks/files/pkgconfig/wpinet.pc index 0946d3e8de..00424a0e2f 100644 --- a/stage3/01-sys-tweaks/files/pkgconfig/wpinet.pc +++ b/stage3/01-sys-tweaks/files/pkgconfig/wpinet.pc @@ -2,12 +2,12 @@ prefix=/usr/local/frc exec_prefix=${prefix} -includedir=${prefix}/include +includedir=${prefix}/include/wpinet libdir=${exec_prefix}/lib Name: wpinet Description: WPILib Robotics Library Networking -Version: 2023.1.1 +Version: 2024.1.1 Requires: wpiutil Libs: -L${libdir} -lwpinet Libs.private: -lpthread -lutil diff --git a/stage3/01-sys-tweaks/files/pkgconfig/wpiutil.pc b/stage3/01-sys-tweaks/files/pkgconfig/wpiutil.pc index e0526dbe29..839b84baeb 100644 --- a/stage3/01-sys-tweaks/files/pkgconfig/wpiutil.pc +++ b/stage3/01-sys-tweaks/files/pkgconfig/wpiutil.pc @@ -2,12 +2,12 @@ prefix=/usr/local/frc exec_prefix=${prefix} -includedir=${prefix}/include +includedir=${prefix}/include/wpiutil libdir=${exec_prefix}/lib Name: wpiutil Description: WPILib Robotics Library utilities -Version: 2023.1.1 +Version: 2024.1.1 Libs: -L${libdir} -lwpiutil -latomic Libs.private: -lpthread Cflags: -I${includedir} diff --git a/stage4/01-sys-tweaks/01-run.sh b/stage4/01-sys-tweaks/01-run.sh index 6ea5f24d67..39cae7eddb 100755 --- a/stage4/01-sys-tweaks/01-run.sh +++ b/stage4/01-sys-tweaks/01-run.sh @@ -21,6 +21,10 @@ sh -c "cd ${BASE_DIR}/deps && tar cf - tools" | \ # pushd "${STAGE_WORK_DIR}/tools" +ls -l ${ROOTFS_DIR}/usr/local/frc-static/include +ls -l ${ROOTFS_DIR}/usr/local/frc/include +ls ${ROOTFS_DIR}/usr/local/frc-static/include/wpiutil + export CXXFLAGS="-std=c++20 --sysroot=${ROOTFS_DIR} -Wl,-rpath -Wl,${ROOTFS_DIR}/opt/vc/lib" export PKG_CONFIG_DIR= export PKG_CONFIG_LIBDIR=${ROOTFS_DIR}/usr/lib/aarch64-linux-gnu/pkgconfig:${ROOTFS_DIR}/usr/lib/pkgconfig:${ROOTFS_DIR}/usr/share/pkgconfig:${ROOTFS_DIR}/usr/local/frc-static/lib/pkgconfig diff --git a/stage4/02-net-tweaks/00-packages b/stage4/02-net-tweaks/00-packages index f0125f6a6d..d446837df7 100644 --- a/stage4/02-net-tweaks/00-packages +++ b/stage4/02-net-tweaks/00-packages @@ -1,5 +1,4 @@ wpasupplicant wireless-tools firmware-atheros firmware-brcm80211 firmware-libertas firmware-misc-nonfree firmware-realtek raspberrypi-net-mods -dhcpcd5 network-manager net-tools diff --git a/stage4/02-net-tweaks/01-run.sh b/stage4/02-net-tweaks/01-run.sh index 3748e6a3bb..d6150f538b 100755 --- a/stage4/02-net-tweaks/01-run.sh +++ b/stage4/02-net-tweaks/01-run.sh @@ -6,10 +6,10 @@ install -v -m 600 files/wpa_supplicant.conf "${ROOTFS_DIR}/etc/wpa_supplicant/" # disable wireless install -m 644 files/raspi-blacklist.conf "${ROOTFS_DIR}/etc/modprobe.d/" -on_chroot << EOF - SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_boot_wait 0 - SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_netconf 1 -EOF +#on_chroot << EOF +# SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_boot_wait 0 +# SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_netconf 1 +#EOF if [ -v WPA_COUNTRY ]; then on_chroot <<- EOF @@ -36,3 +36,4 @@ fi mkdir -p "${ROOTFS_DIR}/var/lib/systemd/rfkill/" echo 1 > "${ROOTFS_DIR}/var/lib/systemd/rfkill/platform-3f300000.mmcnr:wlan" echo 1 > "${ROOTFS_DIR}/var/lib/systemd/rfkill/platform-fe300000.mmcnr:wlan" +echo 1 > "${ROOTFS_DIR}/var/lib/systemd/rfkill/platform-1001100000.mmc:wlan" diff --git a/stage4/06-enable-wayland/00-run.sh b/stage4/06-enable-wayland/00-run.sh new file mode 100755 index 0000000000..bd8bbc3bcc --- /dev/null +++ b/stage4/06-enable-wayland/00-run.sh @@ -0,0 +1,5 @@ +#!/bin/bash -e + +on_chroot << EOF + SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_wayland W2 +EOF diff --git a/stage4/07-disable-pwr-button/00-run.sh b/stage4/07-disable-pwr-button/00-run.sh new file mode 100755 index 0000000000..44646bd122 --- /dev/null +++ b/stage4/07-disable-pwr-button/00-run.sh @@ -0,0 +1,3 @@ +#!/bin/bash -e + +sed -i 's/^.*HandlePowerKey=.*$/HandlePowerKey=ignore/' "${ROOTFS_DIR}/etc/systemd/logind.conf" diff --git a/stage5/01-sys-tweaks/01-run.sh b/stage5/01-sys-tweaks/01-run.sh index 0077243ac9..f89bd406ed 100755 --- a/stage5/01-sys-tweaks/01-run.sh +++ b/stage5/01-sys-tweaks/01-run.sh @@ -36,8 +36,8 @@ source "/home/${FIRST_USER_NAME}/.nvm/nvm.sh" nvm install 14.15.0 npm --unsafe-perm --user=1000 --group=1000 install -g @wpilib/wpilib-ws-robot-romi -npm --unsafe-perm --user=1000 --group=1000 install -g i2c-bus EOF +#npm --unsafe-perm --user=1000 --group=1000 install -g i2c-bus # Fix NVM/NPM owner/group chown -R 1000:1000 "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.nvm"