Skip to content

Instantly share code, notes, and snippets.

@eduard-sukharev
Last active December 25, 2021 20:51
Show Gist options
  • Save eduard-sukharev/c4c4f5cf6bbdf9b0a6be6b8ae4bc0627 to your computer and use it in GitHub Desktop.
Save eduard-sukharev/c4c4f5cf6bbdf9b0a6be6b8ae4bc0627 to your computer and use it in GitHub Desktop.
Sample workflow to mount UBI files to local directory
sudo modprobe -r ubi
sudo modprobe -r mtdram
sudo modprobe nandsim first_id_byte=0x20 second_id_byte=0xaa third_id_byte=0x00 fourth_id_byte=0x15 total_size=40000
cat /proc/mtd
# dev: size erasesize name
# mtd0: 10000000 00020000 "NAND simulator partition 0"
sudo flash_erase /dev/mtd0 0 0
# Erasing 128 Kibyte @ ffe0000 -- 100 % complete
sudo ubiformat /dev/mtd0 -f rootfs.ubi -e 0 -O 2048
# ubiformat: mtd0 (nand), size 268435456 bytes (256.0 MiB), 2048 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
# libscan: scanning eraseblock 2047 -- 100 % complete
# ubiformat: 2048 eraseblocks are supposedly empty
# ubiformat: use erase counter 0 for all eraseblocks
# ubiformat: flashing eraseblock 304 -- 100 % complete
# ubiformat: formatting eraseblock 2047 -- 100 % complete
sudo modprobe ubi
sudo ubiattach /dev/ubi_ctrl -m 0 -O 2048
# UBI device number 0, total 2048 LEBs (260046848 bytes, 248.0 MiB), available 0 LEBs (0 bytes), LEB size 126976 bytes (124.0 KiB)
sudo mount -t ubifs /dev/ubi0_0 rootfs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment