initial agnos-builder release

This commit is contained in:
Adeeb Shihadeh
2021-09-20 14:04:35 -07:00
commit 4e38c8f181
189 changed files with 23317 additions and 0 deletions

9
.dockerignore Normal file
View File

@@ -0,0 +1,9 @@
*.pyc
*.pyo
.*.swp
.*.swo
build/
output/
edk2_tici/
agnos-kernel-sdm845/

3
.gitattributes vendored Normal file
View File

@@ -0,0 +1,3 @@
*.deb filter=lfs diff=lfs merge=lfs -text
*.ko filter=lfs diff=lfs merge=lfs -text
userspace/files/sound/tinymix filter=lfs diff=lfs merge=lfs -text

11
.gitignore vendored Normal file
View File

@@ -0,0 +1,11 @@
*.swp
*.tar.gz
agnos/
output/
build/
tmp/
qdl/
.qemu_registered
.vscode

9
.gitmodules vendored Normal file
View File

@@ -0,0 +1,9 @@
[submodule "edk2_tici"]
path = edk2_tici
url = ../../commaai/edk2_tici.git
[submodule "agnos-firmware"]
path = agnos-firmware
url = ../../commaai/agnos-firmware.git
[submodule "agnos-kernel-sdm845"]
path = agnos-kernel-sdm845
url = ../../commaai/agnos-kernel-sdm845.git

11
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: master
hooks:
- id: check-ast
exclude: tools
- id: check-json
- id: check-xml
- id: check-yaml
- id: check-merge-conflict
- id: check-symlinks

215
Dockerfile.agnos Normal file
View File

