diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..d871259 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,80 @@ +name: Build driver +on: + push: + branches: + - 'master' + - 'releases/**' + pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - name: limelight + script: ./install_limelight.sh + 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 + - name: raspi + script: ./install_pi.sh + 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 + # Orange pi default user seems bjork? also I can't find the where this file ends up in the image? https://github.com/Joshua-Riek/ubuntu-rockchip/blob/0710bd81f5619c25ccddb4e9d69ddbe73827f850/overlay/boot/firmware/user-data#L4 + # - name: opi5 + # script: ./install_opi5.sh + # base_image: https://github.com/Joshua-Riek/ubuntu-rockchip/releases/download/v1.30/ubuntu-22.04.3-preinstalled-server-arm64-orangepi-5.img.xz + + name: "Build for ${{ matrix.name }}" + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Fetch tags + run: git fetch --tags --force + + - uses: pguyot/arm-runner-action@HEAD + id: install_deps + with: + image_additional_mb: 1500 + base_image: ${{ matrix.base_image }} + commands: ${{ matrix.script }} + + - name: Compress built image + run: | + mv ${{ steps.install_deps.outputs.image }} photonvision_${{ matrix.name }}.img + sudo xz -T 0 -v photonvision_${{ matrix.name }}.img + + - uses: actions/upload-artifact@master + with: + name: photonvision_${{ matrix.name }}.img.xz + path: photonvision_${{ matrix.name }}.img.xz + if-no-files-found: error + retention-days: 1 + + release: + needs: [build] + runs-on: ubuntu-22.04 + steps: + # Download literally every single artifact + - uses: actions/download-artifact@v4 + - run: find + # Push to dev release + - uses: pyTooling/Actions/releaser@r0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag: 'Dev' + rm: true + files: | + **/*.xz + if: github.event_name == 'push' + # Upload all xz archives to GH tag if tagged + - uses: softprops/action-gh-release@v1 + with: + files: | + **/*.xz + if: startsWith(github.ref, 'refs/tags/v') + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/config.txt b/config.txt new file mode 100644 index 0000000..bf51113 --- /dev/null +++ b/config.txt @@ -0,0 +1,42 @@ +# Automatically load overlays for detected DSI displays/cameras +display_auto_detect=1 +camera_auto_detect=1 + +# Enable DRM VC4 V3D driver +dtoverlay=vc4-kms-v3d +max_framebuffers=2 + +# Run in 64-bit mode +arm_64bit=1 + +# Disable compensation for displays with overscan +disable_overscan=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 +# (e.g. for USB device mode) or if USB support is not required. +otg_mode=1 + +[pi4] +# Run as fast as firmware / board allows +arm_boost=1 + +[all] +############################################################## +### PHOTONVISION CAM CONFIG +### Comment/Uncomment to change which camera is supported +### Picam V1, V2 or HQ: uncomment (remove leading # ) from camera_auto_detect=1, +### and comment out all following lines +### IMX290/327/OV9281/Any other cameras that require additional overlays: +### Comment out (add a # ) to camera_auto_detect=1, and uncomment the line for +### the sensor you're trying to user + +camera_auto_detect=1 + +# dtoverlay=imx290,clock-frequency=74250000 +# dtoverlay=imx290,clock-frequency=37125000 +# dtoverlay=imx378 +# dtoverlay=ov9281 + +############################################################## \ No newline at end of file diff --git a/files/pigpiod.service b/files/pigpiod.service new file mode 100644 index 0000000..3c79472 --- /dev/null +++ b/files/pigpiod.service @@ -0,0 +1,8 @@ +[Unit] +Description=Daemon required to control GPIO pins via pigpio +[Service] +ExecStart=/usr/bin/pigpiod -l -n 127.0.0.1 -m +ExecStop=/bin/systemctl kill pigpiod +Type=forking +[Install] +WantedBy=multi-user.target diff --git a/files/rpi-blacklist.conf b/files/rpi-blacklist.conf new file mode 100644 index 0000000..19083c7 --- /dev/null +++ b/files/rpi-blacklist.conf @@ -0,0 +1,6 @@ +#wifi +blacklist brcmfmac +blacklist brcmutil +#bt +blacklist btbcm +blacklist hci_uart \ No newline at end of file diff --git a/files/wait.conf b/files/wait.conf new file mode 100644 index 0000000..d52ad0c --- /dev/null +++ b/files/wait.conf @@ -0,0 +1,3 @@ +[Service] +ExecStart= +ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -w \ No newline at end of file diff --git a/install_limelight.sh b/install_limelight.sh new file mode 100755 index 0000000..618c20b --- /dev/null +++ b/install_limelight.sh @@ -0,0 +1,49 @@ +# Run normal photon installer + +wget https://git.io/JJrEP -O install.sh +chmod +x install.sh +./install.sh +rm install.sh + +echo "Installing additional things" +sudo apt-get update +apt-get install -y pigpiod pigpio device-tree-compiler +apt-get install -y network-manager +apt-get install -y net-tools +# libcamera-driver stuff +apt-get install -y libegl1 libopengl0 libopencv-core406 libgl1-mesa-dri libcamera0.1 libgbm1 libatomic1 + +# and edit boot partition + +install -m 644 limelight/config.txt /boot/ +install -m 644 userconf.txt /boot/ + +# install LL DTS +dtc -O dtb limelight/gloworm-dt.dts -o /boot/dt-blob.bin + +# re-size FS, again, at next boot +wget https://raw.githubusercontent.com/PhotonVision/photon-pi-gen/arm64/stage2/01-sys-tweaks/files/resize2fs_once -O files/resize2fs_once +install -m 755 files/resize2fs_once "${ROOTFS_DIR}/etc/init.d/" + +# Kill wifi and other networking things +install -v -m 644 files/wait.conf /etc/systemd/system/dhcpcd.service.d/ +install -v files/rpi-blacklist.conf /etc/modprobe.d/blacklist.conf + +# Update pigipio service file to listen locally +install -v -m 644 files/pigpiod.service /lib/systemd/system/pigpiod.service +systemctl daemon-reload + +# Enable ssh/pigpiod +systemctl enable ssh +systemctl enable pigpiod + +# Remove extra packages too + +apt-get purge -y python3 gdb gcc g++ linux-headers* libgcc*-dev libqt* wpasupplicant wireless-tools firmware-atheros firmware-brcm80211 firmware-libertas firmware-misc-nonfree firmware-realtek raspberrypi-net-mods device-tree-compiler +apt-get autoremove -y + +rm -rf /var/lib/apt/lists/* +apt-get clean + +rm -rf /usr/share/doc +rm -rf /usr/share/locale/ diff --git a/install_opi5.sh b/install_opi5.sh new file mode 100755 index 0000000..face130 --- /dev/null +++ b/install_opi5.sh @@ -0,0 +1,25 @@ +find / + +find / -name user-data + +apt-get update +apt-get upgrade -y + +cd /tmp +wget https://git.io/JJrEP -O install.sh +chmod +x install.sh + +sed -i 's/# AllowedCPUs=4-7/AllowedCPUs=4-7/g' install.sh + +./install.sh + +# Remove extra packages too + +apt-get purge -y python3 gdb gcc g++ linux-headers* libgcc*-dev *qt* +apt-get autoremove -y + +rm -rf /var/lib/apt/lists/* +apt-get clean + +rm -rf /usr/share/doc +rm -rf /usr/share/locale/ diff --git a/install_pi.sh b/install_pi.sh new file mode 100755 index 0000000..82418f2 --- /dev/null +++ b/install_pi.sh @@ -0,0 +1,45 @@ +# Run normal photon installer + +wget https://git.io/JJrEP -O install.sh +chmod +x install.sh +./install.sh +rm install.sh + +echo "Installing additional things" +sudo apt-get update +apt-get install -y pigpiod pigpio device-tree-compiler +apt-get install -y network-manager +apt-get install -y net-tools +# libcamera-driver stuff + libatomic1 for wpilib +apt-get install -y libegl1 libopengl0 libopencv-core406 libgl1-mesa-dri libcamera0.1 libgbm1 libatomic1 + +# and edit boot partition +install -m 644 config.txt /boot/ +install -m 644 userconf.txt /boot/ + +# Kill wifi and other networking things +install -v -m 644 files/wait.conf /etc/systemd/system/dhcpcd.service.d/ +install -v files/rpi-blacklist.conf /etc/modprobe.d/blacklist.conf + +# re-size FS, again, at next boot +wget https://raw.githubusercontent.com/PhotonVision/photon-pi-gen/arm64/stage2/01-sys-tweaks/files/resize2fs_once -O files/resize2fs_once +install -m 755 files/resize2fs_once "${ROOTFS_DIR}/etc/init.d/" + +# Update pigipio service file to listen locally +install -v -m 644 files/pigpiod.service /lib/systemd/system/pigpiod.service +systemctl daemon-reload + +# Enable ssh/pigpiod +systemctl enable ssh +systemctl enable pigpiod + +# Remove extra packages too + +apt-get purge -y python3 gdb gcc g++ linux-headers* libgcc*-dev device-tree-compiler +apt-get autoremove -y + +rm -rf /var/lib/apt/lists/* +apt-get clean + +rm -rf /usr/share/doc +rm -rf /usr/share/locale/ diff --git a/limelight/config.txt b/limelight/config.txt new file mode 100644 index 0000000..d8f2103 --- /dev/null +++ b/limelight/config.txt @@ -0,0 +1,57 @@ +#uncomment to overclock the arm. 700 MHz is the default. +#arm_freq=800 + +# Enable audio (loads snd_bcm2835) +dtparam=audio=on + +[cm3] +dtparam=cam0_reg +dtparam=cam0_reg_gpio=3 +dtoverlay=cm-swap-i2c0 +dtoverlay=ov5647,cam0 + +# Automatically load overlays for detected cameras +camera_auto_detect=1 + +[cm4] +dtoverlay=ov5647 + +[all] + +# Automatically load overlays for detected DSI displays +display_auto_detect=1 + +# Enable DRM VC4 V3D driver +dtoverlay=vc4-kms-v3d +dtparam=spi=on +dtparam=audio=off + +max_framebuffers=2 + +# Run in 64-bit mode +arm_64bit=1 + +# Disable compensation for displays with overscan +disable_overscan=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 +# (e.g. for USB device mode) or if USB support is not required. +otg_mode=1 + +[pi4] +# Run as fast as firmware / board allows +arm_boost=1 + +[all] +#camera_auto_detect=1 +gpu_mem=256 + +[cm3] +dtoverlay=enc28j60 +dtoverlay=pi3-disable-bt +gpio=45=op,dh +disable_camera_led=1 +disable_splash=1 +force_eeprom_read=0 diff --git a/limelight/gloworm-dt.dts b/limelight/gloworm-dt.dts new file mode 100644 index 0000000..6defd4a --- /dev/null +++ b/limelight/gloworm-dt.dts @@ -0,0 +1,607 @@ +/dts-v1/; +/ { + videocore { + pins_cm3 { + pin_config { + pin@default { + polarity = "active_high"; + termination = "pull_down"; + startup_state = "inactive"; + function = "input"; + }; + + pin@p0 { + function = "input"; + termination = "pull_up"; + }; + + pin@p1 { + function = "input"; + termination = "pull_up"; + }; + + pin@p2 { + function = "input"; + termination = "pull_up"; + }; + + pin@p3 { + function = "output"; + termination = "no_pulling"; + }; + + pin@p4 { + function = "input"; + termination = "pull_up"; + }; + + pin@p5 { + function = "input"; + termination = "pull_up"; + }; + + pin@p6 { + function = "input"; + termination = "pull_up"; + }; + + pin@p7 { + function = "input"; + termination = "pull_up"; + }; + + pin@p8 { + function = "input"; + termination = "pull_up"; + }; + + pin@p9 { + function = "input"; + termination = "pull_down"; + }; + + pin@p10 { + function = "input"; + termination = "pull_down"; + }; + + pin@p11 { + function = "input"; + termination = "pull_down"; + }; + + pin@p12 { + function = "input"; + termination = "pull_down"; + }; + + pin@p13 { + function = "input"; + termination = "pull_down"; + }; + + pin@p14 { + function = "input"; + termination = "pull_down"; + }; + + pin@p15 { + function = "input"; + termination = "pull_down"; + }; + + pin@p16 { + function = "input"; + termination = "pull_down"; + }; + + pin@p17 { + function = "input"; + termination = "pull_down"; + }; + + pin@p18 { + function = "input"; + termination = "pull_down"; + }; + + pin@p19 { + function = "input"; + termination = "pull_down"; + }; + + pin@p20 { + function = "input"; + termination = "pull_down"; + }; + + pin@p21 { + function = "input"; + termination = "pull_down"; + }; + + pin@p22 { + function = "input"; + termination = "pull_down"; + }; + + pin@p23 { + function = "input"; + termination = "pull_down"; + }; + + pin@p24 { + function = "input"; + termination = "pull_down"; + }; + + pin@p25 { + function = "input"; + termination = "pull_down"; + }; + + pin@p26 { + function = "input"; + termination = "pull_down"; + }; + + pin@p27 { + function = "input"; + termination = "pull_down"; + }; + + pin@p28 { + function = "input"; + termination = "pull_up"; + }; + + pin@p29 { + function = "input"; + termination = "pull_up"; + }; + + pin@p30 { + function = "output"; + termination = "no_pulling"; + }; + + pin@p31 { + function = "output"; + termination = "no_pulling"; + startup_state = "active"; + }; + + pin@p32 { + function = "output"; + termination = "no_pulling"; + }; + + pin@p33 { + function = "output"; + termination = "no_pulling"; + }; + + pin@p34 { + function = "input"; + termination = "pull_up"; + }; + + pin@p35 { + function = "input"; + termination = "pull_up"; + }; + + pin@p36 { + function = "input"; + termination = "pull_up"; + }; + + pin@p37 { + function = "input"; + termination = "pull_down"; + }; + + pin@p38 { + function = "input"; + termination = "pull_down"; + }; + + pin@p39 { + function = "input"; + termination = "pull_down"; + }; + + pin@p40 { + function = "input"; + termination = "pull_down"; + }; + + pin@p41 { + function = "input"; + termination = "pull_down"; + }; + + pin@p42 { + function = "input"; + termination = "pull_down"; + }; + + pin@p43 { + function = "input"; + termination = "pull_down"; + }; + + pin@p44 { + function = "gp_clk"; + termination = "pull_down"; + }; + + pin@p45 { + function = "output"; + termination = "pull_down"; + }; + + pin@p46 { + function = "input"; + termination = "pull_up"; + }; + + pin@p47 { + function = "input"; + termination = "pull_up"; + }; + + pin@p48 { + function = "sdcard"; + termination = "pull_up"; + drive_strength_mA = <0x08>; + }; + + pin@p49 { + function = "sdcard"; + termination = "pull_up"; + drive_strength_mA = <0x08>; + }; + + pin@p50 { + function = "sdcard"; + termination = "pull_up"; + drive_strength_mA = <0x08>; + }; + + pin@p51 { + function = "sdcard"; + termination = "pull_up"; + drive_strength_mA = <0x08>; + }; + + pin@p52 { + function = "sdcard"; + termination = "pull_up"; + drive_strength_mA = <0x08>; + }; + + pin@p53 { + function = "sdcard"; + termination = "pull_up"; + drive_strength_mA = <0x08>; + }; + + pin@p128 { + function = "input"; + termination = "no_pulling"; + polarity = "active_low"; + }; + + pin@p129 { + function = "output"; + termination = "no_pulling"; + polarity = "active_low"; + }; + }; + + pin_defines { + pin_define@HDMI_CONTROL_ATTACHED { + type = "external"; + number = <0x00>; + }; + + pin_define@EMMC_ENABLE { + type = "external"; + number = <0x01>; + }; + + pin_define@SMPS_SDA { + type = "internal"; + number = <0x2e>; + }; + + pin_define@SMPS_SCL { + type = "internal"; + number = <0x2f>; + }; + + pin_define@ETH_CLK { + type = "internal"; + number = <0x2c>; + }; + + pin_define@LAN_RUN { + type = "internal"; + number = <0x1f>; + }; + + pin_define@NUM_CAMERAS { + type = "internal"; + number = <0x01>; + }; + + pin_define@CAMERA_0_LED { + type = "internal"; + number = <0x1e>; + }; + + pin_define@CAMERA_0_SHUTDOWN { + type = "internal"; + number = <0x03>; + }; + + pin_define@CAMERA_0_UNICAM_PORT { + type = "internal"; + number = <0x00>; + }; + + pin_define@CAMERA_0_I2C_PORT { + type = "internal"; + number = <0x00>; + }; + + pin_define@CAMERA_0_SDA_PIN { + type = "internal"; + number = <0x1c>; + }; + + pin_define@CAMERA_0_SCL_PIN { + type = "internal"; + number = <0x1d>; + }; + }; + }; + + pins_cm4 { + + pin_config { + + pin@default { + polarity = "active_high"; + termination = "pull_down"; + startup_state = "inactive"; + function = "input"; + }; + + pin@p14 { + function = "uart0"; + termination = "no_pulling"; + drive_strength_mA = <0x8>; + }; + + pin@p15 { + function = "uart0"; + termination = "pull_up"; + drive_strength_mA = <0x8>; + }; + + pin@p46 { + function = "input"; + termination = "pull_up"; + }; + + pin@p47 { + function = "input"; + termination = "pull_up"; + }; + + pin@p48 { + function = "sdcard"; + termination = "pull_up"; + drive_strength_mA = <0x8>; + }; + + pin@p49 { + function = "sdcard"; + termination = "pull_up"; + drive_strength_mA = <0x8>; + }; + + pin@p50 { + function = "sdcard"; + termination = "pull_up"; + drive_strength_mA = <0x8>; + }; + + pin@p51 { + function = "sdcard"; + termination = "pull_up"; + drive_strength_mA = <0x8>; + }; + + pin@p52 { + function = "sdcard"; + termination = "pull_up"; + drive_strength_mA = <0x8>; + }; + + pin@p53 { + function = "sdcard"; + termination = "pull_up"; + drive_strength_mA = <0x8>; + }; + + pin@p128 { + function = "output"; + termination = "no_pulling"; + }; + + pin@p129 { + function = "output"; + termination = "no_pulling"; + }; + + pin@p130 { + function = "output"; + termination = "no_pulling"; + polarity = "active_low"; + startup_state = "active"; + }; + + pin@p131 { + function = "output"; + termination = "no_pulling"; + }; + + pin@p132 { + function = "output"; + termination = "no_pulling"; + }; + + pin@p133 { + function = "output"; + termination = "no_pulling"; + }; + + pin@p134 { + function = "output"; + termination = "no_pulling"; + startup_state = "active"; + }; + + pin@p135 { + function = "output"; + termination = "no_pulling"; + }; + }; + + pin_defines { + + pin_define@HDMI_CONTROL_ATTACHED { + type = "external"; + number = <0x0>; + }; + + pin_define@EMMC_ENABLE { + type = "external"; + number = <0x1>; + }; + + pin_define@NUM_CAMERAS { + type = "internal"; + number = <0x1>; + }; + + pin_define@POWER_LOW { + type = "absent"; + }; + + pin_define@LEDS_DISK_ACTIVITY { + type = "absent"; + }; + + pin_define@LAN_RUN { + type = "absent"; + }; + + pin_define@BT_ON { + type = "external"; + number = <0x0>; + }; + + pin_define@WL_ON { + type = "external"; + number = <0x1>; + }; + + pin_define@SMPS_SDA { + type = "internal"; + number = <0x2e>; + }; + + pin_define@SMPS_SCL { + type = "internal"; + number = <0x2f>; + }; + + pin_define@ETH_CLK { + type = "absent"; + }; + + pin_define@WL_LPO_CLK { + type = "absent"; + }; + + pin_define@USB_LIMIT_1A2 { + type = "absent"; + }; + + pin_define@SIO_1V8_SEL { + type = "absent"; + }; + + pin_define@PWML { + type = "absent"; + }; + + pin_define@PWMR { + type = "absent"; + }; + + pin_define@SAFE_MODE { + type = "absent"; + }; + + pin_define@SD_CARD_DETECT { + type = "absent"; + }; + + pin_define@ID_SDA { + type = "internal"; + number = <0x0>; + }; + + pin_define@ID_SCL { + type = "internal"; + number = <0x1>; + }; + + pin_define@CAMERA_0_I2C_PORT { + type = "internal"; + number = <0x0>; + }; + + pin_define@CAMERA_0_SDA_PIN { + type = "internal"; + number = <0x2c>; + }; + + pin_define@CAMERA_0_SCL_PIN { + type = "internal"; + number = <0x2d>; + }; + + pin_define@CAMERA_0_SHUTDOWN { + type = "external"; + number = <0x5>; + }; + + pin_define@CAMERA_0_UNICAM_PORT { + type = "internal"; + number = <0x1>; + }; + + pin_define@CAMERA_0_LED { + type = "absent"; + }; + }; + }; + + }; +}; diff --git a/userconf.txt b/userconf.txt new file mode 100644 index 0000000..d1b029e --- /dev/null +++ b/userconf.txt @@ -0,0 +1 @@ +pi:$6$FynrpHenSGZpjaO9$FUmJ07FFhXkRfO3I3JadUX3oZ6sE4GTTVUTG93c2ocddxCI0TA.kmpIQfu/1A4wt5ixe7IBbncNaraje.NYpM/ \ No newline at end of file