zoukankan      html  css  js  c++  java
  • post-image.sh hacking

    #*********************************************************************************
    #*                      post-image.sh hacking
    #* 说明:
    #*     分析i.MX6 post-images.sh合成SD card工作原理。
    #*
    #*                                              2018-1-23 深圳 宝安西乡 曾剑锋
    #********************************************************************************/
    
    # 一、参考文档:
    #    1. Linux mktemp命令
    #        http://www.runoob.com/linux/linux-comm-mktemp.html
    #    2. Genimage - The Image Creation Tool
    #        https://github.com/pengutronix/genimage
    
    #!/usr/bin/env bash
    
    #
    # dtb_list extracts the list of DTB files from BR2_LINUX_KERNEL_INTREE_DTS_NAME
    # in ${BR_CONFIG}, then prints the corresponding list of file names for the
    # genimage configuration file
    #
    dtb_list()
    {
        local DTB_LIST="$(sed -n 's/^BR2_LINUX_KERNEL_INTREE_DTS_NAME="([a-z0-9 -]*)"$/1/p' ${BR2_CONFIG})"
    
        for dt in $DTB_LIST; do
            echo -n ""$dt.dtb", "
        done
    }
    
    #
    # linux_image extracts the Linux image format from BR2_LINUX_KERNEL_UIMAGE in
    # ${BR_CONFIG}, then prints the corresponding file name for the genimage
    # configuration file
    #
    linux_image()
    {
        if grep -Eq "^BR2_LINUX_KERNEL_UIMAGE=y$" ${BR2_CONFIG}; then
            echo ""uImage""
        else
            echo ""zImage""
        fi
    }
    
    main()
    {
        # 获取dtb和linux image
        local FILES="$(dtb_list) $(linux_image)"
        # 创建配置文件文件
        local GENIMAGE_CFG="$(mktemp --suffix genimage.cfg)"
        local GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
    
        # 替换掉cfg模板文件中的FILES字段
        sed -e "s/%FILES%/${FILES}/" 
            board/freescale/common/imx/genimage.cfg.template > ${GENIMAGE_CFG}
    
        # 可能存在上次的暂存目录,删除
        rm -rf "${GENIMAGE_TMP}"
    
        #
        # outputpath: default: images Mandatory path where all images are written to (must exist).
        # inputpath:  default: input This mandatory path is searched for input images, for example bootloader binaries, kernel images (must exist).
        # rootpath:   default: root Mandatory path to the root filesystem (must exist).
        # tmppath:    default: tmp Optional path to a temporary directory. There must be enough space available here to hold a copy of the root filesystem.
        # config:     default: genimage.cfg Path to the genimage config file.
        #
        # ${TARGET_DIR} = /home/zengjf/zengjf/Buildroot/buildroot/output/target
        # ${GENIMAGE_TMP} = /home/zengjf/zengjf/Buildroot/buildroot/output/build/genimage.tmp
        # ${BINARIES_DIR} = /home/zengjf/zengjf/Buildroot/buildroot/output/images
        # ${BINARIES_DIR} = /home/zengjf/zengjf/Buildroot/buildroot/output/images
        # ${GENIMAGE_CFG} = /tmp/tmp.1Kks4kDC5mgenimage.cfg
        #
        genimage 
            --rootpath "${TARGET_DIR}" 
            --tmppath "${GENIMAGE_TMP}" 
            --inputpath "${BINARIES_DIR}" 
            --outputpath "${BINARIES_DIR}" 
            --config "${GENIMAGE_CFG}"
    
        // 删除配置文件
        rm -f ${GENIMAGE_CFG}
    
        exit $?
    }
    
    main $@
  • 相关阅读:
    高级数据结构(一)----并查集
    分享复杂的线性动态规划问题(一)
    分享利用微信公众号做淘宝客返利机器人系统的3个技巧
    淘宝京东拼多多三合一cms源码怎么搭建优惠券网站
    微信公众号怎么查京东优惠券之3步搭建自己的找券机器人
    【职场提示】什么时间提出涨薪资更合适?
    项目管理之Git
    快速排序,数组去重
    信息安全风险治理——制度与标准篇
    浅谈漏洞管理实践
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/8334889.html
Copyright © 2011-2022 走看看