Android 烧录与修改分区
文章目录
常用分区
开机启动画面区:splash1
内核区:boot,引导分区
系统区:system,系统分区
数据缓存区:cache,手机执行后存放缓存的分区
用户数据区:userdata,手机执行后存在的数据分区
uboot烧录
设置u-boot环境变量
set ethaddr # 设置u-boot程序中的MAC地址
set ipaddr # 设置u-boot程序中的IP地址
set serverip # 指定tftp下载时使用的tftp服务器的IP地址
烧录uboot
tftp 300008000 u-boot-s3c2440.bin # 将u-boot临时下载到SDRAM的30008000地址
nand erase 0 100000 # 将nandflash的0~1M的分区擦除,该分区是用来存放u-boot程序的
nand write 30008000 0 ${filesize} # 将刚下载到SDRAM 30008000地址上的u-boot写到nandflash的0地址偏移处,大小为下载的U-boot文件大小
烧录linux
tftp 300008000 linuxrom-s3c2440.bin # 将linux系统程序临时下载到SDRAM的30008000地址
nand erase 100000 F00000 # 将nandflash的1M~16M的分区(总共15M)擦除,该分区是用来存放linux系统的;
nand write 30008000 100000 ${filesize} # 将刚下载到SDRAM 30008000地址上的linux系统写到nandflash的1M地址偏移处,大小为下载的linux系统文件大小
注意
- nand flash 每一次烧录之前,必须得先擦除(写入,只能把数据(bit)从1改为0;擦除,只能把所有数据(bit)从0改为1)
进入fastboot
上电时在串口终端敲回车进入uboot命令行模式,然后输入以下命令:fastboot 0
dd复制分区
# 查看分区
127|msm8953_64:/ # ls -alh /dev/block/platform/soc/7824900.sdhci/
total 0
drwxr-xr-x 3 root root 1.1K 1970-01-01 08:00 .
drwxr-xr-x 3 root root 60 1970-01-01 08:00 ..
drwxr-xr-x 2 root root 1.1K 1970-01-01 08:00 by-name
lrwxrwxrwx 1 root root 18 1970-01-01 08:00 mmcblk0 -> /dev/block/mmcblk0
lrwxrwxrwx 1 root root 20 1970-01-01 08:00 mmcblk0p1 -> /dev/block/mmcblk0p1
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p10 -> /dev/block/mmcblk0p10
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p11 -> /dev/block/mmcblk0p11
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p12 -> /dev/block/mmcblk0p12
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p13 -> /dev/block/mmcblk0p13
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p14 -> /dev/block/mmcblk0p14
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p15 -> /dev/block/mmcblk0p15
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p16 -> /dev/block/mmcblk0p16
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p17 -> /dev/block/mmcblk0p17
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p18 -> /dev/block/mmcblk0p18
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p19 -> /dev/block/mmcblk0p19
lrwxrwxrwx 1 root root 20 1970-01-01 08:00 mmcblk0p2 -> /dev/block/mmcblk0p2
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p20 -> /dev/block/mmcblk0p20
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p21 -> /dev/block/mmcblk0p21
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p22 -> /dev/block/mmcblk0p22
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p23 -> /dev/block/mmcblk0p23
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p24 -> /dev/block/mmcblk0p24
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p25 -> /dev/block/mmcblk0p25
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p26 -> /dev/block/mmcblk0p26
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p27 -> /dev/block/mmcblk0p27
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p28 -> /dev/block/mmcblk0p28
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p29 -> /dev/block/mmcblk0p29
lrwxrwxrwx 1 root root 20 1970-01-01 08:00 mmcblk0p3 -> /dev/block/mmcblk0p3
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p30 -> /dev/block/mmcblk0p30
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p31 -> /dev/block/mmcblk0p31
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p32 -> /dev/block/mmcblk0p32
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p33 -> /dev/block/mmcblk0p33
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p34 -> /dev/block/mmcblk0p34
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p35 -> /dev/block/mmcblk0p35
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p36 -> /dev/block/mmcblk0p36
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p37 -> /dev/block/mmcblk0p37
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p38 -> /dev/block/mmcblk0p38
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p39 -> /dev/block/mmcblk0p39
lrwxrwxrwx 1 root root 20 1970-01-01 08:00 mmcblk0p4 -> /dev/block/mmcblk0p4
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p40 -> /dev/block/mmcblk0p40
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p41 -> /dev/block/mmcblk0p41
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p42 -> /dev/block/mmcblk0p42
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p43 -> /dev/block/mmcblk0p43
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p44 -> /dev/block/mmcblk0p44
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p45 -> /dev/block/mmcblk0p45
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p46 -> /dev/block/mmcblk0p46
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p47 -> /dev/block/mmcblk0p47
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p48 -> /dev/block/mmcblk0p48
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p49 -> /dev/block/mmcblk0p49
lrwxrwxrwx 1 root root 20 1970-01-01 08:00 mmcblk0p5 -> /dev/block/mmcblk0p5
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p50 -> /dev/block/mmcblk0p50
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p51 -> /dev/block/mmcblk0p51
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p52 -> /dev/block/mmcblk0p52
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p53 -> /dev/block/mmcblk0p53
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p54 -> /dev/block/mmcblk0p54
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p55 -> /dev/block/mmcblk0p55
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 mmcblk0p56 -> /dev/block/mmcblk0p56
lrwxrwxrwx 1 root root 20 1970-01-01 08:00 mmcblk0p6 -> /dev/block/mmcblk0p6
lrwxrwxrwx 1 root root 20 1970-01-01 08:00 mmcblk0p7 -> /dev/block/mmcblk0p7
lrwxrwxrwx 1 root root 20 1970-01-01 08:00 mmcblk0p8 -> /dev/block/mmcblk0p8
lrwxrwxrwx 1 root root 20 1970-01-01 08:00 mmcblk0p9 -> /dev/block/mmcblk0p9
lrwxrwxrwx 1 root root 22 1970-01-01 08:00 mmcblk0rpmb -> /dev/block/mmcblk0rpmb
# dd命令烧写
# 查看分区
cat /proc/partitions
查看文件系统大小
msm8953_64:/ # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 2.9G 1.3G 1.5G 46% /
tmpfs 1.7G 852K 1.7G 1% /dev
tmpfs 1.7G 0 1.7G 0% /mnt
/dev/block/dm-1 992M 508M 484M 52% /vendor
/dev/block/mmcblk0p31 232M 176K 232M 1% /cache
/dev/block/mmcblk0p1 88M 81M 6.6M 93% /vendor/firmware_mnt
/dev/block/mmcblk0p12 12M 6.9M 4.8M 59% /vendor/dsp
/dev/block/mmcblk0p18 27M 332K 27M 2% /mnt/vendor/persist
/dev/block/dm-2 2.7G 111M 2.6G 4% /data
/data/media 2.7G 111M 2.6G 4% /mnt/runtime/default/emulated
查看内存大小
msm8953_64:/ # free -m
total used free shared buffers
Mem: 3579 1993 1585 1 18
-/+ buffers/cache: 1975 1604
Swap: 1023 0 1023
msm8953_64:/ # free -h
total used free shared buffers
Mem: 3.4G 1.9G 1.5G 1.9M 18M
-/+ buffers/cache: 1.9G 1.5G
Swap: 1.0G 0 1.0G
挂载点
# /dev/block/bootdevice/by-name/userdata
源码定义分区大小
# device/qcom/msm8953_64/BoardConfig.mk
# 分区大小
TARGET_USERIMAGES_USE_EXT4 := true
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x04000000
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 3221225472
BOARD_USERDATAIMAGE_PARTITION_SIZE := 3112173568
BOARD_PERSISTIMAGE_PARTITION_SIZE := 33554432
BOARD_PERSISTIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_OEMIMAGE_PARTITION_SIZE := 268435456
BOARD_FLASH_BLOCK_SIZE := 131072 # (BOARD_KERNEL_PAGESIZE * 64)
ifeq ($(TARGET_KERNEL_VERSION), 4.9)
BOARD_METADATAIMAGE_PARTITION_SIZE := 16777216
BOARD_DTBOIMG_PARTITION_SIZE := 0x0800000
endif
ifeq ($(ENABLE_VENDOR_IMAGE), true)
BOARD_VENDORIMAGE_PARTITION_SIZE := 1073741824
BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
TARGET_COPY_OUT_VENDOR := vendor
BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true
endif
# kernel地址
BOARD_KERNEL_BASE := 0x80000000
BOARD_KERNEL_PAGESIZE := 2048
BOARD_KERNEL_TAGS_OFFSET := 0x01E00000
BOARD_RAMDISK_OFFSET := 0x02000000
分区定义文件
# device/qcom/msm8953_64/non_hlos/SDM450.LA.3.2.1/common/config/partition.xml
注意
- 没有find到文件
fastboot
fastboot flash partmap partmap.txt
注意
- 没找到partmap.txt
# bootable/bootloader/lk/app/aboot/fastboot.c
# bootable/bootloader/lk/lib/partition
# bootable/bootloader/lk/lib/partition/partition.c
# bootable/bootloader/lk/platform/msm_shared/partition_parser.c
没找到有关于烧录地址
grep -rn "fastboot=" ./device/qcom/msm8953_64
grep -rn "<partition>" ./device/qcom/msm8953_64
grep -rn "userdata" ./device/qcom/msm8953_64
grep -rn "start_sector=" ./device/
分区挂载
# ./device/qcom/msm8953_64/fstabs-3.18/fstab_non_AB_variant.qti
定义挂载点和类型
备注
作者 [@lhgcs]
2020 年 08月 26日