Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fe7cc6a
Add BR2_PACKAGE_OPENIPC_NFS_ROOT buildroot package
tinylabs Jun 9, 2026
c009342
Merge branch 'upstream/master' into br-package-nfs-root
tinylabs Jun 9, 2026
c49db59
Fix invalid str reference in openipc_ethaddr
tinylabs Jun 9, 2026
f0db936
Update userspace boot scripts, add password and timezone config
tinylabs Jun 10, 2026
e9bb41a
Add config for NTP and DNS. make_nfsroot helper script
tinylabs Jun 11, 2026
ad7e38a
Unify linux init script
tinylabs Jun 11, 2026
4529767
Make nfs root rw behave as expected
tinylabs Jun 11, 2026
fd55557
Update patched ipconfig.c kernel msg
tinylabs Jun 11, 2026
baa57aa
Fix formatting space => tabs
tinylabs Jun 11, 2026
bf2a084
Merge branch 'upstream/master' into br-package-nfs-root
tinylabs Jun 11, 2026
228a596
Cleanup, add hostname support, fix DNS/NTP, hash passwd in helper script
tinylabs Jun 12, 2026
e234ea1
Merge branch 'master' into br-package-nfs-root
widgetii Jun 12, 2026
0c941ca
Fix compile error when feature disabled. Start udhcpc daemon when ker…
tinylabs Jun 13, 2026
dfc77e5
Merge remote-tracking branch 'refs/remotes/origin/br-package-nfs-root…
tinylabs Jun 13, 2026
1266d36
network init/dhcpc should run on every boot for nfs root
tinylabs Jun 13, 2026
0c5b28d
Allow Makefile to see openipc.fragment for repack rule
tinylabs Jun 14, 2026
2b520c7
Update make_nfsroot for prev Makefile commit
tinylabs Jun 15, 2026
84b4844
Cleanup S45setupenv, add msgs when fs defaults are used
tinylabs Jun 15, 2026
2ac4835
Refactor networking, make lo/eth0 no-ops to prevent any process takin…
tinylabs Jun 15, 2026
cdaf50e
Add sed comment in post-build-hook
tinylabs Jun 15, 2026
a92d85b
Merge /init from package overlay to common overlay
tinylabs Jun 15, 2026
144231e
Update kernel patch to support missing eth_hw_addr_set
tinylabs Jun 15, 2026
b51a227
Add note about insecure default password in buildroot config
tinylabs Jun 15, 2026
b1e428f
Merge branch 'upstream/master' into br-package-nfs-root
tinylabs Jun 15, 2026
ba7d520
Merge branch 'master' into br-package-nfs-root
tinylabs Jun 17, 2026
4867a46
Merge branch 'master' into br-package-nfs-root
widgetii Jun 18, 2026
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
25 changes: 24 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ CONFIG := $(shell find br-ext-*/configs/*_defconfig | grep -m1 $(BOARD))
include $(CONFIG)
endif

all: build repack timer
ifneq ($(filter repack,$(MAKECMDGOALS)),)
-include $(BR_CONF)
endif

all: repack-final timer

build: defconfig
@$(BR_MAKE) all -j$(shell nproc)
Expand All @@ -39,6 +43,14 @@ prepare:
@if test ! -e $(TARGET)/buildroot-$(BR_VER); then \
wget -c -q $(BR_LINK)/$(BR_VER).tar.gz -O $(BR_FILE); \
mkdir -p $(TARGET); tar -xf $(BR_FILE) -C $(TARGET); fi
@if test -f $(TARGET)/buildroot-$(BR_VER)/linux/Config.in; then \
sed -i '/source "$$(BR2_EXTERNAL_GENERAL_PATH)\/linux\/Config.ext.in"/d' \
$(TARGET)/buildroot-$(BR_VER)/linux/Config.in; \
grep -qF 'source "$$BR2_EXTERNAL_GENERAL_PATH/linux/Config.ext.in"' \
$(TARGET)/buildroot-$(BR_VER)/linux/Config.in || \
sed -i '/source "linux\/Config.ext.in"/a source "$$BR2_EXTERNAL_GENERAL_PATH/linux/Config.ext.in"' \
$(TARGET)/buildroot-$(BR_VER)/linux/Config.in; \
fi

help:
@printf "BR-OpenIPC usage:\n \
Expand Down Expand Up @@ -98,7 +110,17 @@ endif
@$(BR_MAKE) sdk -j$(shell nproc)
@$(call BUNDLE_SDK)

repack-final: build
@$(MAKE) --no-print-directory BOARD=$(BOARD) TARGET=$(TARGET) repack

repack:
ifeq ($(BR2_PACKAGE_OPENIPC_NFS_ROOT),y)
ifeq ($(BR2_OPENIPC_SOC_VENDOR),"rockchip")
@$(call PREPARE_REPACK,zboot.img,16384,,,nfs-root)
else
@$(call PREPARE_REPACK,uImage,16384,,,nfs-root)
endif
else
ifeq ($(BR2_OPENIPC_SOC_FAMILY),"hi3516cv6xx")
@$(call PREPARE_REPACK,firmware.bin,$(shell expr $(subst ",,$(BR2_OPENIPC_FLASH_SIZE)) \* 1024),,,nor)
else ifneq ($(wildcard $(TARGET)/images/firmware.bin),)
Expand All @@ -124,6 +146,7 @@ ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y)
@$(call PREPARE_REPACK,uImage,16384,,,initramfs)
endif
endif
endif

size-report:
@TARGET_DIR=$(TARGET)/target \
Expand Down
148 changes: 148 additions & 0 deletions contrib/make_nfsroot
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#!/bin/sh
set -eu

usage() {
printf '%s\n' \
"Usage: $0 <defconfig> [optional args]" \
' Optional args:' \
' --passwd Plaintext or hash ($1$...)' \
' --tz iana-timezone (Europe/Berlin)' \
' --ntp NTP server' \
' --dns DNS server' \
' --hostname fallback hostname' \
' --pkgs File with additional buildroot pkgs'
exit 1
}

[ $# -ge 1 ] || usage

FRAGMENT=general/openipc.fragment
FRAGMENT_BAK=
BOARD=
PASSWD=
TIMEZONE=
NTP=
DNS=
HOSTNAME=
PKGS=

while [ $# -gt 0 ]; do
case "$1" in
--passwd)
[ $# -ge 2 ] || usage
PASSWD=$2
shift 2
case "$PASSWD" in
'$'[0-9]'$'*)
;;
*)
PASSWD=$(mkpasswd -5 "$PASSWD")
;;
esac
;;
--tz)
[ $# -ge 2 ] || usage
TIMEZONE=$2
shift 2
;;
--ntp)
[ $# -ge 2 ] || usage
NTP=$2
shift 2
;;
--dns)
[ $# -ge 2 ] || usage
DNS=$2
shift 2
;;
--hostname)
[ $# -ge 2 ] || usage
HOSTNAME=$2
shift 2
;;
--pkgs)
[ $# -ge 2 ] || usage
PKGS=$2
shift 2
;;
--help|-h)
usage
;;
--*)
echo "Unknown option: $1" >&2
usage
;;
*)
if [ -z "$BOARD" ]; then
BOARD=$1
shift
else
echo "Unexpected argument: $1" >&2
usage
fi
;;
esac
done

[ -n "$BOARD" ] || usage

cleanup() {
if [ -n "$FRAGMENT_BAK" ] && [ -f "$FRAGMENT_BAK" ]; then
cp "$FRAGMENT_BAK" "$FRAGMENT"
rm -f "$FRAGMENT_BAK"
fi
}

FRAGMENT_BAK=$(mktemp "${TMPDIR:-/tmp}/openipc.fragment.XXXXXX")
cp "$FRAGMENT" "$FRAGMENT_BAK"
trap cleanup EXIT HUP INT TERM

cat >> "$FRAGMENT" <<EOF

# Temporary settings generated by make_nfsroot.
BR2_PACKAGE_OPENIPC_NFS_ROOT=y
EOF

if [ -n "$PASSWD" ]; then
cat >> "$FRAGMENT" <<EOF
BR2_PACKAGE_OPENIPC_NFS_ROOT_PASSWD="$PASSWD"
EOF
fi

if [ -n "$TIMEZONE" ]; then
cat >> "$FRAGMENT" <<EOF
BR2_PACKAGE_OPENIPC_NFS_ROOT_TIMEZONE="$TIMEZONE"
EOF
fi

if [ -n "$NTP" ]; then
cat >> "$FRAGMENT" <<EOF
BR2_PACKAGE_OPENIPC_NFS_ROOT_NTP_SERVER="$NTP"
EOF
fi

if [ -n "$DNS" ]; then
cat >> "$FRAGMENT" <<EOF
BR2_PACKAGE_OPENIPC_NFS_ROOT_DNS_SERVER="$DNS"
EOF
fi

if [ -n "$HOSTNAME" ]; then
cat >> "$FRAGMENT" <<EOF
BR2_PACKAGE_OPENIPC_NFS_ROOT_HOSTNAME="$HOSTNAME"
EOF
fi

# Add additional packages for nfs build
if [ -n "$PKGS" ] && [ -f "$PKGS" ]; then
cat "$PKGS" >> "$FRAGMENT"
fi

make BOARD="$BOARD" || exit 1

KERNEL=$(find output/images/ -regextype posix-extended -iregex '.*/(uimage|zimage).*')
ROOTFS=$(find output/images/ -name '*.tar')
echo "\nNFS-root build complete"
echo "-----------------------"
echo kernel: "["$(du -h ${KERNEL} | awk '{print $1}')"]\t" $KERNEL
echo rootfs: "["$(du -h ${ROOTFS} | awk '{print $1}')"]\t" $ROOTFS
4 changes: 4 additions & 0 deletions general/linux/Config.ext.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
config BR2_LINUX_KERNEL_EXT_OPENIPC_NFS_ROOT
bool "openipc-nfs-root kernel extension"
help
Apply OpenIPC NFS-root-specific kernel changes.
27 changes: 27 additions & 0 deletions general/linux/linux-ext-openipc-nfs-root.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
################################################################################
#
# openipc-nfs-root kernel extension
#
################################################################################

LINUX_EXTENSIONS += openipc-nfs-root

define OPENIPC_NFS_ROOT_SYNC_ETHADDR_SOURCE
cp $(BR2_EXTERNAL_GENERAL_PATH)/package/openipc-nfs-root/files/openipc_ethaddr.c \
$(@D)/drivers/net/ethernet/openipc_ethaddr.c
grep -q '^obj-y += openipc_ethaddr.o$$' $(@D)/drivers/net/ethernet/Makefile || \
echo 'obj-y += openipc_ethaddr.o' >> $(@D)/drivers/net/ethernet/Makefile
endef

define OPENIPC_NFS_ROOT_CHECK_KERNEL_SUPPORT
grep -qr 'eth_platform_get_mac_address' $(@D)/net $(@D)/include 2>/dev/null || { \
echo "openipc-nfs-root requires Linux >= 4.5 or a vendor kernel with eth_platform_get_mac_address() support" >&2; \
exit 1; \
}
endef

define OPENIPC_NFS_ROOT_PREPARE_KERNEL
$(OPENIPC_NFS_ROOT_CHECK_KERNEL_SUPPORT)
$(APPLY_PATCHES) $(@D) $(BR2_EXTERNAL_GENERAL_PATH)/package/openipc-nfs-root/kernel-patches \*.patch
$(OPENIPC_NFS_ROOT_SYNC_ETHADDR_SOURCE)
endef
16 changes: 15 additions & 1 deletion general/overlay/init
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ trap on_exit EXIT
mount -t proc proc /proc || exit 1
grep -q overlay /proc/filesystems || exit 1

if ! grep -q 'root=.*nfs\|mmcblk\|ram' /proc/cmdline; then
is_flash_root=true
is_nfs_root=false
grep -q 'root=.*nfs\|mmcblk\|ram' /proc/cmdline && is_flash_root=false
grep -q 'root=.*nfs' /proc/cmdline && is_nfs_root=true

if $is_flash_root; then
if grep -q ubifs /proc/cmdline; then
mount -t ubifs ubi0:rootfs_data /overlay
else
Expand All @@ -27,7 +32,16 @@ if ! grep -q 'root=.*nfs\|mmcblk\|ram' /proc/cmdline; then
fi
fi
fi
elif $is_nfs_root && grep -q ' ro ' /proc/cmdline; then
TMPFS_SIZE='@TMPFS_SIZE@'
TMPFS_SIZE="${TMPFS_SIZE:-16M}"
if ! mount -t tmpfs -o mode=0755,size=${TMPFS_SIZE} tmpfs /overlay; then
echo "Cannot mount tmpfs overlay."
exit 1
fi
fi

if $is_flash_root || $is_nfs_root; then
if grep -q overlayfs /proc/filesystems; then
if ! mount -t overlayfs overlayfs -o lowerdir=/,upperdir=/overlay,ro /mnt; then
umount /overlay
Expand Down
1 change: 1 addition & 0 deletions general/package/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ source "$BR2_EXTERNAL_GENERAL_PATH/package/novatek-osdrv-nt9856x/Config.in"
source "$BR2_EXTERNAL_GENERAL_PATH/package/ntfy/Config.in"
source "$BR2_EXTERNAL_GENERAL_PATH/package/onvif-simple-server/Config.in"
source "$BR2_EXTERNAL_GENERAL_PATH/package/openipc-precision-time/Config.in"
source "$BR2_EXTERNAL_GENERAL_PATH/package/openipc-nfs-root/Config.in"
source "$BR2_EXTERNAL_GENERAL_PATH/package/opus-openipc/Config.in"
source "$BR2_EXTERNAL_GENERAL_PATH/package/osd-openipc/Config.in"
source "$BR2_EXTERNAL_GENERAL_PATH/package/quirc-openipc/Config.in"
Expand Down
67 changes: 67 additions & 0 deletions general/package/openipc-nfs-root/Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
config BR2_PACKAGE_OPENIPC_NFS_ROOT
bool "OpenIPC NFS root"
depends on BR2_LINUX_KERNEL
select BR2_LINUX_KERNEL_EXT_OPENIPC_NFS_ROOT
help
NFS-root-specific files and scripts for OpenIPC builds.

When enabled, the post-build flow replaces /init with an NFS
aware init script that mounts a writable tmpfs overlay on top
of a readonly NFS root.

Add any NFS-only init scripts, helper files, or deployment
hooks here as the workflow is fleshed out.

if BR2_PACKAGE_OPENIPC_NFS_ROOT

config BR2_PACKAGE_OPENIPC_NFS_ROOT_TMPFS_SIZE
string "TMPFS size"
default "16M"
help
Size passed to the tmpfs mount used for the writable overlay
when NFS root is mounted in readonly mode.

config BR2_PACKAGE_OPENIPC_NFS_ROOT_PASSWD
string "Root password"
default "12345"
help
Root password to be set during boot. Useful for immutable rootfs.
Can be plaintext or a password hash.
Note: Should set password for production env. Default is 12345

config BR2_PACKAGE_OPENIPC_NFS_ROOT_TIMEZONE
string "IANA timezone"
default ""
help
IANA timezone name used to derive a POSIX TZ rule at build time,
for example: America/Denver or Europe/Berlin.

When left empty, the build attempts to detect the timezone from the
build host and derives the POSIX TZ rule from that zone.

config BR2_PACKAGE_OPENIPC_NFS_ROOT_NTP_SERVER
string "NTP server"
default ""
help
Static NTP server to use.

When left empty, the build uses the default route fo the NTP server.

config BR2_PACKAGE_OPENIPC_NFS_ROOT_DNS_SERVER
string "DNS server"
default ""
help
Static DNS server to use.

When left empty, the build uses the default route fo the DNS server.

config BR2_PACKAGE_OPENIPC_NFS_ROOT_HOSTNAME
string "Hostname"
default ""
help
Fallback hostname.

If server supplied hostname and uboot env hostname don't exist then
use this hostname.

endif
34 changes: 34 additions & 0 deletions general/package/openipc-nfs-root/files/S39netprofiles
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh
#
# Install network profiles for nfs root
#

install_net_profiles() {
# Backup original profiles
if [ ! -f /etc/network/profile/eth0 ]; then
cp /etc/network/interfaces.d/eth0 /etc/network/profiles/eth0
fi
if [ ! -f /etc/network/profile/interfaces ]; then
cp /etc/network/interfaces /etc/network/profiles/interfaces
fi

# Install no-op profiles for nfs root
cp /etc/network/profiles/eth0-nfs-root /etc/network/interfaces.d/eth0
cp /etc/network/profiles/interfaces-nfs-root /etc/network/interfaces
}

case "$1" in
start)
if grep -q 'root=/dev/nfs' /proc/cmdline; then
install_net_profiles
fi
;;

stop)
;;

*)
echo "Usage: $0 {start}"
exit 1
;;
esac
Loading
Loading