Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | .. SPDX-License-Identifier: GPL-2.0+ .. index:: single: blkmap (command) blkmap command ============== Synopsis -------- :: blkmap info blkmap part blkmap dev [<dev>] blkmap read <addr> <blk#> <cnt> blkmap write <addr> <blk#> <cnt> blkmap get <label> dev [<var>] blkmap create <label> blkmap destroy <label> blkmap map <label> <blk#> <cnt> linear <interface> <dev> <blk#> blkmap map <label> <blk#> <cnt> mem <addr> Description ----------- The *blkmap* command is used to create and manage virtual block devices that are composed of one or more "slices" mapped from other block devices or memory regions. See :doc:`../blkmap` for an overview of the blkmap subsystem and usage examples. label Unique label assigned to a blkmap device during creation. Used to identify the device for subsequent operations (map, get, destroy). blk# Block number. Blocks are 512 bytes in size. When used as a starting position, this specifies where in the device to begin the operation. When used as a mapping parameter, it indicates which block in the source or destination to use. cnt Number of blocks (count). Each block is 512 bytes, so cnt=1 represents 512 bytes, cnt=2048 represents 1MB, etc. addr Memory address in hexadecimal format (e.g., ${loadaddr}, 0x82000000). Used for specifying where to read/write data or where a memory region is located. blkmap info ~~~~~~~~~~~ List all configured blkmap devices and their properties:: blkmap info This displays information about all active blkmap devices, including device number, vendor, product, revision, type, and capacity. blkmap part ~~~~~~~~~~~ List available partitions on the current blkmap device:: blkmap part This command displays the partition table of the currently selected blkmap device. If the device has no partition table (whole-disk filesystem), it will report "no blkmap partition table available". blkmap dev ~~~~~~~~~~ Show or set the current blkmap device:: blkmap dev [<dev>] dev Optional device number to set as current. If omitted, displays the current device information. blkmap read ~~~~~~~~~~~ Read data from the current blkmap device:: blkmap read <addr> <blk#> <cnt> blkmap write ~~~~~~~~~~~~ Write data to the current blkmap device:: blkmap write <addr> <blk#> <cnt> **Note**: Write support is limited and may not be available for all blkmap types. blkmap get ~~~~~~~~~~ Get the device number for a labeled blkmap device:: blkmap get <label> dev [<var>] var Optional environment variable name to store the device number. If omitted, the device number is printed to stdout. This is useful for scripting, allowing you to find a blkmap device by its label and store or use its device number. blkmap create ~~~~~~~~~~~~~ Create a new blkmap device with the specified label:: blkmap create <label> After creation, the device has no mappings and is empty. Use ``blkmap map`` to add slices to the device. blkmap destroy ~~~~~~~~~~~~~~ Destroy a blkmap device and free its resources:: blkmap destroy <label> This removes the blkmap device and all its mappings. Any data stored only in the blkmap device will be lost. blkmap map - linear ~~~~~~~~~~~~~~~~~~~ Map a region from another block device into the blkmap device:: blkmap map <label> <blk#> <cnt> linear <interface> <dev> <blk#> label Label of the blkmap device to map into blk# Starting block number in the blkmap device where this mapping begins cnt Number of blocks to map interface Source device interface (e.g., mmc, usb, scsi) dev Source device number blk# (last parameter) Starting block number on the source device This creates a linear mapping that redirects reads from a region of the blkmap device to the corresponding region on another block device. Multiple mappings can be added to compose a single virtual device from multiple sources. blkmap map - mem ~~~~~~~~~~~~~~~~ Map a memory region as a block device:: blkmap map <label> <blk#> <cnt> mem <addr> label Label of the blkmap device to map into blk# Starting block number in the blkmap device where this mapping begins cnt Number of blocks to map addr Memory address of the data to map This creates a mapping that exposes a memory region as block device sectors. The memory region must be at least ``cnt * 512`` bytes in size. Usage Examples -------------- See :doc:`../blkmap` for complete examples including: * Netbooting an Ext4 image * Accessing filesystems inside FIT images * Creating composite devices from multiple sources * Using memory-backed block devices Implementation Details ---------------------- Blkmap devices are implemented as standard U-Boot block devices (UCLASS_BLK) with a custom driver. Each device maintains an ordered list of "slices" - mappings from a range of blocks to a source (another device or memory region). See :doc:`../blkmap` for more details on the implementation. Configuration ------------- The blkmap command is available when CONFIG_CMD_BLKMAP is enabled:: CONFIG_BLKMAP=y CONFIG_CMD_BLKMAP=y Return Value ------------ The return value $? is set to 0 on success, 1 on failure. Examples -------- List all blkmap devices ~~~~~~~~~~~~~~~~~~~~~~~ :: => blkmap info Device 0: Vendor: U-Boot Rev: 1.0 Prod: blkmap Type: Hard Disk Capacity: 60.0 MB = 0.0 GB (122880 x 512) Check or set current device ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: => blkmap dev Device 0: Vendor: U-Boot Rev: 1.0 Prod: blkmap Type: Hard Disk Capacity: 60.0 MB = 0.0 GB (122880 x 512) ... is now current device => blkmap dev 0 Device 0: Vendor: U-Boot Rev: 1.0 Prod: blkmap Type: Hard Disk Capacity: 60.0 MB = 0.0 GB (122880 x 512) ... is now current device Create a new device ~~~~~~~~~~~~~~~~~~~ :: => blkmap create mydisk => blkmap info Device 0: Vendor: U-Boot Rev: 1.0 Prod: blkmap Type: Hard Disk Capacity: 0.0 MB = 0.0 GB (1 x 512) Map a linear region from MMC ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Map MMC blocks 1000-1999 to blkmap blocks 0-999:: => blkmap create composed => blkmap map composed 0 1000 linear mmc 0 1000 Map memory as a block device ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Map 1MB of memory as blocks:: => blkmap create ramdisk => blkmap map ramdisk 0 2048 mem ${loadaddr} Read from a blkmap device ~~~~~~~~~~~~~~~~~~~~~~~~~~ :: => blkmap dev 0 => blkmap read ${loadaddr} 0 10 blkmap read: device 0 block # 0, count 10 ... 10 blocks read: OK Get device number by label ~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: => blkmap get testdev dev mydev => printenv mydev mydev=0 Complete workflow example ~~~~~~~~~~~~~~~~~~~~~~~~~~ Create, map, and use a device:: => blkmap create testdev => blkmap map testdev 0 2048 linear mmc 0 2048 => blkmap dev 0 => blkmap read ${loadaddr} 0 1 Destroy a device ~~~~~~~~~~~~~~~~ :: => blkmap destroy mydisk Accessing whole-disk filesystems ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Blkmap devices often contain whole-disk filesystems (no partition table). Access them using partition 0 or omitting the partition specification:: => ls blkmap 0 / => ext4load blkmap 0 ${loadaddr} /boot/vmlinuz => cat blkmap 0 /etc/config.txt See Also -------- * :doc:`../blkmap` - Blkmap device documentation and examples * :doc:`../luks` - LUKS encryption support (uses blkmap for decrypted access) * :doc:`../tkey-fde` - TKey full disk encryption |