Added kernel-extra.config for customization
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
dev/
|
dev/
|
||||||
out/
|
out/
|
||||||
|
.swp
|
||||||
|
|||||||
30
README.md
30
README.md
@@ -6,6 +6,35 @@ https://docs.mono.si/gateway-development-kit/getting-started
|
|||||||
## Build
|
## Build
|
||||||
```
|
```
|
||||||
make itb # for out/board.itb
|
make itb # for out/board.itb
|
||||||
|
make release # WORK IN PROGRESS
|
||||||
|
```
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
- A/B deployment
|
||||||
|
- Read-only OS
|
||||||
|
|
||||||
|
## Upgrade process
|
||||||
|
Rough idea
|
||||||
|
|
||||||
|
```
|
||||||
|
./configure
|
||||||
|
# - join cluster config
|
||||||
|
|
||||||
|
make release
|
||||||
|
|
||||||
|
|
||||||
|
# Copy the new image to the upgrade-scheduler
|
||||||
|
kubectl cp -n kube-system upgrade-scheduler:/tmp/upgrade.img
|
||||||
|
|
||||||
|
# Upgrade scheduler reads the file that issue a self-reboot
|
||||||
|
reboot
|
||||||
|
|
||||||
|
# uboot to boot into partition B
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
PENDING
|
||||||
```
|
```
|
||||||
|
|
||||||
## tftp (network is required)
|
## tftp (network is required)
|
||||||
@@ -18,6 +47,7 @@ usb start
|
|||||||
usb tree
|
usb tree
|
||||||
fatls usb 0:1 # For fat
|
fatls usb 0:1 # For fat
|
||||||
ext4ls usb 0:1 # For ext4
|
ext4ls usb 0:1 # For ext4
|
||||||
|
fatload usb 0 0x80000000 board.itb
|
||||||
|
|
||||||
setenv bootargs "console=ttyS0,115200 earlycon=uart8250,mmio,0x21c0500 root=/dev/ram0 rootwait rw"
|
setenv bootargs "console=ttyS0,115200 earlycon=uart8250,mmio,0x21c0500 root=/dev/ram0 rootwait rw"
|
||||||
bootm 0x80000000
|
bootm 0x80000000
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
file \
|
file \
|
||||||
flex \
|
flex \
|
||||||
git \
|
git \
|
||||||
|
kmod \
|
||||||
libelf-dev \
|
libelf-dev \
|
||||||
libssl-dev \
|
libssl-dev \
|
||||||
make \
|
make \
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
ARG TAG=dev
|
ARG TAG=dev
|
||||||
ARG DOCKER_IMAGE_ROOT=monok8s
|
ARG DOCKER_IMAGE_ROOT=monok8s
|
||||||
|
FROM --platform=linux/amd64 ${DOCKER_IMAGE_ROOT}/kernel-build:${TAG} AS kernel
|
||||||
|
|
||||||
|
# Selective mods
|
||||||
|
RUN mkdir /out/selected-mods
|
||||||
|
COPY initramfs/selective-mods.sh /
|
||||||
|
RUN /selective-mods.sh /out/rootfs/lib/modules/$(ls /out/rootfs/lib/modules/) /out/selected-mods
|
||||||
|
|
||||||
FROM --platform=linux/amd64 ${DOCKER_IMAGE_ROOT}/build-base:${TAG} AS build
|
FROM --platform=linux/amd64 ${DOCKER_IMAGE_ROOT}/build-base:${TAG} AS build
|
||||||
|
|
||||||
ARG BUSYBOX_VERSION
|
ARG BUSYBOX_VERSION
|
||||||
@@ -30,5 +37,8 @@ WORKDIR /out/initramfs
|
|||||||
|
|
||||||
COPY initramfs/init init
|
COPY initramfs/init init
|
||||||
RUN chmod +x init
|
RUN chmod +x init
|
||||||
RUN mkdir -p bin sbin etc proc sys dev usr/bin usr/sbin
|
RUN mkdir -p bin sbin etc proc sys dev lib usr/bin usr/sbin
|
||||||
|
|
||||||
|
COPY --from=kernel /out/selected-mods/* ./lib/
|
||||||
|
|
||||||
RUN find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../initramfs.cpio.gz
|
RUN find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../initramfs.cpio.gz
|
||||||
|
|||||||
@@ -26,9 +26,13 @@ RUN tar -xf nxplinux.tar.gz \
|
|||||||
|
|
||||||
WORKDIR /build/nxplinux
|
WORKDIR /build/nxplinux
|
||||||
|
|
||||||
|
COPY kernel-extra.config /tmp/kernel-extra.config
|
||||||
|
|
||||||
# NXP tree: use the LSDK defconfig target
|
# 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}" defconfig lsdk.config \
|
||||||
RUN make ARCH="${ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" -j"$(nproc)"
|
&& ./scripts/kconfig/merge_config.sh -m .config /tmp/kernel-extra.config \
|
||||||
|
&& make ARCH="${ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig \
|
||||||
|
&& make ARCH="${ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" -j"$(nproc)"
|
||||||
|
|
||||||
# artifact collection
|
# artifact collection
|
||||||
RUN mkdir -p /out/kernel /out/rootfs \
|
RUN mkdir -p /out/kernel /out/rootfs \
|
||||||
@@ -37,6 +41,8 @@ RUN mkdir -p /out/kernel /out/rootfs \
|
|||||||
&& cp -av System.map .config /out/kernel/ \
|
&& cp -av System.map .config /out/kernel/ \
|
||||||
&& make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} modules_install INSTALL_MOD_PATH=/out/rootfs
|
&& make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} modules_install INSTALL_MOD_PATH=/out/rootfs
|
||||||
|
|
||||||
|
RUN depmod -b /out/rootfs $(ls /out/rootfs/lib/modules/)
|
||||||
|
|
||||||
ARG DTB_TARGET
|
ARG DTB_TARGET
|
||||||
|
|
||||||
RUN find /out/kernel -name "${DTB_TARGET}" -exec cp {} /out/ \;
|
RUN find /out/kernel -name "${DTB_TARGET}" -exec cp {} /out/ \;
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
mount -t proc none /proc
|
mount -t devtmpfs devtmpfs /dev
|
||||||
mount -t sysfs none /sys
|
mount -t proc proc /proc
|
||||||
|
mount -t sysfs sysfs /sys
|
||||||
|
|
||||||
cat <<!
|
# Optional but nice
|
||||||
|
mkdir -p /dev/pts
|
||||||
|
mount -t devpts devpts /dev/pts
|
||||||
|
|
||||||
_ _ _ __ __ _
|
echo "Booting kernel took $(cut -d' ' -f1 /proc/uptime) seconds."
|
||||||
| | | (_) | \/ | | |
|
echo "Dropping to shell on ttyS0..."
|
||||||
| |__| |_ | \ / | ___ _ __ ___ | |
|
|
||||||
| __ | | | |\/| |/ _ \| '_ \ / _ \| |
|
|
||||||
| | | | |_ | | | | (_) | | | | (_) |_|
|
|
||||||
|_| |_|_( ) |_| |_|\___/|_| |_|\___/(_)
|
|
||||||
|/
|
|
||||||
|
|
||||||
Booting kernel took $(cut -d' ' -f1 /proc/uptime) seconds.
|
while true; do
|
||||||
|
setsid cttyhack /bin/sh
|
||||||
|
echo "Shell exited. Starting another one..."
|
||||||
|
done
|
||||||
|
|
||||||
!
|
exec poweroff -f
|
||||||
exec /bin/sh
|
|
||||||
EOF
|
|
||||||
|
|||||||
107
initramfs/selective-mods.sh
Executable file
107
initramfs/selective-mods.sh
Executable file
@@ -0,0 +1,107 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Stage a subset of kernel modules into a target rootfs/initramfs tree.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# ./stage-initramfs-modules.sh \
|
||||||
|
# /out/rootfs/lib/modules/6.18.2 \
|
||||||
|
# /out/initramfs
|
||||||
|
#
|
||||||
|
# Result:
|
||||||
|
# /out/initramfs/lib/modules/6.18.2/...
|
||||||
|
#
|
||||||
|
# Notes:
|
||||||
|
# - This copies selected directories and modules.* metadata.
|
||||||
|
# - It does NOT run depmod for you unless you uncomment that section.
|
||||||
|
# - Best run after kernel modules have already been installed into the source tree.
|
||||||
|
|
||||||
|
if [[ $# -ne 2 ]]; then
|
||||||
|
echo "Usage: $0 <source-lib-modules-version-dir> <dest-root>"
|
||||||
|
echo "Example: $0 /out/rootfs/lib/modules/6.18.2 /out/initramfs"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SRC_MODDIR="$1" # e.g. /out/rootfs/lib/modules/6.18.2
|
||||||
|
DEST_ROOT="$2" # e.g. /out/initramfs
|
||||||
|
|
||||||
|
if [[ ! -d "$SRC_MODDIR" ]]; then
|
||||||
|
echo "Source module dir does not exist: $SRC_MODDIR" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
KVER="$(basename "$SRC_MODDIR")"
|
||||||
|
DEST_MODDIR="$DEST_ROOT/lib/modules/$KVER"
|
||||||
|
|
||||||
|
mkdir -p "$DEST_MODDIR"
|
||||||
|
|
||||||
|
echo "==> Source: $SRC_MODDIR"
|
||||||
|
echo "==> Dest: $DEST_MODDIR"
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Relative paths under /lib/modules/<version>
|
||||||
|
PATHS=(
|
||||||
|
# Metadata files used by modprobe/depmod.
|
||||||
|
"modules.builtin"
|
||||||
|
"modules.builtin.modinfo"
|
||||||
|
"modules.order"
|
||||||
|
|
||||||
|
"modules.dep"
|
||||||
|
"modules.dep.bin"
|
||||||
|
"modules.alias"
|
||||||
|
"modules.alias.bin"
|
||||||
|
"modules.symbols"
|
||||||
|
"modules.symbols.bin"
|
||||||
|
"modules.softdep"
|
||||||
|
|
||||||
|
# Core module dirs we may need.
|
||||||
|
"kernel/drivers/pwm"
|
||||||
|
"kernel/drivers/hwmon"
|
||||||
|
"kernel/drivers/thermal"
|
||||||
|
|
||||||
|
# Optional
|
||||||
|
# "kernel/drivers/i2c"
|
||||||
|
# "kernel/drivers/gpio"
|
||||||
|
# "kernel/drivers/base"
|
||||||
|
# "kernel/drivers/power"
|
||||||
|
# "kernel/drivers/platform"
|
||||||
|
)
|
||||||
|
|
||||||
|
copy_one() {
|
||||||
|
local rel="$1"
|
||||||
|
local src="$SRC_MODDIR/$rel"
|
||||||
|
local dst="$DEST_MODDIR/$rel"
|
||||||
|
|
||||||
|
if [[ -d "$src" ]]; then
|
||||||
|
echo "[DIR ] $rel"
|
||||||
|
mkdir -p "$(dirname "$dst")"
|
||||||
|
cp -a "$src" "$dst"
|
||||||
|
elif [[ -f "$src" ]]; then
|
||||||
|
echo "[FILE] $rel"
|
||||||
|
mkdir -p "$(dirname "$dst")"
|
||||||
|
cp -a "$src" "$dst"
|
||||||
|
else
|
||||||
|
echo "[MISS] $rel"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
for rel in "${PATHS[@]}"; do
|
||||||
|
copy_one "$rel"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "==> Done staging selected modules."
|
||||||
|
|
||||||
|
# Optional: show what got copied
|
||||||
|
echo
|
||||||
|
echo "==> Staged files summary:"
|
||||||
|
find "$DEST_MODDIR" -type f | sed "s#^$DEST_ROOT/##" | sort
|
||||||
|
|
||||||
|
# Optional: if depmod exists INSIDE the build environment and you want to
|
||||||
|
# regenerate metadata for the destination tree, uncomment this block.
|
||||||
|
#
|
||||||
|
# if command -v depmod >/dev/null 2>&1; then
|
||||||
|
# echo
|
||||||
|
# echo "==> Running depmod for destination tree..."
|
||||||
|
# depmod -b "$DEST_ROOT" "$KVER"
|
||||||
|
# fi
|
||||||
3
kernel-extra.config
Normal file
3
kernel-extra.config
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
CONFIG_HWMON=y
|
||||||
|
CONFIG_I2C=y
|
||||||
|
CONFIG_SENSORS_EMC2305=y
|
||||||
4
makefile
4
makefile
@@ -20,7 +20,7 @@ kernel-build: build-base
|
|||||||
--build-arg DTB_TARGET=$(DTB_TARGET) \
|
--build-arg DTB_TARGET=$(DTB_TARGET) \
|
||||||
-t $(DOCKER_IMAGE_ROOT)/kernel-build:$(TAG) .
|
-t $(DOCKER_IMAGE_ROOT)/kernel-build:$(TAG) .
|
||||||
|
|
||||||
fit-build: build-base
|
fit-build: kernel-build
|
||||||
docker build \
|
docker build \
|
||||||
-f docker/fit-build.Dockerfile \
|
-f docker/fit-build.Dockerfile \
|
||||||
--build-arg DOCKER_IMAGE_ROOT=$(DOCKER_IMAGE_ROOT) \
|
--build-arg DOCKER_IMAGE_ROOT=$(DOCKER_IMAGE_ROOT) \
|
||||||
@@ -30,7 +30,7 @@ fit-build: build-base
|
|||||||
--build-arg BUSYBOX_VERSION=$(BUSYBOX_VERSION) \
|
--build-arg BUSYBOX_VERSION=$(BUSYBOX_VERSION) \
|
||||||
-t $(DOCKER_IMAGE_ROOT)/fit-build:$(TAG) .
|
-t $(DOCKER_IMAGE_ROOT)/fit-build:$(TAG) .
|
||||||
|
|
||||||
itb: fit-build kernel-build
|
itb: fit-build
|
||||||
docker build \
|
docker build \
|
||||||
-f docker/itb.Dockerfile \
|
-f docker/itb.Dockerfile \
|
||||||
--build-arg DOCKER_IMAGE_ROOT=$(DOCKER_IMAGE_ROOT) \
|
--build-arg DOCKER_IMAGE_ROOT=$(DOCKER_IMAGE_ROOT) \
|
||||||
|
|||||||
Reference in New Issue
Block a user