Initial commit
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
dev/
|
||||
out/
|
||||
19
README.md
19
README.md
@@ -2,3 +2,22 @@
|
||||
|
||||
Kubernetes image for Mono Gateway Development Kit
|
||||
https://docs.mono.si/gateway-development-kit/getting-started
|
||||
|
||||
## Build
|
||||
```
|
||||
make itb # for out/board.itb
|
||||
```
|
||||
|
||||
## tftp (network is required)
|
||||
setenv ipaddr 10.0.0.153
|
||||
setenv serverip 10.0.0.129
|
||||
tftp 0x80000000 board.itb
|
||||
|
||||
## USB
|
||||
usb start
|
||||
usb tree
|
||||
fatls usb 0:1 # For fat
|
||||
ext4ls usb 0:1 # For ext4
|
||||
|
||||
setenv bootargs "console=ttyS0,115200 earlycon=uart8250,mmio,0x21c0500 root=/dev/ram0 rootwait rw"
|
||||
bootm 0x80000000
|
||||
|
||||
45
board.its
Normal file
45
board.its
Normal file
@@ -0,0 +1,45 @@
|
||||
/dts-v1/;
|
||||
|
||||
/ {
|
||||
description = "LS1046A-RDB FIT Image";
|
||||
#address-cells = <1>;
|
||||
|
||||
images {
|
||||
kernel {
|
||||
description = "ARM64 Kernel";
|
||||
data = /incbin/("Image.gz");
|
||||
type = "kernel";
|
||||
arch = "arm64";
|
||||
os = "linux";
|
||||
compression = "gzip";
|
||||
load = <0x84080000>;
|
||||
entry = <0x84080000>;
|
||||
};
|
||||
fdt {
|
||||
description = "DTB";
|
||||
data = /incbin/("fsl-ls1046a-rdb-sdk.dtb");
|
||||
type = "flat_dt";
|
||||
arch = "arm64";
|
||||
compression = "none";
|
||||
load = <0x90000000>;
|
||||
};
|
||||
initrd {
|
||||
description = "Initrd";
|
||||
data = /incbin/("initramfs.cpio.gz");
|
||||
type = "ramdisk";
|
||||
arch = "arm64";
|
||||
os = "linux";
|
||||
compression = "gzip";
|
||||
};
|
||||
};
|
||||
|
||||
configurations {
|
||||
default = "standard";
|
||||
standard {
|
||||
description = "Standard Boot";
|
||||
kernel = "kernel";
|
||||
fdt = "fdt";
|
||||
ramdisk = "initrd";
|
||||
};
|
||||
};
|
||||
};
|
||||
21
build.env
Normal file
21
build.env
Normal file
@@ -0,0 +1,21 @@
|
||||
DOCKER_IMAGE_ROOT=monok8s
|
||||
|
||||
# Image tag
|
||||
TAG=dev
|
||||
|
||||
# The Linux kernel, from NXP
|
||||
NXP_VERSION=lf-6.18.2-1.0.0
|
||||
|
||||
# Mono's tutorial said fsl-ls1046a-rdb.dtb but our shipped board is not that one
|
||||
# We need fsl-ls1046a-rdb-sdk.dtb here
|
||||
DTB_TARGET=fsl-ls1046a-rdb-sdk.dtb
|
||||
|
||||
|
||||
# Arch, should always be arm64 for our board. This is here in case branching off to other devices
|
||||
ARCH=arm64
|
||||
|
||||
CROSS_COMPILE=aarch64-linux-gnu-
|
||||
|
||||
# Busybox for initramfs
|
||||
BUSYBOX_VERSION=1_36_1
|
||||
|
||||
34
docker/build-base.Dockerfile
Normal file
34
docker/build-base.Dockerfile
Normal file
@@ -0,0 +1,34 @@
|
||||
FROM --platform=linux/amd64 debian:bookworm AS kernel-build
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
bash \
|
||||
bc \
|
||||
bison \
|
||||
build-essential \
|
||||
cpio \
|
||||
curl \
|
||||
file \
|
||||
flex \
|
||||
git \
|
||||
libelf-dev \
|
||||
libssl-dev \
|
||||
make \
|
||||
pahole \
|
||||
perl \
|
||||
python3 \
|
||||
rsync \
|
||||
tar \
|
||||
xz-utils \
|
||||
dwarves \
|
||||
gcc-aarch64-linux-gnu \
|
||||
binutils-aarch64-linux-gnu \
|
||||
libc6-dev-arm64-cross \
|
||||
linux-libc-dev-arm64-cross \
|
||||
u-boot-tools \
|
||||
device-tree-compiler \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
34
docker/fit-build.Dockerfile
Normal file
34
docker/fit-build.Dockerfile
Normal file
@@ -0,0 +1,34 @@
|
||||
ARG TAG=dev
|
||||
ARG DOCKER_IMAGE_ROOT=monok8s
|
||||
FROM --platform=linux/amd64 ${DOCKER_IMAGE_ROOT}/build-base:${TAG} AS build
|
||||
|
||||
ARG BUSYBOX_VERSION
|
||||
ARG ARCH
|
||||
ARG CROSS_COMPILE
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
RUN test -n "${BUSYBOX_VERSION}" || (echo "Please specify BUSYBOX_VERSION" >&2; exit 1); \
|
||||
test -n "${ARCH}" || (echo "Please specify ARCH" >&2; exit 1); \
|
||||
test -n "${CROSS_COMPILE}" || (echo "Please specify CROSS_COMPILE" >&2; exit 1)
|
||||
|
||||
COPY dev/busybox.tar.gz ./
|
||||
RUN tar -xf busybox.tar.gz && mv "busybox-${BUSYBOX_VERSION}" busybox
|
||||
|
||||
# RUN curl -L https://github.com/mirror/busybox/archive/refs/tags/${BUSYBOX_VERSION}.tar.gz -o busybox.tar.gz \
|
||||
# && tar -xf busybox.tar.gz \
|
||||
# && mv "busybox-${BUSYBOX_VERSION}" busybox
|
||||
|
||||
WORKDIR /build/busybox
|
||||
|
||||
RUN make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} defconfig \
|
||||
&& sed -i 's/^# CONFIG_STATIC is not set/CONFIG_STATIC=y/' .config
|
||||
RUN make CROSS_COMPILE=${CROSS_COMPILE} -j"$(nproc)"
|
||||
RUN make CROSS_COMPILE=${CROSS_COMPILE} CONFIG_PREFIX=/out/initramfs install
|
||||
|
||||
WORKDIR /out/initramfs
|
||||
|
||||
COPY initramfs/init init
|
||||
RUN chmod +x init
|
||||
RUN mkdir -p bin sbin etc proc sys dev usr/bin usr/sbin
|
||||
RUN find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../initramfs.cpio.gz
|
||||
24
docker/itb.Dockerfile
Normal file
24
docker/itb.Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
||||
ARG TAG=dev
|
||||
ARG DOCKER_IMAGE_ROOT=monok8s
|
||||
FROM ${DOCKER_IMAGE_ROOT}/kernel-build:${TAG} AS kernel
|
||||
FROM ${DOCKER_IMAGE_ROOT}/fit-build:${TAG} AS fit
|
||||
|
||||
FROM --platform=linux/amd64 ${DOCKER_IMAGE_ROOT}/build-base:${TAG} AS build
|
||||
|
||||
ARG DTB_TARGET
|
||||
|
||||
RUN mkdir /image
|
||||
WORKDIR /image
|
||||
|
||||
COPY --from=kernel /out/kernel/Image.gz ./Image.gz
|
||||
COPY --from=kernel /out/kernel/System.map ./
|
||||
COPY --from=kernel /out/kernel/.config ./
|
||||
COPY --from=fit /out/initramfs.cpio.gz ./
|
||||
COPY --from=kernel /out/${DTB_TARGET} ./
|
||||
|
||||
COPY ./board.its ./
|
||||
|
||||
RUN mkimage -f board.its board.itb
|
||||
|
||||
FROM scratch
|
||||
COPY --from=build /image/board.itb /board.itb
|
||||
43
docker/kernel-build.Dockerfile
Normal file
43
docker/kernel-build.Dockerfile
Normal file
@@ -0,0 +1,43 @@
|
||||
ARG TAG=dev
|
||||
ARG DOCKER_IMAGE_ROOT=monok8s
|
||||
FROM --platform=linux/amd64 ${DOCKER_IMAGE_ROOT}/build-base:${TAG}
|
||||
|
||||
ARG NXP_VERSION
|
||||
ARG ARCH
|
||||
ARG CROSS_COMPILE
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
RUN test -n "${NXP_VERSION}" || (echo "Please specify NXP_VERSION" >&2; exit 1); \
|
||||
test -n "${ARCH}" || (echo "Please specify ARCH" >&2; exit 1); \
|
||||
test -n "${CROSS_COMPILE}" || (echo "Please specify CROSS_COMPILE" >&2; exit 1)
|
||||
|
||||
# Dev-only shortcut
|
||||
COPY dev/nxplinux.tar.gz ./
|
||||
RUN tar -xf nxplinux.tar.gz \
|
||||
&& mv "linux-${NXP_VERSION}" nxplinux \
|
||||
&& rm -f nxplinux.tar.gz
|
||||
|
||||
# Or download directly:
|
||||
# RUN curl -L "https://github.com/nxp-qoriq/linux/archive/refs/tags/${NXP_VERSION}.tar.gz" -o nxplinux.tar.gz \
|
||||
# && tar -xf nxplinux.tar.gz \
|
||||
# && mv "linux-${NXP_VERSION}" nxplinux \
|
||||
# && rm -f nxplinux.tar.gz
|
||||
|
||||
WORKDIR /build/nxplinux
|
||||
|
||||
# NXP tree: use the LSDK defconfig target
|
||||
RUN make ARCH="${ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" defconfig lsdk.config
|
||||
RUN make ARCH="${ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" -j"$(nproc)"
|
||||
|
||||
# artifact collection
|
||||
RUN mkdir -p /out/kernel /out/rootfs \
|
||||
&& cp -av arch/arm64/boot/Image* /out/kernel/ 2>/dev/null || true \
|
||||
&& cp -av arch/arm64/boot/dts /out/kernel/dts 2>/dev/null || true \
|
||||
&& cp -av System.map .config /out/kernel/ \
|
||||
&& make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} modules_install INSTALL_MOD_PATH=/out/rootfs
|
||||
|
||||
ARG DTB_TARGET
|
||||
|
||||
RUN find /out/kernel -name "${DTB_TARGET}" -exec cp {} /out/ \;
|
||||
RUN test -f "/out/${DTB_TARGET}"
|
||||
20
initramfs/init
Executable file
20
initramfs/init
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
mount -t proc none /proc
|
||||
mount -t sysfs none /sys
|
||||
|
||||
cat <<!
|
||||
|
||||
_ _ _ __ __ _
|
||||
| | | (_) | \/ | | |
|
||||
| |__| |_ | \ / | ___ _ __ ___ | |
|
||||
| __ | | | |\/| |/ _ \| '_ \ / _ \| |
|
||||
| | | | |_ | | | | (_) | | | | (_) |_|
|
||||
|_| |_|_( ) |_| |_|\___/|_| |_|\___/(_)
|
||||
|/
|
||||
|
||||
Booting kernel took $(cut -d' ' -f1 /proc/uptime) seconds.
|
||||
|
||||
!
|
||||
exec /bin/sh
|
||||
EOF
|
||||
41
makefile
Normal file
41
makefile
Normal file
@@ -0,0 +1,41 @@
|
||||
include build.env
|
||||
export
|
||||
|
||||
TAG ?= dev
|
||||
|
||||
build-base:
|
||||
docker build \
|
||||
-f docker/build-base.Dockerfile \
|
||||
--build-arg TAG=$(TAG) \
|
||||
-t $(DOCKER_IMAGE_ROOT)/build-base:$(TAG) .
|
||||
|
||||
kernel-build: build-base
|
||||
docker build \
|
||||
-f docker/kernel-build.Dockerfile \
|
||||
--build-arg DOCKER_IMAGE_ROOT=$(DOCKER_IMAGE_ROOT) \
|
||||
--build-arg TAG=$(TAG) \
|
||||
--build-arg ARCH=$(ARCH) \
|
||||
--build-arg CROSS_COMPILE=$(CROSS_COMPILE) \
|
||||
--build-arg NXP_VERSION=$(NXP_VERSION) \
|
||||
--build-arg DTB_TARGET=$(DTB_TARGET) \
|
||||
-t $(DOCKER_IMAGE_ROOT)/kernel-build:$(TAG) .
|
||||
|
||||
fit-build: build-base
|
||||
docker build \
|
||||
-f docker/fit-build.Dockerfile \
|
||||
--build-arg DOCKER_IMAGE_ROOT=$(DOCKER_IMAGE_ROOT) \
|
||||
--build-arg TAG=$(TAG) \
|
||||
--build-arg ARCH=$(ARCH) \
|
||||
--build-arg CROSS_COMPILE=$(CROSS_COMPILE) \
|
||||
--build-arg BUSYBOX_VERSION=$(BUSYBOX_VERSION) \
|
||||
-t $(DOCKER_IMAGE_ROOT)/fit-build:$(TAG) .
|
||||
|
||||
itb: fit-build kernel-build
|
||||
docker build \
|
||||
-f docker/itb.Dockerfile \
|
||||
--build-arg DOCKER_IMAGE_ROOT=$(DOCKER_IMAGE_ROOT) \
|
||||
--build-arg TAG=$(TAG) \
|
||||
--build-arg ARCH=$(ARCH) \
|
||||
--build-arg DTB_TARGET=$(DTB_TARGET) \
|
||||
--output type=local,dest=./out \
|
||||
-t $(DOCKER_IMAGE_ROOT)/itb:$(TAG) .
|
||||
Reference in New Issue
Block a user