当前位置:   article > 正文

Android-源码分析-fastboot_fastboot源码分析

fastboot源码分析

1 需求


2 源码

/system/core/fastboot/fastboot.cpp


3.X 示例: 

  1. 389 static int show_help() {
  2. 390 // clang-format off
  3. 391 fprintf(stdout,
  4. 392 // 1 2 3 4 5 6 7 8
  5. 393 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
  6. 394 "usage: fastboot [OPTION...] COMMAND...\n"
  7. 395 "\n"
  8. 396 "flashing:\n"
  9. 397 " update ZIP Flash all partitions from an update.zip package.\n"
  10. 398 " flashall Flash all partitions from $ANDROID_PRODUCT_OUT.\n"
  11. 399 " On A/B devices, flashed slot is set as active.\n"
  12. 400 " Secondary images may be flashed to inactive slot.\n"
  13. 401 " flash PARTITION [FILENAME] Flash given partition, using the image from\n"
  14. 402 " $ANDROID_PRODUCT_OUT if no filename is given.\n"
  15. 403 "\n"
  16. 404 "basics:\n"
  17. 405 " devices [-l] List devices in bootloader (-l: with device paths).\n"
  18. 406 " getvar NAME Display given bootloader variable.\n"
  19. 407 " reboot [bootloader] Reboot device.\n"
  20. 408 "\n"
  21. 409 "locking/unlocking:\n"
  22. 410 " flashing lock|unlock Lock/unlock partitions for flashing\n"
  23. 411 " flashing lock_critical|unlock_critical\n"
  24. 412 " Lock/unlock 'critical' bootloader partitions.\n"
  25. 413 " flashing get_unlock_ability\n"
  26. 414 " Check whether unlocking is allowed (1) or not(0).\n"
  27. 415 "\n"
  28. 416 "advanced:\n"
  29. 417 " erase PARTITION Erase a flash partition.\n"
  30. 418 " format[:FS_TYPE[:SIZE]] PARTITION\n"
  31. 419 " Format a flash partition.\n"
  32. 420 " set_active SLOT Set the active slot.\n"
  33. 421 " oem [COMMAND...] Execute OEM-specific command.\n"
  34. 422 " gsi wipe|disable Wipe or disable a GSI installation (fastbootd only).\n"
  35. 423 " wipe-super [SUPER_EMPTY] Wipe the super partition. This will reset it to\n"
  36. 424 " contain an empty set of default dynamic partitions.\n"
  37. 425 " create-logical-partition NAME SIZE\n"
  38. 426 " Create a logical partition with the given name and\n"
  39. 427 " size, in the super partition.\n"
  40. 428 " delete-logical-partition NAME\n"
  41. 429 " Delete a logical partition with the given name.\n"
  42. 430 " resize-logical-partition NAME SIZE\n"
  43. 431 " Change the size of the named logical partition.\n"
  44. 432 " snapshot-update cancel On devices that support snapshot-based updates, cancel\n"
  45. 433 " an in-progress update. This may make the device\n"
  46. 434 " unbootable until it is reflashed.\n"
  47. 435 " snapshot-update merge On devices that support snapshot-based updates, finish\n"
  48. 436 " an in-progress update if it is in the \"merging\"\n"
  49. 437 " phase.\n"
  50. 438 " fetch PARTITION OUT_FILE Fetch a partition image from the device."
  51. 439 "\n"
  52. 440 "boot image:\n"
  53. 441 " boot KERNEL [RAMDISK [SECOND]]\n"
  54. 442 " Download and boot kernel from RAM.\n"
  55. 443 " flash:raw PARTITION KERNEL [RAMDISK [SECOND]]\n"
  56. 444 " Create boot image and flash it.\n"
  57. 445 " --dtb DTB Specify path to DTB for boot image header version 2.\n"
  58. 446 " --cmdline CMDLINE Override kernel command line.\n"
  59. 447 " --base ADDRESS Set kernel base address (default: 0x10000000).\n"
  60. 448 " --kernel-offset Set kernel offset (default: 0x00008000).\n"
  61. 449 " --ramdisk-offset Set ramdisk offset (default: 0x01000000).\n"
  62. 450 " --tags-offset Set tags offset (default: 0x00000100).\n"
  63. 451 " --dtb-offset Set dtb offset (default: 0x01100000).\n"
  64. 452 " --page-size BYTES Set flash page size (default: 2048).\n"
  65. 453 " --header-version VERSION Set boot image header version.\n"
  66. 454 " --os-version MAJOR[.MINOR[.PATCH]]\n"
  67. 455 " Set boot image OS version (default: 0.0.0).\n"
  68. 456 " --os-patch-level YYYY-MM-DD\n"
  69. 457 " Set boot image OS security patch level.\n"
  70. 458 // TODO: still missing: `second_addr`, `name`, `id`, `recovery_dtbo_*`.
  71. 459 "\n"
  72. 460 // TODO: what device(s) used this? is there any documentation?
  73. 461 //" continue Continue with autoboot.\n"
  74. 462 //"\n"
  75. 463 "Android Things:\n"
  76. 464 " stage IN_FILE Sends given file to stage for the next command.\n"
  77. 465 " get_staged OUT_FILE Writes data staged by the last command to a file.\n"
  78. 466 "\n"
  79. 467 "options:\n"
  80. 468 " -w Wipe userdata.\n"
  81. 469 " -s SERIAL Specify a USB device.\n"
  82. 470 " -s tcp|udp:HOST[:PORT] Specify a network device.\n"
  83. 471 " -S SIZE[K|M|G] Break into sparse files no larger than SIZE.\n"
  84. 472 " --force Force a flash operation that may be unsafe.\n"
  85. 473 " --slot SLOT Use SLOT; 'all' for both slots, 'other' for\n"
  86. 474 " non-current slot (default: current active slot).\n"
  87. 475 " --set-active[=SLOT] Sets the active slot before rebooting.\n"
  88. 476 " --skip-secondary Don't flash secondary slots in flashall/update.\n"
  89. 477 " --skip-reboot Don't reboot device after flashing.\n"
  90. 478 " --disable-verity Sets disable-verity when flashing vbmeta.\n"
  91. 479 " --disable-verification Sets disable-verification when flashing vbmeta.\n"
  92. 480 " --fs-options=OPTION[,OPTION]\n"
  93. 481 " Enable filesystem features. OPTION supports casefold, projid, compress\n"
  94. 482 // TODO: remove --unbuffered?
  95. 483 " --unbuffered Don't buffer input or output.\n"
  96. 484 " --verbose, -v Verbose output.\n"
  97. 485 " --version Display version.\n"
  98. 486 " --help, -h Show this message.\n"
  99. 487 );
  100. 488 // clang-format on
  101. 489 return 0;
  102. 490 }

