Skip to content

Add support for upfs to switch build. #2045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: Lakka-v6.x
Choose a base branch
from
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
10 changes: 10 additions & 0 deletions packages/sysutils/bindfs/package.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PKG_NAME="bindfs"
PKG_VERSION="9b15e7b9bfaaf0531fba0d3d07f57b6330222ba1"
PKG_ARCH="any"
PKG_SITE="https://github.com/mpartel/bindfs"
PKG_URL="${PKG_SITE}/archive/${PKG_VERSION}.tar.gz"
PKG_DEPENDS_TARGET="toolchain fuse"
PKG_SECTION="tools"
PKG_SHORTDESC="A FUSE filesystem thwt gives Advanced options for bind mounting"
PKG_MAKE_OPTS_TARGET="PREFIX=/usr"
PKG_TOOLCHAIN="autotools"
2 changes: 1 addition & 1 deletion packages/sysutils/e2fsprogs/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ makeinstall_init() {
ln -sf e2fsck ${INSTALL}/usr/sbin/fsck.ext3
ln -sf e2fsck ${INSTALL}/usr/sbin/fsck.ext4

if [ ${INITRAMFS_PARTED_SUPPORT} = "yes" ]; then
if [ ${INITRAMFS_PARTED_SUPPORT} = "yes" -o ${BOOTLOADER} = "switch-bootloader" ]; then
cp misc/mke2fs ${INSTALL}/usr/sbin
ln -sf mke2fs ${INSTALL}/usr/sbin/mkfs.ext2
ln -sf mke2fs ${INSTALL}/usr/sbin/mkfs.ext3
Expand Down
16 changes: 16 additions & 0 deletions packages/sysutils/fuse/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PKG_LICENSE="GPL"
PKG_SITE="https://github.com/libfuse/libfuse/"
PKG_URL="https://github.com/libfuse/libfuse/releases/download/${PKG_NAME}-${PKG_VERSION}/${PKG_NAME}-${PKG_VERSION}.tar.gz"
PKG_DEPENDS_TARGET="toolchain"
PKG_DEPENDS_INIT="toolchain"
PKG_LONGDESC="FUSE provides a simple interface for userspace programs to export a virtual filesystem to the Linux kernel."
PKG_TOOLCHAIN="autotools"

Expand All @@ -20,7 +21,22 @@ PKG_CONFIGURE_OPTS_TARGET="MOUNT_FUSE_PATH=/usr/sbin \
--disable-rpath \
--with-gnu-ld"

PKG_CONFIGURE_OPTS_INIT="MOUNT_FUSE_PATH=/usr/sbin \
--enable-lib\
--disable-util \
--disable-examples \
--enable-mtab \
--disable-rpath \
--with-gnu-ld"

post_makeinstall_target() {
rm -rf ${INSTALL}/etc/init.d
rm -rf ${INSTALL}/etc/udev
}

post_makeinstall_init() {
rm -rf ${INSTALL}/usr/lib/pkgconfig
rm -rf ${INSTALL}/usr/include
rm -rf ${INSTALL}/etc/init.d
rm -rf ${INSTALL}/etc/udev
}
30 changes: 30 additions & 0 deletions packages/sysutils/upFS/package.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
PKG_NAME="upFS"
PKG_VERSION="9a906da00d97d9b31fae91a431031d55ed99571c"
PKG_ARCH="any"
PKG_SITE="https://github.com/GregorR/upfs"
PKG_URL="${PKG_SITE}/archive/${PKG_VERSION}.tar.gz"
PKG_DEPENDS_INIT="toolchain fuse fuse:init"
PKG_DEPENDS_TARGET="toolchain fuse"
PKG_SECTION="tools"
PKG_SHORTDESC="A FUSE filesystem intended to be used like UMSDOS"
PKG_MAKE_OPTS_TARGET="PREFIX=/usr"
PKG_TOOLCHAIN="make"

#Set Compiler Flags
export CFLAGS="${TARGET_CFLAGS}"
export CPPFLAGS="${TARGET_CPPFLAGS}"
export LDFLAGS="${TARGET_LDFLAGS}"
export CROSS_COMPILE="${TARGET_PREFIX}"

makeinstall_target() {
mkdir -p ${INSTALL}/usr/bin
mkdir -p ${INSTALL}/sbin
DESTDIR=${INSTALL} make install
}

makeinstall_init() {
mkdir -p ${INSTALL}/usr/bin
mkdir -p ${INSTALL}/sbin
DESTDIR=${INSTALL} make install
mv ${INSTALL}/sbin ${INSTALL}/usr/sbin
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff -Naur upFS-9a906da00d97d9b31fae91a431031d55ed99571c/Makefile upFS-9a906da00d97d9b31fae91a431031d55ed99571c-3/Makefile
--- upFS-9a906da00d97d9b31fae91a431031d55ed99571c/Makefile 2025-02-21 16:46:36.636480266 +0100
+++ upFS-9a906da00d97d9b31fae91a431031d55ed99571c-3/Makefile 2025-02-22 17:15:50.289720784 +0100
@@ -1,7 +1,6 @@
-CC=gcc
ECFLAGS=-O3
CFLAGS=-DUPFS_LNCP -DUPFS_PERMLOWERCASE -DUPFS_FATNAMES -D_FILE_OFFSET_BITS=64 $(ECFLAGS)
-FUSE_FLAGS=`pkg-config --cflags --libs fuse`
+FUSE_FLAGS=$(shell pkg-config --cflags --libs fuse)

all: upfs upfs-ps mount.upfs mount.upfsps

@@ -18,10 +17,10 @@
$(CC) $(CFLAGS) mountupfsps.c -o mount.upfsps

install: all
- install upfs /usr/bin/upfs
- install upfs-ps /usr/bin/upfs-ps
- install mount.upfs /sbin/mount.upfs
- install mount.upfsps /sbin/mount.upfsps
+ install upfs $(DESTDIR)/usr/bin/upfs
+ install upfs-ps $(DESTDIR)/usr/bin/upfs-ps
+ install mount.upfs $(DESTDIR)/sbin/mount.upfs
+ install mount.upfsps $(DESTDIR)/sbin/mount.upfsps

clean:
rm -f upfs upfs-ps mount.upfs mount.upfsps
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff -Naur upFS-9a906da00d97d9b31fae91a431031d55ed99571c/upfs.c upFS-9a906da00d97d9b31fae91a431031d55ed99571c-3/upfs.c
--- upFS-9a906da00d97d9b31fae91a431031d55ed99571c/upfs.c 2025-02-21 16:46:36.636480266 +0100
+++ upFS-9a906da00d97d9b31fae91a431031d55ed99571c-3/upfs.c 2025-02-22 17:21:16.107561511 +0100
@@ -558,7 +558,7 @@
/* Copy it in the store */
from_file_fd = openat(store_root, sfrom, O_RDONLY);
if (from_file_fd < 0) goto error;
- to_file_fd = openat(store_root, sto, O_WRONLY|O_CREAT|O_EXCL);
+ to_file_fd = openat(store_root, sto, O_WRONLY|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR);
if (to_file_fd < 0) goto error;
buf = malloc(BUFSZ);
if (!buf) goto error;
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ After=syslog.target local-fs.target
[Service]
Type=dbus
BusName=org.pulseaudio.Server
ExecStartPre=/bin/rm -rf /storage/.config/pulse/*
ExecStart=/usr/bin/pulseaudio --system --disallow-exit --exit-idle-time=-1 --disable-shm --enable-memfd --realtime
Restart=on-failure
Environment=PULSE_STATE_PATH=/storage/.config/pulse
Environment=PULSE_CONFIG_PATH=/storage/.config/pulse
Environment=PULSE_STATE_PATH=/run/pulse
Environment=PULSE_CONFIG_PATH=/run/pulse

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Below you can find all supported keys and their defaults.
3: Enable serial logging on UART-C [Left Joycon Rail]
4: Enable serial logging on USB

[fbconsole=1]
0: Enable kernel logging on built-in display.
[fbconsole=9]
0: Enable kernel logging on built-in display, and disable splash screen
1: Enable kernel logging on DP/HDMI/VGA.
9: Or removed, disables kernel logging on any display.

Expand Down Expand Up @@ -80,6 +80,15 @@ Below you can find all supported keys and their defaults.
1: Set GPU clock hard limit to 1075 MHz. T210B01 only.
Helps when `gpu_dvfsc` is enabled and GPU can't handle the higher frequencies
in such low voltages.

[enable_ipv6=0]
0: IPv6 Disabled (default)
1: IPv6 Enabled

[enable_upfs = 0]
0: upfs storage is disabled
1: upfs storage is enabled(experimental): Keep FS permissions in ext4 partition image(Easier to clean)
2: upfsps storage is enabled(experimental) Keep FS permission in storage dir in hidden files
================================================================================


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ test -n ${performance_mode} || setenv performance_mode 0
test -n ${dock_freq_switch_enabled} || setenv dock_freq_switch_enabled 0
test -n ${touch_skip_tuning} || setenv touch_skip_tuning 0
test -n ${wifi_disable_vht80} || setenv wifi_disable_vht80 0
test -n ${enable_ipv6} || setenv enable_ipv6 0
test -n ${enable_upfs} || setenv enable_upfs 0

# Built-in IMU.
test -n ${acc_cal_off_x} || setenv acc_cal_off_x 0x0
Expand Down Expand Up @@ -358,9 +360,22 @@ fi
# Set default wifi mac. initramfs will/can change it.
if test -n ${device_wifi_mac}; then fdt set /chosen nvidia,wifi-mac ${device_wifi_mac}; fi

if test ${enable_ipv6} = 0; then
setenv bootargs_extra ${bootargs_extra} ipv6.disable=1
fi

if test ${enable_upfs} = 1; then
setenv bootargs_extra ${bootargs_extra} upfs-storage
elif test ${enable_upfs} = 2; then
setenv bootargs_extra ${bootargs_extra} upfsps-storage
fi

if test ${fbconsole} = 0; then
setenv bootargs_extra ${bootargs_extra} fbcon=rotate:3 nosplash
fi

# Set kernel cmdline.
setenv bootargs ${bootargs_extra} "boot=/dev/mmcblk0p1 BOOT_IMAGE=@DISTRO_PATH@/KERNEL SYSTEM_IMAGE=@DISTRO_PATH@/SYSTEM nofsck fat32-boot \
setenv bootargs ${bootargs_extra} "boot=/dev/mmcblk0p1 BOOT_IMAGE=@DISTRO_PATH@/KERNEL SYSTEM_IMAGE=@DISTRO_PATH@/SYSTEM nofsck device-has-user fat32-boot \
dock_freq_switch_enabled=${dock_freq_switch_enabled} performance_mode=${performance_mode} \
firmware_class.path=/usr/lib/firmware access=m2 \
pmc_r2p.enabled=1 pmc_r2p.action=${r2p_action} \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
PKG_NAME="switch-bootloader"
PKG_VERSION="2.8"
PKG_VERSION="3.0"
PKG_ARCH="any"
PKG_DEPENDS_TARGET="switch-u-boot:host switch-u-boot:target switch-atf:target"
PKG_DEPENDS_INIT="upFS:init"
PKG_DEPENDS_TARGET="switch-u-boot:host switch-u-boot:target switch-atf:target upFS:target bindfs:target"
PKG_TOOLCHAIN="manual"

make_target() {
Expand Down
8 changes: 4 additions & 4 deletions projects/L4T/packages/busybox/config/busybox-init.conf
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ CONFIG_BASENAME=y
CONFIG_CAT=y
CONFIG_FEATURE_CATN=y
# CONFIG_FEATURE_CATV is not set
# CONFIG_CHGRP is not set
# CONFIG_CHMOD is not set
# CONFIG_CHOWN is not set
# CONFIG_FEATURE_CHOWN_LONG_OPTIONS is not set
CONFIG_CHGRP=y
CONFIG_CHMOD=y
CONFIG_CHOWN=y
CONFIG_FEATURE_CHOWN_LONG_OPTIONS=y
CONFIG_CHROOT=y
# CONFIG_CKSUM is not set
# CONFIG_COMM is not set
Expand Down
99 changes: 93 additions & 6 deletions projects/L4T/packages/busybox/scripts/init
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,13 @@ mount_flash() {
if [ ! "$FAT32_BOOT" = "yes" ]; then
mount_part "$boot" "/flash" "ro,noatime"
else
mount_part "$boot" "/flash" "rw,noatime,umask=0000"
mount_part "$boot" "/flash" "rw,noatime,umask=0000,shortname=winnt"
if [ "$RUN_FSCK" = "no" ]; then
#make sure flash is writable
FLASH_STATUS=$(/usr/bin/busybox cat /proc/mounts | /usr/busybox grep fat | /usr/bin/busybox grep ro,)
if [ ! "$FLASH_STATUS" = "" ]; then
FAT32_MOUNT_ERROR="yes"
fi
fi

if [ -f /flash/post-flash.sh ]; then
Expand All @@ -582,7 +588,7 @@ cleanup_flash() {
mount_storage() {
progress "Mounting storage"

if [ "$LIVE" = "yes" ]; then
if [ "$LIVE" = "yes" -a ! "$DEVICE_HAS_USER" = "yes" ]; then
# mount tmpfs and exit early. disk=xx is not allowed in live mode
mount -t tmpfs none /storage
return
Expand All @@ -591,9 +597,56 @@ mount_storage() {
wakeonlan

if [ "$FAT32_BOOT" = "yes" ]; then
if [ "$FAT32_MOUNT_ERROR" = "yes" ]; then
LIVE="yes"
fi
DISTRO=${IMAGE_SYSTEM%'/'*}
mkdir -p /flash/$DISTRO/storage
mount --bind /flash/$DISTRO/storage /storage

#Handle upfs stuff
if [ "$DEVICE_HAS_USER" = "yes" ]; then
UPFS_STORAGE_PATH="/run/upfs_storage"
else
UPFS_STORAGE_PATH="/storage"
fi

if [ ! -d $UPFS_STORAGE_PATH -a "$UPFS_STORAGE" = "yes" -a ! "$UPFS_STORAGE_PATH" = "/storage" ]; then
mkdir -p $UPFS_STORAGE_PATH
fi

if [ "$UPFS_STORAGE" = "yes" -a "$UPFS_PERMISSIONS_IN_STORE" = "yes" ]; then
if [ ! -f $UPFS_STORAGE_PATH/.upfs_store_created ]; then
echo "" > $UPFS_STORAGE_PATH/.upfs_store_created
CREATE_PERMISSIONS="yes"
rm -rf /flash/$DISTRO/storage/*.upfs*
fi
/usr/sbin/mount.upfsps /flash/$DISTRO/storage $UPFS_STORAGE_PATH
elif [ "$UPFS_STORAGE" = "yes" ]; then
mkdir -p "$UPFS_STORAGE_PATH"_p
if [ ! -f /flash/$DISTRO/storage_p.img ]; then
dd if=/dev/zero of=/flash/$DISTRO/storage_p.img bs=1024 count=10240
mkfs.ext4 /flash/$DISTRO/storage_p.img
CREATE_PERMISSIONS="yes"
fi
/usr/bin/busybox mount -o loop /flash/$DISTRO/storage_p.img /run/upfs_storage_p
/usr/sbin/mount.upfs "$UPFS_STORAGE_PATH"_p:/flash/$DISTRO/storage $UPFS_STORAGE_PATH
fi

#Actually mount something to storage.
if [ "$UPFS_STORAGE" = "yes" ]; then
#Create initial permission store.
if [ "$CREATE_PERMISSIONS" = "yes" ]; then
/usr/bin/busybox chown -R 0:0 $UPFS_STORAGE_PATH/*
fi

#For now bind mount to ensure updater works without more modifications,
#We will handle this in prepare_sysroot
if [ ! "$LIVE" = "yes" ]; then
mount --bind $UPFS_STORAGE_PATH /storage
fi
elif [ ! "$LIVE" = "yes" ]; then
mount --bind /flash/$DISTRO/storage /storage
fi
elif [ -n "$disk" ]; then
if [ -n "$OVERLAY" ]; then
OVERLAY_DIR=$(cat /sys/class/net/eth0/address | tr -d :)
Expand Down Expand Up @@ -969,7 +1022,20 @@ prepare_sysroot() {
progress "Preparing system"

mount --move /flash /sysroot/flash
mount --move /storage /sysroot/storage
if [ "$DEVICE_HAS_USER" = "yes" ]; then
if [ ! "$UPFS_STORAGE" = "yes" ]; then
if [ ! "$LIVE" = "yes" ]; then
mount --move /storage /sysroot/storage
fi
else
#properly mount via chroot before switch_root
if [ ! "$LIVE" = "yes" ]; then
umount /storage
fi
fi
else
mount --move /storage /sysroot/storage
fi

if [ ! "$FAT32_BOOT" = "yes" ]; then
if [ ! -d "/sysroot/usr/lib/kernel-overlays/base/lib/modules/$(uname -r)/" -a -f "/sysroot/usr/lib/systemd/systemd" ]; then
Expand All @@ -988,8 +1054,9 @@ prepare_sysroot() {
# Do init tasks to bring up system

# hide kernel log messages on console
echo '1 4 1 7' > /proc/sys/kernel/printk

if [ ! "$SPLASH" = "no" ] ;then
echo '1 4 1 7' > /proc/sys/kernel/printk
fi
# run platform_init script if exists
if [ -f "./platform_init" ]; then
./platform_init
Expand Down Expand Up @@ -1090,6 +1157,17 @@ for arg in $(cat /proc/cmdline); do
;;
fat32-boot)
FAT32_BOOT="yes"
FAT32_MOUNT_ERROR="no"
;;
upfs-storage)
UPFS_STORAGE="yes"
;;
upfsps-storage)
UPFS_STORAGE="yes"
UPFS_PERMISSIONS_IN_STORE="yes"
;;
device-has-user)
DEVICE_HAS_USER="yes"
;;
esac
done
Expand Down Expand Up @@ -1153,6 +1231,15 @@ done
# setup kernel overlays
/usr/bin/busybox chroot /sysroot /usr/sbin/kernel-overlays-setup

#Deal with user permissions

if [ "$DEVICE_HAS_USER" = "yes" -a "$UPFS_STORAGE" = "yes" ]; then
/usr/bin/busybox chroot /sysroot /usr/bin/bindfs --map=0/1000:@0/@1000 /run/upfs_storage /storage
elif [ "$DEVICE_HAS_USER" = "yes" -a "$LIVE" = "yes" ]; then
mkdir -p /sysroot/run/tmp_storage
/usr/bin/busybox chroot /sysroot /usr/bin/bindfs --map=0/1000:@0/@1000 /run/tmp_storage /storage
fi

# tell OE settings addon to disable updates
if [ "$UPDATE_DISABLED" = "yes" ]; then
echo "" > /sysroot/dev/.update_disabled
Expand Down