• 〖Linux〗联想K860/i Android 4.2及以上的Bootimg解压与打包工具


    因为自己有需要,所以花了一点时间来写了一下。

    1. 解压工具

    #!/bin/bash - 
    #===============================================================================
    #
    #          FILE: unpackszbboot
    # 
    #         USAGE: ./unpackszbboot 
    # 
    #   DESCRIPTION: 
    # 
    #       OPTIONS: ---
    #  REQUIREMENTS: ---
    #          BUGS: ---
    #         NOTES: ---
    #        AUTHOR: linkscue (scue), linkscue@gmail.com
    #  ORGANIZATION: 
    #       CREATED: 2014年02月01日 00时58分49秒 CST
    #      REVISION:  ---
    #===============================================================================
    
    usage(){
        echo "Usage: ${0} bootimg extdir"
    }
    
    if [[ $# -lt 1 ]]; then
        usage && exit
    fi
    
    # 镜像文件位置
    bootimg_org=$(readlink -f ${1})
    [[ ! -e ${bootimg_org} ]] && exit
    
    # 设置输出目录
    extdir=$(dirname ${bootimg_org})/boot_extdir
    [[ ${2} != "" ]] && extdir=${2}
    echo ">> Will unpack to ${extdir}"
    
    # 清除旧目录,创建新目录
    rm -rf ${extdir} 2>/dev/null
    mkdir -p ${extdir}
    cd ${extdir}
    
    # 解压bootimg和ramdisk
    bootimg --unpack-bootimg ${bootimg_org}
    dd if=ramdisk of=ramdisk.gz bs=64 skip=1
    mkdir root && cd root
    gunzip -c ../ramdisk.gz | cpio -i 
    cd ../

    2. 打包工具

    #!/bin/bash - 
    #===============================================================================
    #
    #          FILE: repackszbboot
    # 
    #         USAGE: ./repackszbboot 
    # 
    #   DESCRIPTION: 
    # 
    #       OPTIONS: ---
    #  REQUIREMENTS: ---
    #          BUGS: ---
    #         NOTES: ---
    #        AUTHOR: linkscue (scue), linkscue@gmail.com
    #  ORGANIZATION: 
    #       CREATED: 2014年02月01日 02时16分11秒 CST
    #      REVISION:  ---
    #===============================================================================
    
    # 设置目录
    boot_dir=${PWD}
    [[ ${1} != "" ]] && boot_dir=$(readlink -f ${1})
    root_dir=${boot_dir}/root
    kernel_file=${boot_dir}/kernel
    ramdisk_cpio=ramdisk.img.cpio
    ramdisk_gz=ramdisk.img.cpio.gz
    boot_output=boot.img.new
    
    # 工具位置
    mkbootfs=/media/Source/cm10.1/out/host/linux-x86/bin/mkbootfs
    minigzip=/media/Source/cm10.1/out/host/linux-x86/bin/minigzip
    
    [[ ! -e ${boot_dir} ]] && exit
    
    # 打包
    cd ${boot_dir}
    ${mkbootfs} ${root_dir} | ${minigzip} > ${ramdisk_cpio}
    
    mkimage -A arm -O linux -T ramdisk -C none -a 0x40800000 -e 0x40800000 
        -n "ramdisk" -d ${ramdisk_cpio} ${ramdisk_gz}
    mkbootimg --kernel ${kernel_file} --ramdisk ${ramdisk_gz} 
        --base 0x10000000 --cmdline "" --pagesize 2048 -o ${boot_output}
    
    # 显示结果
    ls -l ${boot_output}
  • 相关阅读:
    SpringBoot整合Mybatis之进门篇
    Tomcat和Java Virtual Machine的性能调优总结
    一次浴火重生的MySQL优化(EXPLAIN命令详解)
    简单聊聊不可或缺的Nginx反向代理服务器--实现负载均衡【上篇】
    Java设计模式之适配器设计模式(项目升级案例)
    前端错误监控
    三栏布局的5种方案
    prototype原型链详解
    关于mysql修改密码 set password for root@localhost = password('xxx');报错解决方法
    页面布局之三栏布局的5种方案
  • 原文地址:https://www.cnblogs.com/scue/p/3536927.html
Copyright © 2020-2023  润新知