3.X 示例:

  1. 141 static Image images[] = {
  2. 142 // clang-format off
  3. 143 { "boot", "boot.img", "boot.sig", "boot", false, ImageType::BootCritical },
  4. 144 { "init_boot",
  5. 145 "init_boot.img", "init_boot.sig",
  6. 146 "init_boot",
  7. 147 true, ImageType::BootCritical },
  8. 148 { nullptr, "boot_other.img", "boot.sig", "boot", true, ImageType::Normal },
  9. 149 { "cache", "cache.img", "cache.sig", "cache", true, ImageType::Extra },
  10. 150 { "dtbo", "dtbo.img", "dtbo.sig", "dtbo", true, ImageType::BootCritical },
  11. 151 { "dts", "dt.img", "dt.sig", "dts", true, ImageType::BootCritical },
  12. 152 { "odm", "odm.img", "odm.sig", "odm", true, ImageType::Normal },
  13. 153 { "odm_dlkm", "odm_dlkm.img", "odm_dlkm.sig", "odm_dlkm", true, ImageType::Normal },
  14. 154 { "product", "product.img", "product.sig", "product", true, ImageType::Normal },
  15. 155 { "pvmfw", "pvmfw.img", "pvmfw.sig", "pvmfw", true, ImageType::BootCritical },
  16. 156 { "recovery", "recovery.img", "recovery.sig", "recovery", true, ImageType::BootCritical },
  17. 157 { "super", "super.img", "super.sig", "super", true, ImageType::Extra },
  18. 158 { "system", "system.img", "system.sig", "system", false, ImageType::Normal },
  19. 159 { "system_dlkm",
  20. 160 "system_dlkm.img", "system_dlkm.sig",
  21. 161 "system_dlkm",
  22. 162 true, ImageType::Normal },
  23. 163 { "system_ext",
  24. 164 "system_ext.img", "system_ext.sig",
  25. 165 "system_ext",
  26. 166 true, ImageType::Normal },
  27. 167 { nullptr, "system_other.img", "system.sig", "system", true, ImageType::Normal },
  28. 168 { "userdata", "userdata.img", "userdata.sig", "userdata", true, ImageType::Extra },
  29. 169 { "vbmeta", "vbmeta.img", "vbmeta.sig", "vbmeta", true, ImageType::BootCritical },
  30. 170 { "vbmeta_system",
  31. 171 "vbmeta_system.img",
  32. 172 "vbmeta_system.sig",
  33. 173 "vbmeta_system",
  34. 174 true, ImageType::BootCritical },
  35. 175 { "vbmeta_vendor",
  36. 176 "vbmeta_vendor.img",
  37. 177 "vbmeta_vendor.sig",
  38. 178 "vbmeta_vendor",
  39. 179 true, ImageType::BootCritical },
  40. 180 { "vendor", "vendor.img", "vendor.sig", "vendor", true, ImageType::Normal },
  41. 181 { "vendor_boot",
  42. 182 "vendor_boot.img", "vendor_boot.sig",
  43. 183 "vendor_boot",
  44. 184 true, ImageType::BootCritical },
  45. 185 { "vendor_dlkm",
  46. 186 "vendor_dlkm.img", "vendor_dlkm.sig",
  47. 187 "vendor_dlkm",
  48. 188 true, ImageType::Normal },
  49. 189 { nullptr, "vendor_other.img", "vendor.sig", "vendor", true, ImageType::Normal },
  50. 190 // clang-format on
  51. 191 };

4 参考资料

Android平台Fastboot介绍_内核工匠的博客-CSDN博客 

Fastbootd实现原理分析_内核工匠的博客-CSDN博客

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/298899
推荐阅读
相关标签
  

闽ICP备14008679号