361 | | The U-boot bootloader used by Ventana has support for ubi: |
362 | | * mounting a ubi |
| 361 | The U-boot bootloader has support for ubi and ubifs. Before working with a ubi image you need to 'attach' an MTD partition, then you can mount and work with ubifs filesystem images. Note that you can remove/create ubi volumes and you can ls and load from ubifs filesystem images but you cant write to ubifs filesystems: |
| 362 | * determining MTD partition containing ubi's: |
| 363 | {{{#!bash |
| 364 | Ventana > mtd |
| 365 | |
| 366 | device nand0 <nand>, # parts = 3 |
| 367 | #: name size offset mask_flags |
| 368 | 0: uboot 0x01000000 0x00000000 0 |
| 369 | 1: env 0x00100000 0x01000000 0 |
| 370 | 2: rootfs 0x7ef00000 0x01100000 0 |
| 371 | |
| 372 | active partition: nand0,0 - (uboot) 0x01000000 @ 0x00000000 |
| 373 | |
| 374 | defaults: |
| 375 | mtdids : nand0=nand |
| 376 | mtdparts: mtdparts=nand:16m(uboot),1m(env),-(rootfs) |
| 377 | }}} |
| 378 | - The above shows there is one RAW NAND device (nand0) and it is partitioned into 3 sections: uboot (from 0x00000000 to 0x01000000), uboot env (from 0x01000000 to 0x01100000) and rootfs (from 0x01100000 to 0x7ef00000). The 'uboot' and 'env' are part of the boot firmware, so the section named 'rootfs' is the section that can contain ubi's |
| 379 | - Note that this partitioning is solely based on the 'mtdids' and 'mtdparts' U-Boot env variables and can be changed if desired. Note also that these variables are used to send information into the kernel so that the kernel creates these sections as specific MTD devices |
| 380 | * attaching a ubi image to an MTD partition: |
| 381 | {{{#!bash |
| 382 | Ventana > ubi part rootfs |
| 383 | ubi0: default fastmap pool size: 256 |
| 384 | ubi0: default fastmap WL pool size: 128 |
| 385 | ubi0: attaching mtd1 |
| 386 | ubi0: scanning is finished |
| 387 | ubi0: attached mtd1 (name "mtd=2", size 2031 MiB) |
| 388 | ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes |
| 389 | ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048 |
| 390 | ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096 |
| 391 | ubi0: good PEBs: 16248, bad PEBs: 0, corrupted PEBs: 0 |
| 392 | ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128 |
| 393 | ubi0: max/mean erase counter: 2/0, WL threshold: 4096, image sequence number: 1592951068 |
| 394 | ubi0: available PEBs: 0, total reserved PEBs: 16248, PEBs reserved for bad PEB handling: 320 |
| 395 | }}} |
| 396 | - The above 'attaches' a ubi image to an MTD partition (equivalent to ubiattach in Linux) so that you can mount ubi volumes. Note that this operation can take several seconds as it must scan the entire ubi image to construct a bad block table (unless [#fastmap fastmap] is used). Once attached you can use {{{ubifsmount}}} and you will need to detach via {{{ubi detach}}} before attaching another or when done using it. |
| 397 | * showing ubi volumes that exist in a ubi image: |
| 398 | {{{#!bash |
| 399 | Ventana > ubi info layout |
| 400 | Volume information dump: |
| 401 | vol_id 0 |
| 402 | reserved_pebs 124 |
| 403 | alignment 1 |
| 404 | data_pad 0 |
| 405 | vol_type 3 |
| 406 | name_len 4 |
| 407 | usable_leb_size 126976 |
| 408 | used_ebs 124 |
| 409 | used_bytes 15745024 |
| 410 | last_eb_bytes 126976 |
| 411 | corrupted 0 |
| 412 | upd_marker 0 |
| 413 | name boot |
| 414 | Volume information dump: |
| 415 | vol_id 1 |
| 416 | reserved_pebs 210 |
| 417 | alignment 1 |
| 418 | data_pad 0 |
| 419 | vol_type 3 |
| 420 | name_len 6 |
| 421 | usable_leb_size 126976 |
| 422 | used_ebs 210 |
| 423 | used_bytes 26664960 |
| 424 | last_eb_bytes 126976 |
| 425 | corrupted 0 |
| 426 | upd_marker 0 |
| 427 | name rootfs |
| 428 | Volume information dump: |
| 429 | vol_id 2 |
| 430 | reserved_pebs 15586 |
| 431 | alignment 1 |
| 432 | data_pad 0 |
| 433 | vol_type 3 |
| 434 | name_len 11 |
| 435 | usable_leb_size 126976 |
| 436 | used_ebs 15586 |
| 437 | used_bytes 1979047936 |
| 438 | last_eb_bytes 126976 |
| 439 | corrupted 0 |
| 440 | upd_marker 0 |
| 441 | name rootfs_data |
| 442 | Volume information dump: |
| 443 | vol_id 2147479551 |
| 444 | reserved_pebs 2 |
| 445 | alignment 1 |
| 446 | data_pad 0 |
| 447 | vol_type 3 |
| 448 | name_len 13 |
| 449 | usable_leb_size 126976 |
| 450 | used_ebs 2 |
| 451 | used_bytes 253952 |
| 452 | last_eb_bytes 2 |
| 453 | corrupted 0 |
| 454 | upd_marker 0 |
| 455 | name layout volume |
| 456 | }}} |
| 457 | - The above shows there are 3 ubi volumes in the attached ubi image named 'boot', 'rootfs', 'rootfs_data'. Note the last dump is the volume layout (think of it as a directory table) |
| 458 | - Note the contents of the various ubi volumes is unknown by the ubi layer |
| 459 | * once a ubi volume is mounted 'if' it is a ubifs you can use {{{ubifsmount}}}, {{{ubifsload}}}, {{{ubifsls}}}, {{{ubifsumount}}} to operate on its contents: |
| 460 | {{{#!bash |
| 461 | Ventana > ubifsmount ubi0:boot |
| 462 | Ventana > ubifsls |
| 463 | <LNK> 31 Tue Jun 23 23:51:55 2020 imx6q-gw53xx.dtb |
| 464 | 38158 Tue Jun 23 23:47:33 2020 gateworks-imx6-imx6q-gw5400-a.dtb |
| 465 | 41991 Tue Jun 23 23:47:30 2020 gateworks-imx6-imx6dl-gw53xx.dtb |
| 466 | 43296 Tue Jun 23 23:47:33 2020 gateworks-imx6-imx6q-gw53xx.dtb |
| 467 | <LNK> 32 Tue Jun 23 23:51:55 2020 imx6dl-gw53xx.dtb |
| 468 | ... |
| 469 | 3275024 Tue Jun 23 23:51:55 2020 gateworks-imx6-uImage |
| 470 | <LNK> 21 Tue Jun 23 23:51:55 2020 uImage |
| 471 | Ventana > ubifsload $loadaddr uImage |
| 472 | Loading file 'uImage' to addr 0x12000000... |
| 473 | Done |
| 474 | Ventana > ubifsumount |
| 475 | Unmounting UBIFS volume boot! |
| 476 | }}} |
| 477 | - Again you can only use ubifs commands on ubi volumes that contain ubifs filesystems |
| 478 | - Be sure to unmount your volume when done working with it |
| 492 | {{{#!bash |
| 493 | Ventana > tftp $loadaddr ventana/test_large.ubifs |
| 494 | Using FEC device |
| 495 | TFTP from server 192.168.1.146; our IP address is 192.168.1.1 |
| 496 | Filename 'ventana/test_large.ubifs'. |
| 497 | Load address: 0x12000000 |
| 498 | Loading: ################################################################# |
| 499 | ################################################################# |
| 500 | ################################################################# |
| 501 | ################################################################# |
| 502 | ################################################################# |
| 503 | ################################################################# |
| 504 | ################################################################# |
| 505 | ################################################################# |
| 506 | ################################################################# |
| 507 | ################################################################# |
| 508 | ################################################################# |
| 509 | ############ |
| 510 | 8.1 MiB/s |
| 511 | done |
| 512 | Bytes transferred = 10665984 (a2c000 hex) |
| 513 | Ventana > ubi remove rootfs |
| 514 | Remove UBI volume rootfs (id 1) |
| 515 | Ventana > ubi create rootfs $filesize static |
| 516 | Creating static volume rootfs of size 10665984 |
| 517 | Ventana > ubi write $loadaddr rootfs $filesize |
| 518 | 10665984 bytes written to volume rootfs |
| 519 | }}} |