| .. | .. |
|---|
| 406 | 406 | return 0; |
|---|
| 407 | 407 | } |
|---|
| 408 | 408 | |
|---|
| 409 | | -void ab_update_root_uuid(void) |
|---|
| 409 | +static void ab_update_root_uuid(void) |
|---|
| 410 | 410 | { |
|---|
| 411 | 411 | /* |
|---|
| 412 | 412 | * In android a/b & avb process, the system.img is mandory and the |
|---|
| .. | .. |
|---|
| 441 | 441 | } |
|---|
| 442 | 442 | } |
|---|
| 443 | 443 | |
|---|
| 444 | +void ab_update_root_partition(void) |
|---|
| 445 | +{ |
|---|
| 446 | + char *boot_args = env_get("bootargs"); |
|---|
| 447 | + char root_part_dev[64] = {0}; |
|---|
| 448 | + disk_partition_t part_info; |
|---|
| 449 | + struct blk_desc *dev_desc; |
|---|
| 450 | + const char *part_type; |
|---|
| 451 | + int part_num; |
|---|
| 452 | + |
|---|
| 453 | + dev_desc = rockchip_get_bootdev(); |
|---|
| 454 | + if (!dev_desc) |
|---|
| 455 | + return; |
|---|
| 456 | + |
|---|
| 457 | + if (ab_is_support_dynamic_partition(dev_desc)) |
|---|
| 458 | + return; |
|---|
| 459 | + |
|---|
| 460 | + /* Get 'system' partition device number. */ |
|---|
| 461 | + part_num = part_get_info_by_name(dev_desc, ANDROID_PARTITION_SYSTEM, &part_info); |
|---|
| 462 | + if (part_num < 0) { |
|---|
| 463 | + printf("%s: Failed to get partition '%s'.\n", __func__, ANDROID_PARTITION_SYSTEM); |
|---|
| 464 | + return; |
|---|
| 465 | + } |
|---|
| 466 | + |
|---|
| 467 | + /* Get partition type. */ |
|---|
| 468 | + part_type = part_get_type(dev_desc); |
|---|
| 469 | + if (!part_type) |
|---|
| 470 | + return; |
|---|
| 471 | + |
|---|
| 472 | + /* Judge the partition device type. */ |
|---|
| 473 | + switch (dev_desc->if_type) { |
|---|
| 474 | + case IF_TYPE_MMC: |
|---|
| 475 | + if (strstr(part_type, "ENV")) |
|---|
| 476 | + snprintf(root_part_dev, 64, "root=/dev/mmcblk0p%d", part_num); |
|---|
| 477 | + else if (strstr(part_type, "EFI")) |
|---|
| 478 | + ab_update_root_uuid(); |
|---|
| 479 | + break; |
|---|
| 480 | + case IF_TYPE_MTD: |
|---|
| 481 | + if (dev_desc->devnum == BLK_MTD_NAND || dev_desc->devnum == BLK_MTD_SPI_NAND) { |
|---|
| 482 | + if (strstr(boot_args, "rootfstype=squashfs") || strstr(boot_args, "rootfstype=erofs")) |
|---|
| 483 | + snprintf(root_part_dev, 64, "ubi.mtd=%d root=/dev/ubiblock0_0", part_num - 1); |
|---|
| 484 | + else if (strstr(boot_args, "rootfstype=ubifs")) |
|---|
| 485 | + snprintf(root_part_dev, 64, "ubi.mtd=%d root=ubi0:system", part_num - 1); |
|---|
| 486 | + } else if (dev_desc->devnum == BLK_MTD_SPI_NOR) { |
|---|
| 487 | + snprintf(root_part_dev, 64, "root=/dev/mtdblock%d", part_num - 1); |
|---|
| 488 | + } |
|---|
| 489 | + break; |
|---|
| 490 | + default: |
|---|
| 491 | + printf("%s: Not found part type, failed to set root part device.\n", __func__); |
|---|
| 492 | + return; |
|---|
| 493 | + } |
|---|
| 494 | + |
|---|
| 495 | + env_update("bootargs", root_part_dev); |
|---|
| 496 | +} |
|---|
| 497 | + |
|---|
| 444 | 498 | int ab_get_slot_suffix(char *slot_suffix) |
|---|
| 445 | 499 | { |
|---|
| 446 | 500 | /* TODO: get from pre-loader or misc partition */ |
|---|