Skip to content

Instantly share code, notes, and snippets.

@rmi1974
Last active March 29, 2020 14:58
Show Gist options
  • Save rmi1974/d4260c4d5858449fab27b70873ecd138 to your computer and use it in GitHub Desktop.
Save rmi1974/d4260c4d5858449fab27b70873ecd138 to your computer and use it in GitHub Desktop.
BitBake/OpenEmbedded build artifacts to SD-Card #bitbake #openembedded #commandlinefu

BitBake/OpenEmbedded build artifacts to SD-Card

Write rootfs using compressed ext4 image to partition on SD-Card

export ROOTFS_PART=/dev/mmcblk0p2
gunzip < rootfs.ext4.gz | sudo dd of=$ROOTFS_PART bs=1M status=progress conv=fdatasync

Write rootfs using compressed tarball to partition on SD-Card

export ROOTFS_PART=/dev/mmcblk0p2
# Format the rootfs partition as 'ext4' and label it 'rootfs'
sudo mkfs.ext4 -F -m 0 -L rootfs $ROOTFS_PART

# Mount the target rootfs
udisksctl mount -b $ROOTFS_PART

# Unpack the rootfs tarball contents to mounted fs
# NOTE: You will need 'pv' tool installed with your host distro for progress indicator
export ROOTFS_MOUNTPOINT=$(lsblk -nro MOUNTPOINT $ROOTFS_PART)

pv rootfs.tar.gz | sudo tar xpzf - -C $ROOTFS_MOUNTPOINT

# Unmount the target rootfs
udisksctl unmount -b $ROOTFS_PART

Update mounted target rootfs using rsync

export ROOTFS_PART=/dev/mmcblk0p2

# Get path to Yocto rootfs staging dir (IMAGE = image recipe)
export ROOTFS_DIR=$(bitbake -e $IMAGE | grep -oP '^IMAGE_ROOTFS=["]*"\K[^"]*')

# Mount the target rootfs
udisksctl mount -b $ROOTFS_PART

# Get mount point of target rootfs
export ROOTFS_MOUNTPOINT=$(lsblk -nro MOUNTPOINT $ROOTFS_PART)

# Use rsync to sync src and dest
sudo rsync -axHAWXS --numeric-ids --no-owner --no-group --info=progress2 $ROOTFS_DIR/ $ROOTFS_MOUNTPOINT --delete

# Unmount the target rootfs
udisksctl unmount -b $ROOTFS_PART
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment