Android eMMC Booting

Android eMMC Booting

Contents

   [hide]

[edit]eMMC binaries

This is the efi partition table as exists on the emmc

Sector#    Size Name
    256     128K xloader
    512     256K bootloader
   2048       8M recovery                                                      
  18432       8M boot                                                          
  34816     512M system                                                        
1083392     256M cache                                                         
1607680     512M userdata                                                      
2656256    2183M media

[edit]Creating the GPT table

On Target
  1. Connect a USB cable to the OTG port on your platform
  2. Boot your platform up with a stock u-boot and MLO
  3. Once you platform is booted you will see the following:
Fastboot entered...
On Host Machine

locate fastboot in you android filesystem

cd $mydroid/out/host/linux-x86/bin/fastboot

Search for fastboot devices

fastboot devices

Create GPT table on eMMC/SD card

fastboot oem format

From the android build these are the binaries that go into each partition:

 Sector#    Size Name            Binary
    256     128K xloader         MLO
    512     256K bootloader      u-boot.bin
   2048       8M recovery        recovery.img                                                    
  18432       8M boot            boot.img                                  
  34816     512M system          system.img                                      
1083392     256M cache           cache.img                                    
1607680     512M userdata        userdata.img                                     
2656256    2183M media           none


File locations

  • MLO --> x-loader/MLO
  • u-boot --> u-boot/u-boot.bin
  • boot.img --> need to create using zImage + ramdisk.img
  • recovery.img ---> need to create using zImage + ramdisk-recovery.img
  • system.img --> $mydroid/out/target/product/<platform>/system.img
  • cache.img -->
  • userdata.img --> $mydroid/out/target/product/<platform>/userdata.img


All these partitions can be flashed with the given binary using fastboot.

 fastboot flash <name> <binary>

Example flashing of all partitions

 fastboot flash xloader     MLO
 fastboot flash bootloader  u-boot.bin
 fastboot flash recovery    recovery.img
 fastboot flash boot        boot.img
 fastboot flash system      system.img
 fastboot flash cache       cache.img
 fastboot flash userdata    userdata.img

[edit]Modifying .IMG Files

Typically when you want to modify any of the partitions, you would need to unzip-modify-rezip and then fastboot flash.

Following section talks about how to do that for each partition

BOOT.IMG

 boot.img = zImage + ramdisk.img
 zImage = kernel image
 ramdisk.img = out/target/product/blaze/root/
 %./out/host/linux-x86/bin/mkbootimg 
 --kernel zImage 
 --ramdisk ramdisk.img 
 --base 0x80000000 
 --cmdline "console=ttyO2,115200n8 mem=456M@0x80000000 mem=512M@0xA0000000 init=/init vram=10M omapfb.vram=0:4M androidboot.console=ttyO2" 
 --board omap4 
 -o boot.img.new
 Output: boot.img.new
 **Note: bootarg is passed to kernel via --cmdline option above

To "just" boot boot.img (before flashing) you can use:

%fastboot boot boot.img

RAMDISK.IMG

 %mkdir root
 %cd root
 %gunzip -c ../ramdisk.img | cpio -i
 <make changes to root/ contents...>
 %./out/host/linux-x86/bin/mkbootfs root/ | ./out/host/linux-x86/bin/minigzip >ramdisk.img.new
 #output: ramdisk.img.new
 ** Note: any init.rc changes will need to use this method

RECOVERY.IMG

Is just like boot.img. 
recovery.img = zImage + ramdisk-recovery.img
*Follow the same steps as boot.img for packing/unpacking

SYSTEM.IMG

 #uncompress
 %./out/host/linux-x86/bin/simg2img system.img system.img.raw
 #mount to directory mnt-point/
 %mkdir mnt-point
 %sudo mount -t ext4 -o loop system.img.raw mnt-point/
 #modify any .so or apk in the mnt-point/ directory
 #rezip
 %sudo out/host/linux-x86/bin/make_ext4fs -s -l 512M -a system system.img.new mnt-point/
 %sudo umount mnt-point/
 Output: system.img.new

Instead of having to reflash the whole big system.img, one can selective update any binary in /system folder on running target

%adb remount
%adb push <local> <remote>
Eg: 
%adb remount
%adb push out/target/product/blaze/obj/lib/overlay.omap4.so /system/lib/hw/overlay.omap4.so
%adb sync

USERDATA.IMG

 #uncompress
 %./out/host/linux-x86/bin/simg2img userdata.img userdata.img.raw
 #mount to directory mnt-point/
 %mkdir mnt-point
 %sudo mount -t ext4 -o loop userdata.img.raw mnt-point/
 #modify any .so or apk in the mnt-point/ directory
 #rezip
 #%sudo ./out/host/linux-x86/bin/make_ext4fs -s -l 512M -a userdata userdata.img.new mnt-point/
 # Above command won't work on GB/HC. For GB/HC, please use the following updated command
 %sudo ./out/host/linux-x86/bin/make_ext4fs -s -l 512M -a data userdata.img.new mnt-point/
 %sudo umount mnt-point/
 Output: userdata.img.new

