Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# This is a basic workflow to help you get started with Actions

name: build

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: [self-hosted, cloud, x86_64]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Runs a single command using the runners shell
- name: Run a one-line script
id: build-artifacts

run: |
echo ::set-output name=build_exit_code::1
DOCKER_BUILDKIT=1 docker build --no-cache -f Dockerfile -t jetson-kernel --target artifact --output type=local,dest=${{github.workspace}}/artifacts/ .
echo ::set-output name=build_exit_code::$?

- name: Pack assets
id: pack-artifacts
if: steps.build-artifacts.outputs.build_exit_code == 0
working-directory: ${{ github.workspace }}/artifacts
run: |
echo ::set-output name=exit_code::1
zip -r \
${{github.workspace}}/jetson_kernel.zip *
echo ::set-output name=exit_code::$?

- name: Upload artifact
id: upload-artifact
if: steps.pack-artifacts.outputs.build_exit_code == 0
uses: cloudkernels/minio-upload@master
with:
url: https://s3.nubificus.co.uk
access-key: ${{ secrets.AWS_ACCESS_KEY }}
secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
local-path: jetson_kernel.zip
remote-path: nbfc-assets/github/jetson_kernel/jetson_kernel.zip
59 changes: 59 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
###
### DOCKER_BUILDKIT=1 docker build -f Dockerfile -t jetson-kernel --target artifact --output type=local,dest=./output .
###
FROM ananos/debian-dev-aarch64 as build

# Grab build dependencies
RUN apt-get update && apt install -y build-essential libssl-dev bc flex bison libelf-dev openssl libssl-dev bc cpio rsync kmod

RUN mkdir -p /build
WORKDIR /build

# Download the L4T source tarball
#RUN wget -c https://developer.nvidia.com/embedded/dlc/r32-3-1_Release_v1.0/Sources/T186/public_sources.tbz2
RUN wget -c https://developer.nvidia.com/embedded/l4t/r32_release_v5.1/r32_release_v5.1/sources/t210/public_sources.tbz2

# Unpack the kernel tarball
RUN tar -jxpf public_sources.tbz2
RUN cd Linux_for_Tegra/source/public && tar -jxpf kernel_src.tbz2

# Get gcc-7 aarch64 toolchain
RUN mkdir -p /store/toolchains
WORKDIR /store/toolchains
RUN wget https://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-linux-gnu/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz && xzcat gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz | tar -xf -

RUN touch /tmp/blah
# Download patch and kernel config.
# If no branch is specified, then the latest L4T release is used.
RUN git clone https://github.com/cloudkernels/Xavier-KVM.git ~/Xavier-KVM -b Nano/t210
WORKDIR /root/Xavier-KVM
RUN git pull

WORKDIR /build/Linux_for_Tegra/source/public/hardware
# Patch the device tree
#RUN patch -Np1 -i ~/Xavier-KVM/patches/hardware/0001-Enable-KVM-support-for-t194.patch
RUN patch -Np1 -i ~/Xavier-KVM/patches/hardware/0001-Enable-KVM-support-for-t210.patch

# Patch the kernel
WORKDIR /build/Linux_for_Tegra/source/public/kernel/kernel-4.9
RUN for i in ~/Xavier-KVM/patches/kernel/*; do patch -Np1 -i $i; done

# Copy the kernel config to the kernel source tree
RUN cp ~/Xavier-KVM/config-4.9.140-kvm arch/arm64/configs/tegra-kvm_defconfig
RUN touch .config
RUN make ARCH=arm64 CROSS_COMPILE=/store/toolchains/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- tegra-kvm_defconfig

# Build kernel components
RUN make ARCH=arm64 Image -j$(nproc) CROSS_COMPILE=/store/toolchains/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
RUN make ARCH=arm64 dtbs -j$(nproc) CROSS_COMPILE=/store/toolchains/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
RUN make ARCH=arm64 modules -j$(nproc) CROSS_COMPILE=/store/toolchains/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

# Install kernel modules and firmware
RUN make ARCH=arm64 modules_install -j$(nproc) CROSS_COMPILE=/store/toolchains/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

FROM scratch as artifact
COPY --from=build /lib/modules/ /modules
COPY --from=build /lib/firmware/ /firmware
COPY --from=build /build/Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/boot/Image /Image
COPY --from=build /build/Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/boot/dts/tegra210-p3448-0000-p3449-0000-a02.dtb /tegra210-p3448-0000-p3449-0000-a02.dtb
COPY --from=build /build/Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/boot/dts/tegra210-p3448-0000-p3449-0000-a02.dtb /tegra210-p3448-0000-p3449-0000-b00.dtb
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
## KVM for Nvidia AGX Xavier - Installation Guide
## KVM for Nvidia AGX Xavier/Nano - Installation Guide

This guide provides instructions to enable KVM virtualization on the Jetson AGX Xavier.
This guide provides instructions to enable KVM virtualization on the Jetson AGX Xavier/Nano.
The Jetson AGX Xavier incorporates an Nvidia Xavier t194 SoC with 8 Carmel processor cores.
The Carmel cores of the Xavier T194 provides full support for virtualization with ARMv8.1 VHE.

##### Requirements:
- An Nvidia Jetson AGX Xavier
- An Nvidia Jetson AGX Xavier/Nano

##### On your Xavier:
##### On your Xavier/Nano:
```
# Grab build dependencies
sudo apt install build-essential libssl-dev bc
Expand All @@ -26,14 +26,17 @@ git clone https://github.com/b-man/Xavier-KVM.git ~/Xavier-KVM

# Patch the device tree
cd hardware/
# for Xavier
patch -Np1 -i ~/Xavier-KVM/patches/hardware/0001-Enable-KVM-support-for-t194.patch
# for Nano
patch -Np1 -i ~/Xavier-KVM/patches/hardware/0001-Enable-KVM-support-for-t210.patch

# Patch the kernel
cd ../kernel/kernel-4.9
for i in ~/Xavier-KVM/patches/kernel/*; do patch -Np1 -i $i; done

# Copy the kernel config to the kernel source tree
cp ~/Xavier-KVM/config-4.9.140-tegra-virt .config
cp ~/Xavier-KVM/config-4.9.140-kvm .config

# Build kernel components
make ARCH=arm64 Image -j8
Expand All @@ -45,15 +48,21 @@ sudo make ARCH=arm64 modules_install -j8

# Install the kernel
# On AGX Xavier, cboot accepts unsigned kernels when Secure Boot is off, which is the default.

# for Xavier
sudo rm /boot/Image.sig
sudo rm /boot/tegra194-p2888-0001-p2822-0000.dtb
sudo rm /boot/tegra194-p2888-0001-p2822-0000.dtb
# for Nano
sudo rm /boot/Image
sudo rm /boot/tegra210-p3448-0000-p3449-0000-a02.dtb

sudo install -m 0644 arch/arm64/boot/Image /boot/
sudo install -m 0644 arch/arm64/boot/Image /boot/
# for Xavier
sudo install -m 0644 arch/arm64/boot/dts/tegra194-p2888-0001-p2822-0000.dtb /boot/dtb/
# for Nano
sudo install -m 0644 arch/arm64/boot/dts/tegra210-p3448-0000-p3449-0000-a02.dtb /boot/dtb/
```

Reboot your Jetson AGX Xavier. After rebooting you can verify that virtualization is enabled
Reboot your Jetson AGX Xavier/Nano. After rebooting you can verify that virtualization is enabled
by running the following commands:

##### Command:
Expand Down
Loading