1 Star 0 Fork 0

unicornx/ilovelinux

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
build_linux.sh 4.46 KB
一键复制 编辑 原始数据 按行查看 历史
unicornx 提交于 2024-10-18 09:52 . support dump_stack
#!/bin/bash
source ./envsetup
#set -v
usage() {
echo "Usage:"
echo " [CONFIG=<config>] ./build_linux.sh [-h] [-d] [-c | -a | -m]"
echo " -h: display usage"
echo " -d: enable debug"
echo " -c: checkdtb"
echo " -a: make distclean"
echo " -m: make menuconfig"
}
while getopts ":hdcam" opt
do
case $opt in
h)
O_HELP=y
;;
d)
O_DEBUG=y
;;
c)
O_CHKDTB=y
;;
a)
O_MAKE_ALL=y
;;
m)
O_MAKE_MENUCFG=y
;;
?)
echo "there is unrecognized parameter."
usage
exit 1
;;
esac
done
#echo "O_HELP = $O_HELP"
#echo "O_DEBUG = $O_DEBUG"
#echo "O_CHKDTB = $O_CHKDTB"
#echo "O_MAKE_ALL = $O_MAKE_ALL"
#echo "O_MAKE_MENUCFG = $O_MAKE_MENUCFG"
if [ "$O_HELP" = "y" ]; then
usage
exit 0
fi
# default config
if [[ -z "${CONFIG}" ]]; then
CONFIG=defconfig
fi
if [[ ${CONFIG} = "defconfig" ]]; then
OUT=$WS_LINUX/out-linux
elif [[ ${CONFIG} = "defconfig 32-bit.config" ]]; then
OUT=$WS_LINUX/out-linux32
elif [[ ${CONFIG} = "sophgo_mango_normal_defconfig" ]]; then
OUT=$WS_LINUX/out-linuxboot
elif [[ ${CONFIG} = "sophgo_mango_ubuntu_defconfig" ]]; then
OUT=$WS_LINUX/out-ubuntu
fi
if [ "$O_DEBUG" = "y" ]; then
OUT=$OUT-debug
fi
export OUT
echo "======> CONFIG=$CONFIG"
echo "======> OUT=$OUT"
export ARCH=riscv
echo "======> ARCH=$ARCH"
#export CROSS_COMPILE=riscv64-linux-
export CROSS_COMPILE=riscv64-buildroot-linux-gnu-
#export CROSS_COMPILE=riscv64-unknown-linux-gnu-
echo "======> CROSS_COMPILE=$CROSS_COMPILE"
#exit
# FIXME: just to make code simple
# "-c" only take effective when CONFIG=defconfig, don't use it for other CONFIGs
if [ "$O_CHKDTB" == "y" ] && [ "$CONFIG" == "defconfig" ]; then
echo "======> Start checking dtb ......"
pushd $PATH_LINUX
rm -f $OUT/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dtb
make -j$(nproc) O=$OUT CHECK_DTBS=y W=1 sophgo/sg2042-milkv-pioneer.dtb
popd
exit
fi
if [ "$O_MAKE_MENUCFG" = "y" ]; then
echo "======> Start making menuconfig ......"
pushd $PATH_LINUX
make O=$OUT menuconfig
popd
exit
fi
echo "======> Start building ......"
pushd $PATH_LINUX
if [ "$O_MAKE_ALL" = "y" ]; then
echo "======> Cleanup for FULLY building ......"
rm -rf $OUT
mkdir $OUT
make O=$OUT $CONFIG
# ./scripts/config --file $OUT/.config -e DYNAMIC_DEBUG
# enable kernel debug, so we can get more info when dump_stack
# default comment out to make image size small, enable it when requierd
<< COMMENT
./scripts/config --file $OUT/.config -e CONFIG_DEBUG_INFO
./scripts/config --file $OUT/.config -d CONFIG_DEBUG_INFO_NONE
./scripts/config --file $OUT/.config -e CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
./scripts/config --file $OUT/.config -d CONFIG_DEBUG_INFO_REDUCED
./scripts/config --file $OUT/.config -e CONFIG_DEBUG_INFO_COMPRESSED_NONE
./scripts/config --file $OUT/.config -d CONFIG_DEBUG_INFO_COMPRESSED_ZLIB
./scripts/config --file $OUT/.config -d CONFIG_DEBUG_INFO_SPLIT
./scripts/config --file $OUT/.config -d CONFIG_DEBUG_INFO_BTF
./scripts/config --file $OUT/.config -e CONFIG_PAHOLE_HAS_SPLIT_BTF
./scripts/config --file $OUT/.config -e CONFIG_PAHOLE_HAS_LANG_EXCLUDE
./scripts/config --file $OUT/.config -d CONFIG_GDB_SCRIPTS
COMMENT
# for sdmmc
# MMC_SDHCI_OF_DWCMSHC already in defconfig
# NLS_ISO8859_1 is enabled as module in defconfig, enabled as built-in
./scripts/config --file $OUT/.config -e NLS_ISO8859_1
# for gpio
./scripts/config --file $OUT/.config -e CONFIG_GPIO_DWAPB
# for poweroff/reboot by command
./scripts/config --file $OUT/.config -e CONFIG_SENSORS_SG2042_MCU
if [ "$O_DEBUG" = "y" ]; then
echo "======> Adding DEBUG info ......"
./scripts/config --file $OUT/.config \
-d CONFIG_COMPILE_TEST \
-e CONFIG_DEBUG_KERNEL \
-e CONFIG_DEBUG_INFO \
-d CONFIG_DEBUG_INFO_NONE \
-e CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT \
-d CONFIG_DEBUG_INFO_REDUCED \
-e CONFIG_DEBUG_INFO_COMPRESSED_NONE \
-d CONFIG_DEBUG_INFO_COMPRESSED_ZLIB \
-d CONFIG_DEBUG_INFO_SPLIT \
-d CONFIG_DEBUG_INFO_BTF \
-d CONFIG_GDB_SCRIPTS
fi
fi
make -j$(nproc) O=$OUT W=1
if [[ ${CONFIG} = "sophgo_mango_ubuntu_defconfig" ]]; then
rm -rf $WS_LINUX/linux-*.deb
rm -rf $WS_LINUX/linux-*.changes
rm -rf $WS_LINUX/linux-*.buildinfo
make -j$(nproc) O=$OUT bindeb-pkg
fi
popd
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/unicornx/ilovelinux.git
[email protected]:unicornx/ilovelinux.git
unicornx
ilovelinux
ilovelinux
master

搜索帮助