@@ -0,0 +1,215 @@
# ################## #
# ###### Base ###### #
# ################## #
FROM scratch AS agnos-base
ADD ubuntu-base-20.04.1-base-arm64.tar.gz /
# Add aarch64 and arm support
COPY --from=multiarch/qemu-user-static:x86_64-aarch64 /usr/bin/qemu-aarch64-static /usr/bin
COPY --from=multiarch/qemu-user-static:x86_64-arm /usr/bin/qemu-arm-static /usr/bin
# Build folder
RUN mkdir -p /tmp/agnos
# Stop on error
RUN set -xe
ENV USERNAME=comma
ENV PASSWD=comma
ENV HOST=tici
# Base system setup
RUN echo "resolvconf resolvconf/linkify-resolvconf boolean false" | debconf-set-selections
COPY ./userspace/base_setup.sh /tmp/agnos
RUN /tmp/agnos/base_setup.sh
# ################## #
# #### Compiler #### #
# ################## #
FROM agnos-base as agnos-compiler
RUN apt-get update && apt-get install --no-install-recommends checkinstall
# Install openpilot dependencies, probably needed for build,
# but we don't want these in the base image
COPY ./userspace/openpilot_dependencies.sh /tmp/agnos/
RUN /tmp/agnos/openpilot_dependencies.sh
# Individual compiling images
FROM agnos-compiler as agnos-compiler-capnp
COPY ./userspace/compile-capnp.sh /tmp/agnos/
RUN /tmp/agnos/compile-capnp.sh
FROM agnos-compiler as agnos-compiler-ffmpeg
COPY ./userspace/compile-ffmpeg.sh /tmp/agnos/
RUN /tmp/agnos/compile-ffmpeg.sh
FROM agnos-compiler as agnos-compiler-mapbox-gl-native
COPY ./userspace/compile-mapbox-gl-native.sh /tmp/agnos/
RUN /tmp/agnos/compile-mapbox-gl-native.sh
FROM agnos-compiler as agnos-compiler-qtlocation
COPY ./userspace/compile-qtlocation.sh /tmp/agnos/
RUN /tmp/agnos/compile-qtlocation.sh
# ################### #
# ###### AGNOS ###### #
# ################### #
FROM agnos-base
# Hardware setup
RUN mkdir -p /tmp/agnos/debs
COPY ./userspace/debs /tmp/agnos/debs
COPY ./userspace/hardware_setup.sh /tmp/agnos
RUN /tmp/agnos/hardware_setup.sh
RUN mv /data/persist /system/ && rm -rf /data/*
# Pre-compiled capnp (must be before python install)
COPY --from=agnos-compiler-capnp /tmp/capnproto.deb /tmp/capnproto.deb
RUN cd /tmp && apt-get -o Dpkg::Options::="--force-overwrite" install -yq ./capnproto.deb
# Install openpilot dependencies
COPY ./userspace/openpilot_dependencies.sh /tmp/agnos/
RUN /tmp/agnos/openpilot_dependencies.sh
COPY ./userspace/openpilot_python_dependencies.sh /tmp/agnos/
RUN /tmp/agnos/openpilot_python_dependencies.sh
# Use other pre-compiled packages
COPY --from=agnos-compiler-ffmpeg /tmp/ffmpeg.deb /tmp/ffmpeg.deb
COPY --from=agnos-compiler-qtlocation /tmp/qtlocation.deb /tmp/qtlocation.deb
RUN cd /tmp && apt-get -o Dpkg::Options::="--force-overwrite" install -yq ./ffmpeg.deb ./qtlocation.deb
COPY --from=agnos-compiler-mapbox-gl-native /tmp/libqmapboxgl.so /lib/aarch64-linux-gnu/libqmapboxgl.so
# Install openpilot python packages
COPY ./userspace/Pipfile* /tmp/agnos/
RUN export PATH="/usr/local/pyenv/bin:/usr/local/pyenv/shims:$PATH" && \
export PYENV_ROOT="/usr/local/pyenv" && \
eval "$(pyenv init -)" && \
pip3 install --no-cache-dir --upgrade pip==20.2.4 && \
pip3 install --no-cache-dir --upgrade pipenv==2020.8.13 && \
cd /tmp/agnos && \
MAKEFLAGS="-j$(nproc)" pipenv install --system --deploy --dev --clear && \
pip uninstall -y pipenv && \
pyenv rehash
# 16.04 libwayland-client + libffi6
COPY ./userspace/qtwayland/libffi.so.6 /lib/aarch64-linux-gnu/
COPY ./userspace/qtwayland/libwayland-client.so.0 /lib/aarch64-linux-gnu/libwayland-client.so.0
# Patched qtwayland that does not use EGL EXT, and outputs a fixed screen size
# Clone qtwayland submodule, checkout 5.12.9 (5.12.8 leaks timers, see https://bugreports.qt.io/browse/QTBUG-82914), apply patch, qmake, make
COPY ./userspace/qtwayland/libqwayland-egl.so /lib/aarch64-linux-gnu/qt5/plugins/platforms/libqwayland-egl.so
COPY ./userspace/qtwayland/libQt5WaylandClient.so.5.12.8 /lib/aarch64-linux-gnu/libQt5WaylandClient.so.5.12.8
# Patched libeglSubDriverWayland with fixed nullptr deref in CommitBuffer
COPY ./userspace/files/libeglSubDriverWayland.so.patched /lib/aarch64-linux-gnu/libeglSubDriverWayland.so
COPY ./userspace/home/ /home/$USERNAME/
COPY ./userspace/home/.config/ /root/.config
RUN chown -R $USERNAME: /home/$USERNAME/.config
# populate /lib
COPY ./userspace/files/*.path /lib/systemd/system/
COPY ./userspace/files/*.mount /lib/systemd/system/
COPY ./userspace/files/*.service /lib/systemd/system/
COPY ./userspace/files/*.timer /lib/systemd/system/
COPY ./userspace/files/ssh_override.conf /lib/systemd/system/ssh.service.d/override.conf
COPY ./userspace/firmware/* /lib/firmware/
# populate /etc
COPY ./userspace/files/fstab /etc
COPY ./userspace/files/profile /etc/profile
COPY ./userspace/files/ethernet.yaml /etc/netplan/
COPY ./userspace/files/allow-network-control.pkla /etc/polkit-1/localauthority/50-local.d/allow-network-control.pkla
COPY ./userspace/files/allow-modem-control.pkla /etc/polkit-1/localauthority/50-local.d/allow-modem-control.pkla
COPY ./userspace/files/*.rules /etc/udev/rules.d/
COPY ./userspace/files/default.pa /etc/pulse/default.pa
COPY ./userspace/files/ssh*_config /etc/ssh/
COPY ./userspace/files/logrotate.conf /etc/
RUN chmod 644 /etc/logrotate.conf
# populate /usr
COPY ./userspace/usr/comma/ /usr/$USERNAME/
COPY ./userspace/usr/share/fonts/* /usr/share/fonts/
COPY ./userspace/libs/* /usr/lib/aarch64-linux-gnu/
COPY ./userspace/libs32/* /usr/lib/arm-linux-gnueabihf/
# Weston with hacked touch rotate and color correction
COPY ./userspace/files/weston /usr/bin/weston
COPY ./userspace/files/gl-renderer.so /usr/lib/arm-linux-gnueabihf/weston
# Setup systemd services
COPY ./userspace/services.sh /tmp/agnos
RUN /tmp/agnos/services.sh
# MOTD
RUN rm -r /etc/update-motd.d/*
COPY --chown=root:root ./userspace/motd/* /etc/update-motd.d/
# Let NetworkManager manage eth0
COPY ./userspace/files/10-globally-managed-devices.conf /etc/NetworkManager/conf.d/10-globally-managed-devices.conf
COPY ./userspace/files/NetworkManager.conf /etc/NetworkManager/NetworkManager.conf
# Add LTE connection
COPY ./userspace/files/lte.nmconnection /usr/lib/NetworkManager/system-connections/
RUN chmod 600 /usr/lib/NetworkManager/system-connections/lte.nmconnection
# Prefer ipv4 over ipv6
RUN echo "precedence ::ffff:0:0/96 100" >> /etc/gai.conf
# Don't let logind delete /dev/shm
COPY ./userspace/files/logind.conf /etc/systemd/logind.conf
# Disable bootkick on shutdown
COPY ./userspace/files/disable_bootkick.py /lib/systemd/system-shutdown/
# Remove qt network bearer plugins
RUN rm -rf /usr/lib/aarch64-linux-gnu/qt5/plugins/bearer
# HACK: get newer version of ModemManager and libqmi from 21.04
# ModemManager 1.12.8 suffers from a bug with reconnecting: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/242
# libqmi 1.24.8 segfaults when power cycling the modem: https://gitlab.freedesktop.org/mobile-broadband/libqmi/-/issues/37
RUN echo "" >> /etc/apt/sources.list && \
echo "deb http://ports.ubuntu.com/ubuntu-ports/ hirsute main restricted" >> /etc/apt/sources.list && \
echo "deb http://ports.ubuntu.com/ubuntu-ports/ hirsute universe" >> /etc/apt/sources.list && \
apt-get remove -y modemmanager && \
apt-get update && \
apt-cache show modemmanager && \
apt-get install -y modemmanager libqmi-glib5 libqmi-utils mobile-broadband-provider-info
# Run ModemManager in debug mode to allow AT commands
COPY ./userspace/files/ModemManager.service /lib/systemd/system/
# Add more T-Mobile networks to mobile-broadband-provider-info (do we still need the package?)
COPY ./userspace/files/serviceproviders.xml /usr/share/mobile-broadband-provider-info/serviceproviders.xml
# TODO: move this to base_setup.sh or build gcc from source
# Remove unused architectures from arm-none-eabi
RUN cd /usr/lib/gcc/arm-none-eabi/9.2.1 && \
rm -rf arm/ && \
rm -rf thumb/nofp thumb/v6* thumb/v8* thumb/v7+fp thumb/v7-r+fp.sp
# keep this last
RUN ldconfig
# Setup RO rootfs
RUN mkdir -p /tmptmp
COPY ./userspace/files/comma.conf /usr/lib/tmpfiles.d/
COPY ./userspace/readonly_setup.sh /tmptmp/readonly_setup.sh
RUN /tmptmp/readonly_setup.sh && rm -rf /tmptmp
# copy at the end, after all apt usage
COPY ./userspace/files/apt.conf /etc/apt/apt.conf
# Write version file
RUN echo -n "1.6" > /VERSION
# ################## #
# #### Cleaunup #### #
# ################## #
RUN rm -rf /usr/share/icons/* && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /home/$USERNAME/.cache && \
rm -rf /root/.cache && \
pyclean /usr && \
apt-get clean

42
README.md Normal file
View File

@@ -0,0 +1,42 @@
# agnos-builder
This is the tool to build AGNOS, our Ubuntu based OS. AGNOS runs on the [comma three devkit](https://comma.ai/shop/products/three).
## Setup
These tools are developed on and targeted for Ubuntu 20.04.
Run once to set things up:
```sh
git submodule update --init agnos-kernel-sdm845
./tools/extract_tools.sh
```
## Build the userspace
build:
```sh
./build_system.sh
```
load:
```sh
./flash_system.sh
```
## Build the kernel
build:
```sh
./build_kernel.sh
```
load:
```sh
# flash over fastboot
./flash_kernel.sh
# or load into running system via ssh
# ssh config needs host named 'tici'
./load_kernel.sh
```

1
agnos-firmware Submodule

Submodule agnos-firmware added at f4c450d90e

1
agnos-kernel-sdm845 Submodule

Submodule agnos-kernel-sdm845 added at b75f6c29a4

24
build_and_package.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/bash -e
read -p "Is the kernel repo up to date? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Update it and run again!"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
read -p "Is the firmware repo up to date? Copied in the new abl if needed?" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Update it and run again!"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
./build_kernel.sh
cp output/wlan.ko userspace/usr/comma
cp output/snd*.ko userspace/usr/comma/sound/
./build_system.sh
./package_ota.sh

21
build_bootloader.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash -e
# Get directories and make sure we're in the correct spot to start the build
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
OUTPUT_DIR=$DIR/output
cd $DIR
# Clone bootloader if not done already
if [ ! -d edk2_tici ]; then
git submodule init edk2_tici
fi
cd edk2_tici
# Create output directory
mkdir -p $OUTPUT_DIR
# Run build
./build.sh
# Copy output
cp out/* $OUTPUT_DIR/

66
build_kernel.sh Executable file
View File

@@ -0,0 +1,66 @@
#!/bin/bash -e
DEFCONFIG=tici_defconfig
# Get directories and make sure we're in the correct spot to start the build
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
TOOLS=$DIR/tools
TMP_DIR=/tmp/agnos-builder-tmp
OUTPUT_DIR=$DIR/output
BOOT_IMG=./boot.img
cd $DIR
# Clone kernel if not done already
if [ ! -d agnos-kernel-sdm845 ]; then
git submodule init agnos-kernel-sdm845
fi
cd agnos-kernel-sdm845
# Build parameters
export ARCH=arm64
export CROSS_COMPILE=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-
export CC=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-gcc
export LD=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-ld.bfd
# these do anything?
export KCFLAGS="-w"
# Load defconfig and build kernel
echo "-- First make --"
make $DEFCONFIG O=out
echo "-- Second make: $(nproc --all) cores --"
make -j$(nproc --all) O=out # Image.gz-dtb
# Turn on if you want perf
# LDFLAGS=-static make -j$(nproc --all) -C tools/perf
# Copy over Image.gz-dtb
mkdir -p $TMP_DIR
cd $TMP_DIR
cp $DIR/agnos-kernel-sdm845/out/arch/arm64/boot/Image.gz-dtb .
# Make boot image
$TOOLS/mkbootimg \
--kernel Image.gz-dtb \
--ramdisk /dev/null \
--cmdline "console=ttyMSM0,115200n8 earlycon=msm_geni_serial,0xA84000 androidboot.hardware=qcom androidboot.console=ttyMSM0 video=DSI-1:1080x2160@60e mdss_mdp.panel=0:dsi:0:dsi_ss_ea8074_fhd_cmd_display ehci-hcd.park=3 lpm_levels.sleep_disabled=1 service_locator.enable=1 androidboot.selinux=permissive firmware_class.path=/lib/firmware/updates net.ifnames=0 dyndbg=\"\"" \
--pagesize 4096 \
--base 0x80000000 \
--kernel_offset 0x8000 \
--ramdisk_offset 0x8000 \
--tags_offset 0x100 \
--output $BOOT_IMG.nonsecure
# le signing
openssl dgst -sha256 -binary $BOOT_IMG.nonsecure > $BOOT_IMG.sha256
openssl pkeyutl -sign -in $BOOT_IMG.sha256 -inkey $DIR/vble-qti.key -out $BOOT_IMG.sig -pkeyopt digest:sha256 -pkeyopt rsa_padding_mode:pkcs1
dd if=/dev/zero of=$BOOT_IMG.sig.padded bs=2048 count=1
dd if=$BOOT_IMG.sig of=$BOOT_IMG.sig.padded conv=notrunc
cat $BOOT_IMG.nonsecure $BOOT_IMG.sig.padded > $BOOT_IMG
# Copy to output dir
mkdir -p $OUTPUT_DIR
mv $BOOT_IMG $OUTPUT_DIR/
cp $DIR/agnos-kernel-sdm845/out/techpack/audio/asoc/snd-soc-sdm845.ko $OUTPUT_DIR/
cp $DIR/agnos-kernel-sdm845/out/techpack/audio/asoc/codecs/snd-soc-wcd9xxx.ko $OUTPUT_DIR/
cp $DIR/agnos-kernel-sdm845/out/drivers/staging/qcacld-3.0/wlan.ko $OUTPUT_DIR/

36
build_kernel_headers.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/bin/bash -e
DEFCONFIG=tici_defconfig
# Get directories and make sure we're in the correct spot to start the build
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
TOOLS=$DIR/tools
TMP_DIR=/tmp/agnos-builder-tmp
OUTPUT_DIR=$DIR/output
BOOT_IMG=./boot.img
cd $DIR
# Clone kernel if not done already
if [ ! -d agnos-kernel-sdm845 ]; then
git submodule init agnos-kernel-sdm845
fi
cd agnos-kernel-sdm845
# Build parameters
export ARCH=arm64
export CROSS_COMPILE=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-
export CC=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-gcc
export LD=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-ld.bfd
# these do anything?
export KCFLAGS="-w"
# Load defconfig and build kernel
echo "-- First make --"
make $DEFCONFIG O=out
echo "-- Second make: $(nproc --all) cores --"
make bindeb-pkg -j$(nproc --all) O=out # Image.gz-dtb
# Copy output
cp linux-headers-*.deb $OUTPUT_DIR

79
build_system.sh Executable file
View File

@@ -0,0 +1,79 @@
#!/bin/bash -e
UBUNTU_BASE_URL="http://cdimage.ubuntu.com/ubuntu-base/releases/20.04/release"
UBUNTU_FILE="ubuntu-base-20.04.1-base-arm64.tar.gz"
# Make sure we're in the correct spot
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd $DIR
BUILD_DIR="$DIR/build"
OUTPUT_DIR="$DIR/output"
ROOTFS_DIR="$BUILD_DIR/agnos-rootfs"
ROOTFS_IMAGE="$BUILD_DIR/system.img.raw"
ROOTFS_IMAGE_SIZE=10G
SPARSE_IMAGE="$BUILD_DIR/system.img"
# Create temp dir if non-existent
mkdir -p $BUILD_DIR $OUTPUT_DIR
# Download Ubuntu Base if not done already
if [ ! -f $UBUNTU_FILE ]; then
echo -e "${GREEN}Downloading Ubuntu: $UBUNTU_FILE ${NO_COLOR}"
wget -c $UBUNTU_BASE_URL/$UBUNTU_FILE --quiet
fi
# TODO: this needs to be re-done sometimes
# Register qemu multiarch if not done
if [ ! -f $DIR/.qemu_registered ] && [ "$(uname -p)" != "aarch64" ]; then
docker run --rm --privileged multiarch/qemu-user-static:register
touch $DIR/.qemu_registered
fi
# Start docker build
echo "Building image"
export DOCKER_CLI_EXPERIMENTAL=enabled
docker build -f Dockerfile.agnos -t agnos-builder $DIR
# Create filesystem ext4 image
echo "Creating empty filesystem"
fallocate -l $ROOTFS_IMAGE_SIZE $ROOTFS_IMAGE
mkfs.ext4 $ROOTFS_IMAGE > /dev/null
# Mount filesystem
echo "Mounting empty filesystem"
mkdir -p $ROOTFS_DIR
sudo umount -l $ROOTFS_DIR > /dev/null || true
sudo mount $ROOTFS_IMAGE $ROOTFS_DIR
# Extract image
echo "Extracting docker image"
CONTAINER_ID=$(docker container create --entrypoint /bin/bash agnos-builder:latest)
docker container export -o $BUILD_DIR/filesystem.tar $CONTAINER_ID
docker container rm $CONTAINER_ID > /dev/null
cd $ROOTFS_DIR
sudo tar -xf $BUILD_DIR/filesystem.tar > /dev/null
# Add hostname and hosts. This cannot be done in the docker container...
echo "Setting network stuff"
HOST=tici
sudo bash -c "echo $HOST > etc/hostname"
sudo bash -c "echo \"127.0.0.1 localhost.localdomain localhost\" > etc/hosts"
sudo bash -c "echo \"127.0.0.1 $HOST\" >> etc/hosts"
# Fix resolv config
sudo bash -c "ln -sf /run/systemd/resolve/stub-resolv.conf etc/resolv.conf"
cd $DIR
# Unmount image
echo "Unmount filesystem"
sudo umount -l $ROOTFS_DIR
# Sparsify
echo "Sparsify image"
img2simg $ROOTFS_IMAGE $SPARSE_IMAGE
mv $SPARSE_IMAGE $OUTPUT_DIR
echo "Done!"

1
edk2_tici Submodule

Submodule edk2_tici added at 00971d64a7

20
flash_bootloader.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash -e
# Config
OUTPUT_DIR="output"
BOOTLOADER_IMAGE="abl.elf"
# Log colors
GREEN="\033[0;32m"
NO_COLOR='\033[0m'
# Make sure we're in the correct spot
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd $DIR
# Flash bootloader
fastboot --set-active=a
fastboot flash abl_a $OUTPUT_DIR/$BOOTLOADER_IMAGE
fastboot flash abl_b $OUTPUT_DIR/$BOOTLOADER_IMAGE
echo -e "${GREEN}Done!"

19
flash_kernel.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash -e
# Config
OUTPUT_DIR="output"
KERNEL_IMAGE="boot.img"
# Log colors
GREEN="\033[0;32m"
NO_COLOR='\033[0m'
# Make sure we're in the correct spot
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd $DIR
# Flash bootloader
fastboot --set-active=a
fastboot flash boot_a $OUTPUT_DIR/$KERNEL_IMAGE
echo -e "${GREEN}Done!"

30
flash_system.sh Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/bash -e
# Config
OUTPUT_DIR="output"
ROOTFS_IMAGE="system.img"
# Log colors
GREEN="\033[0;32m"
NO_COLOR='\033[0m'
# Make sure we're in the correct spot
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd $DIR
# Flash system
fastboot --set-active=a
# TODO: clean this up. move simg2dimg into a common repo?
if [ -d $HOME/openpilot/provisioning ]; then
DIMG=$(mktemp)
$HOME/openpilot/provisioning/scripts/simg2dontcare.py $OUTPUT_DIR/$ROOTFS_IMAGE $DIMG
fastboot erase system_a
fastboot flash system_a $DIMG
else
fastboot flash system_a $OUTPUT_DIR/$ROOTFS_IMAGE
fi
fastboot continue
echo -e "${GREEN}Done!"

7
load_kernel.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash -e
cd "$(dirname "$0")"
scp output/boot.img tici:/tmp/
#scp output/snd-soc-*.ko tici:/usr/comma/sound/
#scp output/wlan.ko tici:/usr/comma
ssh tici "sudo dd if=/tmp/boot.img of=/dev/disk/by-partlabel/boot_a && sudo dd if=/tmp/boot.img of=/dev/disk/by-partlabel/boot_b && sudo reboot"

4
load_kernel_headers.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
scp output/linux-headers*.deb tici:/tmp/
ssh tici "sudo apt install -yq /tmp/linux-headers*.deb"

78
ota_push.sh Executable file
View File

@@ -0,0 +1,78 @@
#!/bin/bash -e
# Make sure we're in the correct directory
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd $DIR
# Constants
OTA_DIR="$DIR/output/ota"
DATA_ACCOUNT="commadist"
# Parse input
FOUND=0
if [ "$1" == "production" ]; then
OTA_JSON="$OTA_DIR/ota.json"
DATA_CONTAINER="agnosupdate"
FOUND=1
fi
if [ "$1" == "staging" ]; then
OTA_JSON="$OTA_DIR/ota-staging.json"
DATA_CONTAINER="agnosupdate-staging"
FOUND=1
fi
if [ $FOUND == 0 ]; then
echo "Supply either 'production' or 'staging' as first argument!"
exit 1
fi
# Read update file
SYSTEM_HASH=$(cat $OTA_JSON | jq -r ".[] | select(.name == \"system\") | .hash_raw")
echo "Found system hash: $SYSTEM_HASH"
BOOT_HASH=$(cat $OTA_JSON | jq -r ".[] | select(.name == \"boot\") | .hash_raw")
echo "Found boot hash: $BOOT_HASH"
ABL_HASH=$(cat $OTA_JSON | jq -r ".[] | select(.name == \"abl\") | .hash_raw")
echo "Found abl hash: $ABL_HASH"
XBL_HASH=$(cat $OTA_JSON | jq -r ".[] | select(.name == \"xbl\") | .hash_raw")
echo "Found xbl hash: $XBL_HASH"
XBL_CONFIG_HASH=$(cat $OTA_JSON | jq -r ".[] | select(.name == \"xbl_config\") | .hash_raw")
echo "Found xbl_config hash: $XBL_CONFIG_HASH"
# Generate token
echo "Logging in..."
SAS_EXPIRY=$(date -u '+%Y-%m-%dT%H:%M:%SZ' -d '+1 hour')
DATA_SAS_TOKEN=$(az storage container generate-sas --as-user --auth-mode login --account-name $DATA_ACCOUNT --name $DATA_CONTAINER --https-only --permissions wr --expiry $SAS_EXPIRY --output tsv)
# Liftoff!
SYSTEM_FILE_NAME="system-$SYSTEM_HASH.img.xz"
BOOT_FILE_NAME="boot-$BOOT_HASH.img.xz"
ABL_FILE_NAME="abl-$ABL_HASH.img.xz"
XBL_FILE_NAME="xbl-$XBL_HASH.img.xz"
XBL_CONFIG_FILE_NAME="xbl_config-$XBL_CONFIG_HASH.img.xz"
echo "Copying system to the cloud..."
SYSTEM_CLOUD_PATH="https://$DATA_ACCOUNT.blob.core.windows.net/$DATA_CONTAINER/$SYSTEM_FILE_NAME"
azcopy cp --overwrite=false $OTA_DIR/$SYSTEM_FILE_NAME "$SYSTEM_CLOUD_PATH?$DATA_SAS_TOKEN"
echo "Copying boot to the cloud..."
BOOT_CLOUD_PATH="https://$DATA_ACCOUNT.blob.core.windows.net/$DATA_CONTAINER/$BOOT_FILE_NAME"
azcopy cp --overwrite=false $OTA_DIR/$BOOT_FILE_NAME "$BOOT_CLOUD_PATH?$DATA_SAS_TOKEN"
echo "Copying abl to the cloud..."
ABL_CLOUD_PATH="https://$DATA_ACCOUNT.blob.core.windows.net/$DATA_CONTAINER/$ABL_FILE_NAME"
azcopy cp --overwrite=false $OTA_DIR/$ABL_FILE_NAME "$ABL_CLOUD_PATH?$DATA_SAS_TOKEN"
echo "Copying xbl to the cloud..."
XBL_CLOUD_PATH="https://$DATA_ACCOUNT.blob.core.windows.net/$DATA_CONTAINER/$XBL_FILE_NAME"
azcopy cp --overwrite=false $OTA_DIR/$XBL_FILE_NAME "$XBL_CLOUD_PATH?$DATA_SAS_TOKEN"
echo "Copying xbl_config to the cloud..."
XBL_CONFIG_CLOUD_PATH="https://$DATA_ACCOUNT.blob.core.windows.net/$DATA_CONTAINER/$XBL_CONFIG_FILE_NAME"
azcopy cp --overwrite=false $OTA_DIR/$XBL_CONFIG_FILE_NAME "$XBL_CONFIG_CLOUD_PATH?$DATA_SAS_TOKEN"
echo "Done!"
echo " System path: $SYSTEM_CLOUD_PATH"
echo " Boot path: $BOOT_CLOUD_PATH"
echo " abl path: $ABL_CLOUD_PATH"
echo " xbl path: $XBL_CLOUD_PATH"
echo " xbl_config path: $XBL_CONFIG_CLOUD_PATH"

193
package_ota.sh Executable file
View File

@@ -0,0 +1,193 @@
#!/bin/bash -e
# Make sure we're in the correct spot
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd $DIR
# Constants
TMP_DIR="/tmp/agnos-builder-tmp"
OUTPUT_DIR="$DIR/output"
OTA_OUTPUT_DIR="$OUTPUT_DIR/ota"
FIRMWARE_DIR="$DIR/agnos-firmware"
SYSTEM_IMAGE_RAW="/tmp/system.img.raw"
SYSTEM_IMAGE="$OUTPUT_DIR/system.img"
BOOT_IMAGE="$OUTPUT_DIR/boot.img"
ABL_IMAGE="$FIRMWARE_DIR/abl.bin"
XBL_IMAGE="$FIRMWARE_DIR/xbl.bin"
XBL_CONFIG_IMAGE="$FIRMWARE_DIR/xbl_config.bin"
AGNOS_UPDATE_URL=${AGNOS_UPDATE_URL:-https://commadist.azureedge.net/agnosupdate}
AGNOS_STAGING_UPDATE_URL=${AGNOS_STAGING_UPDATE_URL:-https://commadist.azureedge.net/agnosupdate-staging}
OUTPUT_JSON="$OTA_OUTPUT_DIR/ota.json"
OUTPUT_STAGING_JSON="$OTA_OUTPUT_DIR/ota-staging.json"
# Create dirs if non-existent
mkdir -p $OTA_OUTPUT_DIR
# Make sure archive dir is empty
rm -r $OTA_OUTPUT_DIR
mkdir -p $OTA_OUTPUT_DIR
# Hashing
echo "Hashing system..."
SPARSE_SYSTEM_HASH=$(sha256sum $SYSTEM_IMAGE | cut -c 1-64)
simg2img $SYSTEM_IMAGE $SYSTEM_IMAGE_RAW
SYSTEM_HASH=$(sha256sum $SYSTEM_IMAGE_RAW | cut -c 1-64)
SYSTEM_SIZE=$(wc -c < $SYSTEM_IMAGE_RAW)
rm $SYSTEM_IMAGE_RAW
echo "Hashing boot..."
BOOT_HASH=$(sha256sum $BOOT_IMAGE | cut -c 1-64)
BOOT_SIZE=$(wc -c < $BOOT_IMAGE)
echo "Hashing abl..."
ABL_HASH=$(sha256sum $ABL_IMAGE | cut -c 1-64)
ABL_SIZE=$(wc -c < $ABL_IMAGE)
echo "Hashing xbl..."
XBL_HASH=$(sha256sum $XBL_IMAGE | cut -c 1-64)
XBL_SIZE=$(wc -c < $XBL_IMAGE)
echo "Hashing xbl_config..."
XBL_CONFIG_HASH=$(sha256sum $XBL_CONFIG_IMAGE | cut -c 1-64)
XBL_CONFIG_SIZE=$(wc -c < $XBL_CONFIG_IMAGE)
# Compressing
SYSTEM_ARCHIVE=$OTA_OUTPUT_DIR/system-$SYSTEM_HASH.img.xz
BOOT_ARCHIVE=$OTA_OUTPUT_DIR/boot-$BOOT_HASH.img.xz
ABL_ARCHIVE=$OTA_OUTPUT_DIR/abl-$ABL_HASH.img.xz
XBL_ARCHIVE=$OTA_OUTPUT_DIR/xbl-$XBL_HASH.img.xz
XBL_CONFIG_ARCHIVE=$OTA_OUTPUT_DIR/xbl_config-$XBL_CONFIG_HASH.img.xz
echo "Compressing system..."
xz -vc $SYSTEM_IMAGE > $SYSTEM_ARCHIVE
echo "Compressing boot..."
xz -vc $BOOT_IMAGE > $BOOT_ARCHIVE
echo "Compressing abl..."
xz -vc $ABL_IMAGE > $ABL_ARCHIVE
echo "Compressing xbl..."
xz -vc $XBL_IMAGE > $XBL_ARCHIVE
echo "Compressing xbl_config..."
xz -vc $XBL_CONFIG_IMAGE > $XBL_CONFIG_ARCHIVE
# Generating JSONs
echo "Generating production JSON ($OUTPUT_JSON)..."
tee $OUTPUT_JSON > /dev/null <<EOM
[
{
"name": "boot",
"url": "$AGNOS_UPDATE_URL/boot-$BOOT_HASH.img.xz",
"hash": "$BOOT_HASH",
"hash_raw": "$BOOT_HASH",
"size": $BOOT_SIZE,
"sparse": false,
"full_check": true,
"has_ab": true
},
{
"name": "abl",
"url": "$AGNOS_UPDATE_URL/abl-$ABL_HASH.img.xz",
"hash": "$ABL_HASH",
"hash_raw": "$ABL_HASH",
"size": $ABL_SIZE,
"sparse": false,
"full_check": true,
"has_ab": true
},
{
"name": "xbl",
"url": "$AGNOS_UPDATE_URL/xbl-$XBL_HASH.img.xz",
"hash": "$XBL_HASH",
"hash_raw": "$XBL_HASH",
"size": $XBL_SIZE,
"sparse": false,
"full_check": true,
"has_ab": true
},
{
"name": "xbl_config",
"url": "$AGNOS_UPDATE_URL/xbl_config-$XBL_CONFIG_HASH.img.xz",
"hash": "$XBL_CONFIG_HASH",
"hash_raw": "$XBL_CONFIG_HASH",
"size": $XBL_CONFIG_SIZE,
"sparse": false,
"full_check": true,
"has_ab": true
},
{
"name": "system",
"url": "$AGNOS_UPDATE_URL/system-$SYSTEM_HASH.img.xz",
"hash": "$SPARSE_SYSTEM_HASH",
"hash_raw": "$SYSTEM_HASH",
"size": $SYSTEM_SIZE,
"sparse": true,
"full_check": false,
"has_ab": true
}
]
EOM
echo "Generating staging JSON ($OUTPUT_STAGING_JSON)..."
tee $OUTPUT_STAGING_JSON > /dev/null <<EOM
[
{
"name": "boot",
"url": "$AGNOS_STAGING_UPDATE_URL/boot-$BOOT_HASH.img.xz",
"hash": "$BOOT_HASH",
"hash_raw": "$BOOT_HASH",
"size": $BOOT_SIZE,
"sparse": false,
"full_check": true,
"has_ab": true
},
{
"name": "abl",
"url": "$AGNOS_STAGING_UPDATE_URL/abl-$ABL_HASH.img.xz",
"hash": "$ABL_HASH",
"hash_raw": "$ABL_HASH",
"size": $ABL_SIZE,
"sparse": false,
"full_check": true,
"has_ab": true
},
{
"name": "xbl",
"url": "$AGNOS_STAGING_UPDATE_URL/xbl-$XBL_HASH.img.xz",
"hash": "$XBL_HASH",
"hash_raw": "$XBL_HASH",
"size": $XBL_SIZE,
"sparse": false,
"full_check": true,
"has_ab": true
},
{
"name": "xbl_config",
"url": "$AGNOS_STAGING_UPDATE_URL/xbl_config-$XBL_CONFIG_HASH.img.xz",
"hash": "$XBL_CONFIG_HASH",
"hash_raw": "$XBL_CONFIG_HASH",
"size": $XBL_CONFIG_SIZE,
"sparse": false,
"full_check": true,
"has_ab": true
},
{
"name": "system",
"url": "$AGNOS_STAGING_UPDATE_URL/system-$SYSTEM_HASH.img.xz",
"hash": "$SPARSE_SYSTEM_HASH",
"hash_raw": "$SYSTEM_HASH",
"size": $SYSTEM_SIZE,
"sparse": true,
"full_check": false,
"has_ab": true
}
]
EOM
echo
echo "Done!"
echo " System hash: $SYSTEM_HASH"
echo " Boot hash: $BOOT_HASH"
echo " abl hash: $ABL_HASH"
echo " xbl hash: $XBL_HASH"
echo " xbl_config hash: $XBL_CONFIG_HASH"

7
scripts/check-space.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash -e
# sudo apt install ncdu
sudo mount build/system.img.raw build/agnos-rootfs
ncdu build/agnos-rootfs/ || true
sudo umount build/agnos-rootfs

2
scripts/shell.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
docker run -it --rm agnos-builder:latest /bin/bash

4
tools/.gitattributes vendored Normal file
View File

@@ -0,0 +1,4 @@
SecImage.tar.gz filter=lfs diff=lfs merge=lfs -text
aarch64-linux-android-4.9.tar.gz filter=lfs diff=lfs merge=lfs -text
aarch64-linux-gnu-gcc.tar.gz filter=lfs diff=lfs merge=lfs -text
llvm-arm-toolchain-ship.tar.gz filter=lfs diff=lfs merge=lfs -text

4
tools/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
aarch64-linux-android-4.9/
aarch64-linux-gnu-gcc/
llvm-arm-toolchain-ship/
SecImage/

3931
tools/avbtool Executable file

File diff suppressed because it is too large Load Diff

45
tools/extract_tools.sh Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/bash -e
echo "Extracting tools..."
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
THIS_SCRIPT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
ROOT=$DIR/..
cd $DIR
LINARO_GCC=aarch64-linux-gnu-gcc
GOOGLE_GCC_4_9=aarch64-linux-android-4.9
EDK2_LLVM=llvm-arm-toolchain-ship
SEC_IMAGE=SecImage
if [ ! -f $LINARO_GCC*.gz ] || \
[ ! -f $GOOGLE_GCC_4_9*.gz ] || \
[ ! -f $EDK2_LLVM*.gz ] || \
[ ! -f $SEC_IMAGE*.gz ]; then
cd $ROOT
git lfs install
git lfs pull
cd $DIR
fi
LINARO_GCC_TARBALL=$LINARO_GCC.tar.gz
GOOGLE_GCC_4_9_TARBALL=$GOOGLE_GCC_4_9.tar.gz
EDK2_LLVM_TARBALL=$EDK2_LLVM.tar.gz
SEC_IMAGE_TARBALL=$SEC_IMAGE.tar.gz
if [ ! -d $LINARO_GCC ]; then
tar -xzf $LINARO_GCC_TARBALL &>/dev/null
fi
if [ ! -d $GOOGLE_GCC_4_9 ]; then
tar -xzf $GOOGLE_GCC_4_9_TARBALL &>/dev/null
fi
if [ ! -d $EDK2_LLVM ]; then
tar -xzf $EDK2_LLVM_TARBALL &>/dev/null
fi
if [ ! -d $SEC_IMAGE ]; then
tar -xzf $SEC_IMAGE_TARBALL &>/dev/null
fi

175
tools/mkbootimg Executable file
View File

@@ -0,0 +1,175 @@
#!/usr/bin/env python
# Copyright 2015, The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from sys import argv, exit, stderr
from argparse import ArgumentParser, FileType, Action
from os import fstat
from struct import pack
from hashlib import sha1
import sys
import re
def filesize(f):
if f is None:
return 0
try:
return fstat(f.fileno()).st_size
except OSError:
return 0
def update_sha(sha, f):
if f:
sha.update(f.read())
f.seek(0)
sha.update(pack('I', filesize(f)))
else:
sha.update(pack('I', 0))
def pad_file(f, padding):
pad = (padding - (f.tell() & (padding - 1))) & (padding - 1)
f.write(pack(str(pad) + 'x'))
def write_header(args):
BOOT_MAGIC = 'ANDROID!'.encode()
args.output.write(pack('8s', BOOT_MAGIC))
args.output.write(pack('10I',
filesize(args.kernel), # size in bytes
args.base + args.kernel_offset, # physical load addr
filesize(args.ramdisk), # size in bytes
args.base + args.ramdisk_offset, # physical load addr
filesize(args.second), # size in bytes
args.base + args.second_offset, # physical load addr
args.base + args.tags_offset, # physical addr for kernel tags
args.pagesize, # flash page size we assume
0, # future expansion: MUST be 0
(args.os_version << 11) | args.os_patch_level)) # os version and patch level
args.output.write(pack('16s', args.board.encode())) # asciiz product name
args.output.write(pack('512s', args.cmdline[:512].encode()))
sha = sha1()
update_sha(sha, args.kernel)
update_sha(sha, args.ramdisk)
update_sha(sha, args.second)
img_id = pack('32s', sha.digest())
args.output.write(img_id)
args.output.write(pack('1024s', args.cmdline[512:].encode()))
pad_file(args.output, args.pagesize)
return img_id
class ValidateStrLenAction(Action):
def __init__(self, option_strings, dest, nargs=None, **kwargs):
if 'maxlen' not in kwargs:
raise ValueError('maxlen must be set')
self.maxlen = int(kwargs['maxlen'])
del kwargs['maxlen']
super(ValidateStrLenAction, self).__init__(option_strings, dest, **kwargs)
def __call__(self, parser, namespace, values, option_string=None):
if len(values) > self.maxlen:
raise ValueError('String argument too long: max {0:d}, got {1:d}'.
format(self.maxlen, len(values)))
setattr(namespace, self.dest, values)
def write_padded_file(f_out, f_in, padding):
if f_in is None:
return
f_out.write(f_in.read())
pad_file(f_out, padding)
def parse_int(x):
return int(x, 0)
def parse_os_version(x):
match = re.search(r'^(\d{1,3})(?:\.(\d{1,3})(?:\.(\d{1,3}))?)?', x)
if match:
a = int(match.group(1))
b = c = 0
if match.lastindex >= 2:
b = int(match.group(2))
if match.lastindex == 3:
c = int(match.group(3))
# 7 bits allocated for each field
assert a < 128
assert b < 128
assert c < 128
return (a << 14) | (b << 7) | c
return 0
def parse_os_patch_level(x):
match = re.search(r'^(\d{4})-(\d{2})-(\d{2})', x)
if match:
y = int(match.group(1)) - 2000
m = int(match.group(2))
# 7 bits allocated for the year, 4 bits for the month
assert y >= 0 and y < 128
assert m > 0 and m <= 12
return (y << 4) | m
return 0
def parse_cmdline():
parser = ArgumentParser()
parser.add_argument('--kernel', help='path to the kernel', type=FileType('rb'),
required=True)
parser.add_argument('--ramdisk', help='path to the ramdisk', type=FileType('rb'))
parser.add_argument('--second', help='path to the 2nd bootloader', type=FileType('rb'))
parser.add_argument('--cmdline', help='extra arguments to be passed on the '
'kernel command line', default='', action=ValidateStrLenAction, maxlen=1536)
parser.add_argument('--base', help='base address', type=parse_int, default=0x10000000)
parser.add_argument('--kernel_offset', help='kernel offset', type=parse_int, default=0x00008000)
parser.add_argument('--ramdisk_offset', help='ramdisk offset', type=parse_int, default=0x01000000)
parser.add_argument('--second_offset', help='2nd bootloader offset', type=parse_int,
default=0x00f00000)
parser.add_argument('--os_version', help='operating system version', type=parse_os_version,
default=0)
parser.add_argument('--os_patch_level', help='operating system patch level',
type=parse_os_patch_level, default=0)
parser.add_argument('--tags_offset', help='tags offset', type=parse_int, default=0x00000100)
parser.add_argument('--board', help='board name', default='', action=ValidateStrLenAction,
maxlen=16)
parser.add_argument('--pagesize', help='page size', type=parse_int,
choices=[2**i for i in range(11,15)], default=2048)
parser.add_argument('--id', help='print the image ID on standard output',
action='store_true')
parser.add_argument('-o', '--output', help='output file name', type=FileType('wb'),
required=True)
return parser.parse_args()
def write_data(args):
write_padded_file(args.output, args.kernel, args.pagesize)
write_padded_file(args.output, args.ramdisk, args.pagesize)
write_padded_file(args.output, args.second, args.pagesize)
def main():
args = parse_cmdline()
img_id = write_header(args)
write_data(args)
if args.id:
if isinstance(img_id, str):
# Python 2's struct.pack returns a string, but py3 returns bytes.
img_id = [ord(x) for x in img_id]
print('0x' + ''.join('{:02x}'.format(c) for c in img_id))
if __name__ == '__main__':
main()

4
userspace/.gitattributes vendored Normal file
View File

@@ -0,0 +1,4 @@
usr/comma/wlan.ko filter=lfs diff=lfs merge=lfs -text
usr/comma/wifi filter=lfs diff=lfs merge=lfs -text
files/weston filter=lfs diff=lfs merge=lfs -text
files/libeglSubDriverWayland.so.patched filter=lfs diff=lfs merge=lfs -text

71
userspace/Pipfile Normal file
View File

@@ -0,0 +1,71 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
ipython = "*"
azure-core = "*"
azure-common = "*"
azure-storage-blob = "~=2.1"
azure-storage-common = "~=2.1"
pycurl = "*"
git-pylint-commit-hook = "*"
tenacity = "*"
mock = "*"
dictdiffer = "*"
aenum = "*"
coverage = "*"
paramiko = "*"
lru-dict = "*"
pprofile = "*"
pyprof2calltree = "*"
pre-commit = "*"
mypy = "*"
parameterized = "*"
inputs = "*"
casadi = "*"
future-fstrings = "*" # needed for acados for now
[packages]
atomicwrites = "*"
cffi = "*"
crcmod = "*"
hexdump = "*"
libusb1 = "*"
numpy = "*"
psutil = "*"
pycapnp = "==1.1.0"
cryptography = "*"
python-dateutil = "*"
pyzmq = "*"
requests = "*"
setproctitle = "*"
six = "*"
smbus2 = "*"
sympy = "!=1.6.1"
tqdm = "*"
Cython = "*"
PyYAML = "*"
websocket_client = "*"
urllib3 = "*"
gunicorn = "*"
utm = "*"
json-rpc = "*"
Flask = "*"
nose = "*"
flake8 = "*"
pylint = "*"
pillow = "*"
scons = "*"
cysignals = "*"
pycryptodome = "*"
"Jinja2" = "*"
PyJWT = "*"
pyserial = "*"
dbus-python = "*"
timezonefinder = "*"
sentry-sdk = "*"
[requires]
python_version = "3.8"

1546
userspace/Pipfile.lock generated Normal file

File diff suppressed because it is too large Load Diff

212
userspace/base_setup.sh Executable file
View File

@@ -0,0 +1,212 @@
#!/bin/bash -e
USERNAME=comma
PASSWD=comma
HOST=tici
# Create identification file
touch /TICI
# Create privileged user
useradd -G sudo -m -s /bin/bash $USERNAME
echo "$USERNAME:$PASSWD" | chpasswd
groupadd gpio
groupadd gpu
adduser $USERNAME root
adduser $USERNAME video
adduser $USERNAME gpio
adduser $USERNAME adm
adduser $USERNAME gpu
adduser $USERNAME audio
adduser $USERNAME disk
# Add armhf as supported architecture
dpkg --add-architecture armhf
# Install packages
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -yq locales systemd
adduser $USERNAME systemd-journal
# Enable serial console on UART
systemctl enable serial-getty@ttyS0.service
# set kernel params
echo "net.ipv4.conf.all.rp_filter = 2" >> /etc/sysctl.conf
echo "vm.dirty_expire_centisecs = 200" >> /etc/sysctl.conf
# raise comma user's process priority limits
echo "comma - rtprio 100" >> /etc/security/limits.conf
echo "comma - nice -10" >> /etc/security/limits.conf
# Locale setup
locale-gen en_US.UTF-8
update-locale LANG=en_US.UTF-8
apt-get upgrade -yq
apt-get install --no-install-recommends -yq \
alsa-utils \
apport-retrace \
bc \
build-essential \
bzip2 \
curl \
chrony \
cpuset \
dfu-util \
evtest \
git \
git-core \
git-lfs \
gdb \
htop \
i2c-tools \
ifmetric \
ifupdown \
jq \
landscape-common \
libi2c-dev \
libqmi-utils \
libtool \
libncursesw5-dev \
libgdbm-dev \
libc6-dev \
libsqlite3-dev \
libssl-dev \
libffi-dev \
llvm \
nano \
net-tools \
nload \
network-manager \
nvme-cli \
openssl \
python-dev \
python-setuptools \
smartmontools \
speedtest-cli \
ssh \
sshfs \
sudo \
traceroute \
tk-dev \
ubuntu-minimal \
ubuntu-server \
ubuntu-standard \
udev \
udhcpc \
wget \
wireless-tools \
zlib1g-dev
rm -rf /var/lib/apt/lists/*
# Allow chrony to make a big adjustment to system time on boot
echo "makestep 0.1 3" >> /etc/chrony/chrony.conf
# Create dirs
mkdir /data && chown $USERNAME:$USERNAME /data
mkdir /persist && chown $USERNAME:$USERNAME /persist
# Disable automatic ondemand switching from ubuntu
systemctl disable ondemand
# Disable pstore service that moves files out of /sys/fs/pstore
systemctl disable systemd-pstore.service
# Nopasswd sudo
echo "comma ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# setup /bin/sh symlink
ln -sf /bin/bash /bin/sh
# Add bionic repo to sources
echo "" >> /etc/apt/sources.list
echo "deb http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted" >> /etc/apt/sources.list
echo "deb http://ports.ubuntu.com/ubuntu-ports/ bionic universe" >> /etc/apt/sources.list
# Install neccesary libs
apt-get update -yq
apt-get install --no-install-recommends -yq \
libacl1:armhf \
libasan2-armhf-cross \
libatomic1-armhf-cross \
libattr1:armhf \
libaudit1:armhf \
libblkid1:armhf \
libc6:armhf \
libc6-armhf-cross \
libc6-dev:armhf \
libc6-dev-armhf-cross \
libcairo2:armhf \
libcap2:armhf \
libdrm2:armhf \
libevdev2:armhf \
libexpat1:armhf \
libffi6:armhf \
libfontconfig1:armhf \
libfreetype6:armhf \
libgbm1:armhf \
libgcc-5-dev-armhf-cross \
libgcc1:armhf \
libglib2.0-0:armhf \
libgomp1-armhf-cross \
libgudev-1.0-0:armhf \
libinput-bin:armhf \
libinput-dev:armhf \
libinput10:armhf \
libjpeg-dev:armhf \
libjpeg-turbo8:armhf \
libjpeg-turbo8-dev:armhf \
libjpeg8:armhf \
libjpeg8-dev:armhf \
libkmod2:armhf \
libmtdev1:armhf \
libpam0g:armhf \
libpam0g-dev:armhf \
libpcre3:armhf \
libpixman-1-0:armhf \
libpng16-16:armhf \
libselinux1:armhf \
libstdc++6:armhf \
libstdc++6-armhf-cross \
libubsan0-armhf-cross \
libudev-dev:armhf \
libudev1:armhf \
libuuid1:armhf \
libwacom2:armhf \
libwayland-client0:armhf \
libwayland-cursor0:armhf \
libwayland-server0:armhf \
libx11-6:armhf \
libxau6:armhf \
libxcb-render0:armhf \
libxcb-shm0:armhf \
libxcb1:armhf \
libxdmcp6:armhf \
libxext6:armhf \
libxkbcommon0:armhf \
libxrender1:armhf \
linux-libc-dev:armhf \
linux-libc-dev-armhf-cross \
zlib1g:armhf \
libegl1 \
libegl-dev \
libgles1 \
libgles2 \
libgles-dev \
libwayland-dev \
pulseaudio \
pulseaudio-utils \
openssh-server \
dnsmasq-base \
isc-dhcp-client \
iputils-ping \
rsyslog \
kmod \
wpasupplicant \
hostapd \
libgtk2.0-dev \
libcap2:armhf \
libxml2:armhf \

14
userspace/compile-capnp.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash -e
# Install capnproto
cd /tmp
VERSION=0.8.0
wget https://capnproto.org/capnproto-c++-${VERSION}.tar.gz
tar xvf capnproto-c++-${VERSION}.tar.gz
cd capnproto-c++-${VERSION}
CXXFLAGS="-fPIC -O2" ./configure
make -j$(nproc)
checkinstall -yD --install=no --pkgname=capnproto
mv capnproto*.deb /tmp/capnproto.deb

13
userspace/compile-ffmpeg.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/bash -e
# Install ffmpeg (the one from the ubuntu repos doesn't work with our libOpenCL)
cd /tmp
wget https://ffmpeg.org/releases/ffmpeg-4.2.2.tar.bz2
tar xvf ffmpeg-4.2.2.tar.bz2
cd ffmpeg-4.2.2
./configure --enable-shared --disable-static
make -j$(nproc)
checkinstall -yD --install=no --pkgname=ffmpeg
mv ffmpeg*.deb /tmp/ffmpeg.deb

View File

@@ -0,0 +1,11 @@
#!/bin/bash -e
# Build mapbox-gl-native
cd /tmp
git clone --recursive https://github.com/commaai/mapbox-gl-native.git
cd mapbox-gl-native
git checkout 69f41ffff655ee28834c167ad1353112f370e6e5
mkdir build && cd build
cmake -DMBGL_WITH_QT=ON ..
make -j$(nproc) mbgl-qt
mv libqmapboxgl.so /tmp/libqmapboxgl.so

12
userspace/compile-qtlocation.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash -e
# Build qtlocation with extra api responses parsed
cd /tmp
git clone https://github.com/commaai/qtlocation.git
cd qtlocation
git checkout d44ce6506d2dda542eb8e4b6fc06a6a6bf74bb48
qmake
make -j$(nproc)
checkinstall -yD --install=no --pkgname=qtlocation --pkgversion=0.0.1
cp qtlocation*.deb /tmp/qtlocation.deb

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:883fc9c1f231f97dc9a3bcbd7afd028bbe22de8ff25f70a53899a10c792c4a25
size 1097008

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7d5166e1df3e0dd5123f63541eab4923164a5003c3c4c867f35bdcbcddde4ba4
size 51109180

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:56980ff55a0571308fb86224c7908b3b233720fd9e9277784544386b465560a9
size 113652

3
userspace/debs/qt.deb Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:38c01e3a8b4f87064e3f4cfdfae8ea004e89d6cf7fd147a8da6a8620f0dd82d6
size 364866520

View File

@@ -0,0 +1,2 @@
[keyfile]
unmanaged-devices=none

View File

@@ -0,0 +1 @@
KERNEL=="adsprpc-smd", GROUP="gpu", MODE="0660"

View File

@@ -0,0 +1,2 @@
ACTION=="add|change", KERNEL=="event[0-9]*", ENV{ID_SEAT}="seat0"
SUBSYSTEM=="input", MODE="666"

View File

@@ -0,0 +1,4 @@
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="panel0-backlight", RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness"
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="panel0-backlight", RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness"
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="panel0-backlight", RUN+="/bin/chgrp video /sys/class/backlight/%k/bl_power"
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="panel0-backlight", RUN+="/bin/chmod g+w /sys/class/backlight/%k/bl_power"

View File

@@ -0,0 +1,3 @@
KERNEL=="kgsl-3d0", GROUP="gpu", MODE="0660"
KERNEL=="ion", GROUP="gpu", MODE="0660"
SUBSYSTEM=="drm", GROUP="gpu", MODE="0660"

View File

@@ -0,0 +1 @@
KERNEL=="i2c-[0-9]*", GROUP="gpio", MODE="0660"

View File

@@ -0,0 +1,2 @@
SUBSYSTEM=="tty", KERNEL=="ttyHS0", GROUP="gpio", MODE="0660"
SUBSYSTEM=="tty", KERNEL=="ttyUSB2", GROUP="gpio", MODE="0660"

View File

@@ -0,0 +1,3 @@
SUBSYSTEM=="usb", ATTRS{idVendor}=="bbaa", ATTRS{idProduct}=="ddee", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="bbaa", ATTRS{idProduct}=="ddcc", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE="0666"

View File

@@ -0,0 +1 @@
SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c 'find -L /sys/class/gpio/ -maxdepth 2 -exec chown root:gpio {} \; -exec chmod 770 {} \; || true'"

View File

@@ -0,0 +1,22 @@
[Unit]
Description=Modem Manager
After=polkit.service
Requires=polkit.service
[Service]
Type=dbus
BusName=org.freedesktop.ModemManager1
ExecStart=/usr/sbin/ModemManager --filter-policy=strict --debug
StandardError=null
Restart=on-abort
CapabilityBoundingSet=CAP_SYS_ADMIN
ProtectSystem=true
ProtectHome=true
PrivateTmp=true
RestrictAddressFamilies=AF_NETLINK AF_UNIX
NoNewPrivileges=true
User=root
[Install]
WantedBy=multi-user.target
Alias=dbus-org.freedesktop.ModemManager1.service

View File

@@ -0,0 +1,9 @@
[main]
plugins=ifupdown,keyfile
dns=systemd-resolved
[ifupdown]
managed=true
[device]
wifi.scan-rand-mac-address=no

View File

@@ -0,0 +1,4 @@
[Allow sudo users to control modem]
Identity=unix-group:sudo
Action=org.freedesktop.ModemManager1.*
ResultAny=yes

View File

@@ -0,0 +1,4 @@
[Allow sudo users to control networking]
Identity=unix-group:sudo
Action=org.freedesktop.NetworkManager.*
ResultAny=yes

14
userspace/files/apt.conf Normal file
View File

@@ -0,0 +1,14 @@
APT::Install {
Pre-Invoke { "/usr/comma/apt_setup.sh"; };
Post-Invoke { "/usr/comma/apt_teardown.sh"; };
};
APT::Update {
Pre-Invoke { "/usr/comma/apt_setup.sh"; };
Post-Invoke { "/usr/comma/apt_teardown.sh"; };
};
DPkg {
Pre-Invoke { "/usr/comma/apt_setup.sh"; };
Post-Invoke { "/usr/comma/apt_teardown.sh"; };
};

View File

@@ -0,0 +1,11 @@
[Unit]
Description=Start cdsp
SourcePath=/usr/bin/cdsp.sh
Before=cdsprpcd.service
[Service]
Type=oneshot
ExecStart=/bin/sh /usr/bin/cdsp.sh
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,10 @@
[Unit]
Description=Color correction copy
[Service]
Type=oneshot
ExecStart=/bin/bash -c "mkdir -p /data/misc/display && cp /sys/devices/platform/soc/894000.i2c/i2c-2/2-0017/color_cal /data/misc/display/color_cal && echo \"Color calibration file succesfully copied!\""
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,27 @@
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
# See tmpfiles.d(5) for details
# /var: rebuild enough for services to be happy
d /var/crash 0755 - - -
q /var/tmp 1777 root root 30d
d /var/lib/dpkg 0755 - - -
f /var/lib/dpkg/lock-frontend 0755 - - -
f /var/lib/dpkg/status 0755 - - -
d /var/lib/logrotate 0755 - - -
d /var/spool 0755 - - -
d /var/spool/cron/atjobs 0755 - - -
d /var/cache/pollinate 0755 pollinate daemon -
# /home: setup overlay upper and work dirs
d /tmp/rw/home_upper 0755 - - -
d /tmp/rw/home_work 0755 - - -

View File

@@ -0,0 +1,15 @@
[Unit]
Description=Comma tmux
After=weston.service gpio.service
[Service]
Type=simple
User=comma
Restart=always
ExecStart=/bin/bash -c "/usr/bin/tmux new-session -s comma -d /usr/comma/comma.sh && sleep infinity"
KillSignal=SIGKILL
LimitRTPRIO=100
LimitNICE=-10
[Install]
WantedBy=multi-user.target

148
userspace/files/default.pa Normal file
View File

@@ -0,0 +1,148 @@
#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
# This startup script is used only if PulseAudio is started per-user
# (i.e. not in system mode)
.fail
### Automatically restore the volume of streams and devices
load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore
### Automatically augment property information from .desktop files
### stored in /usr/share/application
load-module module-augment-properties
### Should be after module-*-restore but before module-*-detect
load-module module-switch-on-port-available
### Use hot-plugged devices like Bluetooth or USB automatically (LP: #1702794)
.ifexists module-switch-on-connect.so
load-module module-switch-on-connect
.endif
### Load audio drivers statically
### (it's probably better to not load these drivers manually, but instead
### use module-udev-detect -- see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink
### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect tsched=0
.else
### Use the static hardware detection module (for systems that lack udev support)
load-module module-detect
.endif
### Automatically connect sink and source if JACK server is present
.ifexists module-jackdbus-detect.so
.nofail
load-module module-jackdbus-detect channels=2
.fail
.endif
### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif
.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif
### Load several protocols
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix
### Network access (may be configured with paprefs, so leave this commented
### here if you plan to use paprefs)
#load-module module-esound-protocol-tcp
#load-module module-native-protocol-tcp
#load-module module-zeroconf-publish
### Load the RTP receiver module (also configured via paprefs, see above)
#load-module module-rtp-recv
### Load the RTP sender module (also configured via paprefs, see above)
#load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 sink_properties="device.description='RTP Multicast Sink'"
#load-module module-rtp-send source=rtp.monitor
### Load additional modules from GSettings. This can be configured with the paprefs tool.
### Please keep in mind that the modules configured by paprefs might conflict with manually
### loaded modules.
.ifexists module-gsettings.so
.nofail
load-module module-gsettings
.fail
.endif
### Automatically restore the default sink/source when changed by the user
### during runtime
### NOTE: This should be loaded as early as possible so that subsequent modules
### that look up the default sink/source get the right value
load-module module-default-device-restore
### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink
### Honour intended role device property
load-module module-intended-roles
### Automatically suspend sinks/sources that become idle for too long
load-module module-suspend-on-idle
### If autoexit on idle is enabled we want to make sure we only quit
### when no local session needs us anymore.
.ifexists module-console-kit.so
load-module module-console-kit
.endif
.ifexists module-systemd-login.so
load-module module-systemd-login
.endif
### Enable positioned event sounds
load-module module-position-event-sounds
### Cork music/video streams when a phone stream is active
load-module module-role-cork
### Block audio recording for snap confined packages unless they have
### the "pulseaudio" or "audio-record" interfaces plugged.
.ifexists module-snap-policy.so
load-module module-snap-policy
.endif
### Modules to allow autoloading of filters (such as echo cancellation)
### on demand. module-filter-heuristics tries to determine what filters
### make sense, and module-filter-apply does the heavy-lifting of
### loading modules and rerouting streams.
load-module module-filter-heuristics
load-module module-filter-apply
### Make some devices default
#set-default-sink output
#set-default-source input

View File

@@ -0,0 +1,22 @@
#!/usr/local/pyenv/shims/python3
import sys
import usb1
REQUEST_OUT = usb1.ENDPOINT_OUT | usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE
USB_POWER_MODE = 0xe6
USB_POWER_CLIENT = 1
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] in ['halt', 'poweroff']:
ctx = usb1.USBContext()
dev = ctx.openByVendorIDAndProductID(0xbbaa, 0xddcc)
if dev is not None:
dev.controlWrite(REQUEST_OUT, USB_POWER_MODE, USB_POWER_CLIENT, 0, b'')
print("Disabled bootkick")
else:
print("No panda found")
else:
print("Please specify shutdown reason")

View File

@@ -0,0 +1,8 @@
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: true
nameservers:
addresses: [8.8.8.8, 8.8.4.4]

View File

@@ -0,0 +1,12 @@
[Unit]
Description=Setup rootfs
After=data.mount
Before=local-fs.target
DefaultDependencies=no
[Service]
Type=oneshot
ExecStart=/usr/comma/fs_setup.sh
[Install]
WantedBy=multi-user.target

6
userspace/files/fstab Normal file
View File

@@ -0,0 +1,6 @@
/dev/disk/by-label/dsp /dsp auto
/dev/disk/by-partlabel/modem_a /firmware auto
/dev/disk/by-partlabel/userdata /data auto discard,nosuid,nodev,nofail 0 0
/dev/nvme0n1 /data/media auto discard,nosuid,nodev,nofail,x-systemd.device-timeout=5s 0 0
tmpfs /var tmpfs rw,nosuid,nodev,size=128M,mode=755 0 0
tmpfs /tmp tmpfs rw,nosuid,nodev,size=50M,mode=1777 0 0

BIN
userspace/files/gl-renderer.so Executable file

Binary file not shown.

View File

@@ -0,0 +1,9 @@
[Unit]
Description=GPIO export
[Service]
Type=oneshot
ExecStart=/usr/comma/gpio.sh
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,14 @@
[Unit]
Description=/home overlay
DefaultDependencies=no
After=systemd-tmpfiles-setup.service
Conflicts=umount.target
[Mount]
What=overlay
Where=/home
Type=overlay
Options=lowerdir=/usr/default/home,upperdir=/tmp/rw/home_upper,workdir=/tmp/rw/home_work
[Install]
WantedBy = multi-user.target

View File

@@ -0,0 +1,10 @@
[Unit]
Description=QCOM init
After=sysinit.target
[Service]
Type=oneshot
ExecStart=/usr/comma/init.qcom.sh
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:34b01105549bba97710ded5916a24a318d4b7dbe91fe4e617ca320a7d98f6a39
size 197632

View File

@@ -0,0 +1,37 @@
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See logind.conf(5) for details.
[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#HandleLidSwitchExternalPower=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
RemoveIPC=no
#InhibitorsMax=8192
#SessionsMax=8192

View File

@@ -0,0 +1,11 @@
[Unit]
Description=Hourly rotation of log files
Documentation=man:logrotate(8) man:logrotate.conf(5)
[Timer]
Unit=logrotate.service
OnCalendar=hourly
Persistent=true
[Install]
WantedBy=timers.target

View File

@@ -0,0 +1,9 @@
# see "man logrotate" for details
hourly
rotate 36
maxsize 1M
create
su root adm
include /etc/logrotate.d

View File

@@ -0,0 +1,27 @@
[connection]
id=lte
uuid=6586fb1f-4a66-46d4-9164-0100b73750ee
type=gsm
interface-name=cdc-wdm0
permissions=
autoconnect=yes
autoconnect-retries=0
[gsm]
auto-config=yes
home-only=yes
[ipv4]
route-metric=1000
dns-priority=1000
dns-search=
method=auto
[ipv6]
ddr-gen-mode=stable-privacy
dns-search=
route-metric=1000
dns-priority=1000
method=auto
[proxy]

View File

@@ -0,0 +1,13 @@
[Unit]
Description=LTE
After=gpio.service network.target
[Service]
Restart=no
KillSignal=SIGKILL
RemainAfterExit=true
ExecStart=/usr/comma/lte/lte.sh start
ExecStop=/usr/comma/lte/lte.sh stop
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,9 @@
[Unit]
Description= Power Drop Monitor Service
[Service]
Restart=always
ExecStart=/usr/local/pyenv/shims/python -u /usr/comma/power_drop_monitor.py
[Install]
WantedBy=multi-user.target

56
userspace/files/profile Normal file
View File

@@ -0,0 +1,56 @@
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "${PS1-}" ]; then
if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
# display setup
export XDG_RUNTIME_DIR="/var/tmp/weston"
export QT_QPA_PLATFORM="wayland-egl"
# python setup
export PYTHONPATH="/data/pythonpath:/data/pythonpath/pyextra"
export PATH="/usr/local/pyenv/bin:$PATH"
export PYENV_VERSION="3.8.5"
export PYENV_ROOT="/usr/local/pyenv"
# output of "pyenv init - --no-rehash"
export PATH="/usr/local/pyenv/shims:${PATH}"
export PYENV_SHELL=bash
source '/usr/local/pyenv/libexec/../completions/pyenv.bash'
pyenv() {
local command
command="${1:-}"
if [ "$#" -gt 0 ]; then
shift
fi
case "$command" in
activate|deactivate|rehash|shell)
eval "$(pyenv "sh-$command" "$@")";;
*)
command pyenv "$command" "$@";;
esac
}

View File

@@ -0,0 +1,15 @@
[Unit]
Description=PulseAudio system server
[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/pulseaudio --realtime
KillSignal=SIGKILL
User=comma
Environment="XDG_RUNTIME_DIR=/var/tmp/weston"
LimitRTPRIO=100
LimitNICE=-10
[Install]
WantedBy=multi-user.target

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
[Unit]
Description=Sound
[Service]
Type=oneshot
ExecStart=/usr/comma/sound/sound_init.sh
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,5 @@
[Path]
PathModified=/data/params/d/SshEnabled
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,10 @@
[Unit]
Description=SSH param watcher
After=multi-user.target
[Service]
Type=oneshot
ExecStart=/usr/comma/set_ssh.sh
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,53 @@
# This is the ssh client system-wide configuration file. See
# ssh_config(5) for more information. This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.
# Configuration data is parsed as follows:
# 1. command line options
# 2. user-specific file
# 3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.
# Site-wide defaults for some commonly used options. For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.
Include /etc/ssh/ssh_config.d/*.conf
Host *
# ForwardAgent no
# ForwardX11 no
# ForwardX11Trusted yes
# PasswordAuthentication yes
# HostbasedAuthentication no
# GSSAPIAuthentication no
# GSSAPIDelegateCredentials no
# GSSAPIKeyExchange no
# GSSAPITrustDNS no
# BatchMode no
# CheckHostIP yes
# AddressFamily any
# ConnectTimeout 0
# StrictHostKeyChecking ask
IdentityFile /data/ssh/id_rsa
IdentityFile /data/ssh/id_dsa
IdentityFile /data/ssh/id_ecdsa
IdentityFile /data/ssh/id_ed25519
# Port 22
# Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
# MACs hmac-md5,hmac-sha1,umac-64@openssh.com
# EscapeChar ~
# Tunnel no
# TunnelDevice any:any
# PermitLocalCommand no
# VisualHostKey no
# ProxyCommand ssh -q -W %h:%p gateway.example.com
# RekeyLimit 1G 1h
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
UserKnownHostsFile /data/ssh/known_hosts

View File

@@ -0,0 +1,5 @@
[Service]
ExecStartPre=
ExecStartPre=/bin/mkdir -p /persist/etc/ssh/
ExecStartPre=/usr/bin/ssh-keygen -A -f /persist
ExecStartPre=/usr/sbin/sshd -t

View File

@@ -0,0 +1,89 @@
# Package generated configuration file
# See the sshd_config(5) manpage for details
# Comma
Port 8022
StrictModes no
AuthorizedKeysFile /data/params/d/GithubSshKeys
PermitRootLogin no
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /persist/etc/ssh/ssh_host_rsa_key
HostKey /persist/etc/ssh/ssh_host_dsa_key
HostKey /persist/etc/ssh/ssh_host_ecdsa_key
HostKey /persist/etc/ssh/ssh_host_ed25519_key
# Logging
SyslogFacility AUTH
LogLevel INFO
# Authentication:
LoginGraceTime 120
#PermitRootLogin prohibit-password
#StrictModes yes
PubkeyAuthentication yes
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes
# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
# Change to no to disable tunnelled clear text passwords
PasswordAuthentication no
# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
ClientAliveInterval 10
ClientAliveCountMax 3
#MaxStartups 10:30:60
#Banner /etc/issue.net
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

3
userspace/files/weston Executable file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:36f385775e6a258625fa4b4259b092858ccee2347feb6958839874f406b09f95
size 781932

View File

@@ -0,0 +1,28 @@
[Unit]
Description=Weston
After=color_correction.service
# If we start weston immediately it just exits without an error
# TODO: Figure out what we need to wait for (drm?)
[Service]
Type=simple
Restart=always
Environment="XDG_RUNTIME_DIR=/var/tmp/weston"
# TODO: detect if display was brought up by bootloader
# Setting backlight to 0 while the screen is not initialized will turn off the regulators, 1023 turns it back on
ExecStart=/bin/bash -c "sleep 4 && \
echo 0 > /sys/class/backlight/panel0-backlight/brightness && \
sleep 0.1 && \
echo 1023 > /sys/class/backlight/panel0-backlight/brightness && \
/usr/comma/modetest -M msm_drm -s 26@111:1080x2160-60 && \
/usr/comma/modetest -M msm_drm -s 26@111:1080x2160-60 && \
sleep 1 && \
mkdir -p $XDG_RUNTIME_DIR && \
chown -R comma: $XDG_RUNTIME_DIR && \
mkdir -p /data/misc/display || true && \
echo 0 > /data/misc/display/sdm_dbg_cfg.txt || true && \
/usr/bin/weston --idle-time=0 --tty=1 --config=/usr/comma/weston.ini"
KillSignal=SIGKILL
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,9 @@
[Unit]
Description=Wifi
[Service]
Type=oneshot
ExecStart=/sbin/insmod /usr/comma/wlan.ko
[Install]
WantedBy=multi-user.target

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

19
userspace/hardware_setup.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash -e
# Install driver deb files (we're fine with overwriting stuff too)
cd /tmp/agnos/debs
apt-get -o Dpkg::Options::="--force-overwrite" install -yq \
./agnos-base_0.0.1.deb \
./agnos-display_0.0.1.deb \
./agnos-wlan_0.0.1.deb
# Install 16.04 version of libjson-c2
cd /tmp
wget http://ports.ubuntu.com/pool/main/j/json-c/libjson-c2_0.11-4ubuntu2.6_arm64.deb -O /tmp/libjson-c2_0.11-4ubuntu2.6_arm64.deb
apt install -yq /tmp/libjson-c2_0.11-4ubuntu2.6_arm64.deb
# Remove apt cache
rm -rf /var/lib/apt/lists/*
USERNAME=comma
adduser $USERNAME netdev

View File

@@ -0,0 +1,10 @@
alias l='ls -lah'
alias gup='git pull --rebase'
alias gl='git pull'
alias gp='git push'
alias gcam='git commit -a -m'
alias gst='git status'
alias gco='git checkout'
alias gsu='git submodule update'
alias dump="/data/pythonpath/selfdrive/debug/dump.py"

View File

@@ -0,0 +1,8 @@
export EDITOR='vim'
export VIMINIT='source $MYVIMRC'
export MYVIMRC="~/.vimrc"
source $HOME/.profile
# TODO: there's probably a better way to do this for only the main tmux session
[ -d "/data/openpilot" ] && cd /data/openpilot

View File

@@ -0,0 +1,2 @@
[main]
unpackaged=true

1
userspace/home/.gdbinit Normal file
View File

@@ -0,0 +1 @@
handle SIGUSR2 nostop noprint

10
userspace/home/.gitconfig Normal file
View File

@@ -0,0 +1,10 @@
[user]
email = device@comma.ai
name = Comma Device
[push]
default = simple
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
required = true
process = git-lfs filter-process

Some files were not shown because too many files have changed in this diff Show More