Android device load process (preparing flashing)


Question

Standard Android OS load process looks like (from docs):




  1. BootROM (starts with 'on' button)

  2. Bootloader

  3. Kernel

  4. init/mounting

  5. Zygote+Dalvik VM

  6. System services



But I have a difficulties understanding load process preparing flashing (how I met it flashing Galaxy Tab and MTK cellphone ROMs)



Could you help me to find a position for those tools on this diagram:



1) The code that show logo (or battery charge in percents when power cable is on) and respond to USB (when phone is off but battery is inside) ? Where it is ? It should be postioned before Boot ROM - but how you name it?



2) who are responsible for handle "on + volumne down" to switch to "bootload" menu ? BootRom or Bootloader?



3) "preloader" how it is positioned there? (I'm not sure that I understand what preloader is).



4) Twrp ? fastboot ? odin3 does they replace Dalvik or run over it? twrp by itself look like full OS.


Answer

Boot process of Android devices up to kernel stage is very vendor specific, device specific and contains mostly closed source code. You may see clear deviations of terminologies used and differences in their implementations. Here I'm giving a simple understanding.




  1. When charger is inserted, device boots very similar to when power button is pressed except that a very limited OS is loaded.



    Device boots normally up to init stage (given at point 4). init, instead of starting services from /system and /vendor partitions, starts a process: /sbin/charger* which is not a part of AOSP. Charger binary is usually closed source and varies for different devices. It may load some pictures / animations stored on some partitions specific for this purpose.



    Also some OEMs allow enabling / disabling off-mode-charge through fastboot to control the behavior i.e. whether the device should be switched on when power is plugged in or not. But it's also not a standard feature and varies for devices.


  2. Bootloaders (SBL / ABOOT or equivalents) handle Power and Volume buttons pressed to start (Emergency) Download mode, SPL mode, fastboot mode etc. and recovery or normal kernel.

  3. Preloader is a bootloader stage (SBL / SPL) before final bootloader (UBOOT / LK / ABOOT)

  4. Here is the boot chain:


    • BootROM

    • Primary / Secondary BooLoader or PreLoader

    • Final bootloader (which provides odin / fastboot)

    • Kernel / Recovery (TWRP)

    • Init (first userspace process and in-charge of all other processes, also mounts filesystems)

    • Services or processes are started from /system and /vendor partitions by init (Zygote / Dalvik is one of those).




So odin (specific to Samsung) and fastboot are two independent protocols for communication with device through USB to format partitions, flash factory firmware, (un)lock bootloader etc. While TWRP is a minimal OS which is booted in place of normal boot.img (usually using same kernel) in case Android is unable to boot or needs OTA update or some modifications / maintenance.



None of them can be related to Dalvik, they are hardware specific and run at pre-kernel or kernel stage. While zygote - a part of AOSP - is a completely userspace process which forks Dalvik Virtual Machine for every app.






For details: Boot Process: Android vs. Linux


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes