Error message here!

Hide Error message here!

忘记密码?

Error message here!

请输入正确邮箱

Hide Error message here!

密码丢失?请输入您的电子邮件地址。您将收到一个重设密码链接。

Error message here!

返回登录

Close

Linux内核编译配置脚本

silencehuan 2019-06-12 06:47:00 阅读数:135 评论数:0 点赞数:0 收藏数:0

环境

宿主机平台:Ubuntu 16.04.6

目标机:iMX6ULL

Linux内核编译配置脚本

在linux开发过程中熟练使用脚本可以大大简化命令行操作,同时对于需要经常重复操作的指令也是一种备忘;

在linux内核源码根目录添加 config-kernel 文件

#!/bin/sh

echo "config menu"
echo "  1   make clean"
echo "  2   make distclean"
echo "  3   config for mys_imx6"
echo "  4   config for myd_y6ulx"
echo "  5   config for mxs"

echo "  a   make menuconfig"
echo "  b   make uImage"
echo "  c   make zImage"
echo "  d   make modules"
echo "  e   make dtbs"

echo "  q   exit"

prompt_make() {
    echo "*** Configure done,execute 'make uImage' to build kernel or try 'make menuconfig' for more customization. Or use a-e***"
    echo
}

make_distclean() {
    echo "make make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean"
    make distclean
}

make_clean() {
    echo "make make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- clean"
    make clean
}

config_mys_imx6() {
    echo "mys_imx6"
    cp .config .config.bk
    cp  arch/arm/configs/mys_imx6_defconfig .config 
    prompt_make
}
config_myd_y6ulx() {
    echo "myd_y6ulx"
    cp .config .config.bk
    cp  arch/arm/configs/myd_y6ulx_defconfig .config 
    prompt_make
}
config_mxs() {
    echo "mxs"
    cp .config .config.bk
    cp  arch/arm/configs/mxs_defconfig .config 
    prompt_make
}

make_menuconfig() {
    make make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
}

make_uImage() {
    make make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage
}

make_zImage() {
    make make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage
}

make_modules() {
    make make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules
}

make_dtbs() {
    make make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- dtbs
}


echo -n "please select your choice: "

while true
do
    read sel
    echo "select $sel"
    
    case $sel in
        "") make_clean;;
        "") make_distclean;;
        "") config_mys_imx6;;
        "") config_myd_y6ulx;;
        "") config_mxs;;
        "a") make_menuconfig;;
        "b") make_uImage;;
        "c") make_zImage;;
        "d") make_modules;;
        "e") make_dtbs;;
        [q] | [Q]) exit ;;
        *)   echo "ONLY accept 1~5,a~e/q/Q"
    esac 
done

运行效果如下

初次内核编译流程一次选择:2 3 c d e

 

版权声明
本文为[silencehuan]所创,转载请带上原文链接,感谢
https://www.cnblogs.com/silencehuan/p/11009623.html