1*288bf522SAndroid Build Coastguard Worker# Dynamic Partition Tools 2*288bf522SAndroid Build Coastguard Worker 3*288bf522SAndroid Build Coastguard Worker## lpmake 4*288bf522SAndroid Build Coastguard Worker 5*288bf522SAndroid Build Coastguard Workerlpmake is a command-line tool for generating a "super" partition image. It can currently generate two types of images: 6*288bf522SAndroid Build Coastguard Worker* Sparse images, for traditional fastboot. 7*288bf522SAndroid Build Coastguard Worker* Metadata-only images, for the lpflash utility. 8*288bf522SAndroid Build Coastguard Worker 9*288bf522SAndroid Build Coastguard WorkerThe following command-line arguments are required: 10*288bf522SAndroid Build Coastguard Worker 11*288bf522SAndroid Build Coastguard Worker* `-d,--device-size` - The size of the "super" partition on the device. It must match exactly, and it must be evenly divisible by the sector size (512 bytes). 12*288bf522SAndroid Build Coastguard Worker* `-m,--metadata-size` - The maximum size that partition metadata may consume. A partition entry uses 64 bytes and an extent entry uses 16 bytes. The minimum size is 512 bytes. 13*288bf522SAndroid Build Coastguard Worker* `-s,--metadata-slots` - The number of slots available for storing metadata. This should match the number of update slots on the device, 2 for A/B devices and 1 for non-A/B. 14*288bf522SAndroid Build Coastguard Worker* `-p,--partition=DATA` - Add a partition to the metadata. At least one partition must be defined. The format for the data string is `<name>:<GUID>:<attributes>:<size>`. The attributes must be either `none` or `readonly`. The size will be rounded up to the nearest aligned block (see below). 15*288bf522SAndroid Build Coastguard Worker* `-o,--output=FILE` - The output file for writing the image. 16*288bf522SAndroid Build Coastguard Worker 17*288bf522SAndroid Build Coastguard WorkerOptional arguments: 18*288bf522SAndroid Build Coastguard Worker 19*288bf522SAndroid Build Coastguard Worker* `--alignment=N` - By default, lpmake will align partitions to 1MiB boundaries. However, an alternate alignment can be specified if desired. This is useful for devices with a minimum I/O request size where mis-aligned partition boundaries could be a performance issue. 20*288bf522SAndroid Build Coastguard Worker* `--alignment-offset=N` - In some cases, the "super" partition is misaligned within its parent block device. This offset can be used to correct for that. 21*288bf522SAndroid Build Coastguard Worker* `--sparse` - If set, the output image will be in sparse format for flashing with fastboot. Otherwise, by default, the image will be a minimal format usable with lpdump and lpflash. 22*288bf522SAndroid Build Coastguard Worker* `-b,--block-size=N` - When writing a sparse image, the device may require a specific block size. That block size can be specified here. The alignment must be a multiple of the block size. By default the block size is 4096. 23*288bf522SAndroid Build Coastguard Worker* `-i,--image=[NAME=FILE]` - When writing a sparse image, include the contents of FILE as the data for the partition named NAME. The file can be a normal file or a sparse image, but the destination size must be less than or equal to the partition size. This option is only available when creating sparse images. 24*288bf522SAndroid Build Coastguard Worker 25*288bf522SAndroid Build Coastguard WorkerExample usage. This specifies a 10GB super partition for an A/B device, with a single 64MiB "cache" partition. 26*288bf522SAndroid Build Coastguard Worker 27*288bf522SAndroid Build Coastguard Worker``` 28*288bf522SAndroid Build Coastguard Workerlpmake --device-size 10240000000 \ 29*288bf522SAndroid Build Coastguard Worker --metadata-size 65536 \ 30*288bf522SAndroid Build Coastguard Worker --metadata-slots 2 \ 31*288bf522SAndroid Build Coastguard Worker -o /tmp/super.img \ 32*288bf522SAndroid Build Coastguard Worker -p "cache:2da85788-f0e1-4fda-9ee7-e5177eab184b:none:67108864" \ 33*288bf522SAndroid Build Coastguard Worker -i "cache=out/target/hikey960/cache.img" 34*288bf522SAndroid Build Coastguard Worker``` 35*288bf522SAndroid Build Coastguard Worker 36*288bf522SAndroid Build Coastguard Worker## lpdump 37*288bf522SAndroid Build Coastguard Worker 38*288bf522SAndroid Build Coastguard Workerlpdump displays pretty-printed partition metadata. It accepts a single argument, which can be: 39*288bf522SAndroid Build Coastguard Worker 40*288bf522SAndroid Build Coastguard Worker* A path to a non-sparse image from lpmake. 41*288bf522SAndroid Build Coastguard Worker* A path to a filesystem image or block device. 42*288bf522SAndroid Build Coastguard Worker 43*288bf522SAndroid Build Coastguard WorkerIt also accepts an optional argument `-s,--slot=N` which can dump a specific metadata slot (the default is 0). 44*288bf522SAndroid Build Coastguard Worker 45*288bf522SAndroid Build Coastguard WorkerUsage: `lpdump [-s,--slot=N] PATH` 46*288bf522SAndroid Build Coastguard Worker 47*288bf522SAndroid Build Coastguard Worker## lpadd 48*288bf522SAndroid Build Coastguard Worker 49*288bf522SAndroid Build Coastguard Workerlpadd is a command-line tool for adding images to a super.img file, or a partition to a super\_empty.img file. This is useful for mixed or split builds involving dynamic partitions. The syntax is: 50*288bf522SAndroid Build Coastguard Worker 51*288bf522SAndroid Build Coastguard Worker``` 52*288bf522SAndroid Build Coastguard Workerlpadd [options] SUPER_FILE PART_NAME GROUP_NAME [IMAGE_FILE] 53*288bf522SAndroid Build Coastguard Worker``` 54*288bf522SAndroid Build Coastguard Worker 55*288bf522SAndroid Build Coastguard WorkerThe parameters are: 56*288bf522SAndroid Build Coastguard Worker* `--readonly` - The partition should be mapped as read-only. 57*288bf522SAndroid Build Coastguard Worker* `SUPER_FILE` - The `super.img` or `super_empty.img` file. If the image is sparsed, it will be temporarily unsparsed, and re-sparsed at the end. 58*288bf522SAndroid Build Coastguard Worker* `PART_NAME` - The partition name. It must not already exist. 59*288bf522SAndroid Build Coastguard Worker* `GROUP_NAME` - The updateable group name for the partition. 60*288bf522SAndroid Build Coastguard Worker* `IMAGE_FILE` - If specified, the contents of the image will be embedded in the given super.img. This does not work for a `super_empty.img` file. If the source image is sparsed, the unsparsed content will be embedded. The new partition size will be the smallest block-aligned size capable of holding the entire image. 61*288bf522SAndroid Build Coastguard Worker 62*288bf522SAndroid Build Coastguard WorkerNote that when interacting with sparsed images, `lpadd` can consume a great deal of space in `TMPDIR`. If `TMPDIR` does not have enough free space, it can be set in the environment, eg: 63*288bf522SAndroid Build Coastguard Worker 64*288bf522SAndroid Build Coastguard Worker``` 65*288bf522SAndroid Build Coastguard WorkerTMPDIR=/path/to/temp lpadd ... 66*288bf522SAndroid Build Coastguard Worker``` 67*288bf522SAndroid Build Coastguard Worker 68*288bf522SAndroid Build Coastguard Worker## lpflash 69*288bf522SAndroid Build Coastguard Worker 70*288bf522SAndroid Build Coastguard Workerlpflash writes a non-sparse image from lpmake to a block device. It is intended to be run on the device itself. 71*288bf522SAndroid Build Coastguard Worker 72*288bf522SAndroid Build Coastguard WorkerUsage: `lpflash /dev/block/sdX /path/to/image/file` 73