commit 9c97871f9785494fa06507c62c712b8bb4412992c328962628b376c24a4bb4ad
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2026-03-20T14:58:57Z |
| subject | Initial commit |
commit 9c97871f9785494fa06507c62c712b8bb4412992c328962628b376c24a4bb4ad
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2026-03-20T14:58:57Z
Initial commit
---
.gitignore | 2 ++
README.md | 21 +++++++++++++++++++-
board.its | 45 ++++++++++++++++++++++++++++++++++++++++++
build.env | 21 ++++++++++++++++++++
docker/build-base.Dockerfile | 34 +++++++++++++++++++++++++++++++
docker/fit-build.Dockerfile | 34 +++++++++++++++++++++++++++++++
docker/itb.Dockerfile | 24 ++++++++++++++++++++++
docker/kernel-build.Dockerfile | 43 ++++++++++++++++++++++++++++++++++++++++
initramfs/init | 20 +++++++++++++++++++
makefile | 41 ++++++++++++++++++++++++++++++++++++++
out/.keep | 0
11 files changed, 284 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8c0964c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+dev/
+out/
diff --git a/README.md b/README.md
index cc74cf5..a1e7acd 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,23 @@
# monok8s
Kubernetes image for Mono Gateway Development Kit
-https://docs.mono.si/gateway-development-kit/getting-started
\ No newline at end of file
+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
diff --git a/board.its b/board.its
new file mode 100644
index 0000000..6994516
--- /dev/null
+++ b/board.its
@@ -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";
+ };
+ };
+};
diff --git a/build.env b/build.env
new file mode 100644
index 0000000..6c6f118
--- /dev/null
+++ b/build.env
@@ -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
+
diff --git a/docker/build-base.Dockerfile b/docker/build-base.Dockerfile
new file mode 100644
index 0000000..1aba290
--- /dev/null
+++ b/docker/build-base.Dockerfile
@@ -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/*
+
diff --git a/docker/fit-build.Dockerfile b/docker/fit-build.Dockerfile
new file mode 100644
index 0000000..e5f831b
--- /dev/null
+++ b/docker/fit-build.Dockerfile
@@ -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
diff --git a/docker/itb.Dockerfile b/docker/itb.Dockerfile
new file mode 100644
index 0000000..f518948
--- /dev/null
+++ b/docker/itb.Dockerfile
@@ -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
diff --git a/docker/kernel-build.Dockerfile b/docker/kernel-build.Dockerfile
new file mode 100644
index 0000000..c281237
--- /dev/null
+++ b/docker/kernel-build.Dockerfile
@@ -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}"
diff --git a/initramfs/init b/initramfs/init
new file mode 100755
index 0000000..f0ba2f1
--- /dev/null
+++ b/initramfs/init
@@ -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
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..1c77107
--- /dev/null
+++ b/makefile
@@ -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) .
diff --git a/out/.keep b/out/.keep
new file mode 100644
index 0000000..473a0f4