CACHE.IMG

 #This is empty ext4 fs image
 %mkdir mnt-point/
 %sudo ./make_ext4fs -s -l 256M -a cache cache.img mnt-point/
 Output: cache.img

[edit]TI Android build setup

Copy kernel zImage, u-boot.bin and MLO for your board in folder device/ti/blaze/boot/.

Rename as:

 %mv MLO MLO_es2.2_emu 
 or 
 %mv MLO MLO_es2.2_gp 
 (based on your board being GP or EMU)

Next start standard android build and all img files are generated in:

out/target/product/blaze/*.img

A script is introduced in TI Android release to make this flashing process easier: device/ti/blaze/boot/fastboot.sh

Usage:
cd device/ti/blaze/boot/
%fastboot.sh --emu
or
%fastboot.sh --gp

Running this script will flash whole android system on your board.

#ifdef __MTK_UFS_BOOTING #define BOOTDEV bootdevice #define FSTYPE_RAW emmc #endif #ifdef __MTK_EMMC_SUPPORT #define BOOTDEV bootdevice #define FSTYPE_RAW emmc #endif #define DEVPATH(_part) /dev/block/platform/BOOTDEV/by-name/_part #define FSTAB_RAW(_part) DEVPATH(_part) /_part FSTYPE_RAW defaults defaults #define FSTAB_RAW2(_part,_mnt) DEVPATH(_part) /_mnt FSTYPE_RAW defaults defaults #if defined(__MTK_UFS_BOOTING) || defined(__MTK_EMMC_SUPPORT) #ifndef __MTK_SYSIMG_FSTYPE #define __MTK_SYSIMG_FSTYPE ext4 #endif #ifndef __MTK_VNDIMG_FSTYPE #define __MTK_VNDIMG_FSTYPE ext4 #endif #ifndef __MTK_ODMIMG_FSTYPE #define __MTK_ODMIMG_FSTYPE ext4 #endif #ifndef __MTK_DATAIMG_FSTYPE #ifndef __USERDATA_USE_F2FS #define __MTK_DATAIMG_FSTYPE ext4 #else #define __MTK_DATAIMG_FSTYPE f2fs #endif #endif /* Can overwrite FDE setting by defining __MTK_FDE_NO_FORCE and __MTK_FDE_TYPE_FILE in this file */ /* For example, you can un-comment the following line to disable FDE for all projects in this platform. */ //#define __MTK_FDE_NO_FORCE /*#ifdef __MTK_FDE_NO_FORCE #define FLAG_FDE_AUTO encryptable #else #define FLAG_FDE_AUTO forceencrypt #endif*/ //zj120250722 //#define FLAG_FDE_AUTO encryptable #ifdef __MTK_FDE_TYPE_FILE #ifdef __MTK_FDE_TO_FBE #define FLAG_FDE_TYPE forcefdeorfbe #else #define FLAG_FDE_TYPE fileencryption #endif #else #define FLAG_FDE_TYPE #endif #if defined(__SYSTEM_AS_ROOT) || defined(__MTK_AB_OTA_UPDATER) #define SYS_MOUNT_POINT / #else #define SYS_MOUNT_POINT /system #endif #ifdef __MTK_AB_OTA_UPDATER #define FLAG_SLOT_SELECT slotselect #else #define FLAG_SLOT_SELECT #endif #ifdef __MTK_SEC_VERITY #ifdef __MTK_AB_OTA_UPDATER #define FSMGR_FLAG_SYSTEM wait,slotselect,verify,recoveryonly #else #define FSMGR_FLAG_SYSTEM wait,verify,recoveryonly #endif #else #ifdef __MTK_AB_OTA_UPDATER #define FSMGR_FLAG_SYSTEM wait,slotselect,recoveryonly #else #define FSMGR_FLAG_SYSTEM wait,recoveryonly #endif #endif #ifdef __MTK_FDE_TYPE_FILE #ifdef __MTK_FDE_TO_FBE #define FSMGR_FLAG_DATA wait,check,quota,reservedsize=128M,formattable,resize,FLAG_FDE_TYPE=DEVPATH(metadata) #else #define FSMGR_FLAG_DATA wait,check,quota,reservedsize=128M,formattable,resize,FLAG_FDE_TYPE=aes-256-xts #endif #else #define FSMGR_FLAG_DATA wait,check,quota,reservedsize=128M,formattable,resize,FLAG_FDE_AUTO=DEVPATH(metadata),FLAG_FDE_TYPE #endif #define FS_FLAG_DISCARD noatime,nosuid,nodev,noauto_da_alloc,discard #define FS_FLAG_NO_DISCARD noatime,nosuid,nodev,noauto_da_alloc #define FS_FLAG_COMMIT noatime,nosuid,nodev,noauto_da_alloc,commit=1,nodelalloc #define FSMGR_FLAG_FMT wait,check,formattable #define FSMGR_FLAG_CHK wait,check #ifndef __USERDATA_USE_F2FS #define FS_FLAG_DATA FS_FLAG_NO_DISCARD,errors=panic #else #define FS_FLAG_DATA noatime,nosuid,nodev,discard,noflush_merge #endif DEVPATH(system) SYS_MOUNT_POINT __MTK_SYSIMG_FSTYPE ro FSMGR_FLAG_SYSTEM #ifdef __VENDOR_PARTITION_SUPPORT DEVPATH(vendor) /vendor __MTK_VNDIMG_FSTYPE ro FSMGR_FLAG_SYSTEM #endif #ifdef __ODM_PARTITION_SUPPORT DEVPATH(odm) /odm __MTK_ODMIMG_FSTYPE ro FSMGR_FLAG_SYSTEM #endif DEVPATH(userdata) /data __MTK_DATAIMG_FSTYPE FS_FLAG_DATA FSMGR_FLAG_DATA #ifndef __MTK_AB_OTA_UPDATER DEVPATH(cache) /cache ext4 FS_FLAG_DISCARD FSMGR_FLAG_FMT #endif DEVPATH(protect1) /mnt/vendor/protect_f ext4 FS_FLAG_COMMIT FSMGR_FLAG_FMT DEVPATH(protect2) /mnt/vendor/protect_s ext4 FS_FLAG_COMMIT FSMGR_FLAG_FMT DEVPATH(nvdata) /mnt/vendor/nvdata ext4 FS_FLAG_DISCARD FSMGR_FLAG_FMT DEVPATH(nvcfg) /mnt/vendor/nvcfg ext4 FS_FLAG_COMMIT FSMGR_FLAG_FMT #ifdef __PERSIST_PARTITION_SUPPORT DEVPATH(persist) /mnt/vendor/persist ext4 FS_FLAG_COMMIT FSMGR_FLAG_FMT #endif /devices/platform/externdevice* auto auto defaults voldmanaged=sdcard1:auto,encryptable=userdata /devices/platform/mt_usb* auto vfat defaults voldmanaged=usbotg:auto #ifdef __MTK_FACTORY_RESET_PROTECTION_SUPPORT FSTAB_RAW2(frp,persistent) #endif FSTAB_RAW(nvram) FSTAB_RAW(proinfo) FSTAB_RAW2(lk,bootloader) FSTAB_RAW2(lk2,bootloader2) FSTAB_RAW2(para,misc) FSTAB_RAW(boot) FSTAB_RAW(recovery) #ifdef __MTK_RECOVERY_RAMDISK_SPLIT FSTAB_RAW(recovery_ramdisk) FSTAB_RAW(recovery_vendor) #endif FSTAB_RAW(logo) FSTAB_RAW(expdb) FSTAB_RAW(seccfg) #if (defined(__MTK_TEE_SUPPORT) || defined(__MTK_ATF_SUPPORT)) FSTAB_RAW(tee1) FSTAB_RAW(tee2) #endif #ifdef __MTK_TINYSYS_SCP_SUPPORT FSTAB_RAW(scp1) FSTAB_RAW(scp2) #endif #ifdef __MTK_TINYSYS_SSPM_SUPPORT FSTAB_RAW(sspm_1) FSTAB_RAW(sspm_2) #endif #ifdef __MTK_EFUSE_WRITER_SUPPORT FSTAB_RAW(efuse) #endif FSTAB_RAW(md1img) FSTAB_RAW(md1dsp) FSTAB_RAW(md1arm7) FSTAB_RAW(md3img) #ifdef __MTK_VPU_SUPPORT FSTAB_RAW(cam_vpu1) FSTAB_RAW(cam_vpu2) FSTAB_RAW(cam_vpu3) #endif #ifdef __SPM_FW_USE_PARTITION FSTAB_RAW(spmfw) #endif FSTAB_RAW(boot_para) #ifdef __MTK_DTBO_FEATURE FSTAB_RAW(odmdtbo) FSTAB_RAW(dtbo) #endif #ifdef __BOARD_AVB_ENABLE FSTAB_RAW(vbmeta) #endif #endif fstab.mt6765的全文是这样,要设置为上面描述的内容有问题么?
最新发布
07-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值