Generating Package Patch for Buildroot

Generating a Patch Using diff 1. Extract the Original Source Ensure you have a pristine copy of the original source for comparison. You can extract it from the tarball in the dl directory: tar -xf dl/<package>-<version>.tar.gz -C /tmp/ This will create a directory like /tmp/<package>-<version>/. Using buildroot’s mechanism Clean the build directory and apply current patches of buildroot make <pkg>-dirclean # Remove <pkg> build directory make <pkg>-extract # Extract <pkg> sources make <pkg>-patch # Apply patches to <pkg> (Optional) cp -r output/build/<package> /tmp/ 2. Generate the Patch Use the diff command to create a unified diff between the original and modified sources: ...

May 20, 2025 · 2 min

Boot to recovery filesystem

Process Mount recovery partition into temporary location mkdir -p /mnt/recovery mount /dev/mmcblk0p6 /mnt/recovery Prepare old_root directory mkdir -p /mnt/recovery/mnt/old_root Switch root using pivot_root cd /mnt/recovery pivot_root . mnt/old_root Now: New root is /mnt/recovery (i.e., /) The previous root (e.g., initramfs or mainfs) is now mounted at /mnt/old_root Note: The chroot must be available under the old root and under the new root(recovery) Remount /proc, /sys, /dev, etc mount -t proc proc /proc mount -t sysfs sysfs /sys mount -o bind /mnt/old_root/dev /dev mount -o bind /mnt/old_root/tmp /tmp mount -o bind /mnt/old_root/run /run Start a shell inside of new root exec /bin/sh Mount root filesystem from NFS Setup nfs-service on host machine (refer [3-Resource/Linux/NFS|this]({< ref “/posts/3-resource/linux/nfs|this/” >}})) Mount NFS filesystem into the board mount -t nfs -o nolock 192.168.1.27:/home/rishav/Public /mnt/nfsroot Mount ext image as a loopback device mkdir -p /mnt/local cp /mnt/nfs/rootfs.ext4 /tmp/rootfs.ext4 mount -o loop /tmp/rootfs.ext4 /mnt/local References Manual page of pivot_root Also see difference between pivot_root and chroot

May 15, 2025 · 1 min

Kernel Space vs User Space

Overview Kernel Space: This is where the Linux kernel executes and provides low-level access to hardware, system memory management, process scheduling, and device drivers. Kernel space has privileged access to system resources and is protected from direct user interference. For example, when a user requests data from a hardware sensor, the kernel driver handles communication with the hardware, processes the request, and returns the data to user space through system calls. User Space: This is where applications and system utilities run. User-space processes operate with restricted privileges and interact with the kernel via system calls, libraries, and IPC mechanisms. For example, a user-space daemon may monitor the watchdog status by writing to /dev/watchdog, or a mobile app may read light intensity from /sys/bus/i2c/devices/1-0039/lux. Communication Methods between Kernel and User Space There are several ways to facilitate communication between user space and kernel space in an embedded Linux environment: ...

February 4, 2025 · 3 min

Making File System

Overview Get the final files into a directory eg. target and treat it as root(/) directory of target board/system. Generate users eg. root, admin, ssh, etc Generate device lists Clean few files Generate ext image using mkfs Taking reference from buildroot common.mk and ext2.mk scripts/makedevs -d output/build/buildroot-fs/full_devices_table.txt output/build/buildroot-fs/ext2/target mkfs.ext4 -d output/build/buildroot-fs/ext2/target -r 1 -N 0 -m 5 -L rootfs -O ^64bit output/images/rootfs.ext2 2G # Fakeroot execution complete /opt/rk3588_nvrx/host/sbin/resize2fs -M output/images/rootfs.ext2 /opt/rk3588_nvrx/host/sbin/e2fsck -fy /output/images/rootfs.ext2 /opt/rk3588_nvrx/host/sbin/resize2fs -M /output/images/rootfs.ext2 Fakeroot Script #!/bin/sh set -ex chown -h -R 0:0 $(TARGET) $(HOST_DIR)/bin/makedevs -d full_devices_table.txt $(TARGET) $(HOST_DIR)/sbin/mkfs.ext4 -d $(TARGET) -r 1 -N 0 -m 5 -L "rootfs" -O ^64bit rootfs.ext2 "2G" Post EXT4 $(HOST_DIR)/sbin/resize2fs -M rootfs.ext2 $(HOST_DIR)/sbin/e2fsck -fy rootfs.ext2 $(HOST_DIR)/sbin/tune2fs -m 5 rootfs.ext2 $(HOST_DIR)/sbin/resize2fs -M rootfs.ext2 Testing on Host sudo mount -o loop path/to/rootfs.ext4 /tmp/fs_path Makedevs Creates a batch of special files as specified in a device table. ...

November 11, 2024 · 